Commit 8b4dacbe authored by Andrew Van Buren's avatar Andrew Van Buren

Added footsteps and victory sound.

parent 1c55fbcd
...@@ -2,15 +2,28 @@ ...@@ -2,15 +2,28 @@
using System.Collections; using System.Collections;
public class HeroMobility : MonoBehaviour { public class HeroMobility : MonoBehaviour {
public enum Footsteps {
GRASS,
WATER
}
public float playerSpeed = 1f; public float playerSpeed = 1f;
private Rigidbody2D playerRB; private Rigidbody2D playerRB;
Animator anim; Animator anim;
private Vector2 lastPos; private Vector2 lastPos;
public Vector2 deltaPos; public Vector2 deltaPos;
private float lastFootstep;
void Start () { public float footStepDelay = 0.3f;
public Footsteps footsetps = Footsteps.GRASS;
private AudioSource audioSource;
public AudioClip[] grassFootsteps;
public AudioClip[] waterFootsteps;
void Start () {
playerRB = GetComponent<Rigidbody2D> (); playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> (); anim = GetComponent<Animator> ();
audioSource = GetComponent<AudioSource>();
lastPos = playerRB.position; lastPos = playerRB.position;
} }
...@@ -18,6 +31,11 @@ public class HeroMobility : MonoBehaviour { ...@@ -18,6 +31,11 @@ public class HeroMobility : MonoBehaviour {
void FixedUpdate () { void FixedUpdate () {
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
playerMove (input); playerMove (input);
if(deltaPos.magnitude > 0.001f && Time.time > lastFootstep) {
lastFootstep += footStepDelay;
Footstep();
}
} }
void playerMove (Vector2 input){ void playerMove (Vector2 input){
...@@ -27,4 +45,15 @@ public class HeroMobility : MonoBehaviour { ...@@ -27,4 +45,15 @@ public class HeroMobility : MonoBehaviour {
lastPos = playerRB.position; lastPos = playerRB.position;
} }
void Footstep() {
switch (footsetps) {
case Footsteps.GRASS:
audioSource.PlayOneShot(grassFootsteps[Random.Range(0, grassFootsteps.Length)]);
break;
case Footsteps.WATER:
audioSource.PlayOneShot(waterFootsteps[Random.Range(0, waterFootsteps.Length)]);
break;
}
}
} }
...@@ -15,10 +15,12 @@ public class Boss : MonoBehaviour { ...@@ -15,10 +15,12 @@ public class Boss : MonoBehaviour {
public float attackRandom = 1.0f; public float attackRandom = 1.0f;
private float lastAttack = 0; private float lastAttack = 0;
public float projectileSpeed = 5; public float projectileSpeed = 5;
public AudioClip attackSound;
public int health = 100; public int health = 100;
public GameObject diety; public GameObject diety;
public Color damageColor; public Color damageColor;
public float damageColorSpeed = 8; public float damageColorSpeed = 8;
public AudioClip damageSound;
public Color dangerColor; public Color dangerColor;
private SpriteRenderer sr; private SpriteRenderer sr;
private Animator animator; private Animator animator;
...@@ -26,6 +28,8 @@ public class Boss : MonoBehaviour { ...@@ -26,6 +28,8 @@ public class Boss : MonoBehaviour {
public AudioClip bossMusic; public AudioClip bossMusic;
private AudioSource bgm; private AudioSource bgm;
private AudioSource audioSource;
GameObject player; GameObject player;
private bool triggered = false; private bool triggered = false;
...@@ -41,6 +45,7 @@ public class Boss : MonoBehaviour { ...@@ -41,6 +45,7 @@ public class Boss : MonoBehaviour {
PickWaypoint(); PickWaypoint();
rb.isKinematic = true; rb.isKinematic = true;
bgm = Camera.main.GetComponentInChildren<AudioSource>(); bgm = Camera.main.GetComponentInChildren<AudioSource>();
audioSource = GetComponent<AudioSource>();
} }
// Update is called once per frame // Update is called once per frame
...@@ -89,6 +94,8 @@ public class Boss : MonoBehaviour { ...@@ -89,6 +94,8 @@ public class Boss : MonoBehaviour {
void GetHit(int amount) { void GetHit(int amount) {
if (triggered) { if (triggered) {
if (damageSound)
audioSource.PlayOneShot(damageSound);
health -= amount; health -= amount;
sr.color = damageColor; sr.color = damageColor;
if (health <= 0) { if (health <= 0) {
...@@ -106,6 +113,8 @@ public class Boss : MonoBehaviour { ...@@ -106,6 +113,8 @@ public class Boss : MonoBehaviour {
IEnumerator Attack() { IEnumerator Attack() {
if (triggered) { if (triggered) {
animator.SetBool("Attacking", true); animator.SetBool("Attacking", true);
if(attackSound)
audioSource.PlayOneShot(attackSound);
yield return new WaitForSeconds(0.3f); yield return new WaitForSeconds(0.3f);
Shoot(0); Shoot(0);
Shoot(90); Shoot(90);
......
fileFormatVersion: 2
guid: 96cad91ec47966b40ac87c2fc78db5e0
timeCreated: 1479605162
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 012cd8c915cb44c4ca82b30f78abaea9
timeCreated: 1479605161
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 1247890cafbe3d441ac106fd249b681b
timeCreated: 1479605359
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2d9ad25239bbf764dabdf9e69ac498c3
timeCreated: 1479605162
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ce039a43b9ef5314b9cb6cba038434dd
timeCreated: 1479605162
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment