Commit f33d110f authored by Andrew R Van Buren's avatar Andrew R Van Buren

Merge branch 'character' into 'master'

Character

See merge request !38
parents d93cc77b 64d16f00
...@@ -8,6 +8,7 @@ public class Actions : MonoBehaviour { ...@@ -8,6 +8,7 @@ public class Actions : MonoBehaviour {
public GameObject currentAbility = null; // Which ability is currently active public GameObject currentAbility = null; // Which ability is currently active
private int abilitiesCounter = 0; // A counter which lets you cycle through the abilities private int abilitiesCounter = 0; // A counter which lets you cycle through the abilities
private Image abilitiesImage; // Picture which shows which ability it active private Image abilitiesImage; // Picture which shows which ability it active
private GameObject myShield;
public int health; public int health;
...@@ -21,6 +22,9 @@ public class Actions : MonoBehaviour { ...@@ -21,6 +22,9 @@ public class Actions : MonoBehaviour {
public float waterShieldCooldown = 5.0f; public float waterShieldCooldown = 5.0f;
public float fireballCooldown = 0.5f; public float fireballCooldown = 0.5f;
private AudioSource audio;
public AudioClip fireball;
private Vector3 LastInput = new Vector2(0, -1); private Vector3 LastInput = new Vector2(0, -1);
void Start () { void Start () {
...@@ -31,6 +35,8 @@ public class Actions : MonoBehaviour { ...@@ -31,6 +35,8 @@ public class Actions : MonoBehaviour {
abilityUnusable = new Color(255.0f,255.0f,255.0f,0.5f); abilityUnusable = new Color(255.0f,255.0f,255.0f,0.5f);
abilityUsable = new Color(255.0f,255.0f,255.0f,1.0f); abilityUsable = new Color(255.0f,255.0f,255.0f,1.0f);
audio = GetComponent<AudioSource>();
} }
...@@ -94,6 +100,9 @@ public class Actions : MonoBehaviour { ...@@ -94,6 +100,9 @@ public class Actions : MonoBehaviour {
case "Ability - Fireball": case "Ability - Fireball":
if (waterShieldUsable == true) { if (waterShieldUsable == true) {
StartCoroutine(move());
audio.PlayOneShot (fireball, 0.5f);
GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject; GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<FireballProjectile> ().move = LastInput; clone.GetComponent<FireballProjectile> ().move = LastInput;
clone.GetComponent<FireballProjectile> ().speed = fireballSpeed; clone.GetComponent<FireballProjectile> ().speed = fireballSpeed;
...@@ -105,7 +114,7 @@ public class Actions : MonoBehaviour { ...@@ -105,7 +114,7 @@ public class Actions : MonoBehaviour {
case "Ability - Water Shield": case "Ability - Water Shield":
if(waterShieldUsable == true) { if(waterShieldUsable == true) {
GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity); myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity);
WaterShield waterShield = myShield.GetComponent<WaterShield>(); WaterShield waterShield = myShield.GetComponent<WaterShield>();
waterShieldTimer = waterShieldCooldown; waterShieldTimer = waterShieldCooldown;
...@@ -141,6 +150,14 @@ public class Actions : MonoBehaviour { ...@@ -141,6 +150,14 @@ public class Actions : MonoBehaviour {
} }
void GetHit(int d){ void GetHit(int d){
health -= d; if(myShield == null)
health -= d;
}
IEnumerator move(){
this.GetComponent<HeroMobility> ().canMove = false;
yield return new WaitForSeconds (0.2f);
this.GetComponent<HeroMobility> ().canMove = true;
} }
} }
...@@ -20,7 +20,6 @@ public class FireballProjectile : MonoBehaviour { ...@@ -20,7 +20,6 @@ public class FireballProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){ void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){ if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage); c.transform.SendMessage ("GetHit", damage);
} }
......
...@@ -20,6 +20,8 @@ public class HeroMobility : MonoBehaviour { ...@@ -20,6 +20,8 @@ public class HeroMobility : MonoBehaviour {
public AudioClip[] grassFootsteps; public AudioClip[] grassFootsteps;
public AudioClip[] waterFootsteps; public AudioClip[] waterFootsteps;
public bool canMove = true;
void Start () { void Start () {
playerRB = GetComponent<Rigidbody2D> (); playerRB = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> (); anim = GetComponent<Animator> ();
...@@ -33,14 +35,15 @@ public class HeroMobility : MonoBehaviour { ...@@ -33,14 +35,15 @@ public class HeroMobility : MonoBehaviour {
playerMove (input); playerMove (input);
if(deltaPos.magnitude > 0.001f && Time.time > lastFootstep) { if(deltaPos.magnitude > 0.001f && Time.time > lastFootstep) {
lastFootstep += footStepDelay; lastFootstep = Time.time + footStepDelay;
Footstep(); Footstep();
} }
} }
void playerMove (Vector2 input){ void playerMove (Vector2 input){
//Controls hero movement in all 8 directions //Controls hero movement in all 8 directions
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed); if(canMove)
playerRB.MovePosition((Vector2)transform.position + input.normalized*playerSpeed);
deltaPos = playerRB.position - lastPos; deltaPos = playerRB.position - lastPos;
lastPos = playerRB.position; lastPos = playerRB.position;
...@@ -57,3 +60,4 @@ public class HeroMobility : MonoBehaviour { ...@@ -57,3 +60,4 @@ public class HeroMobility : MonoBehaviour {
} }
} }
} }
...@@ -12,8 +12,15 @@ public class WaterShield : MonoBehaviour { ...@@ -12,8 +12,15 @@ public class WaterShield : MonoBehaviour {
[HideInInspector] [HideInInspector]
public Vector2 playerDirection; public Vector2 playerDirection;
public AudioSource audio;
public AudioClip start;
public AudioClip end;
void Start() { void Start() {
player = GameObject.FindGameObjectWithTag("Player"); player = GameObject.FindGameObjectWithTag("Player");
audio = GetComponent<AudioSource>();
audio.PlayOneShot (start, 0.5f);
} }
void Update () { void Update () {
...@@ -24,6 +31,7 @@ public class WaterShield : MonoBehaviour { ...@@ -24,6 +31,7 @@ public class WaterShield : MonoBehaviour {
if(timerOfShield >= durationOfShield) { if(timerOfShield >= durationOfShield) {
Explode(); Explode();
player.GetComponent<AudioSource>().PlayOneShot (end, 0.5f);
Destroy(this.gameObject); Destroy(this.gameObject);
} }
} }
...@@ -51,3 +59,4 @@ public class WaterShield : MonoBehaviour { ...@@ -51,3 +59,4 @@ public class WaterShield : MonoBehaviour {
return v; return v;
} }
} }
...@@ -20,7 +20,6 @@ public class WaterShieldProjectile : MonoBehaviour { ...@@ -20,7 +20,6 @@ public class WaterShieldProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){ void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Enemy")){ if(c.transform.CompareTag("Enemy")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage); c.transform.SendMessage ("GetHit", damage);
} }
......
...@@ -31,9 +31,9 @@ public class TurtleActions : MonoBehaviour { ...@@ -31,9 +31,9 @@ public class TurtleActions : MonoBehaviour {
StartCoroutine (dead ()); StartCoroutine (dead ());
} }
//attack
if (DistanceToPlayer ().magnitude < 5 && canShoot == true) { if (DistanceToPlayer ().magnitude < 5 && canShoot == true) {
timer = 0; timer = 0;
Debug.Log ("1");
StartCoroutine (attack ()); StartCoroutine (attack ());
canShoot = false; canShoot = false;
} }
...@@ -91,31 +91,30 @@ public class TurtleActions : MonoBehaviour { ...@@ -91,31 +91,30 @@ public class TurtleActions : MonoBehaviour {
//Animation Control //Animation Control
void AminateMovement() { void AminateMovement() {
if (timer < 0.5) {
animator.SetBool ("isAttacking", true);
} else {
animator.SetFloat("X", Mathf.Abs(DirectionToPlayer().x)); animator.SetFloat("X", Mathf.Abs(DirectionToPlayer().x));
animator.SetFloat("Y", DirectionToPlayer().y); animator.SetFloat("Y", DirectionToPlayer().y);
animator.SetBool ("isAttacking", false);
Vector2 scale = new Vector2(1, 1); Vector2 scale = new Vector2(1, 1);
if(DirectionToPlayer().x != 0) if(DirectionToPlayer().x != 0)
scale.x = DirectionToPlayer().x; scale.x = DirectionToPlayer().x;
transform.localScale = scale; transform.localScale = scale;
}
} }
IEnumerator attack(){ IEnumerator attack(){
animator.SetBool ("isAttacking", true);
Vector2 dir = DirectionToPlayer (); Vector2 dir = DirectionToPlayer ();
yield return new WaitForSeconds (0.3f); yield return new WaitForSeconds (0.3f);
if (animator.GetBool ("isDead") == false) { if (animator.GetBool ("isDead") == false) {
Debug.Log ("2");
GameObject clone = Instantiate (projectile, this.transform.position, Quaternion.identity) as GameObject; GameObject clone = Instantiate (projectile, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<TurtleProjectile> ().move = dir; clone.GetComponent<TurtleProjectile> ().move = DirectionToPlayer ();
clone.GetComponent<TurtleProjectile> ().speed = speed; clone.GetComponent<TurtleProjectile> ().speed = speed;
} }
yield return new WaitForSeconds (0.25f);
animator.SetBool ("isAttacking", false);
} }
IEnumerator dead(){ IEnumerator dead(){
......
...@@ -20,7 +20,6 @@ public class TurtleProjectile : MonoBehaviour { ...@@ -20,7 +20,6 @@ public class TurtleProjectile : MonoBehaviour {
void OnCollisionEnter2D(Collision2D c){ void OnCollisionEnter2D(Collision2D c){
if(c.transform.CompareTag("Player")){ if(c.transform.CompareTag("Player")){
Debug.Log ("hit");
c.transform.SendMessage ("GetHit", damage); c.transform.SendMessage ("GetHit", damage);
} }
......
fileFormatVersion: 2
guid: d82b991eb2507f84bb413aed23f404c7
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ad4bf73242f185d489361f9c27f4f371
timeCreated: 1479606563
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: 6d2bd061f22ed2a4889cf39e38212518
timeCreated: 1479604851
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: 5d70fb513d8ad3f419f18f41110e52bd
timeCreated: 1479604850
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: 77a6f925311437f438471393208c0ea0
timeCreated: 1479604851
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