Beispiel #1
0
        /**
         * @brief   オンライン&ルーム入室中のGUI表示.
         * @param   isDispInputGUI  入力系GUIを表示するかどうかのフラグ(縁取り文字描画機能を活かした場合の、多重描画を防止するため).
         * @param   state           文字表示色.
         */
        private void OnGUI_InRoom(bool isDispInputGUI, GUIStyleState state)
        {
            // ルーム退室GUIレイヤー
            {
                GUILayout.Space(25);

                // ゲーム開始までの時間表示
                if (!isGameStart && gameTimeLimit > 0)
                {
                    GUILayout.Label("Rest Time To Game Start : " + gameTimeLimit, new GUIStyle()
                    {
                        normal = state, fontSize = 16, margin = new RectOffset(6, 6, 6, 6), fixedWidth = 140
                    });
                }

                // ルーム退室ボタン入力表示
                if (isDispInputGUI)
                {
                    if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
                    {
                        // 安全なDisconnectが実行されていることを成立させる
                        isUnsafeDisconnect = false;

                        // 入力があった場合、ルームから退室する
                        MonobitNetwork.LeaveRoom();
                    }
                }
                else
                {
                    GUILayout.Space(25);
                }
            }
        }
 public void LeaveRoom()
 {
     MonobitNetwork.LeaveRoom();
     //Debug.Log("ルームから退出しました");
     //ここでスタートのシーンに遷移する
     SceneManager.LoadScene("StartScene");
 }
        /**
         * ルーム内でのGUI操作.
         */
        private void OnGUI_InRoom()
        {
            // 自身のプレイヤーIDの表示
            GUILayout.Label("Your ID : " + MonobitNetwork.player.ID);

            // ルーム内に存在するプレイヤー数の表示
            GUILayout.Label("PlayerCount : " + MonobitNetwork.room.playerCount + " / " + ((MonobitNetwork.room.maxPlayers == 0) ? "-" : MonobitNetwork.room.maxPlayers.ToString()));

            // ルームの入室制限可否設定の表示
            GUILayout.Label("Room is : " + ((MonobitNetwork.room.open) ? "open," : "close,") + " and " + ((MonobitNetwork.room.visible) ? "visible." : "invisible."));

            // カスタムルームパラメータの表示
            GUILayout.Label("Custom Room Parameters");
            foreach (DictionaryEntry dic in MonobitNetwork.room.customParameters)
            {
                GUILayout.Label("\tKeys : " + dic.Key + ", Value : " + dic.Value);
            }

            // 制限時間の表示
            if (isGameStart)
            {
                GUILayout.Label("Rest Frame : " + this.battleEndFrame);
            }

            // 部屋からの離脱
            if (GUILayout.Button("Leave Room", GUILayout.Width(100)))
            {
                MonobitNetwork.LeaveRoom();
            }

            // ホストの場合
            if (MonobitNetwork.isHost)
            {
                // ゲームスタート
                if (!isGameStart && GUILayout.Button("Start Game", GUILayout.Width(100)))
                {
                    this.isGameStart = true;
                    // room.open = false;
                    monobitView.RPC("GameStart", MonobitTargets.All, null);
                }

                // バトル終了
                if (this.battleEndFrame <= 0)
                {
                    // room.open = true;

                    // 部屋から離脱する
                    monobitView.RPC("LeaveRoomAll", MonobitTargets.All, null);
                }
            }
        }
Beispiel #4
0
    /// <summary>
    /// 退出機能
    /// </summary>
    public void LeaveRoom()
    {
        if (MonobitNetwork.inRoom)
        {
            _cameraCtrl.target = _defaultTarget;
            Destroy(_player, 1f);
            MonobitNetwork.LeaveRoom();

            //名前入力欄表示
            _nameObject.SetActive(true);
            _enterObject.SetActive(true);

            //退出ボタン非表示
            _leaveObject.SetActive(false);
        }
    }
