コード例 #1
0
        private static void Prefix(ref Photon.Realtime.RoomOptions roomOptions)
        {
            if (setCasualPrivate)
            {
                if (roomOptions.CustomRoomProperties["gameMode"] as string == "private")
                {
                    roomOptions.CustomRoomProperties["gameMode"] = "privateCASUAL";
                }

                setCasualPrivate = false;
            }
        }
コード例 #2
0
        public override void OnRoomListUpdate(System.Collections.Generic.List <Photon.Realtime.RoomInfo> roomList)
        {
            var guid        = string.Format("{0}-{1}", System.Guid.NewGuid(), UnityEngine.Random.Range(0, 1000000));
            var roomOptions = new Photon.Realtime.RoomOptions()
            {
                MaxPlayers = _maxPlayer, PublishUserId = true
            };
            var room = roomList.FirstOrDefault(x => x.IsOpen == true);

            if (room != null)
            {
                Photon.Pun.PhotonNetwork.JoinRoom(room.Name);
            }
            else
            {
                Photon.Pun.PhotonNetwork.CreateRoom(guid, roomOptions, Photon.Realtime.TypedLobby.Default);
            }
        }
コード例 #3
0
        /** リクエスト。ルーム。接続。
         */
        private void Main_RequestConnectRoom()
        {
            if (this.status_room.mode != Pun_Status_Room.Mode.Request)
            {
                //不明。
                Tool.Assert(false);
                this.status_master.mode = Status_Master.Mode.Result;
                return;
            }

            if (this.IsConnectRoom() == true)
            {
                //すでに接続済み。
                this.status_room.SetConnect();
                return;
            }

            if (this.IsConnectMaster() == false)
            {
                //マスターが切断されている。
                this.status_room.SetDisconnect();
                return;
            }

            //接続。
            {
                Photon.Realtime.RoomOptions t_room_option = new Photon.Realtime.RoomOptions();
                {
                    //MaxPlayers
                    t_room_option.MaxPlayers = 16;

                    //IsVisible
                    t_room_option.IsVisible = true;

                    //IsOpen
                    t_room_option.IsOpen = true;

                    //CustomRoomProperties
                    ExitGames.Client.Photon.Hashtable t_custom_room_propertie = new ExitGames.Client.Photon.Hashtable();
                    {
                        t_custom_room_propertie.Add("room_info", this.status_room.room_info);
                    }
                    t_room_option.CustomRoomProperties = t_custom_room_propertie;

                    //CustomRoomPropertiesForLobby
                    t_room_option.CustomRoomPropertiesForLobby = new string[] {
                        "room_info"
                    };
                }

                Tool.Log("Pun", "JoinOrCreateRoom : " + "room_key = " + this.status_room.room_key + " : room_info = " + this.status_room.room_info);
                if (Photon.Pun.PhotonNetwork.JoinOrCreateRoom(this.status_room.room_key, t_room_option, Photon.Realtime.TypedLobby.Default) == true)
                {
                    this.status_room.SetBusy();
                }
                else
                {
                    //リクエスト失敗。
                    this.status_room.mode = Pun_Status_Room.Mode.Result;
                }
            }
        }
