Esempio n. 1
0
    //코루틴
    protected virtual IEnumerator MS_Wait()
    {
        float _t = 0.0f;

        do
        {
            yield return(null);

            _t += Time.deltaTime;

            if (IsAlive && !CompareDist(this.transform.position, player.transform.position, 50.0f))
            {
                if (_t >= State.RestTime)
                {
                    SetState(CH_STATE.MS_Run);
                    break;
                }

                if (DetectPlayer() && !player.IsDead())
                {
                    SetState(CH_STATE.MS_AttackRun);
                    break;
                }
            }
        } while (!isNewState);
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            FSMPlayer player = other.GetComponent <FSMPlayer>();

            if (player != null)
            {
                if (player.IsAvoid())
                {
                    return;
                }
                if (player.IsDead())
                {
                    return;
                }
                if (player.IsInvicibility)
                {
                    return;
                }

                if (Name != null)
                {
                    MemoryPoolManager.Instance.CreateObject(Name, transform);
                }

                player.TakeDamage(AttackDamage);

                this.gameObject.SetActive(false);
            }
        }

        //For Plasma
        if (isGroundCollision)
        {
            if (other.gameObject.layer == 8)
            {
                MemoryPoolManager.Instance.CreateObject("Plasma", transform);
                this.gameObject.SetActive(false);
            }
        }
    }