Exemple #1
0
        public static string GetCurrentRoom(this PhotonClient client)
        {
            var di   = new DirectoryInfo($"C:\\Users\\{Environment.UserName}\\AppData\\LocalLow\\VRChat\\VRChat");
            var file = GetNewestFile(di);

            using (var stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (var reader = new StreamReader(stream, Encoding.UTF8))
                {
                    string contents = reader.ReadToEnd();

                    string toBeSearched = "[RoomManager] Joining w";
                    int    ix           = contents.LastIndexOf(toBeSearched);

                    if (ix != -1)
                    {
                        string roomID = contents.Substring(ix + toBeSearched.Length).Split('\n')[0];

                        return("w" + roomID.ToString());
                    }
                }
            }

            return(null);
        }
 public void CreateAndConnect(string applicationName, string serverAddress)
 {
     try
     {
         rwls.EnterWriteLock();
         PhotonClient client = null;
         if (clients.ContainsKey(applicationName))
         {
             client = clients[applicationName];
             if (client.PeerState == ExitGames.Client.Photon.PeerStateValue.Disconnected)
             {
                 client.Connect();
             }
         }
         else
         {
             client = new PhotonClient(applicationName, serverAddress);
             clients.Add(applicationName, client);
             client.Connect();
         }
     }
     finally
     {
         rwls.ExitWriteLock();
     }
 }
Exemple #3
0
 /// <summary>
 /// Starts regional Photon client's connection to the service.
 /// </summary>
 /// <param name="appId">Photon application ID, from game or Photon website.</param>
 /// <param name="gameVersion">Game version string.</param>
 public void StartClient(string appId, string gameVersion)
 {
     if (PhotonClient == null)
     {
         PhotonClient = new PhotonClient(appId, gameVersion, Code);
     }
 }
Exemple #4
0
        public static void JoinRoom(this PhotonClient client, string RoomID)
        {
            EnterRoomParams parms = new EnterRoomParams()
            {
                RoomName          = RoomID,
                CreateIfNotExists = true,
            };
            RoomOptions options = new RoomOptions()
            {
                IsOpen     = true,
                IsVisible  = true,
                MaxPlayers = Convert.ToByte(GetCapacityOfWorld(RoomID) * 2)
            };
            Hashtable table = new Hashtable()
            {
                ["name"] = "name"
            };

            options.CustomRoomProperties = table;
            parms.RoomOptions            = options;
            string[] customroompropertiesforlobby = new string[]
            {
                "name"
            };
            options.CustomRoomPropertiesForLobby = customroompropertiesforlobby;
            options.EmptyRoomTtl         = 0;
            options.DeleteNullProperties = true;
            options.PublishUserId        = false;
            client.OpJoinRoom(parms);
        }
Exemple #5
0
        public static void RegisterTypes(this PhotonClient client)
        {
            Type              typeFromHandle = typeof(Vector3);
            byte              code           = 86;
            SerializeMethod   Serialize1     = new SerializeMethod(JFAFAPNBFLC);
            DeserializeMethod DeSerialize1   = new DeserializeMethod(IKFICLDHAOI);

            PhotonPeer.RegisterType(typeFromHandle, code, Serialize1, DeSerialize1);
            Type              typeFromHandle2 = typeof(Quaternion);
            byte              code2           = 81;
            SerializeMethod   Serialize2      = new SerializeMethod(FECGOFBPKPP);
            DeserializeMethod DeSerialize2    = new DeserializeMethod(KCFONHKNDJH);

            PhotonPeer.RegisterType(typeFromHandle2, code2, Serialize2, DeSerialize2);
            byte              b = 100;
            Type              typeFromHandle3 = typeof(Vector2);
            SerializeMethod   Serialize3      = new SerializeMethod(KMIBNBFAHEN);
            DeserializeMethod DeSerialize3    = new DeserializeMethod(HHBPLJKDKPI);

            GCJHKDFNJEA(typeFromHandle3, ref b, Serialize3, DeSerialize3);
            Type              typeFromHandle4 = typeof(Vector4);
            SerializeMethod   Serialize4      = new SerializeMethod(DFMLPAEPHJD);
            DeserializeMethod DeSerialize4    = new DeserializeMethod(GPJDPFFENPL);

            GCJHKDFNJEA(typeFromHandle4, ref b, Serialize4, DeSerialize4);
        }
