Пример #1
0
        private void HandleMessage(Network.BasePayload payload)
        {
            switch (payload.Code)
            {
            case Network.OpCode.Message:
                this.ChatScreen.Conversation.text = $"[The Stranger] {((Network.Message)payload).Text}\n";
                break;

            case Network.OpCode.Ready:
                this.OtherPlayerReady = true;
                this.ChatScreen.OtherPlayerReadyText.SetActive(this.OtherPlayerReady);
                break;

            default:
                break;
            }
        }
Пример #2
0
        private void Update()
        {
            // Following the active screen, it handles different inputs.
            switch (((UI.BasicScreen) this.Screens.Top()).Name)
            {
            case UI.Names.Menu.Title:
                if (Input.GetKeyDown(KeyCode.Return))
                {
                    this.Screens.Push(this.GameModeSelectionScreen);
                }
                break;

            case UI.Names.Menu.Host:
                if (this.Connection == null && this.HostScreen.GetConnection() != null)
                {
                    this.Connection = this.HostScreen.GetConnection();
                    this.Screens.Push(this.ChatScreen);
                }
                break;

            case UI.Names.Menu.Chat:
                Network.BasePayload payload = this.Connection.Read();
                if (payload != null)
                {
                    this.HandleMessage(payload);
                }

                if (this.Ready && this.OtherPlayerReady)
                {
                    Data.Storage.Connection = this.Connection;
                    SceneManager.LoadScene("GameScene");
                }
                break;

            default:
                break;
            }
        }