Browse Source

amb and bgm and fixed camera

master
Sagittaeri 8 years ago
parent
commit
f5f0541a1b
27 changed files with 303 additions and 39 deletions
  1. +233
    -0
      IronToad_UnityProject/Assets/Scripts/AudioController.cs
  2. +12
    -0
      IronToad_UnityProject/Assets/Scripts/AudioController.cs.meta
  3. +3
    -2
      IronToad_UnityProject/Assets/Scripts/CustomSmoothFollow.cs
  4. +4
    -4
      IronToad_UnityProject/Assets/Scripts/TestMoveController.cs
  5. +1
    -0
      IronToad_UnityProject/Assets/Scripts/UIPanel.cs
  6. +2
    -3
      IronToad_UnityProject/Assets/Sound.meta
  7. +9
    -0
      IronToad_UnityProject/Assets/Sound/Music.meta
  8. +0
    -0
      IronToad_UnityProject/Assets/Sound/Music/attack.wav
  9. +2
    -2
      IronToad_UnityProject/Assets/Sound/Music/attack.wav.meta
  10. +0
    -0
      IronToad_UnityProject/Assets/Sound/Music/spotted.wav
  11. +2
    -2
      IronToad_UnityProject/Assets/Sound/Music/spotted.wav.meta
  12. +0
    -0
      IronToad_UnityProject/Assets/Sound/Music/tense.wav
  13. +2
    -2
      IronToad_UnityProject/Assets/Sound/Music/tense.wav.meta
  14. +9
    -0
      IronToad_UnityProject/Assets/Sound/SFX.meta
  15. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/assassination.wav.meta
  16. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/createWave.wav.meta
  17. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/createWave_2.wav.meta
  18. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/createWave_3.wav.meta
  19. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/oceanAmbience.wav.meta
  20. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/rockWater_1.wav.meta
  21. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/rockWater_2.wav.meta
  22. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/rockWater_3.wav.meta
  23. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/runAground.wav.meta
  24. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/shipSpotted.wav.meta
  25. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/sinkingShip.wav.meta
  26. +2
    -2
      IronToad_UnityProject/Assets/Sound/SFX/spottedDialogue.wav.meta
  27. BIN
      IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity

+ 233
- 0
IronToad_UnityProject/Assets/Scripts/AudioController.cs View File

