/// <summary> /// Initializes this instance. /// </summary> public static void Initialize() { LogicDataTables._dataTables = new LogicDataTable[44]; LogicDataTables.Load("logic/buildings.csv", 0); LogicDataTables.Load("logic/locales.csv", 1); LogicDataTables.Load("logic/resources.csv", 2); LogicDataTables.Load("logic/characters.csv", 3); // LogicDataTables.Load("csv/animations.csv", 4); LogicDataTables.Load("logic/projectiles.csv", 5); LogicDataTables.Load("logic/building_classes.csv", 6); LogicDataTables.Load("logic/obstacles.csv", 7); LogicDataTables.Load("logic/effects.csv", 8); LogicDataTables.Load("csv/particle_emitters.csv", 9); LogicDataTables.Load("logic/experience_levels.csv", 10); LogicDataTables.Load("logic/traps.csv", 11); LogicDataTables.Load("logic/alliance_badges.csv", 12); LogicDataTables.Load("logic/globals.csv", 13); LogicDataTables.Load("logic/townhall_levels.csv", 14); LogicDataTables.Load("logic/alliance_portal.csv", 15); LogicDataTables.Load("logic/npcs.csv", 16); LogicDataTables.Load("logic/decos.csv", 17); LogicDataTables.Load("csv/resource_packs.csv", 18); LogicDataTables.Load("logic/shields.csv", 19); LogicDataTables.Load("logic/missions.csv", 20); LogicDataTables.Load("csv/billing_packages.csv", 21); LogicDataTables.Load("logic/achievements.csv", 22); // LogicDataTables.Load("csv/credits.csv", 23); // LogicDataTables.Load("csv/faq.csv", 24); LogicDataTables.Load("logic/spells.csv", 25); LogicDataTables.Load("csv/hints.csv", 26); LogicDataTables.Load("logic/heroes.csv", 27); LogicDataTables.Load("logic/leagues.csv", 28); LogicDataTables.Load("csv/news.csv", 29); LogicDataTables.Load("logic/war.csv", 30); LogicDataTables.Load("logic/regions.csv", 31); LogicDataTables.Load("csv/client_globals.csv", 32); LogicDataTables.Load("logic/alliance_badge_layers.csv", 33); LogicDataTables.Load("logic/alliance_levels.csv", 34); // LogicDataTables.Load("csv/helpshift.csv", 35); LogicDataTables.Load("logic/variables.csv", 36); LogicDataTables.Load("logic/gem_bundles.csv", 37); LogicDataTables.Load("logic/village_objects.csv", 38); LogicDataTables.Load("logic/calendar_event_functions.csv", 39); LogicDataTables.Load("csv/boombox.csv", 40); LogicDataTables.Load("csv/event_entries.csv", 41); LogicDataTables.Load("csv/deeplinks.csv", 42); LogicDataTables.Load("logic/leagues2.csv", 43); LogicDataTables._globals = new LogicGlobals(); LogicDataTables._clientGlobals = new LogicClientGlobals(); for (int i = 0; i < LogicDataTables._dataTables.Length; i++) { if (LogicDataTables._dataTables[i] != null) { LogicDataTables._dataTables[i].CreateReferences(); } } LogicDataTable buildingDataTable = LogicDataTables._dataTables[0]; for (int i = 0; i < buildingDataTable.GetItemCount(); i++) { LogicBuildingData buildingData = (LogicBuildingData)buildingDataTable.GetItemAt(i); if (buildingData.IsAllianceCastle()) { LogicDataTables._allianceCastleData = buildingData; } if (buildingData.IsTownHall() && LogicDataTables._townHallData == null) { LogicDataTables._townHallData = buildingData; } if (buildingData.IsTownHallVillage2() && LogicDataTables._townHallVillage2Data == null) { LogicDataTables._townHallVillage2Data = buildingData; } } LogicDataTables._bowData = LogicDataTables.GetBuildingByName("Bow"); LogicDataTables._darkTowerData = LogicDataTables.GetBuildingByName("Dark Tower"); LogicDataTables._ancientArtilleryData = LogicDataTables.GetBuildingByName("Ancient Artillery"); LogicDataTables._workerData = LogicDataTables.GetBuildingByName("Worker Building"); LogicDataTables._laboratoryVillage2Data = LogicDataTables.GetBuildingByName("Laboratory2"); LogicDataTables._diamondsData = LogicDataTables.GetResourceByName("Diamonds"); LogicDataTables._goldData = LogicDataTables.GetResourceByName("Gold"); LogicDataTables._elixirData = LogicDataTables.GetResourceByName("Elixir"); LogicDataTables._darkElixirData = LogicDataTables.GetResourceByName("DarkElixir"); LogicDataTables._gold2Data = LogicDataTables.GetResourceByName("Gold2"); LogicDataTables._elixir2Data = LogicDataTables.GetResourceByName("Elixir2"); LogicDataTables._warGoldData = LogicDataTables.GetResourceByName("WarGold"); LogicDataTables._warElixirData = LogicDataTables.GetResourceByName("WarElixir"); LogicDataTables._warDarkElixirData = LogicDataTables.GetResourceByName("WarDarkElixir"); LogicDataTables._skeletonData = LogicDataTables.GetCharacterByName("Skeleton"); LogicDataTables._ballonSkeletonData = LogicDataTables.GetCharacterByName("Balloon Skeleton"); LogicDataTables._globals.CreateReferences(); LogicDataTables._clientGlobals.CreateReferences(); }
/// <summary> /// Called when all instances has been loaded for initialized members in instance. /// </summary> public override void CreateReferences() { this._buildingCaps = new LogicArrayList <int>(); this._buildingGearupCaps = new LogicArrayList <int>(); this._trapCaps = new LogicArrayList <int>(); this._treasuryCaps = new LogicArrayList <int>(); LogicTownhallLevelData previousItem = null; if (this.GetInstanceID() > 0) { previousItem = (LogicTownhallLevelData)this._table.GetItemAt(this.GetInstanceID() - 1); } LogicDataTable buildingTable = LogicDataTables.GetTable(0); for (int i = 0; i < buildingTable.GetItemCount(); i++) { LogicData item = buildingTable.GetItemAt(i); int cap = this.GetIntegerValue(item.GetName(), 0); int gearup = this.GetIntegerValue(item.GetName() + "_gearup", 0); if (previousItem != null) { if (cap == 0) { cap = previousItem._buildingCaps[i]; } if (gearup == 0) { gearup = previousItem._buildingGearupCaps[i]; } } this._buildingCaps.Add(cap); this._buildingGearupCaps.Add(gearup); } LogicDataTable trapTable = LogicDataTables.GetTable(11); for (int i = 0; i < trapTable.GetItemCount(); i++) { int cap = this.GetIntegerValue(trapTable.GetItemAt(i).GetName(), 0); if (previousItem != null) { if (cap == 0) { cap = previousItem._trapCaps[i]; } } this._trapCaps.Add(cap); } LogicDataTable resourceTable = LogicDataTables.GetTable(2); for (int i = 0; i < resourceTable.GetItemCount(); i++) { this._treasuryCaps.Add(this.GetIntegerValue("Treasury" + resourceTable.GetItemAt(i).GetName(), 0)); } if (this.DarkElixirStorageLootPercentage > 100 || this.DarkElixirStorageLootPercentage < 0 || this.ResourceStorageLootPercentage > 100 || this.ResourceStorageLootPercentage < 0) { Debugger.Error("townhall_levels.csv: Invalid loot percentage!"); } }
/// <summary> /// Called when all instances has been loaded for initialized members in instance. /// </summary> public override void CreateReferences() { base.CreateVillageReferences(); this._upgradeLevelCount = this._row.GetBiggestArraySize(); this._buildingClass = LogicDataTables.GetBuildingClassByName(this.BuildingClass); if (this._buildingClass == null) { Debugger.Error("Building class is not defined for " + this.GetName()); } int longestArraySize = this._row.GetBiggestArraySize(); this._buildResourceData = new LogicResourceData[longestArraySize]; this._altBuildResourceData = new LogicResourceData[longestArraySize]; this._storedResourceCounts = new LogicArrayList <int> [longestArraySize]; this._percentageStoredResourceCounts = new LogicArrayList <int> [longestArraySize]; this._townHallLevel = new int[longestArraySize]; this._townHallVillage2Level = new int[longestArraySize]; this._constructionTimes = new int[longestArraySize]; this._gearUpTime = new int[longestArraySize]; this._gearUpCost = new int[longestArraySize]; this._boostCost = new int[longestArraySize]; for (int i = 0; i < longestArraySize; i++) { this._gearUpCost[i] = this.GetClampedIntegerValue("GearUpCost", i); this._gearUpTime[i] = this.GetClampedIntegerValue("GearUpTime", i); this._boostCost[i] = this.GetClampedIntegerValue("BoostCost", i); this._buildResourceData[i] = LogicDataTables.GetResourceByName(this.GetClampedValue("BuildResource", i)); this._altBuildResourceData[i] = LogicDataTables.GetResourceByName(this.GetClampedValue("AltBuildResource", i)); this._townHallLevel[i] = LogicMath.Max(this.GetClampedIntegerValue("TownHallLevel", i) - 1, 0); this._townHallVillage2Level[i] = LogicMath.Max(this.GetClampedIntegerValue("TownHallLevel2", i) - 1, 0); this._storedResourceCounts[i] = new LogicArrayList <int>(); this._percentageStoredResourceCounts[i] = new LogicArrayList <int>(); LogicDataTable table = LogicDataTables.GetTable(2); for (int j = 0; j < table.GetItemCount(); j++) { this._storedResourceCounts[i].Add(this.GetIntegerValue("MaxStored" + table.GetItemAt(j).GetName(), i)); this._percentageStoredResourceCounts[i].Add(this.GetIntegerValue("PercentageStored" + table.GetItemAt(j).GetName(), i)); } this._constructionTimes[i] = 86400 * this.GetIntegerValue("BuildTimeD", i) + 3600 * this.GetIntegerValue("BuildTimeH", i) + 60 * this.GetIntegerValue("BuildTimeM", i) + this.GetIntegerValue("BuildTimeS", i); } this._produceResourceData = LogicDataTables.GetResourceByName(this.GetValue("ProducesResource", 0)); this._gearUpResourceData = LogicDataTables.GetResourceByName(this.GetClampedValue("GearUpResource", 0)); string heroType = this.GetValue("HeroType", 0); if (!string.IsNullOrEmpty(heroType)) { this._heroData = LogicDataTables.GetHeroByName(heroType); } string wallBlockX = this.GetValue("WallBlockX", 0); if (wallBlockX.Length > 0) { this.LoadWallBlock(wallBlockX, out this._wallBlockX); this.LoadWallBlock(this.GetValue("WallBlockY", 0), out this._wallBlockY); } this._isClockTower = this.GetName().Equals("Clock Tower"); this._isFlamer = this.GetName().Equals("Flamer"); this._isBarrackVillage2 = this.GetName().Equals("Barrack2"); }
/// <summary> /// Called when all instances has been loaded for initialized members in instance. /// </summary> public override void CreateReferences() { this._villageType = this.GetIntegerValue("UIGroup", 0); this._diamondReward = this.GetIntegerValue("DiamondReward", 0); this._expReward = this.GetIntegerValue("ExpReward", 0); this._actionCount = this.GetIntegerValue("ActionCount", 0); this._level = this.GetIntegerValue("Level", 0); this._levelCount = this.GetIntegerValue("LevelCount", 0); this._completedTID = this.GetValue("CompetedTID", 0); this._showValue = this.GetBooleanValue("ShowValue", 0); this._androidId = this.GetValue("AndroidID", 0); if (this._actionCount == 0) { Debugger.Error("Achievement has invalid ActionCount 0"); } string action = this.GetValue("Action", 0); switch (action) { case "npc_stars": this._actionType = 0; break; case "upgrade": this._actionType = 1; this._buildingData = LogicDataTables.GetBuildingByName(this.GetValue("ActionData", 0)); if (this._buildingData == null) { Debugger.Error("LogicAchievementData - Building data is NULL for upgrade achievement"); } break; case "victory_points": this._actionType = 2; break; case "unit_unlock": this._actionType = 3; this._characterData = LogicDataTables.GetCharacterByName(this.GetValue("ActionData", 0)); if (this._characterData == null) { Debugger.Error("LogicCharacterData - Character data is NULL for unit_unlock achievement"); } break; case "clear_obstacles": this._actionType = 4; break; case "donate_units": this._actionType = 5; break; case "loot": this._actionType = 6; this._resourceData = LogicDataTables.GetResourceByName(this.GetValue("ActionData", 0)); if (this._resourceData == null) { Debugger.Error("LogicAchievementData - Resource data is NULL for loot achievement"); } break; case "destroy": this._actionType = 9; this._buildingData = LogicDataTables.GetBuildingByName(this.GetValue("ActionData", 0)); if (this._buildingData == null) { Debugger.Error("LogicAchievementData - Building data is NULL for destroy achievement"); } break; case "win_pvp_attack": this._actionType = 10; break; case "win_pvp_defense": this._actionType = 11; break; case "league": this._actionType = 12; break; case "war_stars": this._actionType = 13; break; case "war_loot": this._actionType = 14; break; case "donate_spells": this._actionType = 15; break; case "account_bound": this._actionType = 16; break; case "vs_battle_trophies": this._actionType = 17; break; case "gear_up": this._actionType = 18; break; case "repair_building": this._actionType = 19; this._buildingData = LogicDataTables.GetBuildingByName(this.GetValue("ActionData", 0)); if (this._buildingData == null) { Debugger.Error("LogicAchievementData - Building data is NULL for repair_building achievement"); } break; default: Debugger.Error(string.Format("Unknown Action in achievements {0}", action)); break; } this._achievementLevel = new LogicArrayList <LogicAchievementData>(); String achievementName = this.GetName().Substring(0, this.GetName().Length - 1); LogicDataTable table = LogicDataTables.GetTable(22); for (int i = 0; i < table.GetItemCount(); i++) { LogicAchievementData achievementData = (LogicAchievementData)table.GetItemAt(i); if (achievementData.GetName().Contains(achievementName)) { if (achievementData.GetName().Substring(0, achievementData.GetName().Length - 1).Equals(achievementName)) { this._achievementLevel.Add(achievementData); } } } Debugger.DoAssert(this._achievementLevel.Count == this._levelCount, string.Format("Expected same amount of achievements named {0}X to be same as LevelCount={1} for {2}.", achievementName, this._levelCount, this.GetName())); }