Exemple #6
0
        public void Run()
        {
            Screen.SetScreenSize(40, 60);
            Instance.GameSpeed = 200;

            int choice = Menu.Start();

            switch (choice)
            {
            case 1:
                Player offlinePlayer = new Player();
                Instance.PlayOffline(offlinePlayer);
                break;

            case 2:
            case 3:
                IClient client = new PhotonClient();
                client.ConnectClient();
                Instance.PlayOnline(client);
                break;

            case 4:
                Console.WriteLine("Only in paid version!");
                Thread.Sleep(1000);
                return;

            default:
                break;
            }
        }
Exemple #7
0
 public static void SetAuthentication(this PhotonClient client, string authCookie, string userID)
 {
     Console.WriteLine(authCookie);
     client.AuthValues          = new AuthenticationValues();
     client.AuthValues.AuthType = Photon.Realtime.CustomAuthenticationType.Custom;
     client.AuthValues.AddAuthParameter("token", authCookie);
     client.AuthValues.AddAuthParameter("user", userID);
 }
Exemple #8
0
 public PvpServer(PhotonClient client) : base(client, "pvp server")
 {
     PvpServer.IsMultithreadEnabled = GlobalSettings.Instance.PvpSetting.multiThread;
     if (PvpServer.IsMultithreadEnabled)
     {
         base.UseMultithread = true;
     }
 }
