public override bool Execute(GameObject target)
    {
        FSMPlayer player = target.GetComponent <FSMPlayer>();

        if (player != null)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit HitInfo;

            if (Physics.Raycast(ray, out HitInfo, 100f, player.Layer))
            {
                int layer = HitInfo.transform.gameObject.layer;        //클릭한 레이어의 값

                if (layer == LayerMask.NameToLayer(player.clickLayer)) //땅을 클릭했을 때
                {
                    Vector3 dest = HitInfo.point;                      //마우스로 찍은 위치

                    player.Point.transform.position = dest;

                    if (!player.IsWhirlwind())
                    {
                        player.SetState(CH_STATE.Run);                        //휠윈드 상태가 아닐 때는 달리자
                    }
                    return(true);
                }

                else if (layer == LayerMask.NameToLayer(player.enemyLayer))    //적을 클릭 했을 때
                {
                    player.Enemy = HitInfo.collider.GetComponent <FSMEnemy>(); //적의 컴퍼넌트를 가져온다.

                    player.Point.SetParent(player.Enemy.transform);
                    player.Point.transform.localPosition = Vector3.zero;

                    if (!player.IsWhirlwind() && !player.Enemy.IsDead())
                    {
                        if (Vector3.Distance(player.transform.position, player.Point.transform.position) <= player.State.AttackRange)
                        {
                            player.SetState(CH_STATE.Attack);
                        }
                        else
                        {
                            player.SetState(CH_STATE.AttackRun);
                        }
                    }

                    return(false);
                }
            }
        }

        return(true);
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Enemy"))
        {
            IsAttack = true;
        }


        if (Player.IsWhirlwind() && Player.m_Anim.GetCurrentAnimatorStateInfo(0).IsName("WhirlwindShot") &&
            other.CompareTag("Enemy"))
        {
            FSMEnemy Enemy = other.GetComponent <FSMEnemy>();
            Enemy.TakeDamage();
        }
    }
Beispiel #3
0
    private bool CommonSkill(int index, bool isRaycast, bool isPlayingWhirlwind = false)
    {
        if (player.IsThrowAxe())
        {
            return(false);
        }
        if (player.IsAvoid())
        {
            return(false);
        }
        if (player.IsBuff())
        {
            return(false);
        }
        if (player.IsDash())
        {
            return(false);
        }
        if (player.IsBash())
        {
            return(false);
        }
        if (player.IsWhirlwind())
        {
            return(false);
        }
        if (UIManager.Instance.CoolTimes[index].fillAmount > 0)
        {
            return(false);
        }

        if (!player.IsWeaponEquiped)
        {
            player.EquipWeapon(true);
        }

        if (isRaycast)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit HitInfo;

            if (Physics.Raycast(ray, out HitInfo, 100f, player.Layer))
            {
                Vector3 dest = HitInfo.point;

                player.Point.transform.position = dest;

                if (player.Point.parent)
                {
                    player.ChangeShader(player.Point.parent.GetComponentsInChildren <SkinnedMeshRenderer>(), "Custom/DissolveShader");
                    player.Point.parent = null;
                }
            }
            else
            {
                return(false);
            }
        }

        if (isPlayingWhirlwind == false)
        {
            UIManager.Instance.CoolTimes[index].fillAmount = 1;
            StartCoroutine(UIManager.Instance.SkillCoolTime(index));
        }

        return(true);
    }
    public void TakeDamage()
    {
        if (IsDead())
        {
            return;
        }

        StartCoroutine(ReDoColor());

        ChangeColor(GetComponentsInChildren <SkinnedMeshRenderer>(), new Color(0.3455882f, 0, 0));

        float Damage;

        if (player.IsWhirlwind())
        {
            Damage = Random.Range(player.MinDamage / 2, player.MaxDamage / 2);

            SoundManager.Instance.PlaySFX("Whirlwind_Explosion", 0.3f);

            Health.TakeDamage((int)Damage);
        }
        else if (player.IsBash())
        {
            Damage = Random.Range(player.MinDamage * 2, player.MaxDamage * 2);

            Health.TakeDamage((int)Damage);
        }
        else
        {
            Damage = Random.Range(player.MinDamage, player.MaxDamage);

            SoundManager.Instance.PlaySFX("BasicAttack", 0.5f);

            Health.TakeDamage((int)Damage);
        }

        MemoryPoolManager.Instance.CreateObject("Hit1", transform);

        Vector3 FontPosition;

        if (this.State.Name != "Evil Orca")
        {
            FontPosition = new Vector3(transform.position.x, this.transform.position.y + 2.0f, transform.position.z);
        }
        else
        {
            FontPosition = new Vector3(transform.position.x, this.transform.position.y + 6.0f, transform.position.z);
        }

        MemoryPoolManager.Instance.CreateTextObject("DamageFont", FontPosition, (int)Damage);

        if (Health.IsDeath())
        {
            ChangeShader(GetComponentsInChildren <SkinnedMeshRenderer>(), "Custom/DissolveShader");
            NavMesh.isStopped = true;
            SetState(CH_STATE.MS_Dead);

            stringBuilder.Length = 0;
            stringBuilder.Append(State.Name);
            stringBuilder.Append("_Death");

            SoundManager.Instance.PlaySFX(stringBuilder.ToString());
            return;
        }

        if (CHState != CH_STATE.MS_Attack && CHState != CH_STATE.MS_Attack2 && CHState != CH_STATE.MS_Attack3 && CHState != CH_STATE.MS_BigAttack)
        {
            MoveUtil.RotateToDirBurst(transform, player.transform);
        }
    }