Пример #1
0
    private void Update()
    {
        if (EmailInput.text.Length != 0 && PasswordInput.text.Length != 0)
        {
            BtnImg.sprite = logSpr;
        }
        else
        {
            BtnImg.sprite = regiSpr;
        }

        if (PhotonNetwork.IsConnected)
        {
            if (PhotonNetwork.GetPing() < 40)
            {
                pingSpeed.color = Color.green;
            }
            else if (PhotonNetwork.GetPing() < 100)
            {
                pingSpeed.color = Color.yellow;
            }
            else
            {
                pingSpeed.color = Color.red;
            }
            pingSpeed.text = "Ping : " + PhotonNetwork.GetPing().ToString();
        }
        else
        {
            pingSpeed.text  = "DisConnected";
            pingSpeed.color = Color.white;
        }
        if (LoginPanel.activeSelf)
        {
            //탭키 전환
            if (Input.GetKeyDown(KeyCode.Tab))
            {
                if (EmailInput.isFocused)
                {
                    PasswordInput.ActivateInputField();
                }
                if (PasswordInput.isFocused)
                {
                    UsernameInput.ActivateInputField();
                }
                if (UsernameInput.isFocused)
                {
                    EmailInput.ActivateInputField();
                }
            }

            //엔터키로 로그인
            if (Input.GetKeyDown(KeyCode.Return))
            {
                if (logPanel.activeSelf)
                {
                    LogIn();
                }
                else
                {
                    Register();
                }
            }
        }

        if (LobbyPanel.activeSelf)
        {
//         if(Input.GetKeyDown(KeyCode.Escape))
//            Disconnect();

            if (playerCountSave.instance.isKor())
            {
                LobbyInfoText.text = ("접속자 " + PhotonNetwork.CountOfPlayers + "명 / 로비 " + (PhotonNetwork.CountOfPlayers - PhotonNetwork.CountOfPlayersInRooms)) + "명";
            }
            else
            {
                LobbyInfoText.text = (PhotonNetwork.CountOfPlayers + " Player is Online / " + (PhotonNetwork.CountOfPlayers - PhotonNetwork.CountOfPlayersInRooms)) + " In Lobby";
            }
        }

        if (RoomPanel.activeSelf)
        {
            RoomRenewal();
            if (PhotonNetwork.IsMasterClient) //방주인이면
            {
                StartBtn.SetActive(true);
            }
            else
            {
                StartBtn.SetActive(false);
            }

//         if (Input.GetKeyDown(KeyCode.Escape)) //방에있을때 esc누르면 방에서나감
//            PhotonNetwork.LeaveRoom();

            if (ChatInput.isFocused)
            {
                Player[] players = FindObjectsOfType <Player>();
                foreach (Player p in players)
                {
                    if (p.pv.IsMine)
                    {
                        p.canMove = false;
                        break;
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.Return))
            {
                if (!ChatInput.gameObject.activeSelf)
                {
                    ChatInput.gameObject.SetActive(true);
                    ChatInput.ActivateInputField();
                }
                else
                {
                    Send();
                    Player[] players = FindObjectsOfType <Player>();
                    foreach (Player p in players)
                    {
                        if (p.pv.IsMine)
                        {
                            p.canMove = true;
                            break;
                        }
                    }
                }
            }
        }
    }