コード例 #1
0
        /// <summary>
        /// シーン内の更新処理
        /// </summary>
        public void Update()
        {
            // IPアドレス関連の更新
            IpAddressText.Update();
            PortNumberText.Update();
            if (SaveIpAddressButton.LeftClicked())
            {
                if (IPAddress.TryParse(IpAddressText.Text, out _) &&
                    int.TryParse(PortNumberText.Text, out _))
                {
                    SocketManager.SetAddress(IpAddressText.Text, int.Parse(PortNumberText.Text));
                }
            }

            // メインの更新処理
            switch (state)
            {
            // スタートボタンを押す画面
            case State.Start:
                if (StartButton.LeftClicked())
                {
                    state = State.Select;
                }
                if (EndButton.LeftClicked())
                {
                    DX.DxLib_End();
                    return;
                }
                break;

            // 部屋を作るか、部屋に参加するか選ぶ画面
            case State.Select:
                if (BackButton.LeftClicked())
                {
                    state = State.Start;
                }
                if (MakeRoomButton.LeftClicked())
                {
                    state = State.MakeRoom;
                }
                if (JoinRoomButton.LeftClicked())
                {
                    state         = State.FindRoom;
                    roomName.Text = string.Empty;
                }
                break;

            // 部屋を作る画面
            case State.FindRoom:
                if (BackButton.LeftClicked())
                {
                    state = State.Start;
                }
                if (SubmitButton.LeftClicked())
                {
                    if (roomName.Text.Length != 0 &&
                        playerName.Text.Length != 0)
                    {
                        state           = State.Load;
                        Data.PlayerName = playerName.Text;
                        Data.RoomName   = roomName.Text;
                    }
                    IsWaitJoin = false;
                }
                if (FindRoomButton.LeftClicked())
                {
                    state = State.Popup;
                    FindRoomWindow.IsVisible = true;
                }
                roomName.Update();
                playerName.Update();
                break;

            // 部屋に参加する画面
            case State.MakeRoom:
                if (BackButton.LeftClicked())
                {
                    state = State.Start;
                }
                if (SubmitButton.LeftClicked())
                {
                    if (roomName.Text.Length != 0 &&
                        playerName.Text.Length != 0 &&
                        playerNum.Text.Length != 0)
                    {
                        state           = State.Load;
                        Data.PlayerName = playerName.Text;
                        Data.RoomName   = roomName.Text;
                        var num = int.Parse(playerNum.Text);
                        if (num > 4 || num < 0)
                        {
                            num            = 4;
                            playerNum.Text = num.ToString();
                        }
                        Data.PlayerNum = num;
                        IsWaitJoin     = false;
                    }
                }
                roomName.Update();
                playerName.Update();
                playerNum.Update();
                break;

            // ロード画面
            case State.Load:
                if (BackButton.LeftClicked())
                {
                    state = State.Start;
                }
                if (!IsWaitJoin)
                {
                    IsWaitJoin = true;
                    Task.Run(() => JoinMatch(Data.RoomName, Data.PlayerName));
                }
                if (!LoadTexture.IsVisible())
                {
                    LoadTexture.Start();
                }
                LoadTexture.Update();
                break;

            // 部屋を探す画面
            case State.Popup:
                FindRoomWindow.Update();
                if (!FindRoomWindow.IsVisible)
                {
                    Data.MatchInfo = FindRoomWindow.GetSelectedMatch();
                    roomName.Text  = Data.MatchInfo.MatchKey;
                    state          = State.FindRoom;
                }
                break;

            // ゲームシーンに遷移する処理を行う状態
            case State.ChangeGameScene:
                SceneManager.ChangeScene(SceneManager.SceneName.Game);
                break;

            default:
                break;
            }
        }