Beispiel #5
0
        /**
         * @brief   オンライン&ルーム入室中のGUI表示.
         * @param   isDispInputGUI  入力系GUIを表示するかどうかのフラグ(縁取り文字描画機能を活かした場合の、多重描画を防止するため).
         * @param   state           文字表示色.
         */
        private void OnGUI_InRoom(bool isDispInputGUI, GUIStyleState state)
        {
            // ルーム退室GUIレイヤー
            {
                GUILayout.Space(25);

                // ルーム退室ボタン入力表示
                if (isDispInputGUI)
                {
                    if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
                    {
                        // 安全なDisconnectが実行されていることを成立させる
                        isUnsafeDisconnect = false;
                        isDisconnecting    = false;
                        isReconnecting     = false;
                        isGameStart        = false;
                        isGameEnd          = false;
                        isSpawnMyChara     = false;

                        // 入力があった場合、ルームから退室する
                        MonobitNetwork.LeaveRoom();
                    }
                }
                else
                {
                    GUILayout.Space(25);
                }

                // ゲーム開始ボタン入力表示
                if (MonobitNetwork.isHost && isDispInputGUI && !isGameStart)
                {
                    if (GUILayout.Button("Game Start", GUILayout.Width(150)))
                    {
                        // バトルスタートを通知
                        monobitView.RPC("OnGameStart", MonobitTargets.All, null);
                    }
                }
                else
                {
                    GUILayout.Space(25);
                }
            }
        }
Beispiel #6
0
 public void StopVoiceChat()
 {
     MonobitNetwork.LeaveRoom();
 }
Beispiel #7
0
 private void LeaveRoomAll()
 {
     MonobitNetwork.LeaveRoom();
 }
Beispiel #8
0
        /**
         * ルーム内でのGUI操作.
         */
        private void OnGUI_InRoom()
        {
            // 自身のプレイヤーIDの表示
            GUILayout.Label("Your ID : " + MonobitNetwork.player.ID);

            // ルーム内に存在するプレイヤー数の表示
            GUILayout.Label("PlayerCount : " + MonobitNetwork.room.playerCount + " / " + ((MonobitNetwork.room.maxPlayers == 0) ? "-" : MonobitNetwork.room.maxPlayers.ToString()));

            // ルームの入室制限可否設定の表示
            GUILayout.Label("Room isOpen : " + MonobitNetwork.room.open);

            // ルーム作成者が入力した値
            GUILayout.Label("Room Owner Numeric Value : " + MonobitNetwork.room.customParameters["Value"]);

            // 自身が入力した値
            GUILayout.Label("My Skill Level : " + baseValue);

            // 制限時間の表示
            if (isGameStart)
            {
                GUILayout.Label("Rest Frame : " + this.battleEndFrame);
            }

            // 部屋からの離脱
            if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
            {
                MonobitNetwork.LeaveRoom();
            }

            // ホストの場合
            if (MonobitNetwork.isHost)
            {
                // ゲームスタート
                if (!isGameStart && GUILayout.Button("Start Game", GUILayout.Width(150)))
                {
                    this.isGameStart = true;
                    // room.open = false;
                    monobitView.RPC("GameStart", MonobitTargets.All, null);
                }

                // バトル終了
                if (this.battleEndFrame <= 0)
                {
                    // room.open = true;

                    // 部屋から離脱する
                    monobitView.RPC("LeaveRoomAll", MonobitTargets.All, null);
                }
            }

            // 他にルームが作成されている場合
            if (MonobitNetwork.GetRoomData() != null && MonobitNetwork.GetRoomData().Length >= 1)
            {
                // 他の部屋に入室
                if (GUILayout.Button("Enter Another Room", GUILayout.Width(150)))
                {
                    // 一旦部屋から離脱する
                    MonobitNetwork.LeaveRoom();

                    // 自身の値に対し、検索範囲の最初の閾値を設定する
                    baseValueMin = (baseValue - baseValueIncrease < baseValueLow) ? baseValueLow : baseValue - baseValueIncrease;
                    baseValueMax = (baseValue + baseValueIncrease > baseValueHigh) ? baseValueHigh : baseValue + baseValueIncrease;

                    // 閾値から、クエリー検索のためのWHERE句を生成する
                    string queryLobbyFilter = "Value>=" + baseValueMin + " AND Value<=" + baseValueMax;

                    // ルームへの入室
                    MonobitNetwork.JoinRandomRoom(null, this.maxPlayers, Definitions.MatchmakingMode.SerialMatching, new LobbyInfo()
                    {
                        Kind = LobbyKind.Query, Name = "QueryLobby"
                    }, queryLobbyFilter);
                }
            }
        }
