/*! * Event handler for when arrow hits an object with a collider * @param col is the other object */ void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Enemy") { enemy = col.gameObject.GetComponent <MobHealth> (); switch (arrowDmgType) { case arrowDmgTypes.basic: enemy.DoDamage(player.arrowDmg); break; case arrowDmgTypes.fire: enemy.StartBurn(player.arrowDmg / 2f, player.burnAmount); break; case arrowDmgTypes.ice: enemy.ApplyFreeze(player.arrowDmg, player.freezeTime); break; case arrowDmgTypes.slow: enemy.ApplySlow(player.arrowDmg, player.slowMult); break; } DestroySelf(); } else if (col.gameObject.tag == "World") { DestroySelf(); } }
private void Start() { player = GameObject.FindGameObjectWithTag("Player"); gameManager = FindObjectOfType <GameManager>(); mobHealth = GetComponent <MobHealth>(); baseFireRate *= PlayerPrefs.GetFloat("difficulty"); fireRate = baseFireRate; healthBar = GameObject.FindGameObjectWithTag("HealthBar"); healthBarTransform = healthBar.GetComponent <RectTransform>(); canFire = true; canBurst = true; }
// Update is called once per frame void Update() { if (active && Time.time > nextSpawn) { nextSpawn = Time.time + spawnRate; if (currentMobs < maxMobs) { currentMobs++; MobHealth mh = (MobHealth)Instantiate(mob, transform.position, Quaternion.identity); mh.SetSpawner(gameObject.GetComponent <SpawnerController>()); } } }
private void Start() { mobHealth = GetComponent <MobHealth>(); StartCoroutine(Extinguish()); }
//frames private void Awake() { myAnimator = GetComponent <Animator>(); myRigidbody2D = GetComponent <Rigidbody2D>(); healthScript = GetComponent <MobHealth>(); }