Commit 9eb1fc2b authored by Andrew Van Buren's avatar Andrew Van Buren
Browse files

Added water boss aniations/trigger and added new water sprite.

parent d6f4bbbf
fileFormatVersion: 2
guid: 6a92e97445ac40a43a7a182b47b86de1
timeCreated: 1479597178
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -15,17 +15,30 @@ public class Boss : MonoBehaviour {
public float projectileSpeed = 5;
public int health = 100;
public GameObject diety;
public Color damageColor;
public float damageColorSpeed = 8;
private SpriteRenderer sr;
private Animator animator;
GameObject player;
private bool triggered = false;
public float triggerDist = 10f;
// Use this for initialization
void Start () {
waypoints = GameObject.FindGameObjectsWithTag("Waypoint");
rb = GetComponent<Rigidbody2D>();
sr = GetComponent<SpriteRenderer>();
animator = GetComponent<Animator>();
player = GameObject.FindGameObjectWithTag("Player");
PickWaypoint();
rb.isKinematic = true;
}
// Update is called once per frame
void Update () {
if (currentWaypoint) {
if (currentWaypoint && triggered) {
if (Vector2.Distance(transform.position, currentWaypoint.position) < distanceThreshold) {
PickWaypoint();
} else {
......@@ -37,11 +50,14 @@ public class Boss : MonoBehaviour {
if(Time.time > lastAttack) {
lastAttack = Time.time + attackCooldown + Random.Range(0, attackRandom);
StartCoroutine(Attack());
}
Shoot(0);
Shoot(90);
Shoot(180);
Shoot(270);
sr.color = Color.Lerp(sr.color, Color.white, Time.deltaTime * damageColorSpeed);
if(Vector2.Distance(player.transform.position, transform.position) < triggerDist) {
triggered = true;
animator.SetBool("Moving", true);
rb.isKinematic = false;
}
}
......@@ -59,9 +75,12 @@ public class Boss : MonoBehaviour {
}
void GetHit(int amount) {
health -= health;
if (health <= 0) {
Die();
if (triggered) {
health -= health;
sr.color = damageColor;
if (health <= 0) {
Die();
}
}
}
......@@ -69,4 +88,17 @@ public class Boss : MonoBehaviour {
Instantiate(diety, transform.position, Quaternion.identity);
Destroy(gameObject);
}
IEnumerator Attack() {
if (triggered) {
animator.SetBool("Attacking", true);
yield return new WaitForSeconds(0.3f);
Shoot(0);
Shoot(90);
Shoot(180);
Shoot(270);
yield return new WaitForSeconds(0.3f);
animator.SetBool("Attacking", false);
}
}
}
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