Beispiel #9
0
        /**
         * ルーム内でのGUI操作.
         */
        private void OnGUI_InRoom()
        {
            // 自身のプレイヤーIDの表示
            GUILayout.Label("Your ID : " + MonobitNetwork.player.ID);

            // ルーム内に存在するプレイヤー数の表示
            GUILayout.Label("PlayerCount : " + MonobitNetwork.room.playerCount + " / " + ((MonobitNetwork.room.maxPlayers == 0) ? "-" : MonobitNetwork.room.maxPlayers.ToString()));

            // ルームの入室制限可否設定の表示
            GUILayout.Label("Room is : " + ((MonobitNetwork.room.open) ? "open," : "close,") + " and " + ((MonobitNetwork.room.visible) ? "visible." : "invisible."));

            // カスタムルームパラメータの表示
            GUILayout.Label("Custom Room Parameters");
            foreach (DictionaryEntry dic in MonobitNetwork.room.customParameters)
            {
                GUILayout.Label("\tKeys : " + dic.Key + ", Value : " + dic.Value);
            }

            // 制限時間の表示
            if (isGameStart)
            {
                GUILayout.Label("Rest Frame : " + this.battleEndFrame);
            }

            // 部屋からの離脱
            if (GUILayout.Button("Leave Room", GUILayout.Width(100)))
            {
                MonobitNetwork.LeaveRoom();
            }

            // ホストの場合
            if (MonobitNetwork.isHost)
            {
                // ルームのカスタムパラメータの値入力
                bool isCustomRoomParamChanged = false;
                if (this.customRoomParam.Count > 0)
                {
                    Hashtable tmp = new Hashtable(this.customRoomParam);
                    foreach (string key in this.customRoomParam.Keys)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Key : " + key + ", Value : ");
                        tmp[key] = GUILayout.TextField(this.customRoomParam[key].ToString(), GUILayout.Width(200));
                        GUILayout.EndHorizontal();
                    }
                    foreach (string key in this.customRoomParam.Keys)
                    {
                        if (!tmp.ContainsKey(key) || tmp[key] != this.customRoomParam[key])
                        {
                            isCustomRoomParamChanged = true;
                            this.customRoomParam     = tmp;
                            break;
                        }
                    }
                }

                // ルームのカスタムパラメータのキー追加
                GUILayout.BeginHorizontal();
                GUILayout.Label("New Key : ");
                customRoomKey = GUILayout.TextField(customRoomKey, GUILayout.Width(200));
                if (GUILayout.Button("Add", GUILayout.Width(75)))
                {
                    if (!string.IsNullOrEmpty(customRoomKey))
                    {
                        isCustomRoomParamChanged            = true;
                        this.customRoomParam[customRoomKey] = "" as object;
                        customRoomKey = "";
                    }
                }
                if (isCustomRoomParamChanged)
                {
                    MonobitNetwork.room.SetCustomParameters(this.customRoomParam);
                }
                GUILayout.EndHorizontal();

                // ゲームスタート
                if (!isGameStart && GUILayout.Button("Start Game", GUILayout.Width(100)))
                {
                    this.isGameStart = true;
                    // room.open = false;
                    monobitView.RPC("GameStart", MonobitTargets.All, null);
                }

                // バトル終了
                if (this.battleEndFrame <= 0)
                {
                    // room.open = true;

                    // 部屋から離脱する
                    monobitView.RPC("LeaveRoomAll", MonobitTargets.All, null);
                }
            }
        }
