Esempio n. 1
0
        public static void CreateReferences()
        {
            LogicDataTables.m_tables[(int)LogicDataType.PARTICLE_EMITTER].CreateReferences();

            for (int i = 0; i < LogicDataTables.m_tables.Length; i++)
            {
                if ((LogicDataType)i != LogicDataType.PARTICLE_EMITTER)
                {
                    if (LogicDataTables.m_tables[i] != null)
                    {
                        LogicDataTables.m_tables[i].CreateReferences();
                    }
                }
            }

            for (int i = 0; i < LogicDataTables.m_tables.Length; i++)
            {
                if (LogicDataTables.m_tables[i] != null)
                {
                    LogicDataTables.m_tables[i].CreateReferences2();
                }
            }

            // LogicDataTables.m_animationTable.CreateReferences();

            LogicDataTable buildingDataTable = LogicDataTables.m_tables[(int)LogicDataType.BUILDING];

            for (int i = 0; i < buildingDataTable.GetItemCount(); i++)
            {
                LogicBuildingData buildingData = (LogicBuildingData)buildingDataTable.GetItemAt(i);

                if (buildingData.IsAllianceCastle())
                {
                    LogicDataTables.m_allianceCastleData = buildingData;
                }

                if (buildingData.IsTownHall() && LogicDataTables.m_townHallData == null)
                {
                    LogicDataTables.m_townHallData = buildingData;
                }

                if (buildingData.IsTownHallVillage2() && LogicDataTables.m_townHallVillage2Data == null)
                {
                    LogicDataTables.m_townHallVillage2Data = buildingData;
                }
            }

            LogicDataTables.m_bowData                = LogicDataTables.GetBuildingByName("Bow", null);
            LogicDataTables.m_darkTowerData          = LogicDataTables.GetBuildingByName("Dark Tower", null);
            LogicDataTables.m_ancientArtilleryData   = LogicDataTables.GetBuildingByName("Ancient Artillery", null);
            LogicDataTables.m_workerData             = LogicDataTables.GetBuildingByName("Worker Building", null);
            LogicDataTables.m_laboratoryVillage2Data = LogicDataTables.GetBuildingByName("Laboratory2", null);
            LogicDataTables.m_diamondsData           = LogicDataTables.GetResourceByName("Diamonds", null);
            LogicDataTables.m_goldData               = LogicDataTables.GetResourceByName("Gold", null);
            LogicDataTables.m_elixirData             = LogicDataTables.GetResourceByName("Elixir", null);
            LogicDataTables.m_darkElixirData         = LogicDataTables.GetResourceByName("DarkElixir", null);
            LogicDataTables.m_gold2Data              = LogicDataTables.GetResourceByName("Gold2", null);
            LogicDataTables.m_elixir2Data            = LogicDataTables.GetResourceByName("Elixir2", null);
            LogicDataTables.m_warGoldData            = LogicDataTables.GetResourceByName("WarGold", null);
            LogicDataTables.m_warElixirData          = LogicDataTables.GetResourceByName("WarElixir", null);
            LogicDataTables.m_warDarkElixirData      = LogicDataTables.GetResourceByName("WarDarkElixir", null);
            LogicDataTables.m_skeletonData           = LogicDataTables.GetCharacterByName("Skeleton", null);
            LogicDataTables.m_balloonSkeletonData    = LogicDataTables.GetCharacterByName("Balloon Skeleton", null);
        }
        public void CalculateHousingSpaceCap()
        {
            this.m_maxHousingSpace = 0;

            if (this.GetInstanceID() > 0)
            {
                this.m_table.GetItemAt(this.GetInstanceID() - 1); // Thx supercell for the crappy code.
            }

            LogicDataTable buildingTable  = LogicDataTables.GetTable(LogicDataType.BUILDING);
            int            dataTableCount = this.m_table.GetItemCount();

            if (dataTableCount > 0)
            {
                int unitHousingCostMultiplierForTotal         = LogicDataTables.GetGlobals().GetUnitHousingCostMultiplierForTotal();
                int spellHousingCostMultiplierForTotal        = LogicDataTables.GetGlobals().GetSpellHousingCostMultiplierForTotal();
                int heroHousingCostMultiplierForTotal         = LogicDataTables.GetGlobals().GetHeroHousingCostMultiplierForTotal();
                int allianceUnitHousingCostMultiplierForTotal = LogicDataTables.GetGlobals().GetAllianceUnitHousingCostMultiplierForTotal();

                int idx = 0;

                do
                {
                    LogicBuildingData buildingData = (LogicBuildingData)buildingTable.GetItemAt(idx);
                    int count = this.m_buildingCaps[idx];

                    if (count > 0)
                    {
                        int multiplier  = unitHousingCostMultiplierForTotal;
                        int maxUpgLevel = buildingData.GetMaxUpgradeLevelForTownHallLevel(this.GetInstanceID());

                        if (maxUpgLevel >= 0)
                        {
                            int housingSpace = buildingData.GetUnitStorageCapacity(maxUpgLevel);

                            if (!buildingData.IsAllianceCastle())
                            {
                                if (buildingData.IsForgesMiniSpells() || buildingData.IsForgesSpells())
                                {
                                    multiplier = spellHousingCostMultiplierForTotal;
                                }
                                else if (buildingData.IsHeroBarrack())
                                {
                                    housingSpace = buildingData.GetHeroData().GetHousingSpace();
                                    multiplier   = heroHousingCostMultiplierForTotal;
                                }
                            }
                            else
                            {
                                multiplier = allianceUnitHousingCostMultiplierForTotal;
                            }

                            if (housingSpace > 0)
                            {
                                this.m_maxHousingSpace += multiplier * count * housingSpace / 100;
                            }
                        }
                    }
                } while (++idx != dataTableCount);
            }
        }