Example #1
0
    public void Update()
    {
        if (Input.GetKeyDown("space"))
        {
            Debug.Log("remoteMoveSpeed value: " + remoteMoveSpeed);
            Debug.Log("리모트 캐릭 애니 런 스킬 발동: " + skillOne.receivedSkileOne);
        }

        if (MoveFlag == true)
        {
            Debug.Log("Network Script void Update if MoveFlag Log ");
            player2.eulerAngles = new Vector3(0, Mathf.Atan2(JoyVec.x, JoyVec.y) * Mathf.Rad2Deg, 0);
            Debug.Log("Network Script void Update if MoveFlag Log 1");
            player2.transform.Translate(Vector3.forward * Time.deltaTime * remoteMoveSpeed);
            Debug.Log("Network Script void Update if MoveFlag Log 2");
            remoteAni.ChangeAni(RemoteAni.ANI_WALK);
            Debug.Log("Network Script void Update if MoveFlag Log 3");
            Stop = true;

            //if (skillcheck.Equals("SkillOne") && skillOne.receivedSkileOne == true)
            //{
            //    //skill1Start = true;
            //    //joy.moveSpeed = 8f;
            //    //remoteMoveSpeed = 8f;
            //    remoteMoveSpeed = 8f;
            //    remoteAni.ChangeAni(RemoteAni.ANI_RUN);
            //    StartCoroutine(RemotemoveTimer());
            //    Debug.Log("리모트 캐릭 애니 런");
            //    skillOne.receivedSkileOne = false;

            //    //StartCoroutine(RemotemoveTimer());
            //}
        }

        else if (MoveFlag == false && Stop == true)
        {
            remoteAni.ChangeAni(RemoteAni.ANI_IDLE);

            Stop = false;
        }

        if (attackFlag.Equals("remotePlayer") && attackControl == true)
        {
            playerFsm2.ChangeState(PlayerFSM2.State.Chase, PlayerAni.ANI_WALK);
            attackControl = false;
            attackFlag    = "";
        }
        else if (attackFlag.Equals("redTower"))
        {
            playerFsm2.ChangeState(PlayerFSM2.State.Chase, PlayerAni.ANI_WALK);
            attackControl = false;
            attackFlag    = "";
            Debug.Log("네트워크 스크립트 상태 체인지 > 추적");
        }
    }
