public void RegisterChampionPlatforms(CurrentBattle currentBattle) { SmartEntity smartEntity = null; TroopTypeVO troopTypeVO = null; bool flag = false; NodeList <BuildingNode> nodeList = Service.EntityController.GetNodeList <BuildingNode>(); for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next) { flag = false; smartEntity = (SmartEntity)buildingNode.Entity; troopTypeVO = this.FindChampionTypeIfPlatform(smartEntity.BuildingComp.BuildingType); if (buildingNode.BuildingComp.BuildingType.Type == BuildingType.ChampionPlatform) { if (currentBattle.Type == BattleType.PveAttack || currentBattle.Type == BattleType.ClientBattle || currentBattle.Type == BattleType.PveBuffBase || currentBattle.Type == BattleType.PvpAttackSquadWar) { if (troopTypeVO != null && smartEntity != null) { this.AddDefensiveChampionToPlatfrom(smartEntity, troopTypeVO); } } else if (troopTypeVO != null && currentBattle.DisabledBuildings != null && !currentBattle.DisabledBuildings.Contains(buildingNode.BuildingComp.BuildingTO.Key)) { if (currentBattle.IsPvP()) { if (currentBattle.DefenderChampionsAvailable != null) { foreach (KeyValuePair <string, int> current in currentBattle.DefenderChampionsAvailable) { if (current.Key == troopTypeVO.Uid && current.Value > 0) { flag = true; } } } } else if (currentBattle.Type == BattleType.PveDefend && !ContractUtils.IsBuildingUpgrading(smartEntity) && !ContractUtils.IsChampionRepairing(smartEntity)) { Inventory inventory = Service.CurrentPlayer.Inventory; bool flag2 = inventory.Champion.HasItem(troopTypeVO.Uid) && inventory.Champion.GetItemAmount(troopTypeVO.Uid) > 0; if (flag2) { flag = true; } } if (flag) { this.AddDefensiveChampionToPlatfrom(smartEntity, troopTypeVO); } } } } }
public EatResponse OnEvent(EventId id, object cookie) { if (id <= EventId.EnterEditMode) { if (id <= EventId.TroopNotPlacedInvalidArea) { switch (id) { case EventId.BuildingPlacedOnBoard: case EventId.BuildingMovedOnBoard: case EventId.BuildingRemovedFromBoard: break; default: if (id != EventId.TroopNotPlacedInvalidArea) { return(EatResponse.NotEaten); } this.DisplaySpawnProtection(); return(EatResponse.NotEaten); } } else { switch (id) { case EventId.MapDataProcessingStart: if (!Service.Get <WorldTransitioner>().IsCurrentWorldHome()) { this.IgnoreBoardChanges(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); case EventId.MapDataProcessingEnd: return(EatResponse.NotEaten); case EventId.WorldLoadComplete: if (!Service.Get <WorldTransitioner>().IsCurrentWorldHome()) { this.Initialize(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); case EventId.WorldInTransitionComplete: { if (Service.Get <WorldTransitioner>().IsCurrentWorldHome() || Service.Get <BattleController>().GetCurrentBattle() == null) { return(EatResponse.NotEaten); } CurrentBattle currentBattle = Service.Get <BattleController>().GetCurrentBattle(); if (currentBattle.IsPvP() || currentBattle.Type == BattleType.PvpAttackSquadWar) { this.DisplaySpawnProtection(); return(EatResponse.NotEaten); } return(EatResponse.NotEaten); } default: if (id != EventId.EnterEditMode) { return(EatResponse.NotEaten); } this.ObserveBoardChanges(); this.Initialize(); this.DisplaySpawnProtection(); return(EatResponse.NotEaten); } } } else if (id <= EventId.MissionStarted) { if (id == EventId.ExitEditMode) { this.IgnoreBoardChanges(); return(EatResponse.NotEaten); } if (id != EventId.MissionStarted) { return(EatResponse.NotEaten); } this.DisplaySpawnProtection(); return(EatResponse.NotEaten); } else { if (id == EventId.UserLiftedBuilding) { this.CleanUp(); return(EatResponse.NotEaten); } if (id != EventId.ShieldBorderDestroyed && id != EventId.ShieldDisabled) { return(EatResponse.NotEaten); } } this.Initialize(); this.DisplaySpawnProtection(); return(EatResponse.NotEaten); }
public EatResponse OnEvent(EventId id, object cookie) { if (id == this.applyLightingOverrideEvent) { this.UnregisterOverrideEvent(this.applyLightingOverrideEvent); this.applyLightingOverrideEvent = EventId.Nop; this.LoadPlanetLightingData(this.overrideLightingDataAssetName); return(EatResponse.NotEaten); } if (id == this.removeLightingOverrideEvent) { this.UnregisterOverrideEvent(this.removeLightingOverrideEvent); this.removeLightingOverrideEvent = EventId.Nop; this.RemoveLightingDataOverride(); return(EatResponse.NotEaten); } if (id != EventId.WorldOutTransitionComplete) { if (id == EventId.GameStateChanged) { GameStateMachine gameStateMachine = Service.GameStateMachine; IState currentState = gameStateMachine.CurrentState; uint timeStamp = DateUtils.GetNowSeconds(); if (currentState is BattlePlaybackState) { BattleEntry currentBattleEntry = Service.BattlePlaybackController.CurrentBattleEntry; BattleRecord currentBattleRecord = Service.BattlePlaybackController.CurrentBattleRecord; if (currentBattleEntry != null && currentBattleRecord != null) { uint num = (uint)(currentBattleRecord.BattleLength - currentBattleRecord.BattleAttributes.TimeLeft); timeStamp = currentBattleEntry.EndBattleServerTime - num; } else { timeStamp = (uint)UnityEngine.Random.Range(0, 86400000); } this.CalculateInitialPlanetLightingData(timeStamp); } else if (currentState is HomeState) { this.UnlockAndRestoreTimeOfDay(); } else if (this.IsTimePausedInDayPhase()) { this.SetTimeOfDayColorToTheDayPhase(); } this.RefreshPlanetData(timeStamp); } } else { this.ClearLightingDataOverride(); CurrentBattle currentBattle = Service.BattleController.GetCurrentBattle(); if (currentBattle != null && !currentBattle.IsPvP() && !currentBattle.IsDefense()) { this.pauseTimeOfDayUpdate = true; this.SetTimeOfDayColorToTheDayPhase(); } } return(EatResponse.NotEaten); }
public void RegisterChampionPlatforms(CurrentBattle currentBattle) { SmartEntity smartEntity = null; TroopTypeVO troopTypeVO = null; bool flag = false; NodeList <BuildingNode> nodeList = Service.Get <EntityController>().GetNodeList <BuildingNode>(); for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next) { flag = false; smartEntity = (SmartEntity)buildingNode.Entity; troopTypeVO = this.FindChampionTypeIfPlatform(smartEntity.BuildingComp.BuildingType); if (buildingNode.BuildingComp.BuildingType.Type == BuildingType.ChampionPlatform) { if (currentBattle.Type == BattleType.PveAttack || currentBattle.Type == BattleType.ClientBattle || currentBattle.Type == BattleType.PveBuffBase || currentBattle.Type == BattleType.PvpAttackSquadWar) { if (troopTypeVO != null && smartEntity != null) { this.AddDefensiveChampionToPlatfrom(smartEntity, troopTypeVO); } } else if (troopTypeVO != null && currentBattle.DisabledBuildings != null && !currentBattle.DisabledBuildings.Contains(buildingNode.BuildingComp.BuildingTO.Key)) { if (!currentBattle.IsPvP()) { goto IL_129; } if (currentBattle.DefenderChampionsAvailable != null) { using (Dictionary <string, int> .Enumerator enumerator = currentBattle.DefenderChampionsAvailable.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <string, int> current = enumerator.Current; if (current.get_Key() == troopTypeVO.Uid && current.get_Value() > 0) { flag = true; } } goto IL_182; } goto IL_129; } IL_182: if (flag) { this.AddDefensiveChampionToPlatfrom(smartEntity, troopTypeVO); goto IL_18D; } goto IL_18D; IL_129: if (currentBattle.Type != BattleType.PveDefend || ContractUtils.IsBuildingUpgrading(smartEntity) || ContractUtils.IsChampionRepairing(smartEntity)) { goto IL_182; } Inventory inventory = Service.Get <CurrentPlayer>().Inventory; bool flag2 = inventory.Champion.HasItem(troopTypeVO.Uid) && inventory.Champion.GetItemAmount(troopTypeVO.Uid) > 0; if (flag2) { flag = true; goto IL_182; } goto IL_182; } } IL_18D :; } }