Exemple #1
0
        /// <summary>
        ///     Gets the troop housing build time village 2.
        /// </summary>
        public int GetTroopHousingBuildTimeVillage2(LogicLevel level, int ignoreBuildingCnt)
        {
            LogicBuildingData data = LogicDataTables.GetBuildingByName("Troop Housing2");

            if (data != null)
            {
                return(this._village2TroopHousingBuildTimeSecs[LogicMath.Clamp(level.GetGameObjectManagerAt(1).GetGameObjectCountByData(data) - ignoreBuildingCnt,
                                                                               0,
                                                                               this._village2TroopHousingBuildTimeSecs.Length - 1)]);
            }
            else
            {
                Debugger.Error("Could not find Troop Housing2 data");
            }

            return(0);
        }
        /// <summary>
        ///     Initializes this instance.
        /// </summary>
        public static void Initialize()
        {
            LogicDataTables._dataTables = new LogicDataTable[44];

            LogicDataTables.Load("logic/buildings.csv", 0);
            LogicDataTables.Load("logic/locales.csv", 1);
            LogicDataTables.Load("logic/resources.csv", 2);
            LogicDataTables.Load("logic/characters.csv", 3);
            // LogicDataTables.Load("csv/animations.csv", 4);
            LogicDataTables.Load("logic/projectiles.csv", 5);
            LogicDataTables.Load("logic/building_classes.csv", 6);
            LogicDataTables.Load("logic/obstacles.csv", 7);
            LogicDataTables.Load("logic/effects.csv", 8);
            LogicDataTables.Load("csv/particle_emitters.csv", 9);
            LogicDataTables.Load("logic/experience_levels.csv", 10);
            LogicDataTables.Load("logic/traps.csv", 11);
            LogicDataTables.Load("logic/alliance_badges.csv", 12);
            LogicDataTables.Load("logic/globals.csv", 13);
            LogicDataTables.Load("logic/townhall_levels.csv", 14);
            LogicDataTables.Load("logic/alliance_portal.csv", 15);
            LogicDataTables.Load("logic/npcs.csv", 16);
            LogicDataTables.Load("logic/decos.csv", 17);
            LogicDataTables.Load("csv/resource_packs.csv", 18);
            LogicDataTables.Load("logic/shields.csv", 19);
            LogicDataTables.Load("logic/missions.csv", 20);
            LogicDataTables.Load("csv/billing_packages.csv", 21);
            LogicDataTables.Load("logic/achievements.csv", 22);
            // LogicDataTables.Load("csv/credits.csv", 23);
            // LogicDataTables.Load("csv/faq.csv", 24);
            LogicDataTables.Load("logic/spells.csv", 25);
            LogicDataTables.Load("csv/hints.csv", 26);
            LogicDataTables.Load("logic/heroes.csv", 27);
            LogicDataTables.Load("logic/leagues.csv", 28);
            LogicDataTables.Load("csv/news.csv", 29);
            LogicDataTables.Load("logic/war.csv", 30);
            LogicDataTables.Load("logic/regions.csv", 31);
            LogicDataTables.Load("csv/client_globals.csv", 32);
            LogicDataTables.Load("logic/alliance_badge_layers.csv", 33);
            LogicDataTables.Load("logic/alliance_levels.csv", 34);
            // LogicDataTables.Load("csv/helpshift.csv", 35);
            LogicDataTables.Load("logic/variables.csv", 36);
            LogicDataTables.Load("logic/gem_bundles.csv", 37);
            LogicDataTables.Load("logic/village_objects.csv", 38);
            LogicDataTables.Load("logic/calendar_event_functions.csv", 39);
            LogicDataTables.Load("csv/boombox.csv", 40);
            LogicDataTables.Load("csv/event_entries.csv", 41);
            LogicDataTables.Load("csv/deeplinks.csv", 42);
            LogicDataTables.Load("logic/leagues2.csv", 43);

            LogicDataTables._globals       = new LogicGlobals();
            LogicDataTables._clientGlobals = new LogicClientGlobals();

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

            LogicDataTable buildingDataTable = LogicDataTables._dataTables[0];

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

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

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

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

            LogicDataTables._bowData                = LogicDataTables.GetBuildingByName("Bow");
            LogicDataTables._darkTowerData          = LogicDataTables.GetBuildingByName("Dark Tower");
            LogicDataTables._ancientArtilleryData   = LogicDataTables.GetBuildingByName("Ancient Artillery");
            LogicDataTables._workerData             = LogicDataTables.GetBuildingByName("Worker Building");
            LogicDataTables._laboratoryVillage2Data = LogicDataTables.GetBuildingByName("Laboratory2");
            LogicDataTables._diamondsData           = LogicDataTables.GetResourceByName("Diamonds");
            LogicDataTables._goldData               = LogicDataTables.GetResourceByName("Gold");
            LogicDataTables._elixirData             = LogicDataTables.GetResourceByName("Elixir");
            LogicDataTables._darkElixirData         = LogicDataTables.GetResourceByName("DarkElixir");
            LogicDataTables._gold2Data              = LogicDataTables.GetResourceByName("Gold2");
            LogicDataTables._elixir2Data            = LogicDataTables.GetResourceByName("Elixir2");
            LogicDataTables._warGoldData            = LogicDataTables.GetResourceByName("WarGold");
            LogicDataTables._warElixirData          = LogicDataTables.GetResourceByName("WarElixir");
            LogicDataTables._warDarkElixirData      = LogicDataTables.GetResourceByName("WarDarkElixir");
            LogicDataTables._skeletonData           = LogicDataTables.GetCharacterByName("Skeleton");
            LogicDataTables._ballonSkeletonData     = LogicDataTables.GetCharacterByName("Balloon Skeleton");

            LogicDataTables._globals.CreateReferences();
            LogicDataTables._clientGlobals.CreateReferences();
        }
Exemple #3
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
            }
        }
 /// <summary>
 ///     Gets the unlocked building gearup count.
 /// </summary>
 public int GetUnlockedBuildingGearupCount(LogicBuildingData data)
 {
     return(this._buildingGearupCaps[data.GetInstanceID()]);
 }
Exemple #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()));
        }
Exemple #6
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);
        }