コード例 #4
0
        /** 更新。
         */
        public bool Main()
        {
            switch (this.mode)
            {
            case Mode.Init:
            {
                //初期化。

                //フラグリセット。
                this.connect_monobehaviour.ResetAll();

                //ニックネーム。
                Photon.Pun.PhotoFee.Network.NickName = Time.time.ToString();

                this.SetMode(Mode.ConnectMaster);
            } break;

            case Mode.ConnectMaster:
            {
                //マスターへの接続。

                //バージョン違いとはマッチングしない。
                Photon.Pun.PhotoFee.Network.GameVersion = Config.GAME_VERSION;

                //接続開始。
                bool t_ret = Photon.Pun.PhotoFee.Network.ConnectUsingSettings();

                if (t_ret == true)
                {
                    this.SetMode(Mode.ConnectMasterNow);
                }
            } break;

            case Mode.ConnectMasterNow:
            {
                //マスターへの接続処理中。

                if (this.connect_monobehaviour.result_connected_to_master == true)
                {
                    this.SetMode(Mode.ConnectMasterFix);
                }
                else
                {
                    //TODO:失敗。
                }
            } break;

            case Mode.ConnectMasterFix:
            {
                //マスターへの接続完了。

                this.SetMode(Mode.Join);
            } break;

            case Mode.Join:
            {
                //参加。

                this.connect_monobehaviour.ResetCreateJoinRoom();

                Photon.Pun.PhotoFee.Network.JoinRandomRoom();

                this.SetMode(Mode.JoinNow);
            } break;

            case Mode.JoinNow:
            {
                //参加処理中。

                if (this.connect_monobehaviour.result_joinroom_fix == true)
                {
                    this.SetMode(Mode.JoinFix);
                }
                else if (this.connect_monobehaviour.result_joinroom_failed == true)
                {
                    this.SetMode(Mode.JoinFailed);
                }
            } break;

            case Mode.JoinFix:
            {
                //参加完了。

                this.SetMode(Mode.Room);
            } break;

            case Mode.JoinFailed:
            {
                //参加失敗。

                this.SetMode(Mode.CreateRoom);
            } break;

            case Mode.CreateRoom:
            {
                //部屋作成。

                this.connect_monobehaviour.ResetCreateJoinRoom();

                Photon.Realtime.RoomOptions t_room_optopm = new Photon.Realtime.RoomOptions();
                {
                    t_room_optopm.MaxPlayers    = 3;
                    t_room_optopm.PublishUserId = true;
                }

                Photon.Pun.PhotoFee.Network.CreateRoom(null, t_room_optopm);

                this.SetMode(Mode.CreateRoomNow);
            } break;

            case Mode.CreateRoomNow:
            {
                //部屋作成処理中。

                if (this.connect_monobehaviour.result_createroom_failed == true)
                {
                    this.SetMode(Mode.CreateRoomFailed);
                    break;
                }
                else if (this.connect_monobehaviour.result_joinroom_failed == true)
                {
                    this.SetMode(Mode.CreateRoomFailed);
                    break;
                }
                else
                {
                    if (this.connect_monobehaviour.result_createroom_fix == true)
                    {
                        if (this.connect_monobehaviour.result_joinroom_fix == true)
                        {
                            this.SetMode(Mode.CreateRoomFix);
                            break;
                        }
                    }
                }
            } break;

            case Mode.CreateRoomFix:
            {
                //部屋作成完了。

                this.SetMode(Mode.Room);
            } break;

            case Mode.CreateRoomFailed:
            {
                //部屋作成失敗。

                this.SetMode(Mode.Disconnect);
            } break;

            case Mode.Room:
            {
                //部屋。

                //プレイヤー作成。
                Photon.Pun.PhotoFee.Network.Instantiate(Config.PREFAB_NAME_PLAYER, Vector3.zero, Quaternion.identity, 0);

                this.SetMode(Mode.Room_CreatePlayerNow);
            } break;

            case Mode.Room_CreatePlayerNow:
            {
                //部屋。プレイヤー作成処理中。

                if (Fee.Network.Network.GetInstance().GetMyPlayer() != null)
                {
                    this.SetMode(Mode.RoomNow);
                    break;
                }

                if (Fee.Network.Network.GetInstance().IsDisconnectRequest() == true)
                {
                    //切断リクエストあり。
                    this.SetMode(Mode.Disconnect);
                    break;
                }
                else if (this.connect_monobehaviour.result_disconnected == true)
                {
                    //切断。
                    this.SetMode(Mode.Disconnect);
                    break;
                }
            } break;

            case Mode.RoomNow:
            {
                //部屋処理中。

                if (Fee.Network.Network.GetInstance().IsDisconnectRequest() == true)
                {
                    //切断リクエストあり。
                    this.SetMode(Mode.Disconnect);
                    break;
                }
                else if (this.connect_monobehaviour.result_disconnected == true)
                {
                    //切断。
                    this.SetMode(Mode.Disconnect);
                    break;
                }
            } break;

            case Mode.Disconnect:
            {
                //切断。

                Photon.Pun.PhotoFee.Network.Disconnect();
                this.SetMode(Mode.DisconnectNow);
            } break;

            case Mode.DisconnectNow:
            {
                //切断処理中。

                if (this.connect_monobehaviour.result_disconnected == true)
                {
                    this.SetMode(Mode.DisconnectFix);
                }
            } break;

            case Mode.DisconnectFix:
            {
                //切断完了。

                if (Fee.Network.Network.GetInstance().IsDisconnectRequest() == true)
                {
                    if (Fee.Network.Network.GetInstance().GetPlayerList().Count == 0)
                    {
                        this.SetMode(Mode.End);
                    }
                }
            } break;

            case Mode.End:
            {
                //終了。

                GameObject.Destroy(this.connect_gameobject);
                this.connect_gameobject = null;
            } return(false);
            }

            return(true);
        }