Ejemplo n.º 1
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;
    }
Ejemplo n.º 2
0
    /// <summary> 플레이어 기본 컨트롤러 </summary>
    IEnumerator IE_BaseController()
    {
        while (_currHP > 0 && _myState.Equals(PLAYER_STATE.IDLE))
        {
            #region 이동관련 : 우클릭한 지면 좌표 저장
            if (Input.GetMouseButtonDown(1))
            {
                SetRayHitPos_Ground();
            }
            #endregion

            if (targetUnit == null)
            {
                #region 이동관련 : 입력 좌표에 도달했는가
                if (isMove)
                {
                    distance = Vector3.Distance(transform.position, _targetPos);
                    if (distance < 0.15f)
                    {
                        isMove = false;
                        //_animator.SetTrigger("IDLE");
                        photonView.RPC("CallbackRPC_AnimatorTrigger", RpcTarget.All, photonView.ViewID, "IDLE");
                    }
                    else
                    {
                        //Correction_DirectionVector();
                        transform.Translate(dir * _speed * Time.deltaTime, Space.World);
                    }
                }
                #endregion
            }
            else
            {
                distance = Vector3.Distance(transform.position, targetUnit.Get_Position());
                //공격범위에 들어왔다면 공격
                if (distance < _attackDistance)
                {
                    isMove = false;
                    Set_StateMachine(PLAYER_STATE.ATTACK);
                    yield break;
                }
                //이외에 추적
                else
                {
                    //애니메이션
                    if (!isMove)
                    {
                        //_animator.SetTrigger("MOVE");
                        photonView.RPC("CallbackRPC_AnimatorTrigger", RpcTarget.All, photonView.ViewID, "MOVE");
                    }
                    isMove = true;

                    _animator.transform.LookAt(new Vector3(targetUnit.Get_Position().x, transform.position.y, targetUnit.Get_Position().z));

                    //Correction_DirectionVector();
                    transform.Translate(dir * _speed * Time.deltaTime, Space.World);
                }
            }

            yield return(null);
        }
    }