Example #1
0
        /// <summary>
        ///     Called when all instances has been loaded for initialized members in instance.
        /// </summary>
        public override void CreateReferences()
        {
            base.CreateVillageReferences();

            for (int i = 0; i < this.GetArraySize("Dependencies"); i++)
            {
                LogicMissionData dependency = LogicDataTables.GetMissionByName(this.GetValue("Dependencies", i));

                if (dependency != null)
                {
                    this._missionDependencies.Add(dependency);
                }
            }

            this._action               = this.GetValue("Action", 0);
            this._deprecated           = this.GetBooleanValue("Deprecated", 0);
            this._missionCategory      = this.GetIntegerValue("MissionCategory", 0);
            this._fixVillageObjectData = LogicDataTables.GetVillageObjectByName(this.GetValue("FixVillageObject", 0));

            if (this._fixVillageObjectData != null)
            {
                this._buildBuildingLevel = this.GetIntegerValue("BuildBuildingLevel", 0);
                this._missionType        = 13;
            }

            if (string.Equals(this._action, "travel"))
            {
                this._missionType = 14;
            }
            else if (string.Equals(this._action, "upgrade2"))
            {
                this._characterData = LogicDataTables.GetCharacterByName(this.GetValue("Character", 0));
                this._missionType   = 17;
            }
            else if (string.Equals(this._action, "duel"))
            {
                this._attackNpcData = LogicDataTables.GetNpcByName(this.GetValue("AttackNPC", 0));
                this._missionType   = 18;
            }
            else if (string.Equals(this._action, "duel_end"))
            {
                this._attackNpcData = LogicDataTables.GetNpcByName(this.GetValue("AttackNPC", 0));
                this._missionType   = 19;
            }
            else if (string.Equals(this._action, "duel_end2"))
            {
                this._missionType = 20;
            }
            else if (string.Equals(this._action, "show_builder_menu"))
            {
                this._missionType = 21;
            }

            this._buildBuildingData = LogicDataTables.GetBuildingByName(this.GetValue("BuildBuilding", 0));

            if (this._buildBuildingData != null)
            {
                this._buildBuildingCount = this.GetIntegerValue("BuildBuildingCount", 0);
                this._buildBuildingLevel = this.GetIntegerValue("BuildBuildingLevel", 0) - 1;
                this._missionType        = string.Equals(this._action, "unlock") ? 15 : 5;

                if (this._buildBuildingCount < 0)
                {
                    Debugger.Error("missions.csv: BuildBuildingCount is invalid!");
                }
            }
            else
            {
                if (this._missionType == -1)
                {
                    this._openAchievements = this.GetBooleanValue("OpenAchievements", 0);

                    if (this._openAchievements)
                    {
                        this._missionType = 7;
                    }
                    else
                    {
                        this._defendNpcData = LogicDataTables.GetNpcByName(this.GetValue("DefendNPC", 0));

                        if (this._defendNpcData != null)
                        {
                            this._missionType = 1;
                        }
                        else
                        {
                            this._attackNpcData = LogicDataTables.GetNpcByName(this.GetValue("AttackNPC", 0));

                            if (this._attackNpcData != null)
                            {
                                this._missionType = 2;
                                this._showMap     = this.GetBooleanValue("ShowMap", 0);
                            }
                            else
                            {
                                this._changeName = this.GetBooleanValue("ChangeName", 0);

                                if (this._changeName)
                                {
                                    this._missionType = 6;
                                }
                                else
                                {
                                    this._trainTroopCount = this.GetIntegerValue("TrainTroops", 0);

                                    if (this._trainTroopCount > 0)
                                    {
                                        this._missionType = 4;
                                    }
                                    else
                                    {
                                        this._switchSides = this.GetBooleanValue("SwitchSides", 0);

                                        if (this._switchSides)
                                        {
                                            this._missionType = 8;
                                        }
                                        else
                                        {
                                            this._showWarBase = this.GetBooleanValue("ShowWarBase", 0);

                                            if (this._showWarBase)
                                            {
                                                this._missionType = 9;
                                            }
                                            else
                                            {
                                                this._openInfo = this.GetBooleanValue("OpenInfo", 0);

                                                if (this._openInfo)
                                                {
                                                    this._missionType = 11;
                                                }
                                                else
                                                {
                                                    this._showDonate = this.GetBooleanValue("ShowDonate", 0);

                                                    if (this._showDonate)
                                                    {
                                                        this._missionType = 10;
                                                    }
                                                    else
                                                    {
                                                        this._showStates = this.GetBooleanValue("WarStates", 0);

                                                        if (this._showStates)
                                                        {
                                                            this._missionType = 12;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            this._villagers = this.GetIntegerValue("Villagers", 0);

            if (this._villagers > 0)
            {
                this._missionType = 16;
            }

            this._forceCamera = this.GetBooleanValue("ForceCamera", 0);

            if (this._missionType == -1)
            {
                Debugger.Error(string.Format("missions.csv: invalid mission ({0})", this.GetName()));
            }

            this._rewardResourceData  = LogicDataTables.GetResourceByName(this.GetValue("RewardResource", 0));
            this._rewardResourceCount = this.GetIntegerValue("RewardResourceCount", 0);

            if (this._rewardResourceData != null)
            {
                if (this._rewardResourceCount != 0)
                {
                    if (this._rewardResourceCount < 0)
                    {
                        Debugger.Error("missions.csv: RewardResourceCount is negative!");

                        this._rewardResourceData  = null;
                        this._rewardResourceCount = 0;
                    }
                }
                else
                {
                    this._rewardResourceData = null;
                }
            }
            else if (this._rewardResourceCount != 0)
            {
                Debugger.Warning("missions.csv: RewardResourceCount defined but RewardResource is not!");
                this._rewardResourceCount = 0;
            }

            this._customData = this.GetIntegerValue("CustomData", 0);
            this._rewardXp   = this.GetIntegerValue("RewardXP", 0);

            if (this._rewardXp < 0)
            {
                Debugger.Warning("missions.csv: RewardXP is negative!");
                this._rewardXp = 0;
            }

            this._rewardCharacterData  = LogicDataTables.GetCharacterByName(this.GetValue("RewardTroop", 0));
            this._rewardCharacterCount = this.GetIntegerValue("RewardTroopCount", 0);

            if (this._rewardCharacterData != null)
            {
                if (this._rewardCharacterCount != 0)
                {
                    if (this._rewardCharacterCount < 0)
                    {
                        Debugger.Error("missions.csv: RewardTroopCount is negative!");

                        this._rewardCharacterData  = null;
                        this._rewardCharacterCount = 0;
                    }
                }
                else
                {
                    this._rewardCharacterData = null;
                }
            }
            else if (this._rewardCharacterCount != 0)
            {
                Debugger.Warning("missions.csv: RewardTroopCount defined but RewardTroop is not!");
                this._rewardCharacterCount = 0;
            }

            this._delay        = this.GetIntegerValue("Delay", 0);
            this._villageType  = this.GetIntegerValue("VillageType", 0);
            this._firstStep    = this.GetBooleanValue("FirstStep", 0);
            this._tutorialText = this.GetValue("TutorialText", 0);

            if (this._tutorialText.Length > 0)
            {
                // BLABLABLA
            }
        }
Example #2
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()));
        }
Example #3
0
        /// <summary>
        ///     Called when all instances has been loaded for initialized members in instance.
        /// </summary>
        public override void CreateReferences()
        {
            base.CreateVillageReferences();

            this._width  = this.GetIntegerValue("Width", 0);
            this._height = this.GetIntegerValue("Height", 0);

            this._upgradeLevelCount = this._row.GetBiggestArraySize();

            this._buildCost         = new int[this._upgradeLevelCount];
            this._rearmCost         = new int[this._upgradeLevelCount];
            this._townHallLevel     = new int[this._upgradeLevelCount];
            this._strenghtWeight    = new int[this._upgradeLevelCount];
            this._damage            = new int[this._upgradeLevelCount];
            this._damageRadius      = new int[this._upgradeLevelCount];
            this._ejectHousingLimit = new int[this._upgradeLevelCount];
            this._numSpawns         = new int[this._upgradeLevelCount];
            this._constructionTimes = new int[this._upgradeLevelCount];

            for (int i = 0; i < this._upgradeLevelCount; i++)
            {
                this._buildCost[i]         = this.GetClampedIntegerValue("BuildCost", i);
                this._rearmCost[i]         = this.GetClampedIntegerValue("RearmCost", i);
                this._townHallLevel[i]     = LogicMath.Max(this.GetClampedIntegerValue("TownHallLevel", i) - 1, 0);
                this._strenghtWeight[i]    = this.GetClampedIntegerValue("StrengthWeight", i);
                this._damage[i]            = LogicMath.Min(this.GetClampedIntegerValue("Damage", i), 1000);
                this._damageRadius[i]      = (this.GetClampedIntegerValue("DamageRadius", i) << 9) / 100;
                this._ejectHousingLimit[i] = this.GetIntegerValue("EjectHousingLimit", i);
                this._numSpawns[i]         = this.GetClampedIntegerValue("NumSpawns", i);
                this._constructionTimes[i] = 86400 * this.GetIntegerValue("BuildTimeD", i) +
                                             3600 * this.GetIntegerValue("BuildTimeH", i) +
                                             60 * this.GetIntegerValue("BuildTimeM", i) +
                                             this.GetIntegerValue("BuildTimeS", i);
            }

            this._preferredTargetData      = LogicDataTables.GetCharacterByName(this.GetValue("PreferredTarget", 0));
            this._preferredTargetDamageMod = this.GetIntegerValue("PreferredTargetDamageMod", 0);

            if (this._preferredTargetDamageMod == 0)
            {
                this._preferredTargetDamageMod = 100;
            }

            this._buildResourceData = LogicDataTables.GetResourceByName(this.GetValue("BuildResource", 0));

            if (this._buildResourceData == null)
            {
                Debugger.Error("build resource is not defined for trap: " + this.GetName());
            }

            this._ejectVictims               = this.GetBooleanValue("EjectVictims", 0);
            this._actionFrame                = 1000 * this.GetIntegerValue("ActionFrame", 0) / 24;
            this._pushback                   = this.GetIntegerValue("Pushback", 0);
            this._doNotScalePushByDamage     = this.GetBooleanValue("DoNotScalePushByDamage", 0);
            this._effectData                 = LogicDataTables.GetEffectByName(this.GetValue("Effect", 0));
            this._effect2Data                = LogicDataTables.GetEffectByName(this.GetValue("Effect2", 0));
            this._effectBrokenData           = LogicDataTables.GetEffectByName(this.GetValue("EffectBroken", 0));
            this._damageEffectData           = LogicDataTables.GetEffectByName(this.GetValue("DamageEffect", 0));
            this._pickUpEffectData           = LogicDataTables.GetEffectByName(this.GetValue("PickUpEffect", 0));
            this._placingEffectData          = LogicDataTables.GetEffectByName(this.GetValue("PlacingEffect", 0));
            this._appearEffectData           = LogicDataTables.GetEffectByName(this.GetValue("AppearEffect", 0));
            this._toggleAttackModeEffectData = LogicDataTables.GetEffectByName(this.GetValue("ToggleAttackModeEffect", 0));
            this._triggerRadius              = (this.GetIntegerValue("TriggerRadius", 0) << 9) / 100;
            this._directionCount             = this.GetIntegerValue("DirectionCount", 0);
            this._spell                  = LogicDataTables.GetSpellByName(this.GetValue("Spell", 0));
            this._airTrigger             = this.GetBooleanValue("AirTrigger", 0);
            this._groundTrigger          = this.GetBooleanValue("GroundTrigger", 0);
            this._healerTrigger          = this.GetBooleanValue("HealerTrigger", 0);
            this._speedMod               = this.GetIntegerValue("SpeedMod", 0);
            this._damageMod              = this.GetIntegerValue("DamageMod", 0);
            this._durationMS             = this.GetIntegerValue("DurationMS", 0);
            this._hitDelayMS             = this.GetIntegerValue("HitDelayMS", 0);
            this._hitCount               = this.GetIntegerValue("HitCnt", 0);
            this._minTriggerHousingLimit = this.GetIntegerValue("MinTriggerHousingLimit", 0);
            this._spawnedCharGroundData  = LogicDataTables.GetCharacterByName(this.GetValue("SpawnedCharGround", 0));
            this._spawnedCharAirData     = LogicDataTables.GetCharacterByName(this.GetValue("SpawnedCharAir", 0));
            this._timeBetweenSpawnsMS    = this.GetIntegerValue("TimeBetweenSpawnsMs", 0);
            this._spawnInitialDelayMS    = this.GetIntegerValue("SpawnInitialDelayMs", 0);
            this._throwDistance          = this.GetIntegerValue("ThrowDistance", 0);
            this._hasAltMode             = this.GetBooleanValue("HasAltMode", 0);
            this._enableByCalendar       = this.GetBooleanValue("EnabledByCalendar", 0);

            if (this._enableByCalendar)
            {
                if (this._upgradeLevelCount > 1)
                {
                    Debugger.Error("Temporary traps should not have upgrade levels!");
                }
            }
        }
Example #4
0
        /// <summary>
        ///     Creates a new data item.
        /// </summary>
        public LogicData CreateItem(CSVRow row)
        {
            LogicData data = null;

            switch (this._tableIndex)
            {
            case 0:
            {
                data = new LogicBuildingData(row, this);
                break;
            }

            case 1:
            {
                data = new LogicLocaleData(row, this);
                break;
            }

            case 2:
            {
                data = new LogicResourceData(row, this);
                break;
            }

            case 3:
            {
                data = new LogicCharacterData(row, this);
                break;
            }

            case 5:
            {
                data = new LogicProjectileData(row, this);
                break;
            }

            case 6:
            {
                data = new LogicBuildingClassData(row, this);
                break;
            }

            case 7:
            {
                data = new LogicObstacleData(row, this);
                break;
            }

            case 8:
            {
                data = new LogicEffectData(row, this);
                break;
            }

            case 9:
            {
                data = new LogicParticleEmitterData(row, this);
                break;
            }

            case 10:
            {
                data = new LogicExperienceLevelData(row, this);
                break;
            }

            case 11:
            {
                data = new LogicTrapData(row, this);
                break;
            }

            case 12:
            {
                data = new LogicAllianceBadgeData(row, this);
                break;
            }

            case 13:
            {
                data = new LogicGlobalData(row, this);
                break;
            }

            case 14:
            {
                data = new LogicTownhallLevelData(row, this);
                break;
            }

            case 15:
            {
                data = new LogicAlliancePortalData(row, this);
                break;
            }

            case 16:
            {
                data = new LogicNpcData(row, this);
                break;
            }

            case 17:
            {
                data = new LogicDecoData(row, this);
                break;
            }

            case 18:
            {
                data = new LogicResourcePackData(row, this);
                break;
            }

            case 19:
            {
                data = new LogicShieldData(row, this);
                break;
            }

            case 20:
            {
                data = new LogicMissionData(row, this);
                break;
            }

            case 21:
            {
                data = new LogicBillingPackageData(row, this);
                break;
            }

            case 22:
            {
                data = new LogicAchievementData(row, this);
                break;
            }

            case 23:
            {
                data = new LogicFaqData(row, this);
                break;
            }

            case 25:
            {
                data = new LogicSpellData(row, this);
                break;
            }

            case 26:
            {
                data = new LogicHintData(row, this);
                break;
            }

            case 27:
            {
                data = new LogicHeroData(row, this);
                break;
            }

            case 28:
            {
                data = new LogicLeagueData(row, this);
                break;
            }

            case 29:
            {
                data = new LogicNewsData(row, this);
                break;
            }

            case 30:
            {
                data = new LogicWarData(row, this);
                break;
            }

            case 31:
            {
                data = new LogicRegionData(row, this);
                break;
            }

            case 32:
            {
                data = new LogicGlobalData(row, this);
                break;
            }

            case 33:
            {
                data = new LogicAllianceBadgeLayerData(row, this);
                break;
            }

            case 34:
            {
                data = new LogicAllianceLevelData(row, this);
                break;
            }

            case 36:
            {
                data = new LogicVariableData(row, this);
                break;
            }

            case 37:
            {
                data = new LogicGemBundleData(row, this);
                break;
            }

            case 38:
            {
                data = new LogicVillageObjectData(row, this);
                break;
            }

            case 39:
            {
                data = new LogicCalendarEventFunctionData(row, this);
                break;
            }

            case 40:
            {
                data = new LogicBoomboxData(row, this);
                break;
            }

            case 41:
            {
                data = new LogicEventEntryData(row, this);
                break;
            }

            case 42:
            {
                data = new LogicDeeplinkData(row, this);
                break;
            }

            case 43:
            {
                data = new LogicLeague2Data(row, this);
                break;
            }

            default:
            {
                Debugger.Error("Invalid data table id: " + this._tableIndex);
                break;
            }
            }

            return(data);
        }