Example #2
0
    // 드래그
    public void Drag(BaseEventData _Data)
    {
        if (gameManager.GameEnd == true)
        {
            Debug.Log("JoyStick Script Drag() Log = GameEnd");
            return;
        }

        if (playerFsm2.currentState == PlayerFSM2.State.Dead)
        {
            Debug.Log("JoyStick Script Player State Dead return");
            return;
        }



        playerFsm2.chaseTarget = "";
        MoveFlag           = true;
        attackControl      = true;
        attack.attackFlag  = false;
        playerFsm2.Sendone = true;
        playerFsm2.ChangeState(PlayerFSM2.State.Idle, PlayerAni.ANI_WALK);
        myAni.ChangeAni(PlayerAni.ANI_WALK);

        if (skillButton.skill1Start == true)
        {
            myAni.ChangeAni(PlayerAni.ANI_RUN);
        }

        PointerEventData Data = _Data as PointerEventData;
        Vector3          Pos  = Data.position;

        // 조이스틱을 이동시킬 방향을 구함.(오른쪽,왼쪽,위,아래)
        JoyVec = (Pos - StickFirstPos).normalized;

        // 조이스틱의 처음 위치와 현재 내가 터치하고있는 위치의 거리를 구한다.
        float Dis = Vector3.Distance(Pos, StickFirstPos);

        // 거리가 반지름보다 작으면 조이스틱을 현재 터치하고 있는곳으로 이동.
        if (Dis < Radius)
        {
            Stick.position = StickFirstPos + JoyVec * Dis;
        }
        // 거리가 반지름보다 커지면 조이스틱을 반지름의 크기만큼만 이동.
        else
        {
            Stick.position = StickFirstPos + JoyVec * Radius;
        }

        Player.eulerAngles = new Vector3(0, Mathf.Atan2(JoyVec.x, JoyVec.y) * Mathf.Rad2Deg, 0);
        //anim.SetBool("Move", MoveFlag);



        //string playerRotation = Player.transform.eulerAngles.ToString();
        //playerRotation = playerRotation.Substring(1, playerRotation.Length - 2);

        network.Send(network.myId + "," + JoyVec.x + "," + JoyVec.y + "," + "MoveFlag");
        Debug.Log("JoyVec.x:" + JoyVec.x + "JoyVec.y:" + JoyVec.y);
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        //if(playerParams == null)
        //{
        //    playerParams = GameObject.FindWithTag("Player").GetComponent<PlayerParams>();
        //}

        if (playerParams.isDead == true)
        {
            countDown -= Time.deltaTime;
            greenRespawnTaiLung.SetActive(true);
            greenRespawnCoundDown.text = "" + (int)countDown;
            Debug.Log("리스폰 스크립티 플레이어 isDead value: " + playerParams.isDead);
            if (countDown < 0 && playerParams.isDead == true)
            {
                greenRespawnTaiLung.SetActive(false);
                Debug.Log("Player Base: " + myBase);
                if (myBase.Equals("1"))
                {
                    // 내가 선택한 캐릭터 생성
                    GameObject myCharacter = Resources.Load(myCharacterName) as GameObject;
                    Vector3    pos         = new Vector3(45.02f, 60.3f, 99.59f);
                    characterQuaternion.eulerAngles = new Vector3(0, 100, 0);
                    myCharacter.transform.rotation  = characterQuaternion;
                    Instantiate(myCharacter, pos, myCharacter.transform.rotation).name = network.myId;
                    playerParams        = GameObject.FindWithTag("Player").GetComponent <PlayerParams>();
                    playerParams.isDead = false;
                    Debug.Log("리스폰 스크립트 블루 진영 Log 1");
                    playerParams = GameObject.FindWithTag("Player").GetComponent <PlayerParams>();
                    Debug.Log("리스폰 스크립트 블루 진영 Log 2");
                    joy.Player = GameObject.FindWithTag("Player").GetComponent <Transform>();
                    Debug.Log("리스폰 스크립트 블루 진영 Log 3");
                    joy.anim = GameObject.FindWithTag("Player").GetComponent <Animator>();
                    Debug.Log("리스폰 스크립트 블루 진영 Log 4");
                    joy.myAni = GameObject.FindWithTag("Player").GetComponent <PlayerAni>();
                    Debug.Log("리스폰 스크립트 블루 진영 Log 5");
                    //joy.Stick = GameObject.Find("JoyStick").GetComponent<Transform>();
                    joy.playerFsm2 = GameObject.FindWithTag("Player").GetComponent <PlayerFSM2>();
                    Debug.Log("리스폰 스크립트 블루 진영 Log 6");
                    //playerAni.anim = GameObject.FindWithTag("Player").GetComponent<Animator>();
                    Debug.Log("리스폰 스크립트 블루 진영 Log 7");
                    network.playerFsm2      = GameObject.FindWithTag("Player").GetComponent <PlayerFSM2>();
                    network.player          = GameObject.FindWithTag("Player").transform;
                    playerFSM2.remotePlayer = GameObject.FindWithTag("RemotePlayer").transform;


                    playerFSM2.ChangeState(PlayerFSM2.State.Idle, PlayerAni.ANI_IDLE);
                    Debug.Log("1 진영 리스폰 완료");
                }
                else
                {
                    GameObject myCharacter = Resources.Load(myCharacterName) as GameObject;
                    Vector3    pos         = new Vector3(254.85f, 60.3f, 100.41f);
                    characterQuaternion.eulerAngles = new Vector3(0, -110, 0);
                    myCharacter.transform.rotation  = characterQuaternion;
                    Instantiate(myCharacter, pos, myCharacter.transform.rotation).name = network.myId;
                    playerParams        = GameObject.FindWithTag("Player").GetComponent <PlayerParams>();
                    playerParams.isDead = false;
                    Debug.Log("리스폰 스크립트 레드 진영 Log 1");
                    joy.Player = GameObject.FindWithTag("Player").GetComponent <Transform>();
                    Debug.Log("리스폰 스크립트 레드 진영 Log 2");
                    joy.anim = GameObject.FindWithTag("Player").GetComponent <Animator>();
                    Debug.Log("리스폰 스크립트 레드 진영 Log 3");
                    joy.myAni = GameObject.FindWithTag("Player").GetComponent <PlayerAni>();
                    Debug.Log("리스폰 스크립트 레드 진영 Log 4");
                    //joy.Stick = GameObject.Find("JoyStick").GetComponent<Transform>();
                    joy.playerFsm2 = GameObject.FindWithTag("Player").GetComponent <PlayerFSM2>();
                    Debug.Log("리스폰 스크립트 레드 진영 Log 5");
                    //playerAni.anim = GameObject.FindWithTag("Player").GetComponent<Animator>();
                    Debug.Log("리스폰 스크립트 레드 진영 Log 6");
                    network.playerFsm2 = GameObject.FindWithTag("Player").GetComponent <PlayerFSM2>();
                    Debug.Log("리스폰 스크립트 레드 진영 Log 7");
                    network.player          = GameObject.FindWithTag("Player").transform;
                    playerFSM2.remotePlayer = GameObject.FindWithTag("RemotePlayer").transform;

                    playerFSM2.ChangeState(PlayerFSM2.State.Idle, PlayerAni.ANI_IDLE);
                    Debug.Log("2 진영 리스폰 완료");
                }
            }
        }
        else if (remoteParams.isDead == true)
        {
            countDown -= Time.deltaTime;
            redRespawnTiaLung.SetActive(true);
            redRespawnCoundDown.text = "" + (int)countDown;
            if (countDown < 0 && remoteParams.isDead == true)
            {
                redRespawnTiaLung.SetActive(false);

                Debug.Log("RemotePlayer Base: " + myBase);
                if (myBase.Equals("1"))
                {
                    GameObject YouerCharacter = Resources.Load("RemoteTaiLung") as GameObject;
                    Vector3    remotePos      = new Vector3(254.85f, 60.3f, 100.41f);
                    remoteQuaternion.eulerAngles      = new Vector3(0, -110, 0);
                    YouerCharacter.transform.rotation = remoteQuaternion;
                    Instantiate(YouerCharacter, remotePos, YouerCharacter.transform.rotation).tag = "RemotePlayer";
                    GameObject.FindWithTag("RemotePlayer").name = "RemotePlayer";
                    remoteParams        = GameObject.FindWithTag("RemotePlayer").GetComponent <RemoteParams>();
                    remoteParams.isDead = false;

                    network.player2 = GameObject.FindWithTag("RemotePlayer").GetComponent <Transform>();
                    //network.playerFsm2 = GameObject.FindWithTag("RemotePlayer").GetComponent<PlayerFSM2>();
                    remoteAni.anim          = GameObject.FindWithTag("RemotePlayer").GetComponent <Animator>();
                    playerFSM2.remotePlayer = GameObject.FindWithTag("RemotePlayer").transform;
                    network.remoteFSM       = GameObject.FindWithTag("RemotePlayer").GetComponent <RemoteFSM>();
                    remoteFSM.ChangeState(RemoteFSM.State.Idle, RemoteAni.ANI_IDLE);
                }
                else
                {
                    // 내가 선택한 캐릭터 생성
                    GameObject YouerCharacter = Resources.Load("RemoteTaiLung") as GameObject;
                    Vector3    remotePos      = new Vector3(45.02f, 60.3f, 99.59f);
                    remoteQuaternion.eulerAngles      = new Vector3(0, 100, 0);
                    YouerCharacter.transform.rotation = remoteQuaternion;
                    Instantiate(YouerCharacter, remotePos, YouerCharacter.transform.rotation).tag = "RemotePlayer";
                    GameObject.FindWithTag("RemotePlayer").name = "RemoteTaiLung";
                    remoteParams        = GameObject.FindWithTag("RemotePlayer").GetComponent <RemoteParams>();
                    remoteParams.isDead = false;

                    playerFSM2.remotePlayer = GameObject.FindWithTag("RemotePlayer").transform;
                    network.player2         = GameObject.FindWithTag("RemotePlayer").GetComponent <Transform>();
                    //network.playerFsm2 = GameObject.FindWithTag("RemotePlayer").GetComponent<PlayerFSM2>();
                    remoteAni.anim    = GameObject.FindWithTag("RemotePlayer").GetComponent <Animator>();
                    network.remoteFSM = GameObject.FindWithTag("RemotePlayer").GetComponent <RemoteFSM>();
                    remoteFSM.ChangeState(RemoteFSM.State.Idle, RemoteAni.ANI_IDLE);
                }
            }
        }
    }