コード例 #1
0
        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);
        }
コード例 #2
0
 void Awake()
 {
     instance = this;
     HpChange += SetHp;
     SpChange += SetSp;
     Powerlow += LowerPower;
 }
コード例 #3
0
 public void Interaction()
 {
     OnHpChanged?.Invoke(this, new HpModelEventArgs(Damage));
     if (_hpModel.Hp <= 0)
     {
         OnPlayerDead?.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #4
0
        public void Heal(int healAmount)
        {
            this.Hp += healAmount;
            if (this.Hp > ActorInfo.MaxHp)
            {
                this.Hp = ActorInfo.MaxHp;
            }

            OnHpChanged?.Invoke(this.Hp);
        }
コード例 #5
0
 internal void HpChanged()
 {
     OnHpChanged?.Invoke(this);
     Debug.WriteLine($"{Name} hp changed to {Level.Hp}");
     if (Level.Hp <= 0)
     {
         DropManager.DropAndSpawn(LastHitCharacter);
         Destroy();
     }
 }
コード例 #6
0
 public void DeductHp(int amount)
 {
     Hp -= amount;
     OnHpChanged?.Invoke(Hp);
 }