Exemple #1
0
        public override void DeathEvent()
        {
            LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();
            LogicCharacterData     data = this.GetCharacterData();

            if (hitpointComponent != null && hitpointComponent.GetTeam() == 1 && !this.IsHero() && !data.IsSecondaryTroop() &&
                this.m_level.GetVillageType() == 0 && this.m_allianceUnit)
            {
                LogicAvatar homeOwnerAvatar = this.m_level.GetHomeOwnerAvatar();

                homeOwnerAvatar.RemoveAllianceUnit(data, this.m_upgradeLevel);
                homeOwnerAvatar.GetChangeListener().AllianceUnitRemoved(data, this.m_upgradeLevel);
            }

            if (data.GetSpecialAbilityType() != LogicCharacterData.SPECIAL_ABILITY_TYPE_RESPAWN_AS_CANNON ||
                data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0)
            {
                if (data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_SPAWN_UNITS)
                {
                    if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) > 0)
                    {
                        this.CheckSpawning(null, data.GetSpecialAbilityAttribute(this.m_upgradeLevel), 0, 0);
                    }
                }
                else if (data.GetSecondaryTroop() != null)
                {
                    this.CheckSpawning(null, 0, 0, 0);
                }
            }
            else if (!this.m_ejected)
            {
                this.CheckSpawning(LogicDataTables.GetCharacterByName("MovingCannonSecondary", null), 1, data.GetSpecialAbilityAttribute(this.m_upgradeLevel), 500);
            }

            this.AddTombstoneIfNeeded();

            if (this.m_parent != null)
            {
                this.m_parent.RemoveChildren(this);
                this.m_parent = null;
            }

            base.DeathEvent();
        }
Exemple #2
0
        public bool GetSpecialAbilityAvailable()
        {
            LogicCharacterData data = this.GetCharacterData();

            if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0)
            {
                return(false);
            }

            switch (data.GetSpecialAbilityType())
            {
            case LogicCharacterData.SPECIAL_ABILITY_TYPE_BIG_FIRST_HIT:
                return(this.GetCombatComponent().GetHitCount() <= 0);

            case LogicCharacterData.SPECIAL_ABILITY_TYPE_SPECIAL_PROJECTILE:
                return(this.GetCombatComponent().GetHitCount() < data.GetSpecialAbilityAttribute(this.m_upgradeLevel));
            }

            return(true);
        }
Exemple #3
0
        public void CheckDieDamage(int damage, int radius)
        {
            LogicCharacterData data = (LogicCharacterData)this.m_data;

            if (data.GetSpecialAbilityType() == LogicCharacterData.SPECIAL_ABILITY_TYPE_DIE_DAMAGE)
            {
                if (data.GetSpecialAbilityLevel(this.m_upgradeLevel) <= 0)
                {
                    return;
                }
            }

            if (damage > 0 && radius > 0)
            {
                LogicHitpointComponent hitpointComponent = this.GetHitpointComponent();

                if (hitpointComponent != null)
                {
                    this.m_level.AreaDamage(0, this.GetX(), this.GetY(), radius, damage, null, 0, null, hitpointComponent.GetTeam(), null, 1, 0, 0, true, false, 100,
                                            0, this, 100, 0);
                }
            }
        }
Exemple #4
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();
                    }
                }
            }
        }
Exemple #5
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);
        }