Exemple #9
0
        private void VRChatClient_JoinedRoom(PhotonClient client)
        {
            client.Instantiate(new Vector3(0f, 0.8f, 0f), new Quaternion(360f, 0.8f, 0f, 0f));
            Console.Title = $"PhotonAPI Tests = VRChat = Server Time: {Environment.TickCount}ms = {client.CurrentRoom.Players.Count} Player(s)";
            var    CurrentRoom = client.CurrentRoom;
            string info        = string.Empty;

            info += $"Room: {CurrentRoom.Name}\n";
            info += $"Player Count: {CurrentRoom.PlayerCount}\n";
            info += $"Players in Instance:\n";
            int Index = 0;

            foreach (var Player in CurrentRoom.Players.Values)
            {
                Index++;
                var    tag           = Player.CustomProperties["modTag"];
                var    user          = Player.CustomProperties["user"] as Dictionary <string, object>;
                var    avatar        = Player.CustomProperties["avatarDict"] as Dictionary <string, object>;
                var    avtrID        = avatar["id"];
                var    userID        = user["id"];
                var    username      = user["username"];
                var    displayname   = user["displayName"];
                var    AvatarCopying = user["allowAvatarCopying"];
                string steamID       = Player.CustomProperties["steamUserID"] == null ? "0" : Player.CustomProperties["steamUserID"].ToString();
                if (steamID == "0" && bool.Parse(Player.CustomProperties["inVRMode"].ToString()) == false && Player.ActorNumber != client.LocalPlayer.ActorNumber)
                {
                    info += "================================================\n";
                    info += $"[CHEATER] Player #{Index}:\n";
                    info += $"[CHEATER] Player ActorID: {Player.ActorNumber}\n";
                    info += $"[CHEATER] Player UserID: {userID}\n";
                    info += $"[CHEATER] Player Username: {username}\n";
                    info += $"[CHEATER] Player DisplayName: {displayname}\n";
                    info += $"[CHEATER] Player AvatarID: {avtrID}\n";
                    info += $"[CHEATER] Player Is Master: {Player.IsMasterClient}\n";
                    info += $"[CHEATER] Player Is Moderator: {(tag.ToString() == string.Empty ? "False" : "True")}\n";
                    info += $"[CHEATER] Player Has Cloning Enabled: {AvatarCopying}\n";
                    info += $"[CHEATER] Player SteamID: {(Player.CustomProperties["steamUserID"] == null ? "0" : Player.CustomProperties["steamUserID"].ToString())}\n";
                    info += $"[CHEATER] {username} is using a SteamID Spoofer. Cheater Detected.\n";
                    info += "================================================\n";
                }
                else
                {
                    info += "================================================\n";
                    info += $"Player #{Index}:\n";
                    info += $"Player ActorID: {Player.ActorNumber}\n";
                    info += $"Player UserID: {userID}\n";
                    info += $"Player Username: {username}\n";
                    info += $"Player DisplayName: {displayname}\n";
                    info += $"Player AvatarID: {avtrID}\n";
                    info += $"Player Is Master: {Player.IsMasterClient}\n";
                    info += $"Player Is Moderator: {(tag.ToString() == string.Empty ? "False" : "True")}\n";
                    info += $"Player Has Cloning Enabled: {AvatarCopying}\n";
                    info += $"Player SteamID: {(Player.CustomProperties["steamUserID"] == null ? "0" : Player.CustomProperties["steamUserID"].ToString())}\n";
                    info += "================================================\n";
                }
            }
            Console.WriteLine(info);
        }
        public async Task <EchoResponse> RequestEchoAsync(string message)
        {
            PhotonClient client = GetClient("Test");

            EchoRequest request  = new EchoRequest(message);
            var         response = await client.RequestAsync(request.OperationCode, request.Parameters);

            return(OperationFactory.GetResponse(response.OperationCode, response.Parameters, response.ReturnCode, response.DebugMessage) as EchoResponse);
        }
        public async Task <DelayResponse> RequestDelayAsync(int milliSeconds, string message)
        {
            PhotonClient client = GetClient("Test");

            DelayRequest request  = new DelayRequest(milliSeconds, message);
            var          response = await client.RequestAsync(request.OperationCode, request.Parameters);

            return(OperationFactory.GetResponse(response.OperationCode, response.Parameters, response.ReturnCode, response.DebugMessage) as DelayResponse);
        }
Exemple #12
0
 public CustomClientReliableChannel(MobaPeer _peer, PhotonClient _client, int _channelID)
 {
     this.pvpPeer      = _peer;
     this.client       = _client;
     this.channelID    = _channelID;
     this.recvCacheMgr = new RecvCacheMgr();
     this.sendPkgMgr   = new SendPkgMgr(this);
     this.Reset();
 }
Exemple #13
0
 public MobaPeer(ConnectionProtocol protocolType, PhotonClient client, MobaPeerType peerType) : base(protocolType)
 {
     this.mClient         = client;
     this.mPeerType       = peerType;
     this.mEventHandles   = new Dictionary <byte, INetEventHandleBase>();
     this.mConnectedTimes = 0;
     this.mIsReconnect    = false;
     this.ServerConnected = false;
 }
Exemple #14
0
        static void Main(string[] args)
        {
            var startStrip = new startStripFunc();
            var stopStrip  = new stopStripFunc();

            var startGroup0 = new startGroupFunc(0);
            var stopGroup0  = new stopGroupFunc(0);

            var setColors1 = new setColorsFunc(0, "Christmas5"); // "Pop");
            var setColors2 = new setColorsFunc(0, "Unicorn1");

            var setEffect0 = new setEffectFunc(0, "wave");

            setEffect0.len  = 48;
            setEffect0.glt  = 48;
            setEffect0.fps  = 25;
            setEffect0.mirr = 2;
            var setEffect1 = new setEffectFunc(0, "rainbow");

            setEffect1.len = 255;
            setEffect1.glt = 64;
            setEffect1.fps = 50;
            var setEffect2 = new setEffectFunc(0, "confetti");

            setEffect2.glt = 64;
            setEffect2.fps = 50;
            var setEffect3 = new setEffectFunc(0, "fade");

            setEffect3.glt = 64;
            setEffect3.fps = 20;

            var client = new PhotonClient();

            //Execute(client, startStrip);

            Execute(client, stopGroup0, false);

            Execute(client, setEffect0);
            Execute(client, startGroup0, false);

            Execute(client, setEffect1);
            Execute(client, startGroup0, false);

            Execute(client, setEffect2);
            Execute(client, startGroup0, false);

            Execute(client, setEffect3);
            Execute(client, startGroup0, false);

            Execute(client, setEffect0);
            Execute(client, startGroup0, false);

            //Execute(client, stopStrip);
        }
