Пример #1
0
    private IEnumerator IE_AttackController()
    {
        photonView.RPC("CallbackRPC_AnimatorTrigger", RpcTarget.All, photonView.ViewID, "ATTACK");

        //애니메이션 이벤트 리시버 에러로 인한 코루틴 처리
        StartCoroutine(IE_AnimEvent_Attack());

        float delay = atkAnimTime;

        while (_currHP > 0 && _myState.Equals(PLAYER_STATE.ATTACK))
        {
            if (targetUnit == null)
            {
                break;
            }
            _animator.transform.LookAt(targetUnit.Get_Position());

            //공격모션 중간에 우클릭을 통해 공격캔슬, 이동한다.
            if (Input.GetMouseButtonDown(1))
            {
                SetRayHitPos_Ground();
                Set_StateMachine(PLAYER_STATE.IDLE);
                break;
            }

            delay -= Time.deltaTime;
            if (delay <= 0)
            {
                //공격 후 공격 범위에 있다면 공격을 지속하고, 아니라면 기본 컨트롤러로 상태를 변환한다.
                //또는 상대가 죽었다면 공격을 중지한다.
                distance = Vector3.Distance(targetUnit.Get_Position(), transform.position);
                if (distance > _attackDistance || targetUnit.Check_IsDead())
                {
                    targetUnit = null;
                    Set_StateMachine(PLAYER_STATE.IDLE);
                }
                else
                {
                    Set_StateMachine(PLAYER_STATE.ATTACK);
                }

                yield break;
            }

            yield return(null);
        }
    }
Пример #2
0
    /// <summary>
    /// 평타 프로젝타일 프로세스
    /// </summary>
    /// <param name="spd"></param>
    /// <param name="index"></param>
    /// <returns></returns>
    private IEnumerator IE_MissileAttack(float spd, int index)
    {
        float   subDistance;
        Vector3 dir;

        yield return(new WaitForEndOfFrame());

        Transform misslie = _meleeProjectile[index];

        misslie.transform.position = transform.position + Vector3.up;
        ITargetUnit tempTarget = targetUnit; //타겟 지정

        MainManager.instance.Set_ActiveProjectile(_meleeProjectile[index].gameObject, true);
        //_meleeProjectile[index].gameObject.SetActive(true);

        do
        {
            if (tempTarget == null)
            {
                break;
            }
            subDistance = Vector3.Distance(tempTarget.Get_Position(), new Vector3(misslie.transform.position.x, tempTarget.Get_Position().y, misslie.transform.position.z));

            dir = tempTarget.Get_Position() - new Vector3(misslie.transform.position.x, tempTarget.Get_Position().y, misslie.transform.position.z);
            dir.Normalize();
            misslie.transform.Translate(dir * _speed * Time.deltaTime, Space.World);

            yield return(null);
        } while (subDistance >= 0.1f);

        if (tempTarget != null)
        {
            tempTarget.Set_Target(this);
            tempTarget.TakeDamage(_attackDamage);
            if (tempTarget.Check_IsDead())
            {
                Add_Money(tempTarget.Get_TargetCredit());
            }
        }
        MainManager.instance.Set_ActiveProjectile(misslie.gameObject, false);
        // _meleeProjectile[index].gameObject.SetActive(false);
        //_meleeProjectile.parent = _animator.transform;
    }