Beispiel #10
0
    /**
     * GUI制御.
     */
    void OnGUI()
    {
        // GUI用の解像度を調整する
        Vector2 guiScreenSize = new Vector2(800, 480);

        if (Screen.width > Screen.height)
        {
            // landscape
            GUIUtility.ScaleAroundPivot(new Vector2(Screen.width / guiScreenSize.x, Screen.height / guiScreenSize.y), Vector2.zero);
        }
        else
        {
            // portrait
            GUIUtility.ScaleAroundPivot(new Vector2(Screen.width / guiScreenSize.y, Screen.height / guiScreenSize.x), Vector2.zero);
        }

        // MUNサーバに接続している場合
        if (MonobitNetwork.isConnect)
        {
            // ルームに入室している場合
            if (MonobitNetwork.inRoom)
            {
                // ルーム内のプレイヤー一覧の表示
                GUILayout.BeginHorizontal();
                GUILayout.Label("PlayerList : ");
                foreach (MonobitPlayer player in MonobitNetwork.playerList)
                {
                    GUILayout.Label(player.name + " ");
                }
                GUILayout.EndHorizontal();

                // ルームからの退室
                if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
                {
                    MonobitNetwork.LeaveRoom();
                    chatLog.Clear();
                }

                // チャット発言文の入力
                GUILayout.BeginHorizontal();
                GUILayout.Label("Message : ");
                chatWord = GUILayout.TextField(chatWord, GUILayout.Width(400));
                GUILayout.EndHorizontal();

                // チャット発言文を送信する
                if (GUILayout.Button("Send", GUILayout.Width(100)))
                {
                    monobitView.RPC("RecvChat", MonobitTargets.All, MonobitNetwork.playerName, chatWord);
                    chatWord = "";
                }

                // チャットログを表示する
                string msg = "";
                for (int i = 0; i < 10; ++i)
                {
                    msg += ((i < chatLog.Count) ? chatLog[i] : "") + "\r\n";
                }
                GUILayout.TextArea(msg);
            }
            // ルームに入室していない場合
            else
            {
                // ルーム名の入力
                GUILayout.BeginHorizontal();
                GUILayout.Label("RoomName : ");
                roomName = GUILayout.TextField(roomName, GUILayout.Width(200));
                GUILayout.EndHorizontal();

                // ルームを作成して入室する
                if (GUILayout.Button("Create Room", GUILayout.Width(150)))
                {
                    MonobitNetwork.CreateRoom(roomName);
                    chatLog.Clear();
                }

                // ルーム一覧を検索
                foreach (RoomData room in MonobitNetwork.GetRoomData())
                {
                    // ルームを選択して入室する
                    if (GUILayout.Button("Enter Room : " + room.name + "(" + room.playerCount + "/" + ((room.maxPlayers == 0) ? "-" : room.maxPlayers.ToString()) + ")"))
                    {
                        MonobitNetwork.JoinRoom(room.name);
                    }
                }
            }
        }
        // MUNサーバに接続していない場合
        else
        {
            // プレイヤー名の入力
            GUILayout.BeginHorizontal();
            GUILayout.Label("PlayerName : ");
            MonobitNetwork.playerName = GUILayout.TextField((MonobitNetwork.playerName == null) ? "": MonobitNetwork.playerName, GUILayout.Width(200));
            GUILayout.EndHorizontal();

            // デフォルトロビーへの自動入室を許可する
            MonobitNetwork.autoJoinLobby = true;

            // MUNサーバに接続する
            if (GUILayout.Button("Connect Server", GUILayout.Width(150)))
            {
                MonobitNetwork.ConnectServer("SimpleChat_v1.0");
            }
        }
    }
Beispiel #11
0
    // GUI制御
    private void OnGUI()
    {
        // MUNサーバに接続している場合
        if (MonobitNetwork.isConnect)
        {
            // ルームに入室している場合
            if (MonobitNetwork.inRoom)
            {
                //ルーム内のプレイヤー一覧の表示
                GUILayout.BeginHorizontal();
                GUILayout.Label("PlayerList : ");
                foreach (MonobitPlayer player in MonobitNetwork.playerList)
                {
                    GUILayout.Label(player.name + " ");
                }
                GUILayout.EndHorizontal();

                // ルームからの退室
                if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
                {
                    MonobitNetwork.LeaveRoom();
                    chatLog.Clear();
                }

                // チャット発言文の入力
                GUILayout.BeginHorizontal();
                GUILayout.Label("Message : ");
                chatWord = GUILayout.TextField(chatWord, GUILayout.Width(400));

                GUILayout.EndHorizontal();

                // チャット発言文を送信する
                if (GUILayout.Button("Send", GUILayout.Width(100)))
                {
                    monobitView.RPC("RecvChat",
                                    MonobitTargets.All,
                                    MonobitNetwork.playerName,
                                    chatWord);
                    chatWord = "";
                }

                // チャットログを表示する
                string msg = "";
                for (int i = 0; i < 10; ++i)
                {
                    msg += ((i < chatLog.Count) ? chatLog[i] : "") + "\r\n";
                }
                GUILayout.TextArea(msg);
            }
            // ルームに入室していない場合
            else
            {
                // ルーム名入力
                GUILayout.BeginHorizontal();
                GUILayout.Label("RoomName : ");
                roomName = GUILayout.TextField(roomName, GUILayout.Width(200));
                GUILayout.EndHorizontal();

                // ルームを作成して入室する
                if (GUILayout.Button("CreateRoom", GUILayout.Width(150)))
                {
                    MonobitNetwork.CreateRoom(roomName);
                }

                // ルーム一覧を検索
                foreach (RoomData room in MonobitNetwork.GetRoomData())
                {
                    System.String roomParam =
                        System.String.Format("{0}({1}/{2})",
                                             room.name,
                                             room.playerCount,
                                             ((room.maxPlayers == 0) ? "-" : room.maxPlayers.ToString())
                                             );

                    // ルームを選択して入室する
                    if (GUILayout.Button("Enter Room : " + roomParam))
                    {
                        MonobitNetwork.JoinRoom(room.name);
                    }
                }
            }
        }
        // MUNサーバに接続していない場合
        else
        {
            // プレイヤー名の入力
            GUILayout.BeginHorizontal();
            GUILayout.Label("PlayerName : ");
            MonobitNetwork.playerName = GUILayout.TextField(
                (MonobitNetwork.playerName == null) ?
                "" :
                MonobitNetwork.playerName, GUILayout.Width(200));
            GUILayout.EndHorizontal();

            // デフォルトロビーへの自動入室を許可する
            MonobitNetwork.autoJoinLobby = true;

            // MUNサーバに接続する
            if (GUILayout.Button("ConnectServer", GUILayout.Width(150)))
            {
                MonobitNetwork.ConnectServer("SinpleChat_v1.0");
            }
        }
    }
