public static async void Awake(this BenchmarkClientComponent self, BenchmarkClientComponent.ClientSetting clientSetting) { try { self.networkComponent = clientSetting.networkComponent; self.ipEndPoint = clientSetting.ipEndPoint; self.testPlayerSetting = clientSetting.testPlayerSetting; self.stateMachine = new StateMachine <BenchmarkClientComponent>(); self.robotMode = clientSetting.robotMode; self.roadSettingId = clientSetting.roadSettingId; self.IsFromPool = false; //self.InitializeStateMachine(); /****************/ await self.SignIn(self.testPlayerSetting.DeviceUniqueIdentifier); //設定玩家資料 TestPlayerDataComponent playerDataComponent = self.session.AddComponent <TestPlayerDataComponent>(); playerDataComponent.testPlayerSetting = clientSetting.testPlayerSetting; self.Init(); } catch (Exception e) { Console.WriteLine($"Msg:{e.Message}, Stack:{e.StackTrace}"); } }
protected override void Run(Session session, M2C_MapUnitCreateAndDestroy message) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { MapUnitBotModule roamingBotModule = client.GetComponent <MapUnitBotModule>(); if (!roamingBotModule.isEnableToStartGame) { roamingBotModule._m2cCache.Enqueue(message); } else { for (int i = 0; i < message.DestroyMapUnitIds.Count; i++) { roamingBotModule.SyncM2C_MapUnitDestroy(message.DestroyMapUnitIds[i]); } for (int i = 0; i < message.CreateMapUnitInfos.Count; i++) { roamingBotModule.SyncM2C_MapUnitCreate(message.CreateMapUnitInfos[i]); } } //client.UserLog($"M2C_MapUnitCreateAndDestroyHandler"); } }
protected override void Run(Session session, M2C_TeamGoBattleProgressReceiver message) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { //client.UserLog($"M2C_TeamGoBattleProgressReceiverHandler"); } }
protected override void Run(Session session, M2C_TeamGoBattleProgressAllDone message) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { PartyBotModule partyBotModule = client.GetComponent <PartyBotModule>(); partyBotModule.state = State.Battle; if (partyBotModule.isLeader) { benchmarkComponent.groupToRoomMap.Remove(client.index / 8); } //client.UserLog($"M2C_TeamGoBattleProgressAllDoneHandler"); } }
protected override void Run(Session session, M2C_TeamModifyMember message) { try { _Run(session, message); } catch (Exception e) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { client.UserLog($"Msg:{e.Message}, Stack:{e.StackTrace}"); } } }
protected void _Run(Session session, M2C_TeamModifyMember message) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { PartyBotModule partyBotModule = client.GetComponent <PartyBotModule>(); if (partyBotModule.teams.TryGetValue(partyBotModule.roomId, out var team)) { bool isAdd = true; for (int i = 0; i < team.teamMemberDataList.Count; i++) { if (team.teamMemberDataList[i].Uid == message.Uid) { if (message.MemberData == null) { //刪除 isAdd = false; team.teamMemberDataList.RemoveAt(i); team.Info.NowMemberCount--; //client.UserLog($"RoomId:{partyBotModule.roomId}, NowMemberCount:{team.Info.NowMemberCount}"); } else { //更新 isAdd = false; team.teamMemberDataList[i] = message.MemberData; } break; } } if (isAdd) { team.teamMemberDataList.Add(message.MemberData); team.Info.NowMemberCount++; //client.UserLog($"RoomId:{partyBotModule.roomId}, NowMemberCount:{team.Info.NowMemberCount}"); } } //client.UserLog($"M2C_TeamModifyMemberHandler"); } }
protected override void Run(Session session, M2C_MapUnitUpdate message) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { MapUnitBotModule roamingBotModule = client.GetComponent <MapUnitBotModule>(); if (!roamingBotModule.isEnableToStartGame) { roamingBotModule._m2cCache.Enqueue(message); } else { roamingBotModule.SyncM2C_MapUnitUpdate(message); } //client.UserLog($"M2C_MapUnitUpdateHandler, DistanceTravelled: {roamingBotModule.DistanceTravelled}"); } }
protected override void Run(Session session, M2C_TeamReadyModify message) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { PartyBotModule partyBotModule = client.GetComponent <PartyBotModule>(); if (partyBotModule.teams.TryGetValue(partyBotModule.roomId, out var team)) { for (int i = 0; i < team.teamMemberDataList.Count; i++) { if (team.teamMemberDataList[i].Uid == message.Uid) { team.teamMemberDataList[i].IsReady = message.IsReady; break; } } } //client.UserLog($"M2C_TeamReadyModifyHandler"); } }
protected override void Run(Session session, M2C_TeamGoBattle message) { TestPlayerDataComponent testPlayerDataComponent = session.GetComponent <TestPlayerDataComponent>(); BenchmarkComponent benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); if (benchmarkComponent.clients.TryGetValue(testPlayerDataComponent.testPlayerSetting.DeviceUniqueIdentifier, out var client)) { PartyBotModule partyBotModule = client.GetComponent <PartyBotModule>(); MapUnitBotModule mapUnitBotModule = client.GetComponent <MapUnitBotModule>(); mapUnitBotModule.mapUnitId = message.MapUnitId; for (int i = 0; i < message.MapUnitInfos.Count; i++) { var info = message.MapUnitInfos[i]; mapUnitBotModule.mapUnitInfos.TryAdd(info.MapUnitId, new MapUnitBotModule.MapUnitData { mapUnitInfo = info, }); } partyBotModule.state = State.GoBattle; partyBotModule._inputAsyncTimePre = partyBotModule.timerComponent.time; //client.UserLog($"M2C_TeamGoBattleHandler"); } }