private void UpdatePhotonMessage() { MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance; if (UnityEngine.Object.op_Equality((UnityEngine.Object)instance, (UnityEngine.Object)null)) { return; } List <MyPhoton.MyEvent> events = instance.GetEvents(); if (events == null) { return; } while (events.Count > 0) { MyPhoton.MyEvent myEvent = events[0]; events.RemoveAt(0); if (myEvent.code == MyPhoton.SEND_TYPE.Normal && myEvent.binary != null) { VersusDraftReady.VersusReadyMessageData buffer = (VersusDraftReady.VersusReadyMessageData)null; if (GameUtility.Binary2Object <VersusDraftReady.VersusReadyMessageData>(out buffer, myEvent.binary) && buffer != null) { this.mMessageDataList.Add(buffer); } } } }
private void UpdatePhotonMessage() { MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance; if (UnityEngine.Object.op_Equality((UnityEngine.Object)instance, (UnityEngine.Object)null)) { return; } List <MyPhoton.MyEvent> events = instance.GetEvents(); if (events == null) { return; } while (events.Count > 0) { MyPhoton.MyEvent myEvent = events[0]; events.RemoveAt(0); if (myEvent.code == MyPhoton.SEND_TYPE.Normal && myEvent.binary != null) { VersusDraftList.VersusDraftMessageData buffer = (VersusDraftList.VersusDraftMessageData)null; if (GameUtility.Binary2Object <VersusDraftList.VersusDraftMessageData>(out buffer, myEvent.binary) && buffer != null) { switch (buffer.h) { case 1: VersusDraftUnit.ResetSelectUnit(); if (buffer.uidx0 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx0) { this.mVersusDraftUnitList[buffer.uidx0].SelectUnit(false); } if (buffer.uidx1 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx1) { this.mVersusDraftUnitList[buffer.uidx1].SelectUnit(false); } if (buffer.uidx2 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx2) { this.mVersusDraftUnitList[buffer.uidx2].SelectUnit(false); continue; } continue; case 2: if (buffer.uidx0 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx0) { this.mVersusDraftUnitList[buffer.uidx0].DecideUnit(false); ++this.mEnemyUnitIndex; } if (buffer.uidx1 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx1) { this.mVersusDraftUnitList[buffer.uidx1].DecideUnit(false); ++this.mEnemyUnitIndex; } if (buffer.uidx2 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx2) { this.mVersusDraftUnitList[buffer.uidx2].DecideUnit(false); ++this.mEnemyUnitIndex; continue; } continue; case 3: if (!this.ChangeTurn(true)) { for (int index = 0; index < this.SELECTABLE_UNIT_COUNT_OF_TURN[this.mTurn]; ++index) { this.mVersusDraftSelectedUnit[this.mSelectingUnitIndex + index].Selecting(); } continue; } continue; default: continue; } } } } }
public override void Update(FlowNode_StartMultiPlay self) { MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance; if (instance.CurrentState != MyPhoton.MyState.ROOM) { self.Failure(); } else { MyPhoton.MyRoom currentRoom = instance.GetCurrentRoom(); if (currentRoom == null) { self.Failure(); } else { JSON_MyPhotonRoomParam myPhotonRoomParam = !string.IsNullOrEmpty(currentRoom.json) ? JSON_MyPhotonRoomParam.Parse(currentRoom.json) : (JSON_MyPhotonRoomParam)null; if (myPhotonRoomParam == null) { self.Failure(); } else { if (myPhotonRoomParam.started == 0) { myPhotonRoomParam.started = 1; instance.SetRoomParam(myPhotonRoomParam.Serialize()); } if ((double)this.mStartWait > 0.0) { this.mStartWait -= Time.get_deltaTime(); if ((double)this.mStartWait > 0.0) { return; } GlobalVars.SelectedQuestID = myPhotonRoomParam.iname; GlobalVars.SelectedFriendID = (string)null; GlobalVars.SelectedFriend = (FriendData)null; GlobalVars.SelectedSupport.Set((SupportData)null); self.Success(); DebugUtility.Log("StartMultiPlay: " + myPhotonRoomParam.Serialize()); } else if ((double)this.mWait > 0.0) { this.mWait -= Time.get_deltaTime(); } else { List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList(); if ((myPhotonRoomParam.type == 1 || myPhotonRoomParam.type == 3) && roomPlayerList.Count == 1) { self.FailureStartMulti(); } else if (this.mConfirm) { using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator()) { while (enumerator.MoveNext()) { JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(enumerator.Current.json); if (photonPlayerParam.state != 3) { return; } if (photonPlayerParam.state < 2) { self.Failure(); return; } } } this.mStartWait = 0.1f; } else { MyPhoton.MyPlayer myPlayer = instance.GetMyPlayer(); if (this.mRecvList.Count <= 0) { this.mSend.senderPlayerID = myPlayer.photonPlayerID; this.mSend.playerListJson = (string)null; List <JSON_MyPhotonPlayerParam> photonPlayerParamList = new List <JSON_MyPhotonPlayerParam>(); for (int index = 0; index < roomPlayerList.Count; ++index) { JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(roomPlayerList[index].json); photonPlayerParamList.Add(photonPlayerParam); } photonPlayerParamList.Sort((Comparison <JSON_MyPhotonPlayerParam>)((a, b) => a.playerIndex - b.playerIndex)); FlowNode_StartMultiPlay.PlayerList playerList = new FlowNode_StartMultiPlay.PlayerList(); playerList.players = photonPlayerParamList.ToArray(); Json_MyPhotonPlayerBinaryParam[] playerBinaryParamArray = new Json_MyPhotonPlayerBinaryParam[playerList.players.Length]; for (int index = 0; index < playerList.players.Length; ++index) { playerList.players[index].CreateJsonUnitData(); playerBinaryParamArray[index] = new Json_MyPhotonPlayerBinaryParam(); playerBinaryParamArray[index].Set(playerList.players[index]); } this.mSend.playerList = playerBinaryParamArray; byte[] msg = GameUtility.Object2Binary <FlowNode_StartMultiPlay.RecvData>(this.mSend); instance.SendRoomMessageBinary(true, msg, MyPhoton.SEND_TYPE.Sync, false); this.mRecvList.Add(this.mSend); this.mSend.playerListJson = playerList.Serialize(); } List <MyPhoton.MyEvent> events = instance.GetEvents(); for (int index = events.Count - 1; index >= 0; --index) { FlowNode_StartMultiPlay.RecvData buffer = (FlowNode_StartMultiPlay.RecvData)null; if (!GameUtility.Binary2Object <FlowNode_StartMultiPlay.RecvData>(out buffer, events[index].binary)) { DebugUtility.LogError("[PUN] started player list version error: " + events[index].json); instance.Disconnect(); return; } if (buffer == null || buffer.version < this.mSend.version) { DebugUtility.LogError("[PUN] started player list version error: " + events[index].json); instance.Disconnect(); return; } if (buffer.version <= this.mSend.version) { buffer.senderPlayerID = events[index].playerID; DebugUtility.Log("[PUN] recv started player list: " + events[index].json); this.mRecvList.Add(buffer); events.Remove(events[index]); } } using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator()) { while (enumerator.MoveNext()) { MyPhoton.MyPlayer p = enumerator.Current; if (this.mRecvList.FindIndex((Predicate <FlowNode_StartMultiPlay.RecvData>)(r => r.senderPlayerID == p.photonPlayerID)) < 0) { return; } } } bool flag = true; using (List <FlowNode_StartMultiPlay.RecvData> .Enumerator enumerator = this.mRecvList.GetEnumerator()) { while (enumerator.MoveNext()) { FlowNode_StartMultiPlay.RecvData current = enumerator.Current; if (current.playerList.Length == this.mSend.playerList.Length) { for (int index = 0; index < this.mSend.playerList.Length; ++index) { if (!Json_MyPhotonPlayerBinaryParam.IsEqual(current.playerList[index], this.mSend.playerList[index])) { flag = false; } } if (!flag) { break; } } else { flag = false; break; } } } if (!flag) { DebugUtility.Log("[PUN] started player list is not equal. ver:" + (object)this.mSend.version); this.mRecvList.Clear(); ++this.mSend.version; this.mWait = 1f; } else { DebugUtility.Log("[PUN]started player list decided. ver:" + (object)this.mSend.version); List <JSON_MyPhotonPlayerParam> myPlayersStarted = instance.GetMyPlayersStarted(); myPlayersStarted.Clear(); foreach (JSON_MyPhotonPlayerParam player in JSONParser.parseJSONObject <FlowNode_StartMultiPlay.PlayerList>(this.mSend.playerListJson).players) { player.SetupUnits(); myPlayersStarted.Add(player); } if (instance.IsOldestPlayer()) { instance.UpdateRoomParam("started", (object)this.mSend.playerListJson); } if (events.Count > 0) { DebugUtility.LogError("[PUN] event must be empty."); } events.Clear(); JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(myPlayer.json); photonPlayerParam.state = 3; instance.SetMyPlayerParam(photonPlayerParam.Serialize()); this.mConfirm = true; } } } } } } }
public void Analyze(string log) { string json = string.Empty; string src = string.Empty; if (!string.IsNullOrEmpty(this.mNonAnalyzeLog)) { log = this.mNonAnalyzeLog + log; this.mNonAnalyzeLog = string.Empty; } if (log.IndexOf("creatorName") != -1) { json = log; } else if (log.IndexOf("players") != -1) { src = log; } else if (log.IndexOf("bm") != -1) { try { byte[] data = MyEncrypt.Decrypt(((AudienceLog)JsonUtility.FromJson <AudienceLog>(log)).bm); SceneBattle.MultiPlayRecvData buffer; if (GameUtility.Binary2Object <SceneBattle.MultiPlayRecvData>(out buffer, data)) { if (!this.mTurnLog.ContainsKey(buffer.b)) { this.mTurnLog[buffer.b] = new List <SceneBattle.MultiPlayRecvData>(); } this.mTurnLog[buffer.b].Add(buffer); } } catch { this.mNonAnalyzeLog = log; } } else if (log.IndexOf("bin") != -1) { try { SceneBattle.MultiPlayRecvBinData multiPlayRecvBinData = (SceneBattle.MultiPlayRecvBinData)JsonUtility.FromJson <SceneBattle.MultiPlayRecvBinData>(log); string buffer; GameUtility.Binary2Object <string>(out buffer, multiPlayRecvBinData.bin); this.Analyze(buffer); return; } catch { this.mNonAnalyzeLog = log; } } else { this.mNonAnalyzeLog = log; } if (!string.IsNullOrEmpty(json)) { try { this.mRoomParam = JSON_MyPhotonRoomParam.Parse(json); } catch { Debug.LogWarning((object)json); this.mNonAnalyzeLog = json; } } if (string.IsNullOrEmpty(src)) { return; } try { this.mStartedParam = JSONParser.parseJSONObject <AudienceStartParam>(src); } catch { Debug.LogWarning((object)src); this.mNonAnalyzeLog = src; } }
public override void Update(FlowNode_MultiPlayJoinRoom self) { MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance; if (instance.CurrentState != MyPhoton.MyState.ROOM) { self.Failure(); } else { MyPhoton.MyPlayer myPlayer = instance.GetMyPlayer(); List <MyPhoton.MyPlayer> roomPlayerList = instance.GetRoomPlayerList(); using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator()) { while (enumerator.MoveNext()) { MyPhoton.MyPlayer current = enumerator.Current; JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(current.json); if (current.playerID < myPlayer.playerID && photonPlayerParam.playerIndex <= 0) { DebugUtility.Log("[PUN]waiting for player index turn..." + (object)current.playerID + " me:" + (object)myPlayer.playerID); return; } } } MyPhoton.MyRoom currentRoom = instance.GetCurrentRoom(); if (currentRoom.maxPlayers == 0) { Debug.LogError((object)("Invalid Room:" + currentRoom.name)); PhotonNetwork.room.IsOpen = false; self.Failure(); } else { bool[] flagArray = new bool[currentRoom.maxPlayers]; for (int index = 0; index < flagArray.Length; ++index) { flagArray[index] = false; } using (List <MyPhoton.MyPlayer> .Enumerator enumerator = roomPlayerList.GetEnumerator()) { while (enumerator.MoveNext()) { MyPhoton.MyPlayer current = enumerator.Current; JSON_MyPhotonPlayerParam photonPlayerParam = JSON_MyPhotonPlayerParam.Parse(current.json); if (current.playerID < myPlayer.playerID && photonPlayerParam.playerIndex > 0) { flagArray[photonPlayerParam.playerIndex - 1] = true; DebugUtility.Log("[PUN]player index " + (object)photonPlayerParam.playerIndex + " is used. (room:" + (object)currentRoom.maxPlayers + ")"); } } } for (int index = 0; index < currentRoom.maxPlayers; ++index) { if (!flagArray[index]) { int num = index + 1; DebugUtility.Log("[PUN]empty player index found: " + (object)num); if (instance.IsMultiVersus && num >= 3) { foreach (PhotonPlayer player in PhotonNetwork.playerList) { new MyPhoton.MyPlayer().playerID = player.ID; Hashtable customProperties = player.CustomProperties; if (customProperties != null && ((Dictionary <object, object>)customProperties).Count > 0 && ((Dictionary <object, object>)customProperties).ContainsKey((object)"json")) { string buffer; GameUtility.Binary2Object <string>(out buffer, (byte[])customProperties.get_Item((object)"json")); Debug.Log((object)("player json : " + buffer)); } } Debug.LogError((object)"MultiVersus is playerindex over : 3"); } self.mJoinPlayerParam.playerID = myPlayer.playerID; self.mJoinPlayerParam.playerIndex = num; self.mJoinPlayerParam.UpdateMultiTowerPlacement(true); instance.SetMyPlayerParam(self.mJoinPlayerParam.Serialize()); instance.MyPlayerIndex = num; self.Success(); break; } } } } }