Пример #1
0
        /// <summary>
        ///     Refreshes all open missions.
        /// </summary>
        public void RefreshOpenMissions()
        {
            if (this._level.GetState() != 4)
            {
                LogicClientAvatar playerAvatar = this._level.GetPlayerAvatar();
                LogicDataTable    missionTable = LogicDataTables.GetTable(20);

                for (int i = 0; i < missionTable.GetItemCount(); i++)
                {
                    LogicMissionData missionData = (LogicMissionData)missionTable.GetItemAt(i);

                    if (missionData.IsOpenForAvatar(playerAvatar))
                    {
                        int index = -1;

                        for (int j = 0; j < this._openMissions.Count; j++)
                        {
                            if (this._openMissions[j].GetMissionData() == missionData)
                            {
                                index = j;
                                break;
                            }
                        }

                        if (index == -1)
                        {
                            LogicMission mission = new LogicMission(missionData, this._level);
                            mission.RefreshProgress();
                            this._openMissions.Add(mission);
                        }
                    }
                }
            }
        }
Пример #2
0
        private static bool CanUpgradeTHV2(LogicLevel level)
        {
            if (level.GetVillageType() == 1)
            {
                LogicDataTable buildingTable = LogicDataTables.GetTable(LogicDataType.BUILDING);

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

                    if (buildingData.GetVillageType() == 1 &&
                        !level.IsBuildingCapReached(buildingData, false))
                    {
                        return(false);
                    }
                }

                LogicDataTable trapTable = LogicDataTables.GetTable(LogicDataType.TRAP);

                for (int i = 0; i < trapTable.GetItemCount(); i++)
                {
                    LogicTrapData trapData = (LogicTrapData)trapTable.GetItemAt(i);

                    if (trapData.GetVillageType() == 1 &&
                        !level.IsTrapCapReached(trapData, false))
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
Пример #3
0
        public override void ResourcesStolen(int damage, int hp)
        {
            if (damage > 0 && hp > 0)
            {
                LogicDataTable table = LogicDataTables.GetTable(LogicDataType.RESOURCE);

                for (int i = 0; i < this.m_stealableResourceCount.Size(); i++)
                {
                    LogicResourceData data = (LogicResourceData)table.GetItemAt(i);

                    int stealableResource = this.GetStealableResourceCount(i);

                    if (damage < hp)
                    {
                        stealableResource = damage * stealableResource / hp;
                    }

                    if (stealableResource > 0 && data.GetWarResourceReferenceData() != null)
                    {
                        this.m_parent.GetLevel().GetBattleLog().IncreaseStolenResourceCount(data.GetWarResourceReferenceData(), stealableResource);
                        this.m_resourceCount[i] -= stealableResource;

                        LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar();
                        LogicAvatar visitorAvatar   = this.m_parent.GetLevel().GetVisitorAvatar();

                        homeOwnerAvatar.CommodityCountChangeHelper(0, data, -stealableResource);
                        visitorAvatar.CommodityCountChangeHelper(0, data.GetWarResourceReferenceData(), stealableResource);

                        this.m_stealableResourceCount[i] = LogicMath.Max(this.m_stealableResourceCount[i] - stealableResource, 0);
                    }
                }
            }
        }
        public void ReengageLootCart(int secs)
        {
            LogicObstacleData      obstacleData      = this.GetObstacleData();
            LogicLootCartComponent lootCartComponent = (LogicLootCartComponent)this.GetComponent(LogicComponentType.LOOT_CART);
            LogicBuilding          townHall          = this.m_level.GetGameObjectManagerAt(0).GetTownHall();

            Debugger.DoAssert(obstacleData.IsLootCart(), string.Empty);
            Debugger.DoAssert(lootCartComponent != null, string.Empty);
            Debugger.DoAssert(townHall != null, string.Empty);

            LogicDataTable resourceTable = LogicDataTables.GetTable(LogicDataType.RESOURCE);

            for (int i = 0; i < resourceTable.GetItemCount(); i++)
            {
                LogicResourceData      resourceData      = (LogicResourceData)resourceTable.GetItemAt(i);
                LogicTownhallLevelData townhallLevelData = LogicDataTables.GetTownHallLevel(townHall.GetUpgradeLevel());

                int cap = secs * townhallLevelData.GetCartLootReengagement(resourceData) / 100;

                if (cap > lootCartComponent.GetResourceCount(i))
                {
                    lootCartComponent.SetResourceCount(i, cap);
                }
            }
        }
        public bool HasEnoughFreeHousingSpace()
        {
            LogicCalendar       calendar        = this.m_level.GetCalendar();
            LogicAvatar         homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar();
            LogicUnitProduction unitProduction  = this.m_level.GetGameObjectManagerAt(0).GetUnitProduction();
            LogicDataTable      characterTable  = LogicDataTables.GetTable(LogicDataType.CHARACTER);

            int freeHousingSpace     = unitProduction.GetMaxTrainCount() - (homeOwnerAvatar.GetUnitsTotalCapacity() - unitProduction.GetTotalCount());
            int requiredHousingSpace = 0;

            for (int i = 0; i < characterTable.GetItemCount(); i++)
            {
                LogicCharacterData data = (LogicCharacterData)characterTable.GetItemAt(i);

                if (calendar.IsProductionEnabled(data) && !data.IsSecondaryTroop())
                {
                    int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId);

                    if (count > 0)
                    {
                        requiredHousingSpace += data.GetHousingSpace() * count;
                    }
                }
            }

            if (requiredHousingSpace <= freeHousingSpace)
            {
                LogicUnitProduction spellProduction = this.m_level.GetGameObjectManagerAt(0).GetSpellProduction();
                LogicDataTable      spellTable      = LogicDataTables.GetTable(LogicDataType.SPELL);

                int freeSpellHousingSpace     = spellProduction.GetMaxTrainCount() - (homeOwnerAvatar.GetSpellsTotalCapacity() - spellProduction.GetTotalCount());
                int requiredSpellHousingSpace = 0;

                for (int i = 0; i < spellTable.GetItemCount(); i++)
                {
                    LogicSpellData data = (LogicSpellData)spellTable.GetItemAt(i);

                    if (calendar.IsProductionEnabled(data))
                    {
                        int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId);

                        if (count > 0)
                        {
                            requiredSpellHousingSpace += data.GetHousingSpace() * count;
                        }
                    }
                }

                return(requiredSpellHousingSpace <= freeSpellHousingSpace);
            }

            return(false);
        }
        public static void AddDebugTroopsPreset(LogicLevel level, int townHallLevel, LogicClientAvatar playerAvatar)
        {
            if (playerAvatar != null)
            {
                LogicDataTable    characterTable = LogicDataTables.GetTable(LogicDataType.CHARACTER);
                LogicDataTable    spellTable     = LogicDataTables.GetTable(LogicDataType.SPELL);
                LogicBuildingData laboratoryData = LogicDataTables.GetBuildingByName("Laboratory", null);

                int laboratoryLevel = laboratoryData.GetMaxUpgradeLevelForTownHallLevel(townHallLevel);
                int totalHousing    = LogicDebugUtil.GetTotalCharacterMaxHousing(townHallLevel, true) / 5;

                for (int i = 0; i < characterTable.GetItemCount(); i++)
                {
                    playerAvatar.SetUnitCount((LogicCharacterData)characterTable.GetItemAt(i), 0);
                }

                for (int i = 0; i < spellTable.GetItemCount(); i++)
                {
                    playerAvatar.SetUnitCount((LogicSpellData)spellTable.GetItemAt(i), 0);
                }

                for (int i = 0; i < 7; i++)
                {
                    if (i != 2 && i != 5)
                    {
                        LogicCharacterData characterData = (LogicCharacterData)characterTable.GetItemAt(i);

                        if (characterData.GetVillageType() == 0)
                        {
                            int upgradeLevel = 0;

                            for (int j = characterData.GetUpgradeLevelCount(); j >= 2; j--)
                            {
                                int requiredLaboratoryLevel = characterData.GetRequiredLaboratoryLevel(j - 1);

                                if (laboratoryLevel >= requiredLaboratoryLevel)
                                {
                                    upgradeLevel = j - 1;
                                    break;
                                }
                            }

                            playerAvatar.SetUnitCount(characterData, totalHousing / characterData.GetHousingSpace());
                            playerAvatar.SetUnitUpgradeLevel(characterData, upgradeLevel);
                        }
                    }
                }
            }
            else
            {
                Debugger.Warning("addDebugTroopsPreset: pAvatar is NULL");
            }
        }
        public void TrainUnits()
        {
            LogicAvatar    homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar();
            LogicDataTable characterTable  = LogicDataTables.GetTable(LogicDataType.CHARACTER);
            LogicDataTable spellTable      = LogicDataTables.GetTable(LogicDataType.SPELL);
            LogicArrayList <LogicCombatItemData> productionUnits  = new LogicArrayList <LogicCombatItemData>(characterTable.GetItemCount());
            LogicArrayList <LogicCombatItemData> productionSpells = new LogicArrayList <LogicCombatItemData>(spellTable.GetItemCount());

            for (int i = 0; i < characterTable.GetItemCount(); i++)
            {
                LogicCharacterData data = (LogicCharacterData)characterTable.GetItemAt(i);

                if (this.m_level.GetCalendar().IsProductionEnabled(data) && !data.IsSecondaryTroop())
                {
                    productionUnits.Add(data);
                }
            }

            this.SortProduction(productionUnits);

            for (int i = 0; i < productionUnits.Size(); i++)
            {
                int unitCount = homeOwnerAvatar.GetUnitPresetCount(productionUnits[i], this.m_presetId);

                if (unitCount > 0)
                {
                    this.AddUnitsToQueue(productionUnits[i], unitCount);
                }
            }

            for (int i = 0; i < spellTable.GetItemCount(); i++)
            {
                LogicSpellData data = (LogicSpellData)spellTable.GetItemAt(i);

                if (this.m_level.GetCalendar().IsProductionEnabled(data))
                {
                    productionSpells.Add(data);
                }
            }

            this.SortProduction(productionSpells);

            for (int i = 0; i < productionSpells.Size(); i++)
            {
                int spellCount = homeOwnerAvatar.GetUnitPresetCount(productionSpells[i], this.m_presetId);

                if (spellCount > 0)
                {
                    this.AddUnitsToQueue(productionSpells[i], spellCount);
                }
            }
        }