Beispiel #12
0
    // GUI処理
    void OnGUI()
    {
        // GUI用の解像度を調整する
        Vector2 guiScreenSize = new Vector2(800, 480);

        if (Screen.width > Screen.height)
        {
            // landscape
            GUIUtility.ScaleAroundPivot(new Vector2(Screen.width / guiScreenSize.x, Screen.height / guiScreenSize.y), Vector2.zero);
        }
        else
        {
            // portrait
            GUIUtility.ScaleAroundPivot(new Vector2(Screen.width / guiScreenSize.y, Screen.height / guiScreenSize.x), Vector2.zero);
        }

        // プレイヤーIDの表示
        if (MonobitNetwork.player != null)
        {
            GUILayout.Label("My Player ID : " + MonobitNetwork.player.ID);
        }

        // ルーム情報の取得
        Room room = MonobitNetwork.room;

        if (room != null)
        {
            // ルーム名の表示
            GUILayout.Label("Room Name : " + room.name);

            // ルーム内に存在するプレイヤー数の表示
            GUILayout.Label("PlayerCount : " + room.playerCount);

            // ルームがオープンかクローズか
            GUILayout.Label("Room IsOpen : " + room.open);

            // 制限時間の表示
            if (m_bGameStart)
            {
                GUILayout.Label("Rest Frame : " + this.battleEndFrame);
            }
        }
        // 部屋からの離脱
        if (GUILayout.Button("Leave Room", GUILayout.Width(100)))
        {
            // 部屋から離脱する
            MonobitNetwork.LeaveRoom();

            // 一旦切断する
            MonobitNetwork.DisconnectServer();

            // シーンをオフラインシーンへ
            MonobitNetwork.LoadLevel(OfflineScene.SceneNameOffline);
        }

        // ホストの場合
        if (MonobitNetwork.isHost)
        {
            // ゲームスタート前にゲームスタートするかどうか
            if (!m_bGameStart && GUILayout.Button("Start Game", GUILayout.Width(100)))
            {
                // ゲームスタートフラグを立てる
                m_bGameStart = true;

                // ルームをクローズする
                //room.open = false;

                // バトルスタートを通知
                monobitView.RPC("OnGameStart", MonobitTargets.All, null);
            }

            for (int i = 0; i < MonobitNetwork.otherPlayersList.Length; i++)
            {
                if (!m_bGameStart && GUILayout.Button("Switch Host ID:" + MonobitNetwork.otherPlayersList[i].ID, GUILayout.Width(200)))
                {
                    MonobitNetwork.ChangeHost(MonobitNetwork.otherPlayersList[i]);
                }
            }
        }
    }