Exemple #15
0
        public static Player GetPlayer(this PhotonClient client, string userid)
        {
            foreach (var player in client.CurrentRoom.Players.Values)
            {
                var user = player.CustomProperties["user"] as Dictionary <string, object>;
                if (user["id"].ToString() == userid)
                {
                    return(player);
                }
            }

            return(null);
        }
 private UnitsSnapReporter()
 {
     this._client                   = NetWorkHelper.Instance.client;
     this._coroutineManager         = new CoroutineManager();
     this._lastSnapTimestamp        = 0f;
     this._snapSendIntervalInSecond = 0.1f;
     MobaMessageManager.RegistMessage(PvpCode.C2P_Ping, new MobaMessageFunc(this.OnP2C_Ping));
     MobaMessageManager.RegistMessage(PvpCode.P2C_CheckPing, new MobaMessageFunc(this.OnP2C_CheckPing));
     MobaMessageManager.RegistMessage((ClientMsg)20008, delegate(MobaMessage msg)
     {
         this.OnDisconnect();
     });
 }
Exemple #17
0
        public static void RPC(this PhotonClient client, int[] viewIDs, string MethodName, RpcTarget target, bool encrypt, params object[] parameters)
        {
            int       number    = viewIDs[0];
            Hashtable hashtable = new Hashtable();

            hashtable[(byte)0] = viewIDs;
            hashtable[(byte)1] = number;
            hashtable[(byte)2] = Environment.TickCount;
            hashtable[(byte)3] = MethodName;
            if (parameters.Count() > 0 || parameters != null)
            {
                hashtable[(byte)4] = parameters;
            }

            switch (target)
            {
            case RpcTarget.All:
                client.OpRaiseEvent(200, hashtable, new RaiseEventOptions()
                {
                    Receivers = ReceiverGroup.All
                }, new SendOptions()
                {
                    Reliability = true,
                    Encrypt     = encrypt
                });
                return;

            case RpcTarget.Others:
                client.OpRaiseEvent(200, hashtable, new RaiseEventOptions()
                {
                    Receivers = ReceiverGroup.All
                }, new SendOptions()
                {
                    Reliability = true,
                    Encrypt     = encrypt
                });
                return;

            case RpcTarget.MasterClient:
                client.OpRaiseEvent(200, hashtable, new RaiseEventOptions()
                {
                    Receivers = ReceiverGroup.MasterClient
                }, new SendOptions()
                {
                    Reliability = true,
                    Encrypt     = encrypt
                });
                return;
            }
        }
 public TimeSyncSystem(PhotonClient _client, MobaPeer _peer)
 {
     this.client        = _client;
     this.pvpPeer       = _peer;
     this.firstTickTime = DateTime.Now.Ticks / 10000L;
     for (int i = 0; i < this.timeSyncInfoReceived.Length; i++)
     {
         this.timeSyncInfoReceived[i] = new TimeSyncInfo();
     }
     for (int i = 0; i < this.timeSyncMsgTimeoutLogArr.Length; i++)
     {
         this.timeSyncMsgTimeoutLogArr[i]           = new TimeSyncMsgTimeoutInfo();
         this.timeSyncMsgTimeoutLogArr[i].isAckBack = true;
     }
 }
