aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2019-04-28 07:25:30 +0200
committermarcinzelent <zelent.marcin@gmail.com>2019-04-28 07:25:30 +0200
commit397abd83dc791d0d8cbbd20d918164c0c37143da (patch)
tree2febf471d15e6358ae104dce8b1f078642e4985d /nGJ2019/Assets/Scripts
parent3c5d537524d90993f54600bf78d043110d708b35 (diff)
parent4bef89a38609b1c40f05b81f68e065527701b780 (diff)
Merge branch 'master' of https://github.com/marcinzelent/ngj2019
Diffstat (limited to 'nGJ2019/Assets/Scripts')
-rw-r--r--nGJ2019/Assets/Scripts/DragonMovement.cs42
1 files changed, 35 insertions, 7 deletions
diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs
index 302a9e7..4c377a5 100644
--- a/nGJ2019/Assets/Scripts/DragonMovement.cs
+++ b/nGJ2019/Assets/Scripts/DragonMovement.cs
@@ -17,6 +17,8 @@ public class DragonMovement : MonoBehaviour
public float horizontalBound = 6f;
public float verticalBound = 4f;
+ private float slitherPhase = 0;
+
public HealthBar healthBar;
private float hurtCooldown = 0;
@@ -188,6 +190,16 @@ public class DragonMovement : MonoBehaviour
if(transform.position.x > horizontalBound)
transform.position = new Vector3(horizontalBound, transform.position.y, transform.position.z);
+
+ slitherPhase += 0.1f;
+ foreach(Transform t in swarm.meshRender.bones)
+ {
+ t.Translate(new Vector3(0, Mathf.Sin(t.position.x-transform.position.x+slitherPhase)*0.002f, 0), Space.World);
+ }
+ foreach(Renderer r in solids)
+ {
+ r.transform.Translate(new Vector3(0, Mathf.Sin(r.transform.position.x-transform.position.x+slitherPhase+0.2f)*-0.008f, 0), Space.World);
+ }
}
void Update()
@@ -195,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();
@@ -253,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);
@@ -270,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));
+ }
}
}
}