@ -0,0 +1,233 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioController : MonoBehaviour
{
public AudioSource[] bgmSources;
public AudioSource[] ambSources;
public AudioSource[] sfxSources;
public AudioClip[] bgmClips;
public AudioClip[] ambClips;
public AudioClip[] sfxClips;
void Awake()
{
NotificationServer.register("play bgm", playBgm);
NotificationServer.register("play amb", playAmb);
NotificationServer.register("play sfx", playSfx);
NotificationServer.register("fade bgm", fadeBgm);
NotificationServer.register("fade amb", fadeAmb);
}
void Start()
{
foreach (AudioSource s in bgmSources)
s.volume = 0f;
foreach (AudioSource s in ambSources)
s.volume = 0f;
foreach (AudioSource s in sfxSources)
s.volume = 0f;
NotificationServer.notify("play amb", "oceanAmbience:0.5");
}
public void playAmb(object audioNameObj)
{
string audioName = audioNameObj as string;
if (audioName == null || audioName == "")
return;
string[] tokens = audioName.ToLower().Split(':');
audioName = tokens[0];
float volume = 1f;
if (tokens.Length > 1)
float.TryParse(tokens[1], out volume);
AudioClip clip = null;
foreach (AudioClip c in ambClips)
{
if (c.name.ToLower() == audioName)
{
clip = c;
break;
}
}
if (clip == null)
return;
bool foundEmpty = false;
foreach (AudioSource s in ambSources)
{
if (s.isPlaying)
{
LeanTween.cancel(s.gameObject);
LeanTween.value(s.gameObject, s.volume, 0f, 0.5f).setOnUpdate((float val)=>{
s.volume = val;
}).setOnComplete(()=>{
s.Stop();
s.clip = null;
}).setIgnoreTimeScale(true);
}
else if (!foundEmpty)
{
LeanTween.cancel(s.gameObject);
foundEmpty = true;
s.clip = clip;
s.Play();
LeanTween.value(s.gameObject, s.volume, volume, 0.5f).setOnUpdate((float val)=>{
s.volume = val;
}).setIgnoreTimeScale(true);
}
}
}
public void playSfx(object audioNameObj)
{
string audioName = audioNameObj as string;
if (audioName == null || audioName == "")
return;
string[] tokens = audioName.ToLower().Split(':');
audioName = tokens[0];
float volume = 1f;
if (tokens.Length > 1)
float.TryParse(tokens[1], out volume);
AudioClip clip = null;
foreach (AudioClip c in sfxClips)
{
if (c.name.ToLower() == audioName)
{
clip = c;
break;
}
}
if (clip == null)
return;
foreach (AudioSource s in sfxSources)
{
if (!s.isPlaying)
{
LeanTween.cancel(s.gameObject);
s.clip = clip;
s.volume = volume;
s.Play();
}
}
}
public void playBgm(object audioNameObj)
{
string audioNames = audioNameObj as string;
if (audioNames == null || audioNames == "")
return;
audioNames = audioNames.ToLower();
string[] tokens = audioNames.Split('/');
if (tokens.Length > 1)
{
foreach (string t in tokens)
playBgm(t.Trim());
return;
}
string[] tokens2 = audioNames.Split(':');
string audioName = tokens2[0];
float volume = 1f;
if (tokens2.Length > 1)
float.TryParse(tokens2[1], out volume);
AudioClip clip = null;
foreach (AudioClip c in bgmClips)
{
if (c.name.ToLower() == audioName)
{
clip = c;
break;
}
}
if (clip == null)
return;
AudioSource foundEmpty = null;
foreach (AudioSource s in bgmSources)
{
if (s.clip != null && s.clip == clip)
{
LeanTween.cancel(s.gameObject);
foundEmpty = s;
}
else if (s.isPlaying)
{
LeanTween.cancel(s.gameObject);
LeanTween.value(s.gameObject, s.volume, 0f, 0.5f).setOnUpdate((float val)=>{
s.volume = val;
}).setOnComplete(()=>{
s.Stop();
s.clip = null;
}).setIgnoreTimeScale(true);
}
else if (foundEmpty == null)
{
LeanTween.cancel(s.gameObject);
foundEmpty = s;
}
}
if (foundEmpty != null && !foundEmpty.isPlaying)
{
LeanTween.cancel(foundEmpty.gameObject);
foundEmpty.clip = clip;
foundEmpty.Play();
LeanTween.value(foundEmpty.gameObject, foundEmpty.volume, volume, 0.5f).setOnUpdate((float val)=>{
foundEmpty.volume = val;
}).setIgnoreTimeScale(true);
}
else if (foundEmpty != null && foundEmpty.isPlaying)
{
LeanTween.cancel(foundEmpty.gameObject);
LeanTween.value(foundEmpty.gameObject, foundEmpty.volume, volume, 0.5f).setOnUpdate((float val)=>{
foundEmpty.volume = val;
}).setIgnoreTimeScale(true);
}
}
public void fadeBgm()
{
foreach (AudioSource s in bgmSources)
{
if (s.isPlaying)
{
LeanTween.cancel(s.gameObject);
LeanTween.value(s.gameObject, s.volume, 0f, 0.5f).setOnUpdate((float val)=>{
s.volume = val;
}).setOnComplete(()=>{
s.Stop();
s.clip = null;
}).setIgnoreTimeScale(true);
}
}
}
public void fadeAmb()
{
foreach (AudioSource s in ambSources)
{
if (s.isPlaying)
{
LeanTween.cancel(s.gameObject);
LeanTween.value(s.gameObject, s.volume, 0f, 0.5f).setOnUpdate((float val)=>{
s.volume = val;
}).setOnComplete(()=>{
s.Stop();
s.clip = null;
}).setIgnoreTimeScale(true);
}
}
}
}

+ 12
- 0
IronToad_UnityProject/Assets/Scripts/AudioController.cs.meta View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 66e9541bf46304a888e3e492fda8055d
timeCreated: 1485043076
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 2
IronToad_UnityProject/Assets/Scripts/CustomSmoothFollow.cs View File

@ -42,7 +42,7 @@ public class CustomSmoothFollow : MonoBehaviour
RaycastHit hitInfo;
if (Physics.Raycast(wantedPos, target.position-wantedPos, out hitInfo, (target.position-wantedPos).magnitude * 2f))
{
Debug.LogWarning (hitInfo.collider.name + " -- " + hitInfo.collider.gameObject.layer + " -- " + layerMask);
// Debug.LogWarning (hitInfo.collider.name + " -- " + hitInfo.collider.gameObject.layer + " -- " + layerMask);
if (hitInfo.collider.gameObject.layer == layerMask)
isBlocked = true;
}
@ -51,6 +51,8 @@ public class CustomSmoothFollow : MonoBehaviour
{
wantedPos.y = target.position.y + altHeight;
wantedPos.z = target.position.z + altDistance;
wantedPos.x = target.position.x;
wantedPos = RotatePointAroundPivot(wantedPos, target.transform.position, offsetAngle);
}
float currentHeight = transform.position.y;
@ -73,7 +75,6 @@ public class CustomSmoothFollow : MonoBehaviour
// Set the height of the camera
transform.position = new Vector3(currentSide, currentHeight, currentDistance);
// Always look at the target
Vector3 lookTarget = target.position;
lookTarget.z = transform.position.z;