Exemple #19
0
        public void LoopClients()
        {
            while (isRunning) // TODO: Add server close method
            {
                Console.WriteLine("Waiting for connection...");

                // wait for client connection
                PhotonClient newPClient = new PhotonClient();
                newPClient.Client       = server.AcceptTcpClient();
                newPClient.PlayerName   = "P" + this.playerNumber++; //TODO: use PlayerAuthentication
                newPClient.ClientPlayer = new Player();              //TODO: load game
                this.players.Add(newPClient.PlayerName, newPClient.ClientPlayer);

                // client found & create a thread to handle communication
                Thread t = new Thread(new ParameterizedThreadStart(HandleClient));
                t.Start(newPClient);
            }
        }
Exemple #20
0
 private void InitClient()
 {
     ThreadUtils.Init();
     this._gateReconnection   = new GateReconnection();
     GlobalManager.ClientType = 2;
     this.client    = new PhotonClient();
     this.dicServer = new Dictionary <NetWorkHelper.ServerType, ServerHelpCom>
     {
         {
             NetWorkHelper.ServerType.master,
             new MasterServerNew(this.client)
         },
         {
             NetWorkHelper.ServerType.lobby,
             new LobbyServerNew(this.client)
         },
         {
             NetWorkHelper.ServerType.pvp,
             new PvpServer(this.client)
         },
         {
             NetWorkHelper.ServerType.Gate,
             new GateServer(this.client)
         }
     };
     this.listServer = new List <ServerHelpCom>(this.dicServer.Values.Count);
     foreach (ServerHelpCom current in this.dicServer.Values)
     {
         this.listServer.Add(current);
     }
     this.client.RegistSendMsg2ClientCustom(new PhotonClient.DeleSendMsg2ClientCustom(this.DelePhotonMsgCustom));
     this.client.RegistSendMsg2ClientMasterCode(new PhotonClient.DeleSendMsg2ClientMasterCode(this.DelePhotonMsgMasterCode));
     this.client.RegistSendMsg2ClientGameCode(new PhotonClient.DeleSendMsg2ClientGameCode(this.DelePhotonMsgGameCode));
     this.client.RegistSendMsg2ClientPvpCode(new PhotonClient.DeleSendMsg2ClientPvpCode(this.DelePhotonMsgPvpCode));
     this.client.RegistSendMsg2ClientChatCode(new PhotonClient.DeleSendMsg2ClientChatCode(this.DelePhotonMsgChatCode));
     this.client.RegistSendMsg2ClientFriendCode(new PhotonClient.DeleSendMsg2ClientFriendCode(this.DelePhotonMsgFriendCode));
     this.client.RegistSendMsg2ClientTeamRoomCode(new PhotonClient.DeleSendMsg2ClientTeamRoomCode(this.DelePhotonMsgTeamRoomCode));
     this.client.RegistSendMsg2ClientGateCode(new PhotonClient.DeleSendMsg2ClientGateCode(this.DelePhotonMsgGateCode));
     this.client.RegistSendMsg2ClientLobbyCode(new PhotonClient.DeleSendMsg2ClientLobbyCode(this.DelePhotonMsgLobbyCode));
     this.client.RegistSendMsg2ClientUserDataCode(new PhotonClient.DeleSendMsg2ClientUserDataCode(this.DelePhotonMsgUserDataCode));
     MobaMessageManager.RegistMessage(Photon2ClientMsg.PeerConnected, new MobaMessageFunc(this.OnPeerConnected));
     MobaMessageManager.RegistMessage(Photon2ClientMsg.PeerDisconnected, new MobaMessageFunc(this.OnPeerDisconnected));
     MobaMessageManager.RegistMessage(Photon2ClientMsg.PeerStatusChanged, new MobaMessageFunc(this.OnPeerStatusChanged));
 }
 public void RemoveClient(string applicationName)
 {
     try
     {
         rwls.EnterWriteLock();
         if (clients.ContainsKey(applicationName))
         {
             PhotonClient client = null;
             client = clients[applicationName];
             client.Close();
             client.Dispose();
             clients.Remove(applicationName);
         }
     }
     finally
     {
         rwls.ExitWriteLock();
     }
 }