Beispiel #13
0
    private void OnGUI()
    {
        // デフォルトのボタンと被らないように、段下げを行なう。
        GUILayout.Space(24);

        // MUNサーバに接続している場合
        if (MonobitNetwork.isConnect)
        {
            // ボタン入力でサーバから切断&シーンリセット
            if (GUILayout.Button("Disconnect", GUILayout.Width(150)))
            {
                // サーバから切断する
                MonobitNetwork.DisconnectServer();

                // シーンをリロードする
#if UNITY_5_3_OR_NEWER || UNITY_5_3
                string sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
                UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
#else
                Application.LoadLevel(Application.loadedLevelName);
#endif
            }

            // ルームに入室している場合
            if (MonobitNetwork.inRoom)
            {
                // ボタン入力でルームから退室
                if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
                {
                    MonobitNetwork.LeaveRoom();
                }
            }

            // ルームに入室していない場合
            if (!MonobitNetwork.inRoom)
            {
                GUILayout.BeginHorizontal();

                // ルーム名の入力
                GUILayout.Label("RoomName : ");
                roomName = GUILayout.TextField(roomName, GUILayout.Width(200));

                // ボタン入力でルーム作成
                if (GUILayout.Button("Create Room", GUILayout.Width(150)))
                {
                    MonobitNetwork.CreateRoom(roomName);
                }

                GUILayout.EndHorizontal();

                // 現在存在するルームからランダムに入室する
                if (GUILayout.Button("Join Random Room", GUILayout.Width(200)))
                {
                    MonobitNetwork.JoinRandomRoom();
                }

                // ルーム一覧から選択式で入室する
                foreach (RoomData room in MonobitNetwork.GetRoomData())
                {
                    string strRoomInfo =
                        string.Format("{0}({1}/{2})",
                                      room.name,
                                      room.playerCount,
                                      (room.maxPlayers == 0) ? "-" : room.maxPlayers.ToString());

                    if (GUILayout.Button("Enter Room : " + strRoomInfo))
                    {
                        MonobitNetwork.JoinRoom(room.name);
                    }
                }
            }
        }
    }
Beispiel #14
0
 private void OnDestroy()
 {
     MonobitNetwork.LeaveRoom();
 }
Beispiel #15
0
        /**
         * ルーム内でのGUI操作.
         */
        private void OnGUI_InRoom()
        {
            // 自身のプレイヤーIDの表示
            GUILayout.Label("Your ID : " + MonobitNetwork.player.ID);

            // ルーム内に存在するプレイヤー数の表示
            GUILayout.Label("PlayerCount : " + MonobitNetwork.room.playerCount + " / " + ((MonobitNetwork.room.maxPlayers == 0) ? "-" : MonobitNetwork.room.maxPlayers.ToString()));

            // ルームの入室制限可否設定の表示
            GUILayout.Label("Room isOpen : " + MonobitNetwork.room.open);

            // ルーム作成者が入力した値
            GUILayout.Label("Room Owner Numeric Value : " + MonobitNetwork.room.customParameters["Value"]);

            // 自身が入力した値
            GUILayout.Label("My Skill Level : " + baseValue);

            // 制限時間の表示
            if (isGameStart)
            {
                GUILayout.Label("Rest Frame : " + this.battleEndFrame);
            }

            // 部屋からの離脱
            if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
            {
                MonobitNetwork.LeaveRoom();
            }

            // ホストの場合
            if (MonobitNetwork.isHost)
            {
                // ゲームスタート
                if (!isGameStart && GUILayout.Button("Start Game", GUILayout.Width(150)))
                {
                    this.isGameStart = true;
                    // room.open = false;
                    monobitView.RPC("GameStart", MonobitTargets.All, null);
                }

                // バトル終了
                if (this.battleEndFrame <= 0)
                {
                    // room.open = true;

                    // 部屋から離脱する
                    monobitView.RPC("LeaveRoomAll", MonobitTargets.All, null);
                }
            }

            // 他にルームが作成されている場合
            if (MonobitNetwork.GetRoomData() != null && MonobitNetwork.GetRoomData().Length >= 1)
            {
                // 他の部屋に入室
                if (GUILayout.Button("Enter Another Room", GUILayout.Width(150)))
                {
                    // 一旦部屋から離脱する
                    MonobitNetwork.LeaveRoom();
                    isEnterAnotherRoom = true;
                }
            }
        }
