Example #1
0
    /// <summary>
    /// 라운드가 넘어갈경우나 처음 시작할떄 초기화 해주어야할 변수
    /// </summary>
    public void ResetPlayerVar(SetClient set)
    {
        //클라이언트 플레이어 오브젝트 체력 설정
        SetHealthUI(set.HP);

        //줌 상태 일경우 품
        if (playerList[set.ClientNum].zoomState.Equals(true))
        {
            ZoomChange(set.ClientNum, false);
        }

        playerList[(int)TeamColor.BLUE].transform.position = ToUnityVectorChange(set.StartPos[(int)TeamColor.BLUE]);
        playerList[(int)TeamColor.RED].transform.position  = ToUnityVectorChange(set.StartPos[(int)TeamColor.RED]);

        foreach (var p in playerList)
        {
            if (!p.gameObject.activeSelf)
            {
                p.gameObject.SetActive(true);
            }

            p.isAlive = true;
        }
        //Send
        NetworkManagerTCP.SendTCP(new ReadyCheck(set.ClientNum));
    }
Example #2
0
 /// <summary>
 /// LobbyScene Input
 /// </summary>
 public void LobbySceneFunc()
 {
     //Queue Entry
     if (Input.GetKeyDown(KeyCode.F1))
     {
         NetworkManagerTCP.SendTCP(new QueueEntry());
     }
     //TestRoom
     if (Input.GetKeyDown(KeyCode.F2))
     {
         NetworkManagerTCP.SendTCP(new TestRoom());
     }
 }
Example #3
0
 /// <summary>
 /// Login Scene
 /// </summary>
 public void LoginSceneFunc()
 {
     //Server 연결
     if (Input.GetKeyDown(KeyCode.F1))
     {
         if (!NetworkManagerTCP.clientTcp.Connected)
         {
             NetworkManagerTCP.TcpConnectToServer();
         }
     }
     if (Input.GetKeyDown(KeyCode.F2))
     {
         NetworkManagerTCP.SendTCP(new Login(null));
     }
 }
Example #4
0
    /// <summary>
    ///  새로운 씬 Load 후 이전 씬 Unload
    /// Dondestroy를 사용하지 않고 직접 씬에서 씬으로 오브젝트 이동후 processHandler 추가
    /// </summary>
    /// <returns></returns>
    IEnumerator IngameSceneLoad()
    {
        Scene currentScene = SceneManager.GetActiveScene();

        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("03IngameManager", LoadSceneMode.Additive);

        while (!asyncLoad.isDone)
        {
            yield return(null);
        }

        SceneManager.MoveGameObjectToScene(this.gameObject, allSceneManagerSc.currentScene = SceneManager.GetSceneByName("03IngameManager"));
        //  ProcessHandlerTCP += GameObject.Find("IngameManager").GetComponent<IngameProcess>().IngameDataRequestTCP;
        //  ProcessHandlerUDP += GameObject.Find("IngameManager").GetComponent<IngameProcess>().IngameDataRequestUDP;
        Ingame = true;
        StartCoroutine("ProcessDataUDP");
        NetworkManagerTCP.SendTCP(new StartGameReq(0));
        SceneManager.UnloadSceneAsync(currentScene);
    }