Exemple #22
0
        public static void Instantiate(this PhotonClient client, Vector3 Position, Quaternion Rotation)
        {
            Hashtable hashtable = new Hashtable();

            hashtable[(byte)0] = "VRCPlayer";
            hashtable[(byte)1] = Position;
            hashtable[(byte)2] = Rotation;
            hashtable[(byte)4] = new int[] { int.Parse(client.LocalPlayer.ActorNumber + "00001"), int.Parse(client.LocalPlayer.ActorNumber + "00002") };
            hashtable[(byte)6] = Environment.TickCount;
            hashtable[(byte)7] = int.Parse(client.LocalPlayer.ActorNumber + "00001");

            client.OpRaiseEvent(202, hashtable, new RaiseEventOptions
            {
                CachingOption = EventCaching.AddToRoomCache
            }, new SendOptions()
            {
                DeliveryMode = DeliveryMode.Reliable,
                Reliability  = true,
                Channel      = 1
            });
        }
Exemple #23
0
        private static string Execute(PhotonClient client, IApiFunction func, bool waitForKey = true)
        {
            Console.WriteLine("".PadRight(75, '-'));
            Console.WriteLine($"Executing '{func.FunctionName}' ({func.GetType().Name})...");
            Console.WriteLine($"  Data: {func.GetJsonString()}");
            if (waitForKey)
            {
                Console.WriteLine("ENTER to continue...");
                Console.ReadKey();
                Console.WriteLine();
            }
            var task = client.PostDataAsync(func);

            task.Wait();
            Console.WriteLine($"Finished, result: \r\n  {task.Result}");
            //if (waitForKey)
            //{
            //    Console.WriteLine("ENTER to continue...");
            //    Console.ReadKey();
            //    Console.WriteLine();
            //}
            return(task.Result);
        }
Exemple #24
0
        public static Hashtable Instantiate(this PhotonClient client, string prefabName, Vector3 position, Quaternion rotation, int[] viewIDs)
        {
            int       num       = viewIDs[0];
            Hashtable hashtable = new Hashtable();

            hashtable[(byte)0] = prefabName;
            hashtable[(byte)1] = position;
            hashtable[(byte)2] = rotation;
            hashtable[(byte)4] = viewIDs;
            hashtable[(byte)6] = Environment.TickCount;
            hashtable[(byte)7] = num;

            client.OpRaiseEvent(202, hashtable, new RaiseEventOptions
            {
                CachingOption = EventCaching.AddToRoomCache
            }, new SendOptions()
            {
                DeliveryMode = DeliveryMode.Reliable,
                Reliability  = true,
                Channel      = 1
            });

            return(hashtable);
        }
Exemple #25
0
 public GateServer(PhotonClient client)
 {
     this._client = client;
 }
