void OnDestroy() { if (stats.currentHP <= 0) { gameController.enemiesKilled++; gameController.AddScore(stats.ScoreValue); } }
//Collision Detection Script void OnTriggerEnter(Collider other) { if (other == null) { return; } switch (other.tag) { case "EnemyShieldGenerator": case "EnemyShield": case "Enemy": Debug.Log("This is" + gameObject.tag); player.stats.currentHP -= other.GetComponent <scr_enemyStats>().stats.Damage; gameController.enemiesKilled++; Destroy(other.gameObject); Instantiate(explosion, other.transform.position, other.transform.rotation); gameController.AddScore(other.GetComponent <scr_enemyStats>().stats.ScoreValue); gameController.HUDcharacter.Play("damage"); break; case "FoeWeapon": player.stats.currentHP -= other.GetComponent <scr_enemyStats>().stats.Damage; Destroy(other.gameObject); Instantiate(explosion, other.transform.position, other.transform.rotation); gameController.HUDcharacter.Play("damage"); break; case "PickupGreen": gameController.powerupAction("Green", player); Instantiate(healthPowerup, transform.position, transform.rotation); Destroy(other.gameObject); break; case "PickupRed": gameController.powerupAction("Red", player); Instantiate(redPowerup, transform.position, transform.rotation); Destroy(other.gameObject); break; case "PickupBlue": gameController.powerupAction("Blue", player); Instantiate(bluePowerup, transform.position, transform.rotation); Destroy(other.gameObject); break; } if (player.stats.currentHP < 0) { gameController.powerupAction("Death", player); } }
//Collision Detection Script void OnTriggerEnter(Collider other) { switch (other.tag) { case "Enemy": other.GetComponent <scr_enemyStats>().stats.currentHP -= this.stats.Damage; Instantiate(explosion, transform.position, transform.rotation); if (this.tag != "SS") { Destroy(gameObject); } if (other.GetComponent <scr_enemyStats>().stats.currentHP <= 0) { Destroy(other.gameObject); //gameController.HUDcharacter.Play("enemyDown"); } break; case "EnemyShield": Destroy(gameObject); break; case "EnemyShieldGenerator": other.GetComponent <scr_enemyStats>().stats.currentHP -= this.stats.Damage; Instantiate(explosion, transform.position, transform.rotation); if (this.tag != "SS") { Destroy(gameObject); } if (other.GetComponent <scr_enemyStats>().stats.currentHP <= 0) { gameController.AddScore(other.GetComponent <scr_enemyStats>().stats.ScoreValue); } break; } }
public void addScore(int score) { GC.AddScore(score); }