Exemple #1
0
        private bool validateConnectionSettings()
        {
            this.host = HostText.Text;
            var validIpAddressRegex = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
            var validHostnameRegex  = new Regex(@"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$");

            if (!validHostnameRegex.IsMatch(this.host) && !validIpAddressRegex.IsMatch(this.host))
            {
                StatusTextBlock.Text       = "Host is invalid";
                StatusTextBlock.Foreground = this.errorColor;
                return(false);
            }

            this.port = PortNumberText.Text;
            if (!portNumberTextAllowed(this.port))
            {
                PortNumberText.Focus();
                StatusTextBlock.Text       = "Port number is invalid";
                StatusTextBlock.Foreground = this.errorColor;
                return(false);
            }

            this.username        = UsernameText.Text;
            this.password        = RpcPassword.Password;
            StatusTextBlock.Text = string.Empty;
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// シーン内の描画処理
        /// </summary>
        public void Draw()
        {
            TextureAsset.Draw(LogoImageHandle, 490, 90, 300, 300, DX.TRUE);
            IpAddressText.Draw();
            PortNumberText.Draw();
            SaveIpAddressButton.Draw();
            switch (state)
            {
            case State.Start:
                StartButton.Draw();
                StartButton.DrawText();
                EndButton.Draw();
                EndButton.DrawText();
                break;

            case State.Select:
                BackButton.Draw();
                BackButton.DrawText();
                MakeRoomButton.Draw();
                MakeRoomButton.DrawText();
                JoinRoomButton.Draw();
                JoinRoomButton.DrawText();
                break;

            case State.FindRoom:
                BackButton.Draw();
                BackButton.DrawText();
                FindRoomButton.Draw();
                FindRoomButton.DrawText();
                SubmitButton.Draw();
                SubmitButton.DrawText();
                roomName.Draw();
                playerName.Draw();
                FontAsset.Draw("button1Base", "部屋名", roomName.x1 - 250, roomName.y1 + 5, DX.GetColor(125, 125, 125));
                FontAsset.Draw("button1Base", "プレイヤー名", playerName.x1 - 250, playerName.y1 + 5, DX.GetColor(125, 125, 125));
                break;

            case State.MakeRoom:
                BackButton.Draw();
                BackButton.DrawText();
                SubmitButton.Draw();
                SubmitButton.DrawText();
                roomName.Draw();
                playerName.Draw();
                playerNum.Draw();
                FontAsset.Draw("button1Base", "部屋名", roomName.x1 - 260, roomName.y1 + 5, DX.GetColor(125, 125, 125));
                FontAsset.Draw("button1Base", "プレイヤー名", playerName.x1 - 260, playerName.y1 + 5, DX.GetColor(125, 125, 125));
                FontAsset.Draw("button1Base", "人数", playerNum.x1 - 260, playerNum.y1 + 5, DX.GetColor(125, 125, 125));
                break;

            case State.Load:
                BackButton.Draw();
                BackButton.DrawText();
                LoadTexture.Draw();
                break;

            case State.Popup:
                if (FindRoomWindow.IsVisible)
                {
                    FindRoomWindow.Draw();
                }
                break;

            default:
                break;
            }
        }
Exemple #3
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;
            }
        }