public void TakeDamage(int amount) { if (this.hitPoints <= 0) { this.status = Status.Inactive; } switch (this.status) { case Status.Active: this.hitPoints -= ReduceDamage(amount); destructible.TakeDamage(ReduceDamage(amount)); break; case Status.Inactive: destructible.TakeDamage(amount); break; default: break; } }
// Update is called once per frame void Update() { if (destructibleInFront != null) { try //TODO: remove try catch and return bool if player is death { if (currentTile.GetGameObject(-Vector3.forward) == null) //Gameobject is not there anymore ?? NOT WORKING TODO { destructibleInFront = null; } else if (actionTick.IsAction()) { destructibleInFront.TakeDamage(Damage); } } catch { destructibleInFront = null; } } else if (!moving) { FindSelectableTiles(true); GetMoveOrAttackTile();//Moves the enemy or sets the destructibleInFront if (currentTile.tag == "BaseTile") { Gameover(); } } else { Move(); } if (CurrentHealth <= 0) { Die(); } }
public virtual void Attack(IDestructible target, PlayerStats wielder) { this.Use(); target.TakeDamage(this._attackPower, wielder, wielder.transform.position); }
public void ApplyDamage(IDestructible destructible) { destructible.TakeDamage(DamageAmount); }