Esempio n. 1
0
        /// <summary>
        ///     Gets the resource diamond cost.
        /// </summary>
        public int GetResourceDiamondCost(int count, LogicResourceData data)
        {
            if (LogicDataTables.GetDarkElixirData() != data)
            {
                int resourceDiamondCost100;
                int resourceDiamondCost1000;
                int resourceDiamondCost10000;
                int resourceDiamondCost100000;
                int resourceDiamondCost1000000;
                int resourceDiamondCost10000000;

                if (data.GetVillageType() == 1)
                {
                    resourceDiamondCost100      = this._village2ResourceDiamondCost100;
                    resourceDiamondCost1000     = this._village2ResourceDiamondCost1000;
                    resourceDiamondCost10000    = this._village2ResourceDiamondCost10000;
                    resourceDiamondCost100000   = this._village2resourceDiamondCost100000;
                    resourceDiamondCost1000000  = this._village2resourceDiamondCost1000000;
                    resourceDiamondCost10000000 = this._village2ResourceDiamondCost10000000;
                }
                else
                {
                    resourceDiamondCost100      = this._resourceDiamondCost100;
                    resourceDiamondCost1000     = this._resourceDiamondCost1000;
                    resourceDiamondCost10000    = this._resourceDiamondCost10000;
                    resourceDiamondCost100000   = this._resourceDiamondCost100000;
                    resourceDiamondCost1000000  = this._resourceDiamondCost1000000;
                    resourceDiamondCost10000000 = this._resourceDiamondCost10000000;
                }

                if (count >= 1)
                {
                    if (count >= 100)
                    {
                        if (count >= 1000)
                        {
                            if (count >= 10000)
                            {
                                if (count >= 100000)
                                {
                                    if (count >= 1000000)
                                    {
                                        return(resourceDiamondCost1000000 + ((resourceDiamondCost10000000 - resourceDiamondCost1000000) * (count / 1000 - 1000) + 4500) / 9000);
                                    }

                                    return(resourceDiamondCost100000 + ((resourceDiamondCost1000000 - resourceDiamondCost100000) * (count / 100 - 1000) + 4500) / 9000);
                                }

                                return(resourceDiamondCost10000 + ((resourceDiamondCost100000 - resourceDiamondCost10000) * (count / 10 - 1000) + 4500) / 9000);
                            }

                            return(resourceDiamondCost1000 + ((resourceDiamondCost10000 - resourceDiamondCost1000) * (count - 1000) + 4500) / 9000);
                        }

                        return(resourceDiamondCost100 + ((resourceDiamondCost1000 - resourceDiamondCost100) * (count - 100) + 450) / 900);
                    }

                    return(resourceDiamondCost100);
                }

                return(0);
            }
            else
            {
                return(this.GetDarkElixirDiamondCost(count));
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Gets the worker cost.
        /// </summary>
        public int GetWorkerCost(LogicLevel level)
        {
            int totalWorkers = level.GetWorkerManagerAt(level.GetVillageType()).GetTotalWorkers() + level.GetUnplacedObjectCount(LogicDataTables.GetWorkerData());

            switch (totalWorkers)
            {
            case 1: return(this._workerCostSecondBuildCost);

            case 2: return(this._workerCostThirdBuildCost);

            case 3: return(this._workerCostFourthBuildCost);

            case 4: return(this._workerCostFifthBuildCost);

            default: return(this._workerCostFifthBuildCost);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Creates references.
        /// </summary>
        public void CreateReferences()
        {
            this._speedUpDiamondCostPerMin          = this.GetIntValue("SPEED_UP_DIAMOND_COST_1_MIN");
            this._speedUpDiamondCostPerHour         = this.GetIntValue("SPEED_UP_DIAMOND_COST_1_HOUR");
            this._speedUpDiamondCostPerDay          = this.GetIntValue("SPEED_UP_DIAMOND_COST_24_HOURS");
            this._speedUpDiamondCostPerWeek         = this.GetIntValue("SPEED_UP_DIAMOND_COST_1_WEEK");
            this._speedUpDiamondCostPerMinVillage2  = this.GetIntValue("VILLAGE2_SPEED_UP_DIAMOND_COST_1_MIN");
            this._speedUpDiamondCostPerHourVillage2 = this.GetIntValue("VILLAGE2_SPEED_UP_DIAMOND_COST_1_HOUR");
            this._speedUpDiamondCostPerDayVillage2  = this.GetIntValue("VILLAGE2_SPEED_UP_DIAMOND_COST_24_HOURS");
            this._speedUpDiamondCostPerWeekVillage2 = this.GetIntValue("VILLAGE2_SPEED_UP_DIAMOND_COST_1_WEEK");

            this._resourceDiamondCost100              = this.GetIntValue("RESOURCE_DIAMOND_COST_100");
            this._resourceDiamondCost1000             = this.GetIntValue("RESOURCE_DIAMOND_COST_1000");
            this._resourceDiamondCost10000            = this.GetIntValue("RESOURCE_DIAMOND_COST_10000");
            this._resourceDiamondCost100000           = this.GetIntValue("RESOURCE_DIAMOND_COST_100000");
            this._resourceDiamondCost1000000          = this.GetIntValue("RESOURCE_DIAMOND_COST_1000000");
            this._resourceDiamondCost10000000         = this.GetIntValue("RESOURCE_DIAMOND_COST_10000000");
            this._village2ResourceDiamondCost100      = this.GetIntValue("VILLAGE2_RESOURCE_DIAMOND_COST_100");
            this._village2ResourceDiamondCost1000     = this.GetIntValue("VILLAGE2_RESOURCE_DIAMOND_COST_1000");
            this._village2ResourceDiamondCost10000    = this.GetIntValue("VILLAGE2_RESOURCE_DIAMOND_COST_10000");
            this._village2resourceDiamondCost100000   = this.GetIntValue("VILLAGE2_RESOURCE_DIAMOND_COST_100000");
            this._village2resourceDiamondCost1000000  = this.GetIntValue("VILLAGE2_RESOURCE_DIAMOND_COST_1000000");
            this._village2ResourceDiamondCost10000000 = this.GetIntValue("VILLAGE2_RESOURCE_DIAMOND_COST_10000000");
            this._darkElixirDiamondCost1              = this.GetIntValue("DARK_ELIXIR_DIAMOND_COST_1");
            this._darkElixirDiamondCost10             = this.GetIntValue("DARK_ELIXIR_DIAMOND_COST_10");
            this._darkElixirDiamondCost100            = this.GetIntValue("DARK_ELIXIR_DIAMOND_COST_100");
            this._darkElixirDiamondCost1000           = this.GetIntValue("DARK_ELIXIR_DIAMOND_COST_1000");
            this._darkElixirDiamondCost10000          = this.GetIntValue("DARK_ELIXIR_DIAMOND_COST_10000");
            this._darkElixirDiamondCost100000         = this.GetIntValue("DARK_ELIXIR_DIAMOND_COST_100000");

            this._startingDiamonds                            = this.GetIntValue("STARTING_DIAMONDS");
            this._startingGold                                = this.GetIntValue("STARTING_GOLD");
            this._startingElixir                              = this.GetIntValue("STARTING_ELIXIR");
            this._startingGold2                               = this.GetIntValue("STARTING_GOLD2");
            this._startingElixir2                             = this.GetIntValue("STARTING_ELIXIR2");
            this._liveReplayFrequencySecs                     = this.GetIntValue("LIVE_REPLAY_UPDATE_FREQUENCY_SECONDS");
            this._challengeBaseSaveCooldown                   = this.GetIntValue("CHALLENGE_BASE_SAVE_COOLDOWN");
            this._allianceCreateCost                          = this.GetIntValue("ALLIANCE_CREATE_COST");
            this._clockTowerBoostCooldownSecs                 = 60 * this.GetIntValue("CLOCK_TOWER_BOOST_COOLDOWN_MINS");
            this._clampLongTimeStampsToDays                   = this.GetIntValue("CLAMP_LONG_TIME_STAMPS_TO_DAYS");
            this._workerCostSecondBuildCost                   = this.GetIntValue("WORKER_COST_2ND");
            this._workerCostThirdBuildCost                    = this.GetIntValue("WORKER_COST_3RD");
            this._workerCostFourthBuildCost                   = this.GetIntValue("WORKER_COST_4TH");
            this._workerCostFifthBuildCost                    = this.GetIntValue("WORKER_COST_5TH");
            this._challengeBaseCooldownEnabledOnTh            = this.GetIntValue("CHALLENGE_BASE_COOLDOWN_ENABLED_ON_TH");
            this._obstacleRespawnSecs                         = this.GetIntValue("OBSTACLE_RESPAWN_SECONDS");
            this._obstacleMaxCount                            = this.GetIntValue("OBSTACLE_COUNT_MAX");
            this._resourceProductionLootPercentage            = this.GetIntValue("RESOURCE_PRODUCTION_LOOT_PERCENTAGE");
            this._darkElixirProductionLootPercentage          = this.GetIntValue("RESOURCE_PRODUCTION_LOOT_PERCENTAGE_DARK_ELIXIR");
            this._village2MinTownHallLevelForDestructObstacle = this.GetIntValue("VILLAGE2_DO_NOT_ALLOW_CLEAR_OBSTACLE_TH");
            this._attackVillage2PreparationLengthSecs         = this.GetIntValue("ATTACK_PREPARATION_LENGTH_VILLAGE2_SEC");
            this._attackPreparationLengthSecs                 = this.GetIntValue("ATTACK_PREPARATION_LENGTH_SEC");
            this._attackLengthSecs                            = this.GetIntValue("ATTACK_LENGTH_SEC");
            this._village2StartUnitLevel                      = this.GetIntValue("VILLAGE2_START_UNIT_LEVEL");
            this._resourceProductionBoostSecs                 = 60 * this.GetIntValue("RESOURCE_PRODUCTION_BOOST_MINS");
            this._barracksBoostSecs                           = 60 * this.GetIntValue("BARRACKS_BOOST_MINS");
            this._spellFactoryBoostSecs                       = 60 * this.GetIntValue("SPELL_FACTORY_BOOST_MINS");
            this._troopTrainingSpeedUpCostTutorial            = this.GetIntValue("TROOP_TRAINING_SPEED_UP_COST_TUTORIAL");
            this._newTrainingBoostBarracksCost                = this.GetIntValue("NEW_TRAINING_BOOST_BARRACKS_COST");
            this._newTrainingBoostLaboratoryCost              = this.GetIntValue("NEW_TRAINING_BOOST_LABORATORY_COST");
            this._personalBreakLimitSeconds                   = this.GetIntValue("PERSONAL_BREAK_LIMIT_SECONDS");

            this._clockTowerBoostMultiplier          = this.GetIntValue("CLOCK_TOWER_BOOST_MULTIPLIER");
            this._resourceProductionBoostMultiplier  = this.GetIntValue("RESOURCE_PRODUCTION_BOOST_MULTIPLIER");
            this._spellTrainingCostMultiplier        = this.GetIntValue("SPELL_TRAINING_COST_MULTIPLIER");
            this._spellSpeedUpCostMultiplier         = this.GetIntValue("SPELL_SPEED_UP_COST_MULTIPLIER");
            this._heroHealthSpeedUpCostMultipler     = this.GetIntValue("HERO_HEALTH_SPEED_UP_COST_MULTIPLIER");
            this._troopRequestSpeedUpCostMultiplier  = this.GetIntValue("TROOP_REQUEST_SPEED_UP_COST_MULTIPLIER");
            this._troopTrainingCostMultiplier        = this.GetIntValue("TROOP_TRAINING_COST_MULTIPLIER");
            this._speedUpBoostCooldownCostMultiplier = this.GetIntValue("SPEEDUP_BOOST_COOLDOWN_COST_MULTIPLIER");
            this._clockTowerSpeedUpMultiplier        = this.GetIntValue("CHALLENGE_BASE_COOLDOWN_ENABLED_ON_TH");
            this._barracksBoostMultiplier            = this.GetIntValue("BARRACKS_BOOST_MULTIPLIER");
            this._barracksBoostNewMultiplier         = this.GetIntValue("BARRACKS_BOOST_MULTIPLIER_NEW");
            this._spellFactoryBoostNewMultiplier     = this.GetIntValue("SPELL_FACTORY_BOOST_MULTIPLIER_NEW");
            this._spellFactoryBoostMultiplier        = this.GetIntValue("SPELL_FACTORY_BOOST_MULTIPLIER");
            this._heroRestBoostMultiplier            = this.GetIntValue("HERO_REST_BOOST_MULTIPLIER");
            this._buildCancelMultiplier = this.GetIntValue("BUILD_CANCEL_MULTIPLIER");
            this._trainCancelMultiplier = this.GetIntValue("TRAIN_CANCEL_MULTIPLIER");
            this._spellCancelMultiplier = this.GetIntValue("SPELL_CANCEL_MULTIPLIER");

            this._useNewPathFinder             = this.GetBoolValue("USE_NEW_PATH_FINDER");
            this._useTroopWalksOutFromTraining = this.GetBoolValue("USE_TROOP_WALKS_OUT_FROM_TRAINING");
            this._useVillageObjects            = this.GetBoolValue("USE_VILLAGE_OBJECTS");
            this._moreAccurateTime             = this.GetBoolValue("MORE_ACCURATE_TIME");
            this._useNewTraining                        = this.GetBoolValue("USE_NEW_TRAINING");
            this._dragInTraining                        = this.GetBoolValue("DRAG_IN_TRAINING");
            this._dragInTrainingFix                     = this.GetBoolValue("DRAG_IN_TRAINING_FIX");
            this._dragInTrainingFix2                    = this.GetBoolValue("DRAG_IN_TRAINING_FIX2");
            this._revertBrokenWarLayouts                = this.GetBoolValue("REVERT_BROKEN_WAR_LAYOUTS");
            this._liveReplayEnabled                     = this.GetBoolValue("LIVE_REPLAY_ENABLED");
            this._removeRevengeWhenBattleIsLoaded       = this.GetBoolValue("REMOVE_REVENGE_WHEN_BATTLE_IS_LOADED");
            this._completeConstructionOnlyHome          = this.GetBoolValue("COMPLETE_CONSTRUCTIONS_ONLY_HOME");
            this._useNewSpeedUpCalculation              = this.GetBoolValue("USE_NEW_SPEEDUP_CALCULATION");
            this._clampBuildingTimes                    = this.GetBoolValue("CLAMP_BUILDING_TIMES");
            this._stopBoostPauseWhenBoostTimeZeroOnLoad = this.GetBoolValue("STOP_BOOST_PAUSE_WHEN_BOOST_TIME_ZERO_ON_LOAD");
            this._fixMergeOldBarrackBoostPausing        = this.GetBoolValue("FIX_MERGE_OLD_BARRACK_BOOST_PAUSING");
            this._saveVillageObjects                    = this.GetBoolValue("SAVE_VILLAGE_OBJECTS");
            this._workerForZeroBuildingTime             = this.GetBoolValue("WORKER_FOR_ZERO_BUILD_TIME");
            this._adjustEndSubtickUseCurrentTime        = this.GetBoolValue("ADJUST_END_SUBTICK_USE_CURRENT_TIME");
            this._collectAllResourcesAtOnce             = this.GetBoolValue("COLLECT_ALL_RESOURCES_AT_ONCE");
            this._useSwapBuildings                      = this.GetBoolValue("USE_SWAP_BUILDINGS");
            this._treasurySizeBasedOnTawnHall           = this.GetBoolValue("TREASURY_SIZE_BASED_ON_TH");
            this._startInLastUsedVillage                = this.GetBoolValue("START_IN_LAST_USED_VILLAGE");
            this._useTeslaTriggerCommand                = this.GetBoolValue("USE_TESLA_TRIGGER_CMD");
            this._useTrapTriggerCommand                 = this.GetBoolValue("USE_TRAP_TRIGGER_CMD");
            this._validateTroopUpgradeLevels            = this.GetBoolValue("VALIDATE_TROOP_UPGRADE_LEVELS");
            this._allowCancelBuildingConstruction       = this.GetBoolValue("ALLOW_CANCEL_BUILDING_CONSTRUCTION");
            this._village2TrainingOnlyUseRegularStorage = this.GetBoolValue("V2_TRAINING_ONLY_USE_REGULAR_STORAGE");
            this._enableTroopDeletion                   = this.GetBoolValue("ENABLE_TROOP_DELETION");

            this._allianceCreateResourceData = LogicDataTables.GetResourceByName(this.GetGlobalData("ALLIANCE_CREATE_RESOURCE").TextValue);

            LogicGlobalData village2TroopHousingBuildCostData = this.GetGlobalData("TROOP_HOUSING_V2_COST");

            this._village2TroopHousingBuildCost = new int[village2TroopHousingBuildCostData.GetNumberArraySize()];

            for (int i = 0; i < this._village2TroopHousingBuildCost.Length; i++)
            {
                this._village2TroopHousingBuildCost[i] = village2TroopHousingBuildCostData.GetNumberArray(i);
            }

            LogicGlobalData village2TroopHousingBuildTimeSecsData = this.GetGlobalData("TROOP_HOUSING_V2_BUILD_TIME_SECONDS");

            this._village2TroopHousingBuildTimeSecs = new int[village2TroopHousingBuildTimeSecsData.GetNumberArraySize()];

            for (int i = 0; i < this._village2TroopHousingBuildTimeSecs.Length; i++)
            {
                this._village2TroopHousingBuildTimeSecs[i] = village2TroopHousingBuildTimeSecsData.GetNumberArray(i);
            }

            LogicGlobalData lootMultiplierByTownHallDifferenceObject = this.GetGlobalData("LOOT_MULTIPLIER_BY_TH_DIFF");

            this._lootMultiplierByTownHallDifference = new int[lootMultiplierByTownHallDifferenceObject.GetNumberArraySize()];

            for (int i = 0; i < this._lootMultiplierByTownHallDifference.Length; i++)
            {
                this._lootMultiplierByTownHallDifference[i] = lootMultiplierByTownHallDifferenceObject.GetNumberArray(i);
            }

            LogicGlobalData barrackReduceTrainingDivisorObject = this.GetGlobalData("BARRACK_REDUCE_TRAINING_DIVISOR");

            this._barrackReduceTrainingDivisor = new int[barrackReduceTrainingDivisorObject.GetNumberArraySize()];

            for (int i = 0; i < this._barrackReduceTrainingDivisor.Length; i++)
            {
                this._barrackReduceTrainingDivisor[i] = barrackReduceTrainingDivisorObject.GetNumberArray(i);
            }

            LogicGlobalData darkBarrackReduceTrainingDivisorObject = this.GetGlobalData("DARK_BARRACK_REDUCE_TRAINING_DIVISOR");

            this._darkBarrackReduceTrainingDivisor = new int[darkBarrackReduceTrainingDivisorObject.GetNumberArraySize()];

            for (int i = 0; i < this._darkBarrackReduceTrainingDivisor.Length; i++)
            {
                this._darkBarrackReduceTrainingDivisor[i] = darkBarrackReduceTrainingDivisorObject.GetNumberArray(i);
            }

            LogicGlobalData clockTowerBoostObject = this.GetGlobalData("CLOCK_TOWER_BOOST_MINS");

            this._clockTowerBoostSecs = new int[clockTowerBoostObject.GetNumberArraySize()];

            for (int i = 0; i < this._clockTowerBoostSecs.Length; i++)
            {
                this._clockTowerBoostSecs[i] = clockTowerBoostObject.GetNumberArray(i);
            }
        }
Esempio n. 4
0
 /// <summary>
 ///     Gets the data instance by the name.
 /// </summary>
 private LogicGlobalData GetGlobalData(string name)
 {
     return(LogicDataTables.GetGlobalByName(name));
 }
Esempio n. 5
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()));
        }