void OnHitEvent()
    {
        if (_lockTarget != null) // player is targeted
        {
            // hp
            GeneralStat targetStat = _lockTarget.GetComponent <GeneralStat>();
            targetStat.OnAttacked(_stat);

            if (targetStat.Hp > 0)
            {
                float distance = (_lockTarget.transform.position - transform.position).magnitude;
                if (_attackRange >= distance)
                {
                    SoundManager.instance.PlaySFX("SFX_Hit", 1.0f);
                    State = Define.State.Skill;
                }
                else
                {
                    State = Define.State.Moving;
                }
            }
            else
            {
                State = Define.State.Idle;
            }
        }
        else  // 플레이어 타겟팅 중이 아닐 땐
        {
            State = Define.State.Idle;
        }
    }
Beispiel #2
0
    protected virtual void OnDead(GeneralStat attacker)
    {
        PlayerStat playerStat = attacker as PlayerStat;

        if (playerStat != null)
        {
            playerStat.Exp += 1;
        }
        Managers.Game.Despawn(gameObject);
    }
    public override void Init()
    {
        WorldObjectType = Define.WorldObject.Monster;
        _stat           = gameObject.GetComponent <GeneralStat>();

        if (gameObject.GetComponentInChildren <UI_HPBar>() == null)
        {
            Managers.UI.MakeWorldSpaceUI <UI_HPBar>(transform);
        }
    }
Beispiel #4
0
    public virtual void OnAttacked(GeneralStat _attacker)
    {
        int damage = Mathf.Max(0, _attacker.Attack - Defense);

        Hp -= damage;

        if (Hp <= 0)
        {
            Hp = 0;
            SoundManager.instance.PlaySFX("SFX_MonsterDead", 1.0f);
            OnDead(_attacker);
        }
    }
    void OnHitEvent()
    {
        if (_lockTarget != null)
        {
            GeneralStat targetStat = _lockTarget.GetComponent <GeneralStat>();
            SoundManager.instance.PlaySFX(attackSoundName, 1.0f);
            targetStat.OnAttacked(_stat);
        }

        if (_stopSkill)
        {
            State = Define.State.Idle;
        }
        else
        {
            State = Define.State.Skill;
        }
    }
 public override void Init()
 {
     Bind <GameObject>(typeof(GameObjects));
     _stat = transform.parent.GetComponent <GeneralStat>();
 }
 protected override void OnDead(GeneralStat attacker)
 {
     Debug.Log("Player Dead");
     SoundManager.instance.PlaySFX("SFX- Female DEAD", 1.0f);
     loseCondition.Lose();
 }