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"); } }
public void Awake() { parent = GetParent <BenchmarkClientComponent>(); timerComponent = Game.Scene.GetComponent <TimerComponent>(); session = parent.session; benchmarkComponent = Game.Scene.GetComponent <BenchmarkComponent>(); mapUnitBotModule = parent.GetComponent <MapUnitBotModule>(); state = State.CreateOrEnterRoom; //_nowSpeed = random.Next(5, 30); _nowSpeed = 1; //while (!IsDisposed) //{ // await timerComponent.WaitForSecondAsync(5); // Console.WriteLine($"Name:{parent.userName}, State:{state}"); //} }
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}"); } }
public async void Awake() { parent = GetParent <BenchmarkClientComponent>(); timerComponent = Game.Scene.GetComponent <TimerComponent>(); session = parent.session; mapUnitBotModule = parent.GetComponent <MapUnitBotModule>(); L2C_RoamingGetList l2C_RoamingGetList = await RoamingUtility.GetMapList(session); if (l2C_RoamingGetList.Error != ErrorCode.ERR_Success) { Console.WriteLine($"To get roaming road list Failed"); return; } var info = l2C_RoamingGetList.Infos.FirstOrDefault(e => e.RoadSettingId == parent.roadSettingId); long roomId = info != null ? info.RoomId : 0L; L2C_RoamingEnter l2C_RoamingEnter = await RoamingUtility.EnterRoamingRoom(session, roomId); if (l2C_RoamingEnter.Error != ErrorCode.ERR_Success) { Console.WriteLine($"To enter roaming room[{roomId}] Failed. Error:{l2C_RoamingEnter.Error}"); return; } //記錄自身MapUnitId mapUnitId = l2C_RoamingEnter.SelfInfo.MapUnitId; //記錄自身MapUnitInfo mapUnitBotModule.mapUnitInfos.TryAdd(mapUnitId, new MapUnitBotModule.MapUnitData { mapUnitInfo = l2C_RoamingEnter.SelfInfo, m2C_MapUnitUpdate = null, }); _nowSpeed = random.Next(5, 30); mapUnitBotModule.EnableGame(true); }
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"); } }