Beispiel #16
0
        /**
         * GUI制御.
         */
        void OnGUI()
        {
            // GUI用の解像度を調整する
            Vector2 guiScreenSize = new Vector2(800, 480);

            if (Screen.width > Screen.height)
            {
                // landscape
                GUIUtility.ScaleAroundPivot(new Vector2(Screen.width / guiScreenSize.x, Screen.height / guiScreenSize.y), Vector2.zero);
            }
            else
            {
                // portrait
                GUIUtility.ScaleAroundPivot(new Vector2(Screen.width / guiScreenSize.y, Screen.height / guiScreenSize.x), Vector2.zero);
            }

            // MUNサーバに接続している場合
            if (MonobitNetwork.isConnect)
            {
                // ルームに入室している場合
                if (MonobitNetwork.inRoom)
                {
                    // ルーム内のプレイヤー一覧の表示
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("PlayerList : ");
                    foreach (MonobitPlayer player in MonobitNetwork.playerList)
                    {
                        GUILayout.Label(player.name + " ");
                    }
                    GUILayout.EndHorizontal();

                    // ルームからの退室
                    if (GUILayout.Button("Leave Room", GUILayout.Width(150)))
                    {
                        MonobitNetwork.LeaveRoom();
                    }

                    if (myVoice != null)
                    {
                        // 送信タイプの設定
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("VoiceChat Send Type : ");
                        Int32 streamType = myVoice.SendStreamType == StreamType.BROADCAST ? 0 : 1;
                        myVoice.SendStreamType = (StreamType)GUILayout.Toolbar(streamType, new string[] { "broadcast", "multicast" });
                        GUILayout.EndHorizontal();

                        // マルチキャスト送信の場合の、ボイスチャットの送信可否設定
                        if (myVoice.SendStreamType == StreamType.MULTICAST)
                        {
                            List <MonobitPlayer> playerList = new List <MonobitPlayer>(vcPlayerInfo.Keys);
                            List <MonobitPlayer> vcTargets  = new List <MonobitPlayer>();
                            foreach (MonobitPlayer player in playerList)
                            {
                                // GUI による送信可否の切替
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("PlayerName : " + player.name + " ");
                                GUILayout.Label("Send Permission: ");
                                vcPlayerInfo[player] = GUILayout.Toolbar(vcPlayerInfo[player], new string[] { "Allow", "Deny" });
                                GUILayout.EndHorizontal();
                                // ボイスチャットの送信可のプレイヤー情報を登録する
                                if (vcPlayerInfo[player] == (Int32)EnableVC.ENABLE)
                                {
                                    vcTargets.Add(player);
                                }
                            }

                            // ボイスチャットの送信可否設定を反映させる
                            myVoice.SetMulticastTarget(vcTargets.ToArray());
                        }
                    }
                }
                // ルームに入室していない場合
                else
                {
                    // ルーム名の入力
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("RoomName : ");
                    roomName = GUILayout.TextField(roomName, GUILayout.Width(200));
                    GUILayout.EndHorizontal();

                    // ルームを作成して入室する
                    if (GUILayout.Button("Create Room", GUILayout.Width(150)))
                    {
                        MonobitNetwork.CreateRoom(roomName);
                    }

                    // ルーム一覧を検索
                    foreach (RoomData room in MonobitNetwork.GetRoomData())
                    {
                        // ルームを選択して入室する
                        if (GUILayout.Button("Enter Room : " + room.name + "(" + room.playerCount + "/" + ((room.maxPlayers == 0) ? "-" : room.maxPlayers.ToString()) + ")"))
                        {
                            MonobitNetwork.JoinRoom(room.name);
                        }
                    }
                }
            }
            // MUNサーバに接続していない場合
            else
            {
                // プレイヤー名の入力
                GUILayout.BeginHorizontal();
                GUILayout.Label("PlayerName : ");
                MonobitNetwork.playerName = GUILayout.TextField((MonobitNetwork.playerName == null) ? "" : MonobitNetwork.playerName, GUILayout.Width(200));
                GUILayout.EndHorizontal();

                // デフォルトロビーへの自動入室を許可する
                MonobitNetwork.autoJoinLobby = true;

                // MUNサーバに接続する
                if (GUILayout.Button("Connect Server", GUILayout.Width(150)))
                {
                    MonobitNetwork.ConnectServer("SimpleVoiceChat_v1.0");
                }
            }
        }
Beispiel #17
0
 public static void LeaveRoom()
 {
     MonobitNetwork.LeaveRoom();
     Debug.Log("退室しました");
 }