Пример #8
0
        public static void ParseAllianceBadgeLayer(int allianceBadgeId, out LogicAllianceBadgeLayerData middle, out LogicAllianceBadgeLayerData background, out LogicAllianceBadgeLayerData foreground)
        {
            LogicDataTable allianceBadgeLayerTable = LogicDataTables.GetTable(LogicDataType.ALLIANCE_BADGE_LAYER);

            int allianceBadgeCount      = LogicDataTables.GetTable(LogicDataType.ALLIANCE_BADGE_LAYER).GetItemCount();
            int allianceBadgeMiddle     = (byte)(allianceBadgeId) % allianceBadgeCount;
            int allianceBadgeBackground = (byte)(allianceBadgeId >> 8) % allianceBadgeCount;
            int allianceBadgeForeground = (byte)(allianceBadgeId >> 16) % allianceBadgeCount;

            middle     = allianceBadgeMiddle != 0 ? (LogicAllianceBadgeLayerData)allianceBadgeLayerTable.GetItemAt(allianceBadgeMiddle) : null;
            background = allianceBadgeBackground != 0 ? (LogicAllianceBadgeLayerData)allianceBadgeLayerTable.GetItemAt(allianceBadgeBackground) : null;
            foreground = allianceBadgeForeground != 0 ? (LogicAllianceBadgeLayerData)allianceBadgeLayerTable.GetItemAt(allianceBadgeForeground) : null;
        }
        public LogicLootCartComponent(LogicGameObject gameObject) : base(gameObject)
        {
            LogicDataTable resourceTable = LogicDataTables.GetTable(LogicDataType.RESOURCE);

            this.m_lootCount = new LogicArrayList <int>(resourceTable.GetItemCount());
            this.m_capCount  = new LogicArrayList <int>(resourceTable.GetItemCount());

            for (int i = 0; i < resourceTable.GetItemCount(); i++)
            {
                this.m_lootCount.Add(0);
                this.m_capCount.Add(0);
            }
        }
