diff options
author | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-28 07:00:22 +0200 |
---|---|---|
committer | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-28 07:00:22 +0200 |
commit | 4bef89a38609b1c40f05b81f68e065527701b780 (patch) | |
tree | b32a9d0afdcaee05a3264e52ab9ec7106fb7c80e /nGJ2019/Assets/Scripts | |
parent | 62194a5924f0ab8f26693d96a58195cb4380d69c (diff) |
dragon death
Diffstat (limited to 'nGJ2019/Assets/Scripts')
-rw-r--r-- | nGJ2019/Assets/Scripts/DragonMovement.cs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs index f0965a2..4c377a5 100644 --- a/nGJ2019/Assets/Scripts/DragonMovement.cs +++ b/nGJ2019/Assets/Scripts/DragonMovement.cs @@ -207,6 +207,9 @@ public class DragonMovement : MonoBehaviour if(hurtCooldown > 0) hurtCooldown -= Time.deltaTime; + if(healthBar.health <= 0) + return; + // keyboard scheme if(Input.GetKey("w")) moveUp(); @@ -265,11 +268,11 @@ public class DragonMovement : MonoBehaviour Gizmos.DrawWireCube(Vector3.zero, new Vector3(2*horizontalBound, 2*verticalBound, 0)); } - private IEnumerator makeGoAway(Transform t) + private IEnumerator makeGoAway(Transform t, float spread) { Vector3 delta = Random.onUnitSphere * Random.Range(0.03f, 0.1f); Vector3 start = t.position; - while((start-t.position).magnitude < 3) + while((start-t.position).magnitude < spread) { t.Translate(delta); yield return new WaitForSeconds(0.01f); @@ -282,12 +285,25 @@ public class DragonMovement : MonoBehaviour if(hurtCooldown <= 0) { healthBar.health--; - hurtCooldown = 3; - - for(int i=0; i<30; i++) + if(healthBar.health == 0) + { + for(int i=0; i<200; i++) + { + Transform t = ((GameObject)Instantiate(hurtPrefab, transform.position + swarm.collapseCenter, Quaternion.identity)).transform; + StartCoroutine(makeGoAway(t, 6)); + } + turnVisible(false); + swarm.activate(false); + } + else if(healthBar.health > 0) { - Transform t = ((GameObject)Instantiate(hurtPrefab, transform.position + swarm.collapseCenter, Quaternion.identity)).transform; - StartCoroutine(makeGoAway(t)); + hurtCooldown = 1.5f; + + for(int i=0; i<30; i++) + { + Transform t = ((GameObject)Instantiate(hurtPrefab, transform.position + swarm.collapseCenter, Quaternion.identity)).transform; + StartCoroutine(makeGoAway(t, 3)); + } } } } |