Beispiel #1
0
    // 接続が切断されたときの処理
    public void OnDisconnectedFromServer()
    {
        Debug.Log("Disconnected from server");

        // シーンをオフラインシーンへ
        MonobitNetwork.LoadLevel(OfflineScene.SceneNameOffline);
    }
    // ルームが存在しなかった場合
    // 指定ルーム入室失敗時の処理
    public void OnJoinRoomFailed(object[] parameters)
    {
        Debug.Log("OnJoinRoomFailed : ErrorCode = " + parameters[0] + ", DebugMsg = " + parameters[1]);

        // オフラインシーンに戻す
        MonobitNetwork.LoadLevel(OfflineSceneReconnect.SceneNameOffline);
    }
Beispiel #3
0
    // ルーム作成時の処理
    public void OnCreatedRoom()
    {
        Debug.Log("OnCreateRoom");

        // シーンをオンラインシーンに
        MonobitNetwork.LoadLevel(SceneNameOnline);
    }
Beispiel #4
0
    // ルーム入室時の処理
    public void OnJoinedRoom()
    {
        Debug.Log("OnJoinedRoom player=" + MonobitNetwork.player);

        // シーンをオンラインシーンに
        MonobitNetwork.LoadLevel(SceneNameOnline);
    }
Beispiel #5
0
    void OnGameEnd()
    {
        Debug.Log("OnGameEnd");

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

        // シーンをオフラインシーンへ
        MonobitNetwork.LoadLevel(OfflineScene.SceneNameOffline);
    }
    // ウィンドウ表示
    void WindowGUI(int WindowID)
    {
        GUIStyle style = new GUIStyle();

        style.alignment = TextAnchor.MiddleCenter;
        GUIStyleState stylestate = new GUIStyleState();

        stylestate.textColor = Color.white;
        style.normal         = stylestate;
        if (bDisconnecting)
        {
            GUILayout.Label("MUN is disconnect.\nAre you reconnect?", style);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Yes", GUILayout.Width(50)))
            {
                // もう一度接続処理を実行する
                bDisconnecting = false;
                bReconnecting  = true;
                m_bGameStart   = false;
                spawnMyChara   = false;
                MonobitNetwork.ConnectServer("RandomMatchingReconnect_v1.0");
            }
            if (GUILayout.Button("No", GUILayout.Width(50)))
            {
                bDisconnecting = false;

                // シーンをオフラインシーンへ
                MonobitNetwork.LoadLevel(OfflineSceneReconnect.SceneNameOffline);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            GUILayout.Label("reconnecting...", style);
        }
    }
Beispiel #7
0
        // ウィンドウ表示
        void OnGUI_UnsafeDisconnect(int WindowID)
        {
            GUIStyle style = new GUIStyle();

            style.alignment = TextAnchor.MiddleCenter;
            GUIStyleState stylestate = new GUIStyleState();

            stylestate.textColor = Color.white;
            style.normal         = stylestate;
            if (isDisconnecting)
            {
                GUILayout.Label("MUN is disconnect.\nAre you reconnect?", style);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Yes", GUILayout.Width(50)))
                {
                    // もう一度接続処理を実行する
                    isDisconnecting = false;
                    isReconnecting  = true;
                    isGameStart     = false;
                    isGameEnd       = false;
                    MonobitNetwork.ConnectServer("RakeupGame_ServerSide_v1.0");
                }
                if (GUILayout.Button("No", GUILayout.Width(50)))
                {
                    isDisconnecting = false;

                    // シーンをオフラインシーンへ
                    MonobitNetwork.LoadLevel(OfflineSceneReconnect.SceneNameOffline);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.Label("reconnecting...", style);
            }
        }
    // 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(string.Format("My Player ID : {0}", MonobitNetwork.player.ID));
        }

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

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

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

            // ルームがオープンかクローズか
            GUILayout.Label(string.Format("Room IsOpen : {0}", room.open));

            // 制限時間の表示
            if (m_bGameStart)
            {
                GUILayout.Label(string.Format("Rest Frame : {0}", this.battleEndFrame));
            }

            GUILayout.Label(string.Format("IsHost : {0}", MonobitNetwork.isHost));
            if (null != MonobitNetwork.host)
            {
                GUILayout.Label(string.Format("Host : {0}", MonobitNetwork.host));
            }
            GUILayout.Label(string.Format("IsLeader : {0}", MonobitNetwork.isLeader));

            if (!MonobitNetwork.isHost)
            {
                if (GUILayout.Button("Change Host", GUILayout.Width(100)))
                {
                    MonobitNetwork.ChangeHost(MonobitNetwork.player);
                }
            }

            foreach (MonobitPlayer otherPlayer in MonobitNetwork.otherPlayersList)
            {
                if (GUILayout.Button("Kick " + otherPlayer, GUILayout.Width(200)))
                {
                    MonobitNetwork.Kick(otherPlayer);
                }
            }

            if (GUILayout.Button("Buffered RPC", GUILayout.Width(100)))
            {
                // RPCのBuffered確認用
                monobitView.RPC("BufferedRPC", MonobitTargets.AllBuffered, MonobitNetwork.player.ID, battleEndFrame);
            }
        }
        // 部屋からの離脱
        if (GUILayout.Button("Leave Room", GUILayout.Width(100)))
        {
            // 安全なDisconnect
            bSafeDiscoonect = true;

            // 部屋から離脱する
            MonobitNetwork.DisconnectServer();

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

            return;
        }

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

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

            // バトル終了
            if (battleEndFrame <= 0)
            {
                // 安全なDisconnect
                bSafeDiscoonect = true;

                // ルームを抜ける
                MonobitNetwork.DisconnectServer();

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

                return;
            }
        }

        // 意図しないタイミングで切断されたとき
        if (!MonobitNetwork.isConnect && !bSafeDiscoonect)
        {
            GUILayout.Window(0, new Rect(Screen.width / 2 - 100, Screen.height / 2 - 40, 200, 80), WindowGUI, "Disconnect");
        }
    }
    // 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);
        }

        // マイクデバイスの表示
        GUILayout.Label("Microphone: " + MonobitMicrophone.MicrophoneDeviceName);

        // マイクデバイスの切り替え
        for (int i = 0; i < Microphone.devices.Length; ++i)
        {
            string name = (Microphone.devices[i].Length > 0) ? Microphone.devices[i] : null;

            if (i == 0)
            {
                if (null != MonobitMicrophone.MicrophoneDeviceName)
                {
                    // i == 0はデフォルト。デフォルトに必ず戻せるようにしておく
                    if (GUILayout.Button("Default" + ((null == name) ? "" : " < " + name + " >"), GUILayout.Width(400)))
                    {
                        MonobitMicrophone.MicrophoneDeviceName = null;
                    }
                }
                continue;
            }
            else if (name == null)
            {
                // Unity2018より前のバージョンだと、日本語を含むデバイス名が空文字列になり、選択できないので、無視
                continue;
            }

            // 選択済のデバイスは無視
            if (name == MonobitMicrophone.MicrophoneDeviceName)
            {
                continue;
            }

            if (GUILayout.Button(name, GUILayout.Width(400)))
            {
                MonobitMicrophone.MicrophoneDeviceName = name;
            }
        }

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

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

        if (room != null)
        {
            // ルーム名の表示
            GUILayout.Label("Voice bps : " + m_bps);

            // ルーム名の表示
            GUILayout.Label(string.Format("Room Name : {0}", room.name));

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

            // ルームがオープンかクローズか
            GUILayout.Label(string.Format("Room IsOpen : {0}", room.open));

            // 制限時間の表示
            if (m_bGameStart)
            {
                GUILayout.Label(string.Format("Rest Frame : {0}", this.battleEndFrame));
            }

            GUILayout.Label(string.Format("IsHost : {0}", MonobitNetwork.isHost));
            if (null != MonobitNetwork.host)
            {
                GUILayout.Label(string.Format("Host : {0}", MonobitNetwork.host));
            }
            GUILayout.Label(string.Format("IsLeader : {0}", MonobitNetwork.isLeader));

            if (!MonobitNetwork.isHost)
            {
                if (GUILayout.Button("Change Host", GUILayout.Width(100)))
                {
                    MonobitNetwork.ChangeHost(MonobitNetwork.player);
                }
            }

            foreach (MonobitPlayer otherPlayer in MonobitNetwork.otherPlayersList)
            {
                if (GUILayout.Button("Kick " + otherPlayer, GUILayout.Width(200)))
                {
                    MonobitNetwork.Kick(otherPlayer);
                }
            }

            if (GUILayout.Button("Buffered RPC", GUILayout.Width(100)))
            {
                // RPCのBuffered確認用
                monobitView.RPC("BufferedRPC", MonobitTargets.AllBuffered, MonobitNetwork.player.ID, battleEndFrame);
            }
        }
        // 部屋からの離脱
        if (GUILayout.Button("Leave Room", GUILayout.Width(100)))
        {
            // 安全なDisconnect
            bSafeDiscoonect = true;

            // 部屋から離脱する
            MonobitNetwork.DisconnectServer();

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

            return;
        }

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

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

            // バトル終了
            if (battleEndFrame <= 0)
            {
                // 安全なDisconnect
                bSafeDiscoonect = true;

                // ルームを抜ける
                MonobitNetwork.DisconnectServer();

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

                return;
            }
        }

        // 意図しないタイミングで切断されたとき
        if (!MonobitNetwork.isConnect && !bSafeDiscoonect)
        {
            GUILayout.Window(0, new Rect(Screen.width / 2 - 100, Screen.height / 2 - 40, 200, 80), WindowGUI, "Disconnect");
        }
    }
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);
        }

        // プレイヤー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]);
                }
            }
        }
    }
    // 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)))
        {
            // 安全なDisconnect
            bSafeDiscoonect = true;

            // 部屋から離脱する
            MonobitNetwork.DisconnectServer();

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

            return;
        }

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

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

            // バトル終了
            if (battleEndFrame <= 0)
            {
                // 安全なDisconnect
                bSafeDiscoonect = true;

                // ルームを抜ける
                MonobitNetwork.DisconnectServer();

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

                return;
            }
        }

        // 意図しないタイミングで切断されたとき
        if (!MonobitNetwork.isConnect && !bSafeDiscoonect)
        {
            GUILayout.Window(0, new Rect(Screen.width / 2 - 100, Screen.height / 2 - 40, 200, 80), WindowGUI, "Disconnect");
        }
    }