+ 4
- 4
IronToad_UnityProject/Assets/Scripts/TestMoveController.cs View File

@ -9,12 +9,12 @@ public class TestMoveController : MonoBehaviour
void Update ()
{
if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
transform.Translate(Vector3.back * Time.deltaTime * speed);
transform.Translate(Vector3.right * Time.deltaTime * speed);
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
transform.Translate(Vector3.left * Time.deltaTime * speed);
transform.Translate(Vector3.back * Time.deltaTime * speed);
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
transform.Translate(Vector3.forward * Time.deltaTime * speed);
transform.Translate(Vector3.left * Time.deltaTime * speed);
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
transform.Translate(Vector3.right * Time.deltaTime * speed);
transform.Translate(Vector3.forward * Time.deltaTime * speed);
}
}

+ 1
- 0
IronToad_UnityProject/Assets/Scripts/UIPanel.cs View File

@ -162,6 +162,7 @@ public class UIPanel : MonoBehaviour
public void startGame()
{
NotificationServer.notify("show GameUI");
NotificationServer.notify("play bgm", "tense:0.75");
unpauseGame();
}

IronToad_UnityProject/Assets/Sound.meta~4053ea0ea1489f4604c1626fb0538989dd66037b.meta~927ced4c4317bc1f86f167c9b1594cec30b8e540.meta → IronToad_UnityProject/Assets/Sound.meta View File

@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: 599e1530282487c46b63fa0f00f5c846
timeCreated: 1485039717
licenseType: Pro
guid: 0fbabcae9313543ffbf1429aeac3664d
folderAsset: yes
DefaultImporter:
userData:
assetBundleName:

+ 9
- 0
IronToad_UnityProject/Assets/Sound/Music.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: be2c14b0c562c483bbe057367939b479
folderAsset: yes
timeCreated: 1485052376
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

IronToad_UnityProject/Assets/Sound/Music/22-1245ironToad(attack).wav → IronToad_UnityProject/Assets/Sound/Music/attack.wav View File


IronToad_UnityProject/Assets/Sound/Music/22-1245ironToad(attack).wav.meta → IronToad_UnityProject/Assets/Sound/Music/attack.wav.meta View File

@ -5,11 +5,11 @@ licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
loadType: 2
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0

IronToad_UnityProject/Assets/Sound/Music/22-1245ironToad(spotted).wav → IronToad_UnityProject/Assets/Sound/Music/spotted.wav View File


IronToad_UnityProject/Assets/Sound/Music/22-1245ironToad(spotted).wav.meta → IronToad_UnityProject/Assets/Sound/Music/spotted.wav.meta View File

@ -5,11 +5,11 @@ licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
loadType: 2
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0

IronToad_UnityProject/Assets/Sound/Music/22-1245ironToad(tense).wav → IronToad_UnityProject/Assets/Sound/Music/tense.wav View File


IronToad_UnityProject/Assets/Sound/Music/22-1245ironToad(tense).wav.meta → IronToad_UnityProject/Assets/Sound/Music/tense.wav.meta View File

@ -5,11 +5,11 @@ licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
loadType: 2
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0

+ 9
- 0
IronToad_UnityProject/Assets/Sound/SFX.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: bb5698073b8d847298f0287fcfbdd0de
folderAsset: yes
timeCreated: 1485052376
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/assassination.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/createWave.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/createWave_2.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/createWave_3.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/oceanAmbience.wav.meta View File

@ -5,11 +5,11 @@ licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
loadType: 2
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/rockWater_1.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/rockWater_2.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/rockWater_3.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/runAground.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/shipSpotted.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/sinkingShip.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

+ 2
- 2
IronToad_UnityProject/Assets/Sound/SFX/spottedDialogue.wav.meta View File

@ -9,12 +9,12 @@ AudioImporter:
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
quality: 0.7
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
preloadAudioData: 0
loadInBackground: 0
3D: 1
userData:

BIN
IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity View File


Loading…
Cancel
Save