Commit 1c55fbcd authored by Andrew Van Buren's avatar Andrew Van Buren

Added water boss damage/danger and boss music.

parent 0cb36019
......@@ -4,7 +4,9 @@ using System.Collections;
public class Boss : MonoBehaviour {
private Rigidbody2D rb;
public float speed = 1f;
public float speed = 75f;
public float dangerSpeedMultiplier = 2f;
public int dangerTheshold = 10;
public GameObject[] waypoints;
private Transform currentWaypoint;
public float distanceThreshold = 0.5f;
......@@ -17,9 +19,13 @@ public class Boss : MonoBehaviour {
public GameObject diety;
public Color damageColor;
public float damageColorSpeed = 8;
public Color dangerColor;
private SpriteRenderer sr;
private Animator animator;
public AudioClip bossMusic;
private AudioSource bgm;
GameObject player;
private bool triggered = false;
......@@ -34,6 +40,7 @@ public class Boss : MonoBehaviour {
player = GameObject.FindGameObjectWithTag("Player");
PickWaypoint();
rb.isKinematic = true;
bgm = Camera.main.GetComponentInChildren<AudioSource>();
}
// Update is called once per frame
......@@ -43,18 +50,24 @@ public class Boss : MonoBehaviour {
PickWaypoint();
} else {
Vector2 dir = currentWaypoint.position - transform.position;
Vector2 force = new Vector2(dir.x, dir.y) * speed;
rb.AddForce(Vector2.ClampMagnitude(force, speed));
Vector2 force = new Vector2(dir.x, dir.y) * speed * (health < dangerTheshold ? dangerSpeedMultiplier : 1);
rb.AddForce(Vector2.ClampMagnitude(force, speed * (health < dangerTheshold ? dangerSpeedMultiplier : 1)));
}
}
if(Time.time > lastAttack) {
lastAttack = Time.time + attackCooldown + Random.Range(0, attackRandom);
lastAttack = Time.time + (attackCooldown + Random.Range(0, attackRandom)) / (health < dangerTheshold ? dangerSpeedMultiplier : 1);
StartCoroutine(Attack());
}
sr.color = Color.Lerp(sr.color, Color.white, Time.deltaTime * damageColorSpeed);
// Set color
sr.color = Color.Lerp(sr.color, (health < dangerTheshold ? dangerColor : Color.white), Time.deltaTime * damageColorSpeed);
if(Vector2.Distance(player.transform.position, transform.position) < triggerDist) {
if (!triggered) {
bgm.clip = bossMusic;
bgm.Play();
}
triggered = true;
animator.SetBool("Moving", true);
rb.isKinematic = false;
......@@ -76,7 +89,7 @@ public class Boss : MonoBehaviour {
void GetHit(int amount) {
if (triggered) {
health -= health;
health -= amount;
sr.color = damageColor;
if (health <= 0) {
Die();
......@@ -85,6 +98,7 @@ public class Boss : MonoBehaviour {
}
void Die() {
bgm.Stop();
Instantiate(diety, transform.position, Quaternion.identity);
Destroy(gameObject);
}
......
fileFormatVersion: 2
guid: 85eee806e25b00c42bd485a380e2d51d
timeCreated: 1479602249
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