示例#1
0
        public static LogicGameObject CreateGameObject(LogicGameObjectData data, LogicLevel level, int villageType)
        {
            LogicGameObject gameObject = null;

            switch (data.GetDataType())
            {
            case LogicDataType.BUILDING:
                gameObject = new LogicBuilding(data, level, villageType);
                break;

            case LogicDataType.CHARACTER:
            case LogicDataType.HERO:
                gameObject = new LogicCharacter(data, level, villageType);
                break;

            case LogicDataType.PROJECTILE:
                gameObject = new LogicProjectile(data, level, villageType);
                break;

            case LogicDataType.OBSTACLE:
                gameObject = new LogicObstacle(data, level, villageType);
                break;

            case LogicDataType.TRAP:
                gameObject = new LogicTrap(data, level, villageType);
                break;

            case LogicDataType.ALLIANCE_PORTAL:
                gameObject = new LogicAlliancePortal(data, level, villageType);
                break;

            case LogicDataType.DECO:
                gameObject = new LogicDeco(data, level, villageType);
                break;

            case LogicDataType.SPELL:
                gameObject = new LogicSpell(data, level, villageType);
                break;

            case LogicDataType.VILLAGE_OBJECT:
                gameObject = new LogicVillageObject(data, level, villageType);
                break;

            default:
            {
                Debugger.Warning("Trying to create game object with data that does not inherit LogicGameObjectData. GlobalId=" + data.GetGlobalID());
                break;
            }
            }

            return(gameObject);
        }
示例#2
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;
            }
        }
示例#3
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();
                    }
                }
            }
        }
