Beispiel #1
0
        /// <summary>
        /// Initializes the <see cref="Globals"/> class.
        /// </summary>
        internal static void Init()
        {
            if (Globals.Initialized)
            {
                return;
            }

            Globals.StartingGold          = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_GOLD")).NumberValue;
            Globals.StartingDiamonds      = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_DIAMONDS")).NumberValue;
            Globals.EnergyRegenateSeconds = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("ENERGY_REGENERATE_SECONDS")).NumberValue;

            Globals.StartingCharacter = (LogicHeroData)CSV.Tables.Get(Gamefile.Heroes).GetDataByName(((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_CHARACTER")).TextValue);
            Globals.StartingQuest     = (LogicQuestData)CSV.Tables.Get(Gamefile.Quests).GetDataByName(((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_QUEST")).TextValue);

            Globals.SpeedUpDiamondCost1Min    = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_1_MIN")).NumberValue;
            Globals.SpeedUpDiamondCost1Hour   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_1_HOUR")).NumberValue;
            Globals.SpeedUpDiamondCost24Hours = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_24_HOURS")).NumberValue;
            Globals.SpeedUpDiamondCost1Week   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_1_WEEK")).NumberValue;

            Globals.ResourceDiamondCost10      = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_10")).NumberValue;
            Globals.ResourceDiamondCost100     = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_100")).NumberValue;
            Globals.ResourceDiamondCost1000    = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_1000")).NumberValue;
            Globals.ResourceDiamondCost10000   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_10000")).NumberValue;
            Globals.ResourceDiamondCost50000   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_50000")).NumberValue;
            Globals.ResourceDiamondCost100000  = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_100000")).NumberValue;
            Globals.ResourceDiamondCost500000  = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_500000")).NumberValue;
            Globals.ResourceDiamondCost1000000 = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_1000000")).NumberValue;

            LogicCharacters.Init();
            LogicQuests.Init();

            Globals.Initialized = true;
        }
        internal override void Decode()
        {
            this.Item = this.Stream.ReadDataReference <LogicItemsData>();
            this.Hero = this.Stream.ReadDataReference <LogicHeroData>();

            this.ReadHeader();
        }
        public override void LoadFromJSON(LogicJSONObject jsonRoot)
        {
            LogicJSONObject baseObject = jsonRoot.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("Replay LogicPlaceHeroCommand load failed! Base missing!");
            }

            base.LoadFromJSON(baseObject);

            LogicJSONNumber dataNumber = jsonRoot.GetJSONNumber("d");

            if (dataNumber != null)
            {
                this.m_data = (LogicHeroData)LogicDataTables.GetDataById(dataNumber.GetIntValue(), LogicDataType.HERO);
            }

            if (this.m_data == null)
            {
                Debugger.Error("Replay LogicPlaceHeroCommand load failed! Hero is NULL!");
            }

            this.m_x = jsonRoot.GetJSONNumber("x").GetIntValue();
            this.m_y = jsonRoot.GetJSONNumber("y").GetIntValue();
        }
        public static LogicCharacter PlaceHero(LogicHeroData data, LogicLevel level, int x, int y, int hitpoints, int upgLevel)
        {
            LogicCharacter character = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(data, level, level.GetVillageType());

            character.SetUpgradeLevel(upgLevel);
            character.GetHitpointComponent().SetHitpoints(hitpoints);
            character.SetInitialPosition(x, y);

            if (data.IsJumper())
            {
                character.GetMovementComponent().EnableJump(3600000);
                character.GetCombatComponent().RefreshTarget(true);
            }

            level.GetGameObjectManager().AddGameObject(character, -1);
            level.GetGameListener().AttackerPlaced(data);

            LogicBattleLog battleLog = level.GetBattleLog();

            if (battleLog != null)
            {
                battleLog.IncrementDeployedAttackerUnits(data, 1);
                battleLog.SetCombatItemLevel(data, upgLevel);
            }

            return(character);
        }
Beispiel #5
0
 /// <summary>
 /// Starts upgrading the specified hero.
 /// </summary>
 internal void Start(LogicHeroData hero)
 {
     if (this.CanUpgrade(hero))
     {
         this.HeroData = hero.GlobalID;
         this.Timer.StartTimer(this.Avatar.Time, hero.UpgradeTimeSeconds[this.Avatar.HeroLevels.GetCount(hero.GlobalID)]);
     }
 }
        public override void Decode(ByteStream stream)
        {
            this.m_x    = stream.ReadInt();
            this.m_y    = stream.ReadInt();
            this.m_data = (LogicHeroData)ByteStreamHelper.ReadDataReference(stream, LogicDataType.HERO);

            base.Decode(stream);
        }
        public static float GetHeroStrength(LogicHeroData data, int upgLevel, bool useHeroStrengthWeight)
        {
            if (data.IsProductionEnabled())
            {
                float startStrength = data.GetHitpoints(upgLevel) * 0.04f + data.GetAttackerItemData(upgLevel).GetDamagePerMS(0, false) * 0.2f;
                return(startStrength * 0.1f * (useHeroStrengthWeight ? data.GetStrengthWeight2(upgLevel) : data.GetStrengthWeight(upgLevel)));
            }

            return(0f);
        }
Beispiel #8
0
        /// <summary>
        /// Determines whether the specified hero can be upgraded.
        /// </summary>
        internal bool CanUpgrade(LogicHeroData hero)
        {
            if (!this.Upgrading)
            {
                if (this.Avatar.HeroLevels.ContainsKey(hero.GlobalID))
                {
                    return(hero.Cost.Count > this.Avatar.HeroLevels[hero.GlobalID].Count + 1);
                }
            }

            return(false);
        }
        public void UpdateHeroHealthToAvatar(int hitpoint)
        {
            LogicAvatar   avatar = this.m_team == 1 ? this.m_parent.GetLevel().GetHomeOwnerAvatar() : this.m_parent.GetLevel().GetVisitorAvatar();
            LogicHeroData data   = null;

            int upgLevel = 0;

            if (this.m_parent.IsHero())
            {
                LogicCharacter character = (LogicCharacter)this.m_parent;

                data     = (LogicHeroData)character.GetCharacterData();
                upgLevel = character.GetUpgradeLevel();
            }
            else if (this.m_parent.GetGameObjectType() == LogicGameObjectType.BUILDING)
            {
                LogicBuilding          building          = (LogicBuilding)this.m_parent;
                LogicHeroBaseComponent heroBaseComponent = building.GetHeroBaseComponent();

                if (heroBaseComponent == null)
                {
                    return;
                }

                LogicBuildingData buildingData = building.GetBuildingData();

                if (!buildingData.GetShareHeroCombatData())
                {
                    return;
                }

                LogicCombatComponent combatComponent = building.GetCombatComponent();

                if (combatComponent == null || !combatComponent.IsEnabled())
                {
                    return;
                }

                data     = buildingData.GetHeroData();
                upgLevel = avatar.GetUnitUpgradeLevel(data);
            }

            if (data != null)
            {
                int secs = LogicMath.Min(data.GetSecondsToFullHealth(hitpoint, upgLevel), data.GetFullRegenerationTimeSec(upgLevel));

                if (avatar != null)
                {
                    avatar.GetChangeListener().CommodityCountChanged(0, data, secs);
                    avatar.SetHeroHealth(data, secs);
                }
            }
        }
Beispiel #10
0
        internal override void Decode()
        {
            for (int i = 0; i < 3; i++)
            {
                LogicHeroData hero = this.Stream.ReadDataReference <LogicHeroData>();

                if (hero != null)
                {
                    this.Connection.Avatar.Sailing.Heroes.AddItem(hero.GlobalID, 1);
                    this.Connection.Avatar.Sailing.HeroLevels.AddItem(hero.GlobalID, this.Connection.Avatar.HeroLevels.GetCount(hero.GlobalID));
                }
            }

            this.ReadHeader();
        }
Beispiel #11
0
        public void StartAbility()
        {
            if (this.IsHero())
            {
                LogicHeroData heroData = (LogicHeroData)this.m_data;

                this.m_abilityCooldown    = 60 * heroData.GetAbilityCooldown() / 4000;
                this.m_abilityTriggerTime = 5;
                this.m_abilityTime        = 60 * heroData.GetAbilityTime(this.m_upgradeLevel) / 20000;
                this.m_summonSpawnCount   = 0;

                this.GetHitpointComponent().CauseDamage(-100 * heroData.GetAbilityHealthIncrease(this.m_upgradeLevel), 0, this);

                this.m_abilityAttackCount = this.GetCombatComponent().GetHitCount() + heroData.GetAbilityAttackCount(this.m_upgradeLevel);

                if (heroData.GetAbilityDelay() > 0)
                {
                    this.GetCombatComponent().SetAttackDelay(0, heroData.GetAbilityDelay());
                    // Listener.
                }

                LogicSpellData abilitySpellData = heroData.GetAbilitySpell(this.m_upgradeLevel);

                if (abilitySpellData != null)
                {
                    this.m_abilitySpell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(abilitySpellData, this.m_level, this.m_villageType);
                    this.m_abilitySpell.SetUpgradeLevel(heroData.GetAbilitySpellLevel(this.m_upgradeLevel));
                    this.m_abilitySpell.SetInitialPosition(this.GetX(), this.GetY());
                    this.m_abilitySpell.AllowDestruction(false);

                    this.GetGameObjectManager().AddGameObject(this.m_abilitySpell, -1);
                }

                if (heroData.GetActivationTime() > 0)
                {
                    this.m_activationTimeState = 1;
                    this.m_activationTime      = heroData.GetActivationTime();

                    this.GetMovementComponent().GetMovementSystem().SetFreezeTime(this.m_activationTime);
                    this.GetCombatComponent().SetActivationTime(this.m_activationTime);

                    // Listener.
                }

                this.m_abilityUsed = true;
            }
        }
Beispiel #12
0
        public bool IsHeroUnlocked(LogicHeroData data)
        {
            LogicArrayList <LogicComponent> components = this.m_components[(int)LogicComponentType.HERO_BASE];

            for (int i = 0; i < components.Size(); i++)
            {
                LogicHeroBaseComponent component = (LogicHeroBaseComponent)components[i];

                if (component.GetHeroData() == data)
                {
                    LogicBuilding building = (LogicBuilding)component.GetParent();

                    if (!building.IsLocked())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #13
0
        /// <summary>
        /// Initializes the <see cref="Globals"/> class.
        /// </summary>
        internal static void Init()
        {
            if (Globals.Initialized)
            {
                return;
            }

            Globals.StartingGold          = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_GOLD")).NumberValue;
            Globals.StartingDiamonds      = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_DIAMONDS")).NumberValue;
            Globals.EnergyRegenateSeconds = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("ENERGY_REGENERATE_SECONDS")).NumberValue;

            Globals.StartingCharacter = (LogicHeroData)CSV.Tables.Get(Gamefile.Heroes).GetDataByName(((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_CHARACTER")).TextValue);
            Globals.StartingQuest     = (LogicQuestData)CSV.Tables.Get(Gamefile.Quests).GetDataByName(((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("STARTING_QUEST")).TextValue);

            Globals.ShipSailDurationHours = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SHIP_SAIL_DURATION_HOURS")).NumberValue;

            Globals.TeamGoalSeasonDurationHours = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("TEAM_GOAL_SEASON_DURATION_HOURS")).NumberValue;

            Globals.SpeedUpDiamondCost1Min    = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_1_MIN")).NumberValue;
            Globals.SpeedUpDiamondCost1Hour   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_1_HOUR")).NumberValue;
            Globals.SpeedUpDiamondCost24Hours = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_24_HOURS")).NumberValue;
            Globals.SpeedUpDiamondCost1Week   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("SPEED_UP_DIAMOND_COST_1_WEEK")).NumberValue;

            Globals.ResourceDiamondCost10      = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_10")).NumberValue;
            Globals.ResourceDiamondCost100     = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_100")).NumberValue;
            Globals.ResourceDiamondCost1000    = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_1000")).NumberValue;
            Globals.ResourceDiamondCost10000   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_10000")).NumberValue;
            Globals.ResourceDiamondCost50000   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_50000")).NumberValue;
            Globals.ResourceDiamondCost100000  = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_100000")).NumberValue;
            Globals.ResourceDiamondCost500000  = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_500000")).NumberValue;
            Globals.ResourceDiamondCost1000000 = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("RESOURCE_DIAMOND_COST_1000000")).NumberValue;

            Globals.PVPFirstTurnTimeSeconds = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("PVP_FIRST_TURN_MAX_TURN_TIME_SECONDS")).NumberValue;
            Globals.PVPMaxTurnTimeSeconds   = ((LogicGlobalData)CSV.Tables.Get(Gamefile.Globals).GetDataByName("PVP_MAX_TURN_TIME_SECONDS")).NumberValue;

            LogicCharacters.Init();
            LogicQuests.Init();

            Globals.Initialized = true;
        }
        public override int Execute(LogicLevel level)
        {
            LogicBuilding building = (LogicBuilding)level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId);

            if (!building.IsLocked())
            {
                if (building.GetBuildingData().GetVillageType() == level.GetVillageType())
                {
                    LogicHeroBaseComponent heroBaseComponent = building.GetHeroBaseComponent();

                    if (heroBaseComponent != null && heroBaseComponent.CanStartUpgrading(true))
                    {
                        LogicClientAvatar playerAvatar = level.GetPlayerAvatar();
                        LogicHeroData     heroData     = building.GetBuildingData().GetHeroData();
                        int upgLevel    = playerAvatar.GetUnitUpgradeLevel(heroData);
                        int upgradeCost = heroData.GetUpgradeCost(upgLevel);
                        LogicResourceData upgradeResourceData = heroData.GetUpgradeResource(upgLevel);

                        if (playerAvatar.HasEnoughResources(upgradeResourceData, upgradeCost, true, this, false))
                        {
                            if (level.HasFreeWorkers(this, -1))
                            {
                                playerAvatar.CommodityCountChangeHelper(0, upgradeResourceData, -upgradeCost);
                                heroBaseComponent.StartUpgrading();

                                return(0);
                            }
                        }
                    }

                    return(-1);
                }

                return(-32);
            }

            return(-23);
        }
Beispiel #15
0
    protected override bool ParseConfig()
    {
        try
        {
            HeroLogicData = new Dictionary <int, LogicHeroData>();

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(m_XmlString);
            XmlNode root = doc.LastChild;
            foreach (XmlNode hero in root.ChildNodes)
            {
                LogicHeroData hd = new LogicHeroData();
                foreach (XmlNode attr in hero.ChildNodes)
                {
                    if (attr.Name == "id")
                    {
                        hd.id = int.Parse(attr.InnerText);
                    }
                    else if (attr.Name == "idle_time")
                    {
                        hd.idle_time = float.Parse(attr.InnerText);
                    }
                    else if (attr.Name == "empower_time")
                    {
                        hd.empower_time = float.Parse(attr.InnerText);
                    }
                    else if (attr.Name == "attack_time")
                    {
                        hd.attack_time = float.Parse(attr.InnerText);
                    }
                    else if (attr.Name == "max_hp")
                    {
                        hd.max_hp = int.Parse(attr.InnerText);
                    }
                    else if (attr.Name == "hp_recover")
                    {
                        hd.hp_recover_rate = int.Parse(attr.InnerText);
                    }
                    else if (attr.Name == "Skills")
                    {
                        hd.skills = new List <int>();
                        foreach (XmlNode sid in attr.ChildNodes)
                        {
                            hd.skills.Add(int.Parse(sid.InnerText));
                        }
                    }
                }
                if (HeroLogicData.ContainsKey(hd.id))
                {
                    m_Error += string.Format("Hero id {0} repeated \n", hd.id);
                }

                HeroLogicData[hd.id] = hd;
            }
            return(true);
        }
        catch (System.Exception ex) {
            m_Error = ex.ToString();
            return(true);
        }
    }
Beispiel #16
0
        internal override void Execute()
        {
            if (this.Data != null)
            {
                if (this.DataType == 0)
                {
                    LogicTauntData taunt = (LogicTauntData)this.Data;

                    if (!this.Connection.Avatar.Extras.ContainsKey(taunt.GlobalID))
                    {
                        if (!string.IsNullOrEmpty(taunt.CharacterUnlock))
                        {
                            LogicHeroData hero = (LogicHeroData)CSV.Tables.Get(Gamefile.Heroes).GetDataByName(taunt.CharacterUnlock);

                            if (!this.Connection.Avatar.HeroLevels.ContainsKey(hero.GlobalID))
                            {
                                Debugger.Error($"Unable to buy the taunt. {this.Connection.Avatar.Name} ({this.Connection.Avatar}) doesn't have the hero {taunt.CharacterUnlock}.");
                                return;
                            }
                        }

                        if (taunt.Cost > 0)
                        {
                            LogicResourceData resource = (LogicResourceData)CSV.Tables.Get(Gamefile.Resources).GetDataByName(taunt.Resource);

                            if (this.Connection.Avatar.Resources.GetCount(resource.GlobalID) < taunt.Cost)
                            {
                                Debugger.Error($"Unable to buy the taunt. {this.Connection.Avatar.Name} does not have enough {taunt.Resource}. {taunt.Resource} : {this.Connection.Avatar.Resources.GetCount(resource.GlobalID)}, Require : {taunt.Cost}.");
                                return;
                            }

                            this.Connection.Avatar.Resources.Remove(resource.GlobalID, taunt.Cost);
                        }

                        this.Connection.Avatar.Extras.Set(taunt.GlobalID, 1);
                    }
                }
                else
                {
                    LogicDecoData deco = (LogicDecoData)this.Data;

                    if (!this.Connection.Avatar.Extras.ContainsKey(deco.GlobalID))
                    {
                        if (deco.UnlockLevel > this.Connection.Avatar.ExpLevel)
                        {
                            Debugger.Error($"Unable to buy the deco. {this.Connection.Avatar.Name} ({this.Connection.Avatar}) is not at the required level.");
                            return;
                        }

                        if (deco.Cost > 0)
                        {
                            LogicResourceData resource = (LogicResourceData)CSV.Tables.Get(Gamefile.Resources).GetDataByName(deco.Resource);

                            if (this.Connection.Avatar.Resources.GetCount(resource.GlobalID) < deco.Cost)
                            {
                                Debugger.Error($"Unable to buy the deco. {this.Connection.Avatar.Name} ({this.Connection.Avatar}) does not have enough {deco.Resource}. ({deco.Resource} : {this.Connection.Avatar.Resources.GetCount(resource.GlobalID)}, Require : {deco.Cost}.");
                                return;
                            }

                            this.Connection.Avatar.Resources.Remove(resource.GlobalID, deco.Cost);
                        }

                        this.Connection.Avatar.Extras.Set(deco.GlobalID, 2);

                        if (this.Connection.Avatar.Extras.Count > 1)
                        {
                            foreach (Item item in this.Connection.Avatar.Extras.Values)
                            {
                                if (item.Id / 1000000 == deco.GetDataType())
                                {
                                    if (item.Count != 1 && item.Id != deco.GlobalID)
                                    {
                                        item.Count = 1;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (this.Connection.Avatar.Extras.GetCount(deco.GlobalID) == 1)
                        {
                            this.Connection.Avatar.Extras.Set(deco.GlobalID, 2);

                            foreach (Item item in this.Connection.Avatar.Extras.Values)
                            {
                                if (item.Id / 1000000 == deco.GetDataType())
                                {
                                    if (item.Count != 1 && item.Id != deco.GlobalID)
                                    {
                                        item.Count = 1;
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.Connection.Avatar.Extras.Set(deco.GlobalID, 1);
                        }
                    }
                }
            }
            else
            {
                Debugger.Error("Unable to buy the extra. Data is null.");
            }
        }
 public override void Destruct()
 {
     base.Destruct();
     this.m_data = null;
 }
        /// <summary>
        /// Creates the data for the specified row.
        /// </summary>
        internal LogicData Create(Row row)
        {
            LogicData data;

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

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

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

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

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

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

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

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

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

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

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

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

            case 24:
            {
                data = new LogicTauntData(row, this);
                break;
            }

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

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

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

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

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

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

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

            default:
            {
                data = new LogicData(row, this);
                break;
            }
            }

            return(data);
        }
Beispiel #19
0
        public void SetUpgradeLevel(int upgLevel)
        {
            this.m_upgradeLevel = upgLevel;

            LogicCharacterData     data = this.GetCharacterData();
            LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();
            LogicCombatComponent   combatComponent   = this.GetCombatComponent();

            int hp = data.GetHitpoints(upgLevel);
            int damagePercentage = 100;

            if (data.GetScaleByTH())
            {
                LogicAvatar avatar = this.m_level.GetHomeOwnerAvatar();

                if (hitpointComponent != null && hitpointComponent.GetTeam() == 0)
                {
                    avatar = this.m_level.GetVisitorAvatar();
                }

                int tmp1 = 700 * avatar.GetTownHallLevel() / (LogicDataTables.GetTownHallLevelCount() - 1);

                damagePercentage = tmp1 / 10 + 30;
                hp = damagePercentage * hp / 100;

                if (damagePercentage * hp < 200)
                {
                    hp = 1;
                }

                if (tmp1 < -289)
                {
                    damagePercentage = 1;
                }
            }

            hitpointComponent.SetMaxHitpoints(hp);
            hitpointComponent.SetHitpoints(data.GetHitpoints(upgLevel));
            hitpointComponent.SetDieEffect(data.GetDieEffect(upgLevel), data.GetDieEffect2(upgLevel));

            if (combatComponent != null)
            {
                combatComponent.SetAttackValues(data.GetAttackerItemData(upgLevel), damagePercentage);
            }

            if (this.m_childrens != null)
            {
                for (int i = 0; i < this.m_childrens.Size(); i++)
                {
                    this.m_childrens[i].SetUpgradeLevel(upgLevel);
                }
            }

            if (this.IsHero())
            {
                LogicHeroData heroData = (LogicHeroData)this.m_data;
                LogicAvatar   avatar   = this.m_level.GetHomeOwnerAvatar();

                if (hitpointComponent.GetTeam() == 0)
                {
                    avatar = this.m_level.GetVisitorAvatar();
                }

                this.m_flying = heroData.IsFlying(avatar.GetHeroMode(heroData));
                this.GetMovementComponent().SetFlying(this.m_flying);
            }

            if (data.GetAutoMergeDistance() > 0)
            {
                this.m_autoMergeTime = 2000;
            }

            int speed = data.GetSpeed();

            if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) > 0 &&
                data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_SPEED_BOOST)
            {
                speed = speed * data.GetSpecialAbilityAttribute(this.m_upgradeLevel) / 100;
            }

            this.GetMovementComponent().SetSpeed(speed);
        }
Beispiel #20
0
        public override void Tick()
        {
            base.Tick();

            LogicCharacterData data = this.GetCharacterData();

            if (!this.IsAlive())
            {
                if (!this.IsHero())
                {
                    int dieDamageDelay = this.GetCharacterData().GetDieDamageDelay();
                    int prevDieTime    = this.m_dieTime;

                    this.m_dieTime += 64;

                    if (dieDamageDelay >= prevDieTime && dieDamageDelay < this.m_dieTime && (!this.m_duplicate || this.m_duplicateLifeTime >= 0))
                    {
                        this.CheckDieDamage(data.GetDieDamage(this.m_upgradeLevel), data.GetDieDamageRadius());
                        this.m_level.UpdateBattleStatus();
                    }
                }

                this.m_spawnTime     = 0;
                this.m_spawnIdleTime = 0;

                if (this.m_auraSpell != null)
                {
                    this.GetGameObjectManager().RemoveGameObject(this.m_auraSpell);
                    this.m_auraSpell = null;
                }

                if (this.m_abilitySpell != null)
                {
                    this.GetGameObjectManager().RemoveGameObject(this.m_abilitySpell);
                    this.m_abilitySpell = null;
                }

                if (this.m_retributionSpell != null)
                {
                    this.GetGameObjectManager().RemoveGameObject(this.m_retributionSpell);
                    this.m_retributionSpell = null;
                }
            }
            else
            {
                if (data.GetLoseHpPerTick() > 0)
                {
                    this.m_loseHpTime += 64;

                    if (this.m_loseHpTime > data.GetLoseHpInterval())
                    {
                        LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();

                        if (hitpointComponent != null)
                        {
                            hitpointComponent.CauseDamage(100 * data.GetLoseHpPerTick(), this.m_globalId, this);
                            // Listener.
                        }

                        this.m_loseHpTime = 0;
                    }
                }

                if (data.GetAttackCount(this.m_upgradeLevel) > 0 && this.GetCombatComponent() != null && this.GetHitpointComponent() != null &&
                    this.GetCombatComponent().GetHitCount() >= data.GetAttackCount(this.m_upgradeLevel))
                {
                    this.GetHitpointComponent().Kill();
                }

                this.m_spawnTime     = LogicMath.Max(this.m_spawnTime - 64, 0);
                this.m_spawnIdleTime = LogicMath.Max(this.m_spawnIdleTime - 64, 0);

                if (this.m_spawnTime == 0 && this.m_hasSpawnDelay)
                {
                    this.m_spawnIdleTime = LogicMath.Max(10, data.GetSpawnIdle());
                    this.m_hasSpawnDelay = false;
                }

                if (data.GetBoostedIfAlone() || data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_RAGE_ALONE && this.GetSpecialAbilityAvailable())
                {
                    if (++this.m_rageAloneTime >= 5)
                    {
                        this.m_level.AreaBoostAlone(this, 6);
                        this.m_rageAloneTime = 0;
                    }
                }

                if (this.IsHero())
                {
                    LogicHeroData heroData = (LogicHeroData)data;

                    if (this.m_abilityTime > 0)
                    {
                        if (heroData.GetAbilityAttackCount(this.m_upgradeLevel) > 0 && this.GetCombatComponent().GetHitCount() >= this.m_abilityAttackCount)
                        {
                            Debugger.HudPrint("Hero ability: No more attacks left!");

                            this.m_abilityTime        = 0;
                            this.m_abilityTriggerTime = 0;
                            this.m_activationTime     = 0;
                        }
                        else
                        {
                            if (++this.m_abilityTriggerTime >= 5)
                            {
                                this.m_abilityTime       -= 1;
                                this.m_abilityTriggerTime = 0;

                                this.m_level.AreaAbilityBoost(this, 5);
                            }
                        }
                    }

                    if (this.m_abilityCooldown > 0)
                    {
                        this.m_abilityCooldown -= 1;
                    }

                    if (this.m_abilitySpell != null && this.m_abilitySpell.GetHitsCompleted())
                    {
                        this.GetGameObjectManager().RemoveGameObject(this.m_abilitySpell);
                        this.m_abilitySpell = null;
                    }
                }

                if (this.m_auraSpell == null || this.m_auraSpell.GetHitsCompleted())
                {
                    if (this.m_auraSpell != null)
                    {
                        this.GetGameObjectManager().RemoveGameObject(this.m_auraSpell);
                        this.m_auraSpell = null;
                    }

                    if (data.GetAuraSpell(this.m_upgradeLevel) != null)
                    {
                        LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();

                        if (hitpointComponent != null && hitpointComponent.GetTeam() == 0)
                        {
                            this.m_auraSpell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(data.GetAuraSpell(this.m_upgradeLevel), this.m_level, this.m_villageType);
                            this.m_auraSpell.SetUpgradeLevel(data.GetAuraSpellLevel(this.m_upgradeLevel));
                            this.m_auraSpell.SetInitialPosition(this.GetX(), this.GetY());
                            this.m_auraSpell.AllowDestruction(false);
                            this.m_auraSpell.SetTeam(hitpointComponent.GetTeam());

                            this.GetGameObjectManager().AddGameObject(this.m_auraSpell, -1);
                        }
                    }
                }

                if (!this.m_retributionSpellCreated)
                {
                    if (data.GetRetributionSpell(this.m_upgradeLevel) != null)
                    {
                        LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();

                        if (hitpointComponent.GetHitpoints() <=
                            hitpointComponent.GetMaxHitpoints() * data.GetRetributionSpellTriggerHealth(this.m_upgradeLevel) / 100)
                        {
                            this.m_retributionSpellCreated = true;
                            this.m_retributionSpell        =
                                (LogicSpell)LogicGameObjectFactory.CreateGameObject(data.GetRetributionSpell(this.m_upgradeLevel), this.m_level, this.m_villageType);
                            this.m_retributionSpell.SetUpgradeLevel(data.GetRetributionSpellLevel(this.m_upgradeLevel));
                            this.m_retributionSpell.SetPositionXY(this.GetX(), this.GetY());
                            this.m_retributionSpell.AllowDestruction(false);
                            this.m_retributionSpell.SetTeam(hitpointComponent.GetTeam());

                            this.GetGameObjectManager().AddGameObject(this.m_retributionSpell, -1);
                        }
                    }
                }

                if (this.m_activationTimeState == 2)
                {
                    this.m_activationTime -= 64;

                    if (this.m_activationTime < 0)
                    {
                        this.m_activationTimeState = 0;
                        this.m_activationTime      = 0;
                    }
                }
                else if (this.m_activationTimeState == 1)
                {
                    this.m_activationTime -= 64;

                    if (this.m_activationTime < 0)
                    {
                        this.m_activationTimeState = 2;
                        this.m_activationTime      = ((LogicHeroData)this.m_data).GetActiveDuration();
                    }
                }
            }

            this.CheckSummons();

            if (this.IsAlive())
            {
                if (data.GetAutoMergeDistance() > 0)
                {
                    this.m_autoMergeTime = LogicMath.Max(this.m_autoMergeTime - 64, 0);
                }

                if (data.GetInvisibilityRadius() > 0)
                {
                    this.m_level.AreaInvisibility(this.GetMidX(), this.GetMidY(), data.GetInvisibilityRadius(), 4, this.GetHitpointComponent().GetTeam());
                }

                if (data.GetHealthReductionPerSecond() > 0)
                {
                    this.GetHitpointComponent().CauseDamage(100 * data.GetHealthReductionPerSecond() / 15, 0, this);
                }
            }

            if (this.m_duplicate)
            {
                if (this.m_duplicateLifeTime-- <= 0)
                {
                    LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();

                    if (hitpointComponent != null)
                    {
                        hitpointComponent.SetHitpoints(0);
                        this.m_level.UpdateBattleStatus();
                    }
                }
            }
        }
 public LogicHeroBaseComponent(LogicGameObject gameObject, LogicHeroData data) : base(gameObject)
 {
     this.m_hero = data;
 }