Пример #10
0
        public void DebugCompleteAllTutorials(bool onlyHomeMissions, bool completeNameMission, bool completeWarMissions)
        {
            LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar();
            LogicDataTable    table        = LogicDataTables.GetTable(LogicDataType.MISSION);

            bool restartMission = false;

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicMissionData data = (LogicMissionData)table.GetItemAt(i);

                if (!completeWarMissions && data.GetMissionCategory() == 1)
                {
                    continue;
                }

                if (onlyHomeMissions)
                {
                    if (data.GetMissionCategory() != 0)
                    {
                        continue;
                    }
                }
                else if (data.GetMissionCategory() == 2 &&
                         this.m_level.GetGameObjectManagerAt(0).GetShipyard().GetUpgradeLevel() == 0 &&
                         this.m_level.GetVillageType() == 0)
                {
                    continue;
                }

                if (restartMission)
                {
                    playerAvatar.SetMissionCompleted(data, false);
                    playerAvatar.GetChangeListener().CommodityCountChanged(0, data, 0);
                }

                if (!completeNameMission)
                {
                    if (data.GetMissionType() == 6)
                    {
                        restartMission = true;
                        continue;
                    }
                }

                playerAvatar.SetMissionCompleted(data, true);
                playerAvatar.GetChangeListener().CommodityCountChanged(0, data, 1);
            }

            this.RefreshOpenMissions();
        }
        public void Init()
        {
            LogicDataTable table = LogicDataTables.GetTable(LogicDataType.GEM_BUNDLE);

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicGemBundleData data  = (LogicGemBundleData)table.GetItemAt(i);
                LogicOffer         offer = new LogicOffer(new LogicBundleOfferData(data), this.m_level);

                this.m_offers.Add(offer);
            }

            // TODO: Implement this.
        }
