Commit 6618db9d authored by Jordan B Mckenney's avatar Jordan B Mckenney
Browse files

Added turtle enemy

parent ef138b1e
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3012442563a124740896406d7298194d guid: 0ba698c06397ec44e8ab14d4f7c8487a
timeCreated: 1479439371 timeCreated: 1479439371
licenseType: Free licenseType: Free
NativeFormatImporter: NativeFormatImporter:
......
...@@ -19,6 +19,7 @@ public class Actions : MonoBehaviour { ...@@ -19,6 +19,7 @@ public class Actions : MonoBehaviour {
public bool waterShieldUsable = true; public bool waterShieldUsable = true;
private float waterShieldTimer = 0.0f; private float waterShieldTimer = 0.0f;
public float waterShieldCooldown = 5.0f; public float waterShieldCooldown = 5.0f;
public float fireballCooldown = 0.5f;
private Vector3 LastInput = new Vector2(0, -1); private Vector3 LastInput = new Vector2(0, -1);
...@@ -47,8 +48,8 @@ public class Actions : MonoBehaviour { ...@@ -47,8 +48,8 @@ public class Actions : MonoBehaviour {
} }
if(waterShieldUsable == false) { if(waterShieldUsable == false) {
waterShieldTimer += Time.deltaTime; waterShieldTimer -= Time.deltaTime;
if(waterShieldTimer > waterShieldCooldown) { if(waterShieldTimer <= 0) {
waterShieldUsable = true; waterShieldUsable = true;
waterShieldTimer = 0.0f; waterShieldTimer = 0.0f;
} }
...@@ -92,9 +93,14 @@ public class Actions : MonoBehaviour { ...@@ -92,9 +93,14 @@ public class Actions : MonoBehaviour {
switch(myCurrentAbility) { switch(myCurrentAbility) {
case "Ability - Fireball": case "Ability - Fireball":
GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject; if (waterShieldUsable == true) {
clone.GetComponent<FireballProjectile>().move = LastInput; GameObject clone = Instantiate (currentAbility, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<FireballProjectile>().speed = fireballSpeed; clone.GetComponent<FireballProjectile> ().move = LastInput;
clone.GetComponent<FireballProjectile> ().speed = fireballSpeed;
waterShieldTimer = fireballCooldown;
waterShieldUsable = false;
}
break; break;
case "Ability - Water Shield": case "Ability - Water Shield":
...@@ -102,6 +108,7 @@ public class Actions : MonoBehaviour { ...@@ -102,6 +108,7 @@ public class Actions : MonoBehaviour {
GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity); GameObject myShield = (GameObject)Instantiate(currentAbility, transform.position, Quaternion.identity);
WaterShield waterShield = myShield.GetComponent<WaterShield>(); WaterShield waterShield = myShield.GetComponent<WaterShield>();
waterShieldTimer = waterShieldCooldown;
waterShieldUsable = false; waterShieldUsable = false;
} }
break; break;
......
...@@ -11,33 +11,39 @@ public class TurtleActions : MonoBehaviour { ...@@ -11,33 +11,39 @@ public class TurtleActions : MonoBehaviour {
private bool canShoot = true; private bool canShoot = true;
private float timer = 0f; private float timer = 0f;
private float animTimer = 0f;
private Animator animator;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
animator = GetComponent<Animator>();
} }
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
AminateMovement ();
dist = DistanceToPlayer ().magnitude; dist = DistanceToPlayer ().magnitude;
p = DirectionToPlayer (); p = DirectionToPlayer ();
if (health <= 0) { if (health <= 0) {
Destroy (gameObject); animator.SetBool ("isDead", true);
StartCoroutine (dead ());
} }
if (DistanceToPlayer ().magnitude < 5 && canShoot == true) { if (DistanceToPlayer ().magnitude < 5 && canShoot == true) {
GameObject clone = Instantiate (projectile, this.transform.position, Quaternion.identity) as GameObject; timer = 0;
clone.GetComponent<TurtleProjectile> ().move = DirectionToPlayer (); Debug.Log ("1");
clone.GetComponent<TurtleProjectile> ().speed = speed; StartCoroutine (attack ());
canShoot = false; canShoot = false;
} }
if (canShoot == false) { if (canShoot == false) {
timer += Time.deltaTime; timer += Time.deltaTime;
if (timer >= 2) { if (timer >= 2) {
canShoot = true; canShoot = true;
timer = 0;
} }
} }
} }
...@@ -81,4 +87,41 @@ public class TurtleActions : MonoBehaviour { ...@@ -81,4 +87,41 @@ public class TurtleActions : MonoBehaviour {
return dir; return dir;
} }
//Animation Control
void AminateMovement() {
if (timer < 0.5) {
animator.SetBool ("isAttacking", true);
} else {
animator.SetFloat("X", Mathf.Abs(DirectionToPlayer().x));
animator.SetFloat("Y", DirectionToPlayer().y);
animator.SetBool ("isAttacking", false);
Vector2 scale = new Vector2(1, 1);
if(DirectionToPlayer().x != 0)
scale.x = DirectionToPlayer().x;
transform.localScale = scale;
}
}
IEnumerator attack(){
Vector2 dir = DirectionToPlayer ();
yield return new WaitForSeconds (0.3f);
if (animator.GetBool ("isDead") == false) {
Debug.Log ("2");
GameObject clone = Instantiate (projectile, this.transform.position, Quaternion.identity) as GameObject;
clone.GetComponent<TurtleProjectile> ().move = dir;
clone.GetComponent<TurtleProjectile> ().speed = speed;
}
}
IEnumerator dead(){
yield return new WaitForSeconds (0.5f);
Destroy (this.gameObject);
}
} }
fileFormatVersion: 2
guid: a25513e707cbe794aa471c196b40ee22
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -32,7 +32,7 @@ TextureImporter: ...@@ -32,7 +32,7 @@ TextureImporter:
cubemapConvolutionSteps: 7 cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5 cubemapConvolutionExponent: 1.5
seamlessCubemap: 0 seamlessCubemap: 0
textureFormat: -1 textureFormat: -3
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
filterMode: 0 filterMode: 0
......
...@@ -32,7 +32,7 @@ TextureImporter: ...@@ -32,7 +32,7 @@ TextureImporter:
cubemapConvolutionSteps: 7 cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5 cubemapConvolutionExponent: 1.5
seamlessCubemap: 0 seamlessCubemap: 0
textureFormat: -1 textureFormat: -3
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
filterMode: 0 filterMode: 0
......
...@@ -31,7 +31,7 @@ TextureImporter: ...@@ -31,7 +31,7 @@ TextureImporter:
cubemapConvolutionSteps: 7 cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5 cubemapConvolutionExponent: 1.5
seamlessCubemap: 0 seamlessCubemap: 0
textureFormat: -1 textureFormat: -3
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
filterMode: 0 filterMode: 0
......
fileFormatVersion: 2
guid: b5c8349c3dcc74544a2c657ffc029ae9
folderAsset: yes
timeCreated: 1475801899
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: de34d2e5dacc1954db51bf3eb83a2bf1
timeCreated: 1479596022
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 229a89a03d477f24eb8a396178fb02f6
timeCreated: 1479596302
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2 fileFormatVersion: 2
guid: 1f42adc9c6eebcd438edc4fce3785851 guid: bda143e81e957594dbf68ac33d929d87
timeCreated: 1479434707 timeCreated: 1479595168
licenseType: Free licenseType: Free
NativeFormatImporter: NativeFormatImporter:
userData: userData:
......
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