private static void UpdateFakeSelectHero(int seq) { int num = 0; for (int i = 0; i < CFakePvPHelper.FakeHeroSelectList.get_Count(); i++) { CFakePvPHelper.FakeHeroSelect fakeHeroSelect = CFakePvPHelper.FakeHeroSelectList.get_Item(i); if (fakeHeroSelect.bConfirmed) { num++; } else if (fakeHeroSelect.idleSec == fakeHeroSelect.nextActionSec) { CFakePvPHelper.DoSelectAction(ref fakeHeroSelect); fakeHeroSelect.idleSec = 0; fakeHeroSelect.nextActionSec = Random.Range(3, 6); } else { fakeHeroSelect.idleSec++; } } if (num == CFakePvPHelper.FakeHeroSelectList.get_Count()) { Singleton <CTimerManager> .GetInstance().RemoveTimer(new CTimer.OnTimeUpHandler(CFakePvPHelper.UpdateFakeSelectHero)); } }
private static CFakePvPHelper.FakeHeroSelect GetFakeHeroSelect(ulong playerUid) { CFakePvPHelper.FakeHeroSelect result = null; for (int i = 0; i < CFakePvPHelper.FakeHeroSelectList.get_Count(); i++) { if (CFakePvPHelper.FakeHeroSelectList.get_Item(i).FakePlayer.ullUid == playerUid) { result = CFakePvPHelper.FakeHeroSelectList.get_Item(i); break; } } return(result); }
public static void BeginFakeSelectHero() { CFakePvPHelper.HeroConfirmedPlayerNum = 0; CFakePvPHelper.FakeHeroSelectList.Clear(); CFakePvPHelper.ChosenHeroes.Clear(); CFakePvPHelper.EnemyChosenHeroes.Clear(); RoomInfo roomInfo = Singleton <CRoomSystem> .GetInstance().roomInfo; DebugHelper.Assert(roomInfo != null); DebugHelper.Assert(roomInfo.roomAttrib.bWarmBattle); COM_PLAYERCAMP selfCamp = roomInfo.GetSelfCamp(); ListView <MemberInfo> listView = roomInfo[selfCamp]; for (int i = 0; i < listView.get_Count(); i++) { MemberInfo memberInfo = listView.get_Item(i); if (memberInfo.RoomMemberType == 2u) { CFakePvPHelper.FakeHeroSelect fakeHeroSelect = new CFakePvPHelper.FakeHeroSelect(); fakeHeroSelect.FakePlayer = memberInfo.WarmNpc; if (Singleton <CHeroSelectBaseSystem> .get_instance().selectType == enSelectType.enRandom) { fakeHeroSelect.maxChangeHeroCount = Random.Range(0, 2); CFakePvPHelper.DoSelectAction(ref fakeHeroSelect); } else { fakeHeroSelect.maxChangeHeroCount = Random.Range(1, 4); } fakeHeroSelect.nextActionSec = Random.Range(3, 6); CFakePvPHelper.FakeHeroSelectList.Add(fakeHeroSelect); } } if (CFakePvPHelper.FakeHeroSelectList.get_Count() > 0) { Singleton <CTimerManager> .GetInstance().AddTimer(1000, 60, new CTimer.OnTimeUpHandler(CFakePvPHelper.UpdateFakeSelectHero)); CFakePvPHelper.bInFakeSelect = true; } Singleton <CTimerManager> .GetInstance().AddTimer(60000, 1, new CTimer.OnTimeUpHandler(CFakePvPHelper.OnSelectHeroTimeout)); }
private static void ReqStartSingleWarmBattle() { CFakePvPHelper.bInFakeSelect = false; Singleton <CTimerManager> .GetInstance().RemoveTimer(new CTimer.OnTimeUpHandler(CFakePvPHelper.OnSelectHeroTimeout)); CFakePvPHelper.RemoveAllFakeTimer(); CSPkg cSPkg = NetworkModule.CreateDefaultCSPKG(1050u); RoomInfo roomInfo = Singleton <CRoomSystem> .GetInstance().roomInfo; if (roomInfo == null) { DebugHelper.Assert(roomInfo != null, "RoomInfo Should not be NULL!!!"); return; } if (roomInfo != null) { cSPkg.stPkgData.get_stStartSingleGameReq().stBattleParam.bGameType = 1; cSPkg.stPkgData.get_stStartSingleGameReq().stBattleParam.stGameDetail.set_stGameOfCombat(Singleton <CHeroSelectBaseSystem> .get_instance().m_stGameOfCombat); cSPkg.stPkgData.get_stStartSingleGameReq().stBattleList.stBattleList.wHeroCnt = 1; if (cSPkg.stPkgData.get_stStartSingleGameReq().stBattleParam.stGameDetail.get_stGameOfCombat() == null) { return; } MemberInfo masterMemberInfo = roomInfo.GetMasterMemberInfo(); if (masterMemberInfo == null) { DebugHelper.Assert(roomInfo != null, "selfInfo Should not be NULL!!!"); return; } cSPkg.stPkgData.get_stStartSingleGameReq().stBattleList.stBattleList.BattleHeroList[0] = masterMemberInfo.ChoiceHero[0].stBaseInfo.stCommonInfo.dwHeroID; ResDT_LevelCommonInfo pvpMapCommonInfo = CLevelCfgLogicManager.GetPvpMapCommonInfo(roomInfo.roomAttrib.bMapType, roomInfo.roomAttrib.dwMapId); if (pvpMapCommonInfo != null) { COM_PLAYERCAMP cOM_PLAYERCAMP = 1; int dwHeroID = 0; for (COM_PLAYERCAMP cOM_PLAYERCAMP2 = 1; cOM_PLAYERCAMP2 < 3; cOM_PLAYERCAMP2++) { ListView <MemberInfo> listView = roomInfo[cOM_PLAYERCAMP2]; for (int i = 0; i < listView.get_Count(); i++) { if (listView.get_Item(i).ullUid == roomInfo.selfInfo.ullUid) { cOM_PLAYERCAMP = listView.get_Item(i).camp; dwHeroID = (int)listView.get_Item(i).ChoiceHero[0].stBaseInfo.stCommonInfo.dwHeroID; break; } } } CSDT_BATTLE_PLAYER_BRIEF stBattlePlayer = cSPkg.stPkgData.get_stStartSingleGameReq().stBattlePlayer; int num = 0; for (COM_PLAYERCAMP cOM_PLAYERCAMP3 = 1; cOM_PLAYERCAMP3 < 3; cOM_PLAYERCAMP3++) { ListView <MemberInfo> listView2 = roomInfo[cOM_PLAYERCAMP3]; for (int j = 0; j < listView2.get_Count(); j++) { MemberInfo memberInfo = listView2.get_Item(j); if (memberInfo != null) { if (memberInfo.RoomMemberType == 2u) { stBattlePlayer.astFighter[num].bObjType = 2; stBattlePlayer.astFighter[num].bPosOfCamp = (byte)j; stBattlePlayer.astFighter[num].bObjCamp = cOM_PLAYERCAMP3; stBattlePlayer.astFighter[num].dwLevel = memberInfo.dwMemberPvpLevel; CFakePvPHelper.FakeHeroSelect fakeHeroSelect = CFakePvPHelper.GetFakeHeroSelect(memberInfo.ullUid); if (fakeHeroSelect != null) { stBattlePlayer.astFighter[num].astChoiceHero[0].stBaseInfo.stCommonInfo.dwHeroID = fakeHeroSelect.selectedHero; stBattlePlayer.astFighter[num].astChoiceHero[0].stBaseInfo.stCommonInfo.stSkill.dwSelSkillID = fakeHeroSelect.selectedPlayerSkill; stBattlePlayer.astFighter[num].astChoiceHero[0].stBaseInfo.stCommonInfo.wSkinID = (ushort)fakeHeroSelect.selectedSkin; stBattlePlayer.astFighter[num].szName = fakeHeroSelect.FakePlayer.szUserName; stBattlePlayer.astFighter[num].stDetail.set_stPlayerOfNpc(new COMDT_PLAYERINFO_OF_NPC()); stBattlePlayer.astFighter[num].stDetail.get_stPlayerOfNpc().ullFakeUid = fakeHeroSelect.FakePlayer.ullUid; stBattlePlayer.astFighter[num].stDetail.get_stPlayerOfNpc().dwFakePvpLevel = fakeHeroSelect.FakePlayer.dwAcntPvpLevel; stBattlePlayer.astFighter[num].stDetail.get_stPlayerOfNpc().dwFakeLogicWorldID = fakeHeroSelect.FakePlayer.dwLogicWorldId; } else { CFakePvPHelper.SelectHeroForEnemyPlayer(ref stBattlePlayer.astFighter[num].astChoiceHero[0].stBaseInfo, stBattlePlayer.astFighter[num].dwLevel); stBattlePlayer.astFighter[num].szName = memberInfo.WarmNpc.szUserName; stBattlePlayer.astFighter[num].stDetail.set_stPlayerOfNpc(new COMDT_PLAYERINFO_OF_NPC()); stBattlePlayer.astFighter[num].stDetail.get_stPlayerOfNpc().ullFakeUid = memberInfo.WarmNpc.ullUid; stBattlePlayer.astFighter[num].stDetail.get_stPlayerOfNpc().dwFakePvpLevel = memberInfo.WarmNpc.dwAcntPvpLevel; stBattlePlayer.astFighter[num].stDetail.get_stPlayerOfNpc().dwFakeLogicWorldID = memberInfo.WarmNpc.dwLogicWorldId; } } else if (memberInfo.RoomMemberType == 1u) { stBattlePlayer.astFighter[num].bObjType = 1; stBattlePlayer.astFighter[num].bPosOfCamp = (byte)j; stBattlePlayer.astFighter[num].bObjCamp = cOM_PLAYERCAMP; for (int k = 0; k < (int)pvpMapCommonInfo.bHeroNum; k++) { stBattlePlayer.astFighter[num].astChoiceHero[k].stBaseInfo.stCommonInfo.dwHeroID = (uint)dwHeroID; } } num++; } } } stBattlePlayer.bNum = (byte)num; roomInfo.roomAttrib.bWarmBattle = false; roomInfo.roomAttrib.npcAILevel = 2; Singleton <NetworkModule> .GetInstance().SendLobbyMsg(ref cSPkg, true); Singleton <WatchController> .GetInstance().Stop(); } } }
private static void DoSelectAction(ref CFakePvPHelper.FakeHeroSelect fakeSelect) { if (!CFakePvPHelper.IsInSelectHero()) { return; } if (fakeSelect.changeHeroCount < fakeSelect.maxChangeHeroCount) { uint num2; if (fakeSelect.FakePlayer.dwAcntPvpLevel <= 6u) { int num = Random.Range(0, GameDataMgr.robotRookieHeroSkinDatabin.Count()); ResFakeAcntHero dataByIndex = GameDataMgr.robotRookieHeroSkinDatabin.GetDataByIndex(num); if (dataByIndex == null) { return; } num2 = dataByIndex.dwHeroID; while (CFakePvPHelper.ChosenHeroes.ContainsValue(dataByIndex.dwHeroID)) { num = Random.Range(0, GameDataMgr.robotRookieHeroSkinDatabin.Count()); dataByIndex = GameDataMgr.robotRookieHeroSkinDatabin.GetDataByIndex(num); if (dataByIndex == null) { return; } num2 = dataByIndex.dwHeroID; } } else { CRoleInfo masterRoleInfo = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo(); int num3 = GameDataMgr.robotVeteranHeroSkinDatabin.Count(); int max = num3 + ((masterRoleInfo == null) ? 0 : masterRoleInfo.freeHeroList.get_Count()); int num = Random.Range(0, max); if (num < num3) { ResFakeAcntHero dataByIndex = GameDataMgr.robotVeteranHeroSkinDatabin.GetDataByIndex(num); if (dataByIndex == null) { return; } num2 = dataByIndex.dwHeroID; } else { num2 = masterRoleInfo.freeHeroList.get_Item(num - num3).dwFreeHeroID; } while (CFakePvPHelper.ChosenHeroes.ContainsValue(num2)) { num = Random.Range(0, max); if (num < num3) { ResFakeAcntHero dataByIndex = GameDataMgr.robotVeteranHeroSkinDatabin.GetDataByIndex(num); if (dataByIndex == null) { return; } num2 = dataByIndex.dwHeroID; } else { num2 = masterRoleInfo.freeHeroList.get_Item(num - num3).dwFreeHeroID; } } } CFakePvPHelper.ChosenHeroes.set_Item(fakeSelect.FakePlayer.ullUid, num2); fakeSelect.selectedHero = num2; fakeSelect.changeHeroCount++; RoomInfo roomInfo = Singleton <CHeroSelectBaseSystem> .get_instance().roomInfo; if (roomInfo == null) { return; } MemberInfo memberInfo = roomInfo.GetMemberInfo(fakeSelect.FakePlayer.ullUid); if (memberInfo != null && memberInfo.ChoiceHero[0] != null) { memberInfo.ChoiceHero[0].stBaseInfo.stCommonInfo.dwHeroID = num2; Singleton <CHeroSelectNormalSystem> .GetInstance().RefreshHeroPanel(false, true); } } else { if (fakeSelect.FakePlayer.dwAcntPvpLevel <= 6u) { ResFakeAcntHero dataByKey = GameDataMgr.robotRookieHeroSkinDatabin.GetDataByKey(fakeSelect.selectedHero); if (dataByKey != null && dataByKey.dwSkinID != 0u) { int num4 = Random.Range(0, 10000); if ((long)num4 < (long)((ulong)dataByKey.dwSkinRate)) { fakeSelect.selectedSkin = (int)dataByKey.dwSkinID; } } } else { ResFakeAcntHero dataByKey2 = GameDataMgr.robotVeteranHeroSkinDatabin.GetDataByKey(fakeSelect.selectedHero); if (dataByKey2 != null && dataByKey2.dwSkinID != 0u) { int num5 = Random.Range(0, 10000); if ((long)num5 < (long)((ulong)dataByKey2.dwSkinRate)) { fakeSelect.selectedSkin = (int)dataByKey2.dwSkinID; } } } ResFakeAcntSkill dataByKey3 = GameDataMgr.robotPlayerSkillDatabin.GetDataByKey(fakeSelect.FakePlayer.dwAcntPvpLevel); if (dataByKey3 != null) { int num6 = Random.Range(0, dataByKey3.SkillId.Length); while (dataByKey3.SkillId[num6] == 0u) { num6 = Random.Range(0, dataByKey3.SkillId.Length); } uint selectedPlayerSkill = dataByKey3.SkillId[num6]; fakeSelect.selectedPlayerSkill = selectedPlayerSkill; } fakeSelect.bConfirmed = true; CFakePvPHelper.HeroConfirmedPlayerNum++; RoomInfo roomInfo2 = Singleton <CRoomSystem> .GetInstance().roomInfo; MemberInfo memberInfo2 = roomInfo2.GetMemberInfo(fakeSelect.FakePlayer.ullUid); if (memberInfo2 != null && memberInfo2.ChoiceHero[0] != null) { memberInfo2.ChoiceHero[0].stBaseInfo.stCommonInfo.stSkill.dwSelSkillID = fakeSelect.selectedPlayerSkill; memberInfo2.isPrepare = true; Singleton <CHeroSelectNormalSystem> .GetInstance().RefreshHeroPanel(false, true); } if (CFakePvPHelper.HeroConfirmedPlayerNum == CFakePvPHelper.FakeHeroSelectList.get_Count() + 1) { CFakePvPHelper.ReqStartSingleWarmBattle(); } } }