Пример #12
0
        public void BuildingDestroyedInPvP(LogicBuildingData buildingData)
        {
            LogicDataTable    table        = LogicDataTables.GetTable(LogicDataType.ACHIEVEMENT);
            LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar();

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicAchievementData data = (LogicAchievementData)table.GetItemAt(i);

                if (data.GetActionType() == LogicAchievementData.ACTION_TYPE_DESTROY && data.GetBuildingData() == buildingData)
                {
                    this.RefreshAchievementProgress(playerAvatar, data, playerAvatar.GetAchievementProgress(data) + 1);
                }
            }
        }
Пример #13
0
        public void IncreaseWarGoldResourceLoot(int count)
        {
            LogicDataTable    table        = LogicDataTables.GetTable(LogicDataType.ACHIEVEMENT);
            LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar();

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicAchievementData data = (LogicAchievementData)table.GetItemAt(i);

                if (data.GetActionType() == LogicAchievementData.ACTION_TYPE_WAR_LOOT)
                {
                    this.RefreshAchievementProgress(playerAvatar, data, playerAvatar.GetAchievementProgress(data) + count);
                }
            }
        }
Пример #14
0
        public void PvpAttackWon()
        {
            LogicDataTable    table        = LogicDataTables.GetTable(LogicDataType.ACHIEVEMENT);
            LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar();

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicAchievementData data = (LogicAchievementData)table.GetItemAt(i);

                if (data.GetActionType() == LogicAchievementData.ACTION_TYPE_WIN_PVP_ATTACK)
                {
                    this.RefreshAchievementProgress(playerAvatar, data, playerAvatar.GetAchievementProgress(data) + 1);
                }
            }
        }
        public int GetResourceCost(LogicResourceData resourceData)
        {
            int cost = 0;

            LogicAvatar    homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar();
            LogicCalendar  calendar        = this.m_level.GetCalendar();
            LogicDataTable table           = LogicDataTables.GetTable(LogicDataType.CHARACTER);

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicCharacterData data = (LogicCharacterData)table.GetItemAt(i);

                if (calendar.IsProductionEnabled(data) && !data.IsSecondaryTroop())
                {
                    int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId);

                    if (count > 0)
                    {
                        if (data.GetTrainingResource() == resourceData)
                        {
                            cost += count * calendar.GetTrainingCost(data, homeOwnerAvatar.GetUnitUpgradeLevel(data));
                        }
                    }
                }
            }

            table = LogicDataTables.GetTable(LogicDataType.SPELL);

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicSpellData data = (LogicSpellData)table.GetItemAt(i);

                if (calendar.IsProductionEnabled(data))
                {
                    int count = homeOwnerAvatar.GetUnitPresetCount(data, this.m_presetId);

                    if (count > 0)
                    {
                        if (data.GetTrainingResource() == resourceData)
                        {
                            cost += count * calendar.GetTrainingCost(data, homeOwnerAvatar.GetUnitUpgradeLevel(data));
                        }
                    }
                }
            }

            return(cost);
        }
        public static LogicLeagueVillage2Data GetLeagueVillage2(int score)
        {
            LogicDataTable table = LogicDataTables.GetTable(LogicDataType.LEAGUE_VILLAGE2);

            for (int i = table.GetItemCount() - 1; i >= 0; i--)
            {
                LogicLeagueVillage2Data data = (LogicLeagueVillage2Data)table.GetItemAt(i);

                if (data.GetTrophyLimitHigh() > score && data.GetTrophyLimitLow() <= score)
                {
                    return(data);
                }
            }

            return((LogicLeagueVillage2Data)table.GetItemAt(0));
        }
