public void FindEnemies() { Hit = Physics2D.OverlapCircleAll(transform.position, 200 << LayerMask.NameToLayer("Default")); for (int i = 0; i < Hit.Length; i++) { if (!IsEnemy && Hit[i].tag == "Enemy" && Hit[i].GetComponent <BaseKnightMovement>().Attackable) { FK = Hit[i].GetComponent <BaseKnightMovement>(); if (FK.GetComponent <Archer>()) { FK.GetComponent <Archer>().ArcherOpponent = this; } FK.Attackable = false; FK.FK = this; FK.OnDeath += TargetDied; OnDeath += FK.TargetDied; break; } else if (IsEnemy && Hit[i].tag == "Friendly" && Hit[i].GetComponent <BaseKnightMovement>().Attackable) { FK = Hit[i].GetComponent <BaseKnightMovement>(); if (FK.GetComponent <Archer>()) { FK.GetComponent <Archer>().ArcherOpponent = this; } FK.Attackable = false; //FK.OnDeath += TargetDied; OnDeath += FK.TargetDied; break; } } }
public void TargetDied() { if (FK != null) { FK.OnDeath -= TargetDied; OnDeath -= FK.TargetDied; FK.Attackable = true; } FK = null; if (!IsDead) { CanMove = true; } Attackable = true; }
public void TakeDamage(int Damage, BaseKnightMovement Sender) { Health -= Damage; if (Sender.GetComponent <Mage>()) { AOEEffect.SetActive(true); EffectActive = true; } if (Health <= 0) { //OnDeath(FK); HasDied(); } //StartCoroutine(RepeatAttack(Damage)); }
public void TakeDamage(int Damage, BaseKnightMovement Sender) { BaseHealth -= Damage; BaseHPText.text = "HP: " + BaseHealth; if (BaseHealth <= 0) { if (PlayerBase) { BattleManager.Instance.PlayerLost(); } else { BattleManager.Instance.PlayerWon(); } } }
public void Fire() { GameObject arrow = Instantiate(Arrow, FirePoint.transform.position, Quaternion.Euler(new Vector3(0, 0, -90))); if (FK != null) { arrow.GetComponent <Arrow>().Target = FK.gameObject; FK = null; ArcherOpponent = null; FindTarget(); } else if (NoMoreEnemies) { arrow.GetComponent <Arrow>().Target = OpponentsBase; } arrow.GetComponent <Arrow>().Damage = Damage; arrow.GetComponent <Arrow>().Sender = this; }
private void OnEnable() { if (PSM == null) { PSM = PlayerStatManager.Instance; } if (WM == null) { WM = WaveManager.Instance; } if (FK != null) { TargetDied(); } CanMove = true; IsDead = false; SetStats = true; FK = null; }