Ejemplo n.º 1
0
    /// <summary>
    /// 라운드가 넘어갈경우나 처음 시작할떄 초기화 해주어야할 변수
    /// </summary>
    public void ResetPlayerVar(byte num, int hp, System.Numerics.Vector3[] p, float[] yRot)
    {
        //클라이언트 플레이어 오브젝트 체력 설정
        for (int i = 0; i < 2; i++)
        {
            var tmpP = playerList[i];
            tmpP.transform.position    = TotalUtility.ToUnityVectorChange(p[i]);
            tmpP.transform.eulerAngles = new Vector3(0, yRot[i], 0);

            if (tmpP.clientCheck)
            {
                tmpP.cam.yRot = yRot[i];
                tmpP.cam.xRot = 0;
            }

            if (tmpP.zoomState)
            {
                tmpP.weaponManagerSc.ZoomChange(tmpP.zoomState = false);
            }

            tmpP.isAlive = true;
            tmpP.animSc.anim.SetBool("Alive", tmpP.isAlive);
        }
        //Send
        NetworkManager.Instance.SendPacket(new Player_Ready(clientPlayerNum), NetworkManager.Protocol.TCP);
    }
Ejemplo n.º 2
0
    private void ProcessPacket(IPacket p, NetworkManager.Protocol pt)
    {
        if (pt == NetworkManager.Protocol.TCP)
        {
            if (p is Player_Init)
            {
                //받았을때 클라이언트 생성(아군 적군 모두)
                var s = (Player_Init)p;

                CreatePlayerObject(s.clientIdx, s.hp, TotalUtility.ToUnityVectorChange(s.startPos), s.startLook, s.assign, s.character, s.weapon1, s.weapon2, s.item);
                if (s.assign)
                {
                    NetworkManager.Instance.SendPacket(new Player_Ready(clientPlayerNum), NetworkManager.Protocol.TCP);
                }
            }
            else if (p is Player_Reset)
            {
                var s = (Player_Reset)p;
                ResetPlayerVar(s.clientIdx, s.hp, s.startPos, s.LookPosYrot);
            }
            //else if (p is Round_Start)
            //{
            //    var s = (Round_Start)p;
            //}
            //else if (p is Round_End)
            //{
            //    var s = (Round_End)p;
            //}
            else if (p is Match_End)
            {
                var s = (Match_End)p;
                NetworkManager.Instance.RecvHandler -= ProcessPacket;
            }
            else if (p is Round_Timer)
            {
                //Timer countdown == 0  : 타이머를 시작 1 : 타이머 종료
                var s = (Round_Timer)p;
            }
            else if (p is Player_Input)
            {
                //Player key 관련 처리
                var s = (Player_Input)p;
                if (playerList[s.clientIdx] == null)
                {
                    return;
                }
                playerList[s.clientIdx].KeyDownClient(s.key, s.down);
            }
            else if (p is Player_Grounded)
            {
                //player isGrounded 처리
                var s = (Player_Grounded)p;
                if (playerList[s.clientIdx] == null)
                {
                    return;
                }
                playerList[s.clientIdx].IsGroundedFromServer = s.state;
            }
            else if (p is Use_Item)
            {
                //폭탄 던지기
                var s = (Use_Item)p;
                if (playerList[s.clientIdx] == null)
                {
                    return;
                }
                if (playerList[s.clientIdx] != null)
                {
                    playerList[s.clientIdx].weaponManagerSc.UseItem(s.clientIdx, TotalUtility.ToUnityVectorChange(s.pos), TotalUtility.ToUnityVectorChange(s.rot));
                }
            }
            else if (p is Throw_BombAnim)
            {
                var s = (Throw_BombAnim)p;
                if (playerList[s.clientIdx] != null)
                {
                    playerList[s.clientIdx].animSc.anim.SetTrigger("Shoot");
                }
            }

            else if (p is Player_Sync)
            {
                //체력 설정
                var s = (Player_Sync)p;
            }
            else if (p is Player_Recover)
            {
                var s = (Player_Recover)p;
                if (playerList[s.clientIdx] != null)
                {
                    playerList[s.clientIdx].weaponManagerSc.UseItem(s.clientIdx, Vector3.zero, Vector3.zero);
                }
            }
            else if (p is Player_Dead)
            {
                //주금
                var s = (Player_Dead)p;
                if (playerList[s.clientIdx] != null)
                {
                    playerList[s.clientIdx].Death();
                }
            }
            else if (p is Round_Result)
            {
                var s = (Round_Result)p;
                Debug.Log("Round 결과 패킷 받음");
            }
            else if (p is Match_End)
            {
            }

            //총알 생성
            //폭탄 던지기
            //체력회복
            //주금
            //데미지받는부분

            //else if()
        }
        else
        {
            if (p is Player_Info)
            {
                //싱크(적편에게만 적용)
                var s = (Player_Info)p;
                if (playerList[s.clientIdx] == null)
                {
                    return;
                }

                if (clientPlayerNum != s.clientIdx)
                {
                    var i = s.clientIdx;
                    //Position
                    if (playerList[i] != null)
                    {
                        playerList[i].transform.position = TotalUtility.ToUnityVectorChange(s.pos);

                        playerList[i].lookTarget = TotalUtility.ToUnityVectorChange(s.lookTarget);
                    }
                }
            }
        }
    }