示例#4
0
        public void TargetReached(int damagePercent)
        {
            this.m_damageTime = this.GetProjectileData().GetDamageDelay();
            this.UpdateDamage(damagePercent);
            this.m_targetReached = true;

            if (!this.m_dummy)
            {
                if (this.m_hitEffect != null)
                {
                    if (this.m_target != null)
                    {
                        LogicHitpointComponent hitpointComponent = this.m_target.GetHitpointComponent();

                        if (hitpointComponent != null)
                        {
                            if (!this.m_bounceProjectile)
                            {
                                // Listener.
                            }
                        }
                    }
                    else if (!this.m_penetrating && this.m_shockwavePushStrength == 0)
                    {
                        // Listener.
                    }
                }

                if (this.m_hitEffect2 != null)
                {
                    if (this.m_target != null)
                    {
                        LogicHitpointComponent hitpointComponent = this.m_target.GetHitpointComponent();

                        if (hitpointComponent != null)
                        {
                            if (!this.m_bounceProjectile)
                            {
                                // Listener.
                            }
                        }
                    }
                    else if (!this.m_penetrating && this.m_shockwavePushStrength == 0)
                    {
                        // Listener.
                    }
                }

                if (this.m_target != null)
                {
                    if (this.m_bounceCount > 0)
                    {
                        this.m_bounceTargets[this.m_bounceCount - 1] = this.m_target;
                        this.UpdateBounces();
                    }
                }

                LogicSpellData hitSpell = this.GetProjectileData().GetHitSpell();

                if (hitSpell != null)
                {
                    LogicSpell spell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(hitSpell, this.m_level, this.m_villageType);

                    spell.SetUpgradeLevel(this.GetProjectileData().GetHitSpellLevel());
                    spell.SetInitialPosition(this.GetMidX(), this.GetMidY());
                    spell.SetTeam(1);

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

                if (this.m_bounceProjectile)
                {
                    int idx = -1;

                    for (int i = 0; i < LogicProjectile.MAX_BOUNCES; i++)
                    {
                        if (this.m_bouncePositions[i] != null)
                        {
                            idx = i;
                            break;
                        }
                    }

                    if (idx != -1)
                    {
                        LogicVector2 bouncePosition = this.m_bouncePositions[idx];

                        this.m_bouncePositions[idx] = null;
                        this.m_target = null;

                        LogicEffectData bounceEffect = this.GetProjectileData().GetBounceEffect();

                        if (bounceEffect != null)
                        {
                            this.m_listener.PlayEffect(bounceEffect);
                        }

                        this.m_targetPosition.m_x = 8 * bouncePosition.m_x;
                        this.m_targetPosition.m_y = 8 * bouncePosition.m_y;

                        this.m_randomHitRange = this.m_flyingTarget ? 1000 : 0;

                        // Listener.

                        this.m_targetReached = false;
                        this.m_travelTime    = 0;

                        bouncePosition.Destruct();
                    }
                    else
                    {
                        this.m_target = null;
                    }
                }

                if (this.m_targetReached)
                {
                    LogicEffectData destroyedEffect = this.GetProjectileData().GetDestroyedEffect();

                    if (destroyedEffect != null)
                    {
                        // Listener.
                    }
                }
            }
        }
        public override void Tick()
        {
            base.Tick();

            if (this.m_constructionTimer != null)
            {
                if (this.m_level.GetRemainingClockTowerBoostTime() > 0 &&
                    this.m_data.GetVillageType() == 1)
                {
                    this.m_constructionTimer.SetFastForward(this.m_constructionTimer.GetFastForward() + 4 * LogicDataTables.GetGlobals().GetClockTowerBoostMultiplier() - 4);
                }

                if (this.m_constructionTimer.GetRemainingSeconds(this.m_level.GetLogicTime()) <= 0)
                {
                    this.FinishConstruction(false);
                }
            }

            if (this.m_disarmed)
            {
                if (this.m_fadeTime >= 0)
                {
                    this.m_fadeTime = LogicMath.Min(this.m_fadeTime + 64, 1000);
                }
            }

            LogicTriggerComponent triggerComponent = this.GetTriggerComponent();

            if (triggerComponent.IsTriggered() && !this.m_disarmed && !this.m_upgrading)
            {
                LogicTrapData data = this.GetTrapData();

                if (this.m_numSpawns > 0)
                {
                    if (this.m_spawnInitDelay != 0)
                    {
                        this.m_spawnInitDelay -= 1;
                    }
                    else
                    {
                        this.SpawnUnit(1);
                        this.m_numSpawns     -= 1;
                        this.m_spawnInitDelay = this.GetTrapData().GetTimeBetweenSpawnsMS() / 64;
                    }
                }

                if (this.m_actionTime >= 0)
                {
                    this.m_actionTime += 64;
                }

                if (this.m_hitTime >= 0)
                {
                    this.m_hitTime += 64;
                }

                if (this.m_actionTime > data.GetActionFrame())
                {
                    this.m_hitTime    = data.GetHitDelayMS();
                    this.m_actionTime = -1;
                }
                else if (this.m_hitTime > data.GetHitDelayMS())
                {
                    if (data.GetSpell() != null)
                    {
                        LogicSpell spell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(data.GetSpell(), this.m_level, this.m_villageType);

                        spell.SetUpgradeLevel(0);
                        spell.SetInitialPosition(this.GetMidX(), this.GetMidY());
                        spell.SetTeam(1);

                        this.GetGameObjectManager().AddGameObject(spell, -1);
                    }
                    else if (data.GetProjectile(this.m_upgLevel) != null)
                    {
                        this.CreateProjectile(data.GetProjectile(this.m_upgLevel));
                    }
                    else if (data.GetDamageMod() != 0)
                    {
                        this.m_level.AreaBoost(this.GetMidX(), this.GetMidY(), data.GetDamageRadius(this.m_upgLevel), -data.GetSpeedMod(), -data.GetSpeedMod(), data.GetDamageMod(),
                                               0, data.GetDurationMS() / 16, 0, false);
                    }
                    else if (data.GetEjectVictims())
                    {
                        if (data.GetThrowDistance() <= 0)
                        {
                            this.EjectCharacters();
                        }
                        else
                        {
                            this.ThrowCharacters();
                        }
                    }
                    else
                    {
                        bool defaultMode = true;

                        if (data.GetSpawnedCharAir() != null && data.GetSpawnedCharGround() != null || data.HasAlternativeMode())
                        {
                            int activeLayout = this.m_level.GetActiveLayout();

                            if (activeLayout <= 7)
                            {
                                defaultMode = this.m_useAirMode[activeLayout] ^ true;
                            }
                        }

                        this.m_level.AreaDamage(0, this.GetMidX(), this.GetMidY(), data.GetDamageRadius(this.m_upgLevel), data.GetDamage(this.m_upgLevel),
                                                data.GetPreferredTarget(),
                                                data.GetPreferredTargetDamageMod(), data.GetDamageEffect(), 1, null, defaultMode ? 1 : 0, 0, 100, true, false, 100, 0, this, 100,
                                                0);
                    }

                    this.m_hitTime   = 0;
                    this.m_hitCount += 1;

                    if (this.m_hitCount >= data.GetHitCount() && this.m_numSpawns == 0)
                    {
                        this.m_fadeTime       = 1;
                        this.m_hitTime        = -1;
                        this.m_disarmed       = true;
                        this.m_numSpawns      = data.GetNumSpawns(this.m_upgLevel);
                        this.m_spawnInitDelay = data.GetSpawnInitialDelayMS() / 64;
                    }
                }
            }
        }