Exemple #26
0
 public MasterServerNew(PhotonClient client)
 {
     this._client = client;
 }
 public LobbyServerNew(PhotonClient client) : base(client, "lobby server")
 {
 }
    void Awake()
    {
        Application.runInBackground = true;      //防止后台掉线
        CustomTypes.Register();
        _client       = new PhotonClient();
        _client.AppId = "49395063-2a0e-4e1f-a35d-3d4600790bc2";      //Turnbased 的 ID
        //_client.AppId="bc31b098-957d-4231-9ad5-b75adc3c6fb7";// RealTime 的ID
        bool connectInProcess = _client.ConnectToRegionMaster("asia");

        _go_GuessBricks = GameObject.Find("GuessBricks").transform;
        MyDock          = GameObject.Find("DockD").transform;
        PickPop         = GameObject.Find("PickPop").transform;
        _planet         = GameObject.Find("Planet");
        _table          = _planet.transform.GetChild(0).gameObject;
        _unOccupied     = _table.transform.GetChild(5).gameObject;
        //--------------找到UI元素------------
        Notify      = GetComponent <Notification>();
        Panel       = GameObject.Find("Panel").transform;
        StartBtn    = GameObject.Find("Start").transform;
        _canvas     = GameObject.Find("Canvas");
        _winBanner  = GameObject.Find("Win").transform;
        _panel      = GameObject.Find("Panel");
        _readyPanel = GameObject.Find("ReadyPanel");
        _overPanel  = GameObject.Find("OverPanel");
        DoneBtn     = GameObject.Find("AdjustDone").transform;
        CancelBtn   = GameObject.Find("Cancel").transform;
        ContinueBtn = GameObject.Find("ContinueGuess").transform;
        _loading    = GameObject.Find("Loading").transform;
        //-----------------------



        if (GameControl._instance == null)
        {
            GameControl._instance = this;
        }
        DontDestroyOnLoad(gameObject);

        #region 注册UI事件
        GameObject.Find("Create").GetComponent <Button>().onClick.AddListener(
            () => {
            if (_roomName != "")
            {
                _client.OpCreateRoom(_roomName, new RoomOptions()
                {
                    MaxPlayers = _playerNum
                }, TypedLobby.Default);
            }
        });
        GameObject.Find("Join").GetComponent <Button>().onClick.AddListener(
            () => {
            if (_roomName != "")
            {
                _client.OpJoinRoom(_roomName);
            }
        });
        GameObject.Find("PlayerNum").GetComponent <Dropdown>().onValueChanged
        .AddListener(x => {
            _playerNum = (byte)(x + 2);
        });
        GameObject.Find("RoomName").GetComponent <InputField>().onValueChanged
        .AddListener(x => {
            _roomName = x;
        });
        GameObject.Find("Leave").GetComponent <Button>().onClick.AddListener(
            () => {
            //销毁玩家头像
            foreach (var icon in _playerIcons)
            {
                Destroy(icon.gameObject);
            }
            _playerIcons.Clear();

            //通知其他人  我离开了
            _client.OpRaiseEvent(MyEventCode.OneLeave, _myID, true, RaiseEventOptions.Default);

            _client.OpLeaveRoom(false);
            _overPanel.SetActive(false);
            _panel.SetActive(true);
        });
        GameObject.Find("Again").GetComponent <Button>().onClick.AddListener(
            () => {
            //currentID 为自己
            CurrentID = _myID;
            //重新设置玩家头像的parent
            for (int i = 0; i < _playerNum; i++)
            {
                var icon = _playerIcons[i];
                icon.SetParent(_readyPanel.transform);
            }
            //自己的头像放到readypos  并且通知别人
            //playerIcons readyPos的顺序和id一样 注意ID从1 开始
            var myIcon = _playerIcons[_myID - 1];
            AnimElement.Prepare()
            .InitUGUI(myIcon.localPosition,
                      readyPos[_myID - 1],
                      myIcon,
                      0,
                      40)
            .AddScaleAnimation(myIcon.localScale, Vector3.one * 0.6f)
            .Play();
            _client.OpRaiseEvent(MyEventCode.OnePlayAgain, _myID, true, RaiseEventOptions.Default);


            //载入等待面板
            _overPanel.SetActive(false);
            _readyPanel.SetActive(true);

            EnterRoom(_playerNum);
        });
        //房主开始游戏
        GameObject.Find("Start").GetComponent <Button>().onClick.AddListener(
            () => {
            //洗牌
            ShuffleDeck();
            //-----------------------------
            //把所有的牌发送给其他玩家
            //-----------------------
            _client.OpRaiseEvent(MyEventCode.SyncAllBricks, indexMap, true
                                 , RaiseEventOptions.Default);
            //放置牌到桌子上
            PlaceAllBricksOnTable(indexMap);
            StartGame();
        });
        // 完成 按钮的点击逻辑
        DoneBtn.GetComponent <Button>().onClick.AddListener(() => {
            // 玩家确认完成Adjust过程中的joker放置后 点击
            if (GameState.Instance.CurrentState == GameState.State.Adjust)
            {
                //通知其他玩家在逻辑层更新我的Joker位置
                int msgType = 0;
                int[] msg   = new int[4];
                msg[0]      = _myID;
                if (_decks[_myDeckIndex].Contains(_jokerWhite))
                {
                    msgType = -1;
                    msg[2]  = _decks[_myDeckIndex].IndexOf(_jokerWhite);
                }
                if (_decks[_myDeckIndex].Contains(_jokerBlack))
                {
                    msgType = -msgType;
                    msg[3]  = _decks[_myDeckIndex].IndexOf(_jokerBlack);
                }
                msg[1] = msgType;
                _client.OpRaiseEvent(MyEventCode.SyncJoker, msg, true, RaiseEventOptions.Default);

                //
                LocalReadyToGo();
                //隐藏所有arrows for joker
                _jokerBlack.GetComponent <Brick>().DestroyArrows();
                _jokerWhite.GetComponent <Brick>().DestroyArrows();
            }
            //  每一round中抽到joker的玩家确认完成joker的放置后点击
            else if (GameState.Instance.CurrentState == GameState.State.PlacingJoker)
            {
                //进入Guess状态
                GameState.Instance.CurrentState = GameState.State.GuessABrick;
                //视觉提示 让我猜牌
                Notify.autoNtf("请猜牌", Vector2.zero, new Vector2(1, 1), 1);

                //隐藏所有arrows for joker
                _jokerBlack.GetComponent <Brick>().DestroyArrows();
                _jokerWhite.GetComponent <Brick>().DestroyArrows();
            }
            else if (GameState.Instance.CurrentState == GameState.State.GuessingABrick)
            {
                //不猜了   轮到下一个玩家
                ToNextOne();
                //隐藏按钮
                ContinueBtn.gameObject.SetActive(false);
                DoneBtn.gameObject.SetActive(false);
                //切换状态
                GameState.Instance.CurrentState = GameState.State.WaitForOthers;
            }

            DoneBtn.gameObject.SetActive(false);
        });
        //取消猜牌按钮的点击逻辑
        CancelBtn.GetComponent <Button>().onClick.AddListener(() => {
            CancelBtn.gameObject.SetActive(false);
            //隐藏所有PossibleBrick
            HidePossibleBricks();
            //状态回到GuessABrick
            GameState.Instance.CurrentState = GameState.State.GuessABrick;
        });
        //继续猜
        ContinueBtn.GetComponent <Button>().onClick.AddListener(() => {
            GameState.Instance.CurrentState = GameState.State.GuessABrick;
            ContinueBtn.gameObject.SetActive(false);
            DoneBtn.gameObject.SetActive(false);
        });
        #endregion

        //----初始化UI状态----------
        _readyPanel.SetActive(false);
        DoneBtn.gameObject.SetActive(false);
        CancelBtn.gameObject.SetActive(false);
        ContinueBtn.gameObject.SetActive(false);
        Panel.gameObject.SetActive(false);
        StartBtn.gameObject.SetActive(false);
        _overPanel.SetActive(false);

        //--------------------------------------
    }
Exemple #29
0
 public MobaPvpServerClientPeer(ConnectionProtocol protocolType, PhotonClient client) : base(protocolType, client, MobaPeerType.C2PvpServer)
 {
     this.mClient  = client;
     base.Listener = this;
 }
 public UdpDriver(PhotonClient _client, MobaPeer _peer)
 {
     this.client  = _client;
     this.pvpPeer = _peer;
 }