Example #5
0
    //private List<GameObject> playerList = new List<GameObject>();
    /// <summary>
    /// IngameProcessHandler;
    /// </summary>
    /// <param name="p"></param>
    public void IngameDataRequestTCP(Packet p)
    {
        switch (p.MsgName)
        {
        case "ClientIns":
            var clientInsData = JsonConvert.DeserializeObject <ClientIns>(p.Data);
            InsClient(clientInsData.ClientNum, clientInsData.HP, ToUnityVectorChange(clientInsData.StartPos), clientInsData.Client, clientInsData.WeaponArray);
            if (clientInsData.Client)
            {
                NetworkManagerTCP.SendTCP(new ReadyCheck(clientPlayerNum));
            }
            break;

        case "SetClient":
            var setClientData = JsonConvert.DeserializeObject <SetClient>(p.Data);
            ResetPlayerVar(setClientData);
            break;

        case "RoundStart":
            TimerState = 0;
            var roundStartData = JsonConvert.DeserializeObject <RoundStart>(p.Data);
            SetViewRoundUI(roundStartData.CurrentRound);
            SetRoundResultUI(roundStartData.RoundPoint, null);
            break;

        case "RoundEnd":
            TimerState = 1;
            var roundEndData = JsonConvert.DeserializeObject <RoundEnd>(p.Data);
            SetViewRoundUI(roundEndData.CurrentRound);
            SetRoundResultUI(roundEndData.RoundPoint, roundEndData.RoundResult);
            break;

        case "MatchingEnd":
            npSC.Ingame = false;
            npSC.LobbyCouroutineFunc();
            break;

        case "RoundTimer":
            var timerData = JsonConvert.DeserializeObject <RoundTimer>(p.Data);
            SetTimerUI(timerData.CurrentTime);
            break;

        case "ClientMoveSync":
            var posData = JsonConvert.DeserializeObject <ClientMoveSync>(p.Data);
            if (playerList[posData.ClientNum] != null)
            {
                playerList[posData.ClientNum].transform.position = new Vector3(posData.CurrentPos.X, posData.CurrentPos.Y, posData.CurrentPos.Z);
            }
            break;

        case "KeyDown":
            var keyDownData = JsonConvert.DeserializeObject <KeyDown>(p.Data);
            if (playerList[keyDownData.ClientNum] != null)
            {
                KeyDownClient(keyDownData.ClientNum, keyDownData.DownKey);
            }
            break;

        case "KeyUP":
            var keyUpData = JsonConvert.DeserializeObject <KeyUP>(p.Data);
            if (playerList[keyUpData.ClientNum] != null)
            {
                KeyUpClient(keyUpData.ClientNum, keyUpData.UpKey);
            }
            break;

        case "IsGrounded":
            var groundData = JsonConvert.DeserializeObject <IsGrounded>(p.Data);
            if (playerList[groundData.ClientNum] != null)
            {
                playerList[groundData.ClientNum].IsGroundedFromServer = groundData.State;
            }
            break;

        case "InsShell":
            var shellData = JsonConvert.DeserializeObject <InsShell>(p.Data);
            if (playerList[shellData.ClientNum] != null)
            {
                playerList[shellData.ClientNum].weaponManagerSc.Shoot(shellData.ClientNum, ToUnityVectorChange(shellData.Pos), ToUnityVectorChange(shellData.Rot));
            }
            //총알이 발사가 실행된 후 반동이 실행되도록
            if (!shellData.ClientNum.Equals(clientPlayerNum))
            {
                return;
            }
            inputSc.ReboundPlayerRotation();
            inputSc.ReboundAimImage();
            break;

        case "ThrowBomb":
            var bombData = JsonConvert.DeserializeObject <ThrowBomb>(p.Data);
            playerList[bombData.ClientNum].weaponManagerSc.Shoot(bombData.ClientNum, ToUnityVectorChange(bombData.Pos), ToUnityVectorChange(bombData.Rot));
            break;

        case "Zoom":
            var zoomData = JsonConvert.DeserializeObject <Zoom>(p.Data);
            ZoomChange(zoomData.ClientNum, zoomData.ZoomState);
            break;

        case "SyncHealth":
            var healthData = JsonConvert.DeserializeObject <SyncHealth>(p.Data);
            SetHealthUI(healthData.CurrentHealth);
            break;

        case "Death":
            var deathData = JsonConvert.DeserializeObject <Death>(p.Data);
            playerList[deathData.ClientNum].Death();
            break;

        case "RecoverHealth":
            var recoverData = JsonConvert.DeserializeObject <RecoverHealth>(p.Data);
            //SyncHealth로 처리해도되지만 이것으로 처리함으로써 오브젝트 파괴및 이벤트 처리가능
            //회복량이 아닌 그냥 서버에서 체력을 보냄으로써 바로 설정
            SetHealthUI(recoverData.FillHP);
            playerList[recoverData.ClientNum].weaponManagerSc.Shoot(recoverData.ClientNum, Vector3.zero, Vector3.zero);
            break;

        default:
            Debug.Log("[Ingame Proces] TCP : Mismatching Message");
            break;
        }
    }
Example #6
0
 /// <summary>
 /// 강제종료등 게임을 종료할 경우
 /// </summary>
 private void OnApplicationQuit()
 {
     NetworkManagerTCP.SendTCP(new ExitReq());
 }