using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; public class Collisions : MonoBehaviour { /*CODE DEALING WITH COLLISIONS ON THE ENEMY...*/ private float hitpoints = 10; // base ten for now, will change with hp stat, etc (implement later) public WeaponStats[] weapons; public int currentWeapon = 0; void Update() { if (hitpoints <= 0) { Death(); } } void OnTriggerEnter2D(Collider2D col) { if (this.tag == "Weapon") { // weapons won't break return; } else { hitpoints = hitpoints - Random.Range(weapons[currentWeapon].damageMin,weapons[currentWeapon].damageMax); } } void Death() { if (this.tag == "Player") { SceneManager.LoadScene("mainScene1"); // spawn player in the town } else { Destroy(this); // delete enemy } } }