Пример #17
0
        public int CollectResources()
        {
            int collected = -1;

            if (this.m_parent.GetLevel().GetHomeOwnerAvatar().IsClientAvatar())
            {
                collected = 0;

                LogicClientAvatar playerAvatar = (LogicClientAvatar)this.m_parent.GetLevel().GetHomeOwnerAvatar();
                LogicDataTable    table        = LogicDataTables.GetTable(LogicDataType.RESOURCE);

                for (int i = 0; i < table.GetItemCount(); i++)
                {
                    LogicResourceData data = (LogicResourceData)table.GetItemAt(i);

                    if (data.GetWarResourceReferenceData() != null)
                    {
                        int count = playerAvatar.GetResourceCount(data);

                        if (count > 0)
                        {
                            int unusedResourceCap = playerAvatar.GetUnusedResourceCap(data.GetWarResourceReferenceData());

                            if (unusedResourceCap != 0)
                            {
                                if (count > unusedResourceCap)
                                {
                                    count = unusedResourceCap;
                                }

                                if (data.GetName().Equals("WarGold"))
                                {
                                    this.m_parent.GetLevel().GetAchievementManager().IncreaseWarGoldResourceLoot(count);
                                }

                                collected = count;

                                playerAvatar.CommodityCountChangeHelper(0, data.GetWarResourceReferenceData(), count);
                                playerAvatar.CommodityCountChangeHelper(0, data, -count);
                            }
                        }
                    }
                }
            }

            return(collected);
        }
