using UnityEngine; using System.Threading.Tasks; using System.Linq; //Designed by Jacob Weedman // Attatch to particle weapons public class EnemyParticleWeapon : MonoBehaviour { public bool destroy = false; public bool rotate = false; public bool opacity = false; public bool destroyOnCollide = false; public bool damageEnemies; public int damageAmmount; public float timer; float startTime; void Awake() { startTime = timer; } void FixedUpdate() { /* if (IsExplosion) { // Tick down animation counter AnimationTimer -= Time.deltaTime; GetComponent().sprite = ExplosionSprites[CurrentFrame]; if (AnimationTimer <= 0 && CurrentFrame < 0) { AnimationTimer = 0.5f; CurrentFrame++; } } */ // Rotation if (rotate) { transform.rotation = Quaternion.Euler(Vector3.forward * UnityEngine.Random.Range(-90, 90)); } // Opacity if (opacity) { gameObject.GetComponent().color = new Color(1f, 1f, 1f, (timer / startTime)); } // Destruction Timer if (destroy) { timer -= Time.deltaTime; if (timer <= 0) { Destroy(gameObject); } } // Remove Collider To Prevent Multiple Damage Occurances if (timer/startTime <= 0.99) { gameObject.GetComponent().enabled = false; } } void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { //Damage GameObject.Find("GameData").GetComponent().CurrentHealth -= damageAmmount; } if (collision.gameObject.tag == "Attackable") { //Enemies if (collision.GetComponent()) { collision.GetComponent().Health -= damageAmmount; } //Generic Destructable Object if (collision.GetComponent()) { collision.GetComponent().Health -= damageAmmount; } } if (destroyOnCollide) { if (collision.gameObject.tag == "Ground") { if (collision.gameObject.layer == 6) { Destroy(gameObject); } } } } }