/// <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._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>
 ///     Gets the level cap.
 /// </summary>
 public static int GetLevelCap()
 {
     return(LogicDataTables.GetTable(10).GetItemCount());
 }
Beispiel #4
0
        /// <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()));
        }