Пример #18
0
        public virtual void ResourcesStolen(int damage, int hp)
        {
            if (damage > 0 && hp > 0)
            {
                LogicDataTable table = LogicDataTables.GetTable(LogicDataType.RESOURCE);

                for (int i = 0; i < this.m_stealableResourceCount.Size(); i++)
                {
                    LogicResourceData data = (LogicResourceData)table.GetItemAt(i);

                    int stealableResource = this.GetStealableResourceCount(i);

                    if (damage < hp)
                    {
                        stealableResource = damage * stealableResource / hp;
                    }

                    if (stealableResource > 0)
                    {
                        this.m_parent.GetLevel().GetBattleLog().IncreaseStolenResourceCount(data, stealableResource);
                        this.m_resourceCount[i] -= stealableResource;

                        LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar();
                        LogicAvatar visitorAvatar   = this.m_parent.GetLevel().GetVisitorAvatar();

                        homeOwnerAvatar.CommodityCountChangeHelper(0, data, -stealableResource);
                        visitorAvatar.CommodityCountChangeHelper(0, data, stealableResource);

                        if (homeOwnerAvatar.IsNpcAvatar())
                        {
                            LogicNpcData npcData = ((LogicNpcAvatar)homeOwnerAvatar).GetNpcData();

                            if (data == LogicDataTables.GetGoldData())
                            {
                                visitorAvatar.CommodityCountChangeHelper(1, npcData, stealableResource);
                            }
                            else if (data == LogicDataTables.GetElixirData())
                            {
                                visitorAvatar.CommodityCountChangeHelper(2, npcData, stealableResource);
                            }
                        }

                        this.m_stealableResourceCount[i] = LogicMath.Max(this.m_stealableResourceCount[i] - stealableResource, 0);
                    }
                }
            }
        }
Пример #19
0
        public void DivideAvatarResourcesToStorages()
        {
            LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar();

            if (homeOwnerAvatar != null)
            {
                LogicArrayList <LogicComponent> resourceStorageComponents    = this.m_components[(int)LogicComponentType.RESOURCE_STORAGE];
                LogicArrayList <LogicComponent> warResourceStorageComponents = this.m_components[(int)LogicComponentType.WAR_RESOURCE_STORAGE];
                LogicDataTable resourceTable = LogicDataTables.GetTable(LogicDataType.RESOURCE);

                for (int i = 0; i < resourceTable.GetItemCount(); i++)
                {
                    LogicResourceData data = (LogicResourceData)resourceTable.GetItemAt(i);

                    if (!data.IsPremiumCurrency())
                    {
                        if (data.GetWarResourceReferenceData() != null)
                        {
                            Debugger.DoAssert(warResourceStorageComponents.Size() < 2, "Too many war storage components");

                            for (int j = 0; j < warResourceStorageComponents.Size(); j++)
                            {
                                LogicWarResourceStorageComponent warResourceStorageComponent = (LogicWarResourceStorageComponent)warResourceStorageComponents[j];
                                warResourceStorageComponent.SetCount(i, homeOwnerAvatar.GetResourceCount(data));
                            }
                        }
                        else
                        {
                            for (int j = 0; j < resourceStorageComponents.Size(); j++)
                            {
                                ((LogicResourceStorageComponent)resourceStorageComponents[j]).SetCount(i, 0);
                            }

                            int resourceCount = homeOwnerAvatar.GetResourceCount(data);

                            if (this.m_level.GetBattleLog() != null && data.GetVillageType() == 1)
                            {
                                resourceCount = LogicMath.Max(resourceCount - this.m_level.GetBattleLog().GetCostCount(data), 0);
                            }

                            this.AddResources(i, resourceCount, true);
                        }
                    }
                }
            }
        }
        /// <summary>
        ///     Executes this command.
        /// </summary>
        public override int Execute(LogicLevel level)
        {
            if (this._newShopItemsType <= 17)
            {
                if (level.SetUnlockedShopItemCount(LogicDataTables.GetTable(this._newShopItemsType).GetItemAt(this._newShopItemsIndex),
                                                   this._newShopItemsIndex,
                                                   this._newShopItemsCount,
                                                   level.GetVillageType()))
                {
                    return(0);
                }

                return(-2);
            }

            return(-1);
        }
        public static void Init()
        {
            GameResourceManager.CompressedStartingHomeJSON = GameResourceManager.Compress(ServerHttpClient.DownloadBytes("data/level/starting_home.json"));
            GameResourceManager.NpcHomes = new LogicClientHome[LogicDataTables.GetTable(LogicDataType.NPC).GetItemCount()];

            LogicDataTable table = LogicDataTables.GetTable(LogicDataType.NPC);

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicNpcData    data            = (LogicNpcData)table.GetItemAt(i);
                LogicClientHome logicClientHome = new LogicClientHome();

                logicClientHome.GetCompressibleHomeJSON().Set(GameResourceManager.Compress(ServerHttpClient.DownloadBytes("data/" + data.GetLevelFile())));

                GameResourceManager.NpcHomes[i] = logicClientHome;
            }
        }
Пример #22
0
        public LogicResourceStorageComponent(LogicGameObject gameObject) : base(gameObject)
        {
            int resourceCount = LogicDataTables.GetTable(LogicDataType.RESOURCE).GetItemCount();

            this.m_maxResourceCount           = new LogicArrayList <int>(resourceCount);
            this.m_stealableResourceCount     = new LogicArrayList <int>(resourceCount);
            this.m_resourceCount              = new LogicArrayList <int>(resourceCount);
            this.m_maxPercentageResourceCount = new LogicArrayList <int>(resourceCount);

            for (int i = 0; i < resourceCount; i++)
            {
                this.m_resourceCount.Add(0);
                this.m_maxResourceCount.Add(0);
                this.m_stealableResourceCount.Add(0);
                this.m_maxPercentageResourceCount.Add(100);
            }
        }
Пример #23
0
        public static LogicAllianceBadgeLayerData GetFirstUnlockedAllianceBadgeLayerByType(LogicAllianceBadgeLayerType type, int allianceLevel)
        {
            LogicAllianceBadgeLayerData allianceBadgeLayer = null;
            LogicDataTable allianceBadgeLayerTable         = LogicDataTables.GetTable(LogicDataType.ALLIANCE_BADGE_LAYER);

            for (int i = 0; i < allianceBadgeLayerTable.GetItemCount(); i++)
            {
                LogicAllianceBadgeLayerData data = (LogicAllianceBadgeLayerData)allianceBadgeLayerTable.GetItemAt(i);

                if (data.GetBadgeType() == LogicAllianceBadgeLayerType.FOREGROUND && data.GetRequiredClanLevel() <= allianceLevel)
                {
                    allianceBadgeLayer = data;
                    break;
                }
            }

            return(allianceBadgeLayer);
        }
Пример #24
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="LogicResourceStorageComponent" /> class.
        /// </summary>
        public LogicResourceStorageComponent(LogicGameObject gameObject) : base(gameObject)
        {
            int resourceDataCount = LogicDataTables.GetTable(2).GetItemCount();

            this._maxResourceCount           = new LogicArrayList <int>(resourceDataCount);
            this._availableLootResourceCount = new LogicArrayList <int>(resourceDataCount);
            this._resourceCount = new LogicArrayList <int>(resourceDataCount);
            this._maxPercentageResourceCount = new LogicArrayList <int>(resourceDataCount);

            for (int i = 0; i < resourceDataCount; i++)
            {
                this._resourceCount.Add(0);
                this._maxResourceCount.Add(0);
                this._availableLootResourceCount.Add(0);

                this._maxPercentageResourceCount.Add(100);
            }
        }
Пример #25
0
        public void PvpDefenseWon()
        {
            if (this.m_level.GetHomeOwnerAvatar().IsClientAvatar())
            {
                LogicDataTable    table           = LogicDataTables.GetTable(LogicDataType.ACHIEVEMENT);
                LogicClientAvatar homeOwnerAvatar = (LogicClientAvatar)this.m_level.GetHomeOwnerAvatar();

                for (int i = 0; i < table.GetItemCount(); i++)
                {
                    LogicAchievementData data = (LogicAchievementData)table.GetItemAt(i);

                    if (data.GetActionType() == LogicAchievementData.ACTION_TYPE_WIN_PVP_DEFENSE)
                    {
                        this.RefreshAchievementProgress(homeOwnerAvatar, data, homeOwnerAvatar.GetAchievementProgress(data) + 1);
                    }
                }
            }
        }
Пример #26
0
        public void AlianceSpellDonated(LogicSpellData data)
        {
            if (data != null)
            {
                LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar();
                LogicDataTable    dataTable    = LogicDataTables.GetTable(LogicDataType.ACHIEVEMENT);

                for (int i = 0; i < dataTable.GetItemCount(); i++)
                {
                    LogicAchievementData achievementData = (LogicAchievementData)dataTable.GetItemAt(i);

                    if (achievementData.GetActionType() == LogicAchievementData.ACTION_TYPE_DONATE_SPELLS)
                    {
                        this.RefreshAchievementProgress(playerAvatar, achievementData, playerAvatar.GetAchievementProgress(achievementData) + data.GetHousingSpace());
                    }
                }
            }
        }
Пример #27
0
        /// <summary>
        ///     Gets if the player has travel.
        /// </summary>
        public bool HasTravel(LogicAvatar playerAvatar)
        {
            LogicDataTable missionTable = LogicDataTables.GetTable(20);

            for (int i = 0; i < missionTable.GetItemCount(); i++)
            {
                LogicMissionData missionData = (LogicMissionData)missionTable.GetItemAt(i);

                if (missionData.GetMissionType() == 23)
                {
                    if (playerAvatar.IsMissionCompleted(missionData))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public static void Init()
        {
            GameBaseGenerator.HomeOwnerAvatar = new LogicClientAvatar();
            GameBaseGenerator.HomeOwnerAvatar.SetName("Supercell - Private CoC Server");
            GameBaseGenerator.HomeOwnerAvatar.SetExpLevel(500);
            GameBaseGenerator.HomeOwnerAvatar.SetScore(5000);
            GameBaseGenerator.HomeOwnerAvatar.SetLeagueType(LogicDataTables.GetTable(LogicDataType.LEAGUE).GetItemCount() - 1);

            GameBaseGenerator.m_random = new LogicRandom(Environment.TickCount);
            GameBaseGenerator.m_defenseBuildingArray = new LogicArrayList <LogicBuildingData>();
            GameBaseGenerator.m_otherBuildingArray   = new LogicArrayList <LogicBuildingData>();
            GameBaseGenerator.m_trapArray            = new LogicArrayList <LogicTrapData>();

            LogicDataTable buildingTable = LogicDataTables.GetTable(LogicDataType.BUILDING);
            LogicDataTable trapTable     = LogicDataTables.GetTable(LogicDataType.TRAP);

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

                if (buildingData.IsEnabledInVillageType(0))
                {
                    if (buildingData.GetBuildingClass().GetName() == "Defense")
                    {
                        GameBaseGenerator.m_defenseBuildingArray.Add(buildingData);
                    }
                    else
                    {
                        GameBaseGenerator.m_otherBuildingArray.Add(buildingData);
                    }
                }
            }

            for (int i = 0; i < trapTable.GetItemCount(); i++)
            {
                LogicTrapData trapData = (LogicTrapData)trapTable.GetItemAt(i);

                if (trapData.IsEnabledInVillageType(0))
                {
                    GameBaseGenerator.m_trapArray.Add(trapData);
                }
            }
        }
        public override int Execute(LogicLevel level)
        {
            if (this.m_newShopItemsType == LogicDataType.BUILDING ||
                this.m_newShopItemsType == LogicDataType.TRAP ||
                this.m_newShopItemsType == LogicDataType.DECO)
            {
                if (level.SetUnlockedShopItemCount((LogicGameObjectData)LogicDataTables.GetTable(this.m_newShopItemsType).GetItemAt(this.m_newShopItemsIndex),
                                                   this.m_newShopItemsIndex,
                                                   this.m_newShopItemsCount,
                                                   level.GetVillageType()))
                {
                    return(0);
                }

                return(-2);
            }

            return(-1);
        }
Пример #30
0
        public bool IsNotEmpty()
        {
            LogicAvatar    homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar();
            LogicDataTable table           = LogicDataTables.GetTable(LogicDataType.RESOURCE);

            for (int i = 0; i < table.GetItemCount(); i++)
            {
                LogicResourceData data = (LogicResourceData)table.GetItemAt(i);

                if (data.GetWarResourceReferenceData() != null)
                {
                    if (homeOwnerAvatar.GetResourceCount(data) > 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }