public bool GiveDamage(ActorBase attacker, int damage) { if (IsInvincible == true) { return(false); } this.Hp -= damage; if (this.Hp <= 0) { this.Hp = 0; ActorContainer.Instance.Remove(this); EffectManager.Instance.Show(EffectType.Dead, this.transform.position); Destroy(this.gameObject); } OnHpChanged?.Invoke(this.Hp); OnDamaged?.Invoke(); Vector2 attackDirection = this.transform.position - attacker.transform.position; float pushPower = 10f; if (attacker is Character && (attacker as Character).Weapon is MeleeWeapon) { pushPower = ((attacker as Character).Weapon as MeleeWeapon).MeleeWeaponInfo.PushPower; } PushByHit(pushPower, attackDirection.normalized); StartCoroutine(InvincibleProcess()); return(true); }
public void Interaction() { OnHpChanged?.Invoke(this, new HpModelEventArgs(Damage)); if (_hpModel.Hp <= 0) { OnPlayerDead?.Invoke(this, EventArgs.Empty); } }
public void Heal(int healAmount) { this.Hp += healAmount; if (this.Hp > ActorInfo.MaxHp) { this.Hp = ActorInfo.MaxHp; } OnHpChanged?.Invoke(this.Hp); }
internal void HpChanged() { OnHpChanged?.Invoke(this); Debug.WriteLine($"{Name} hp changed to {Level.Hp}"); if (Level.Hp <= 0) { DropManager.DropAndSpawn(LastHitCharacter); Destroy(); } }
public void DeductHp(int amount) { Hp -= amount; OnHpChanged?.Invoke(Hp); }