Exemplo n.º 1
0
        public LogicCharacter CreateDuplicateCharacter(LogicCharacterData data, int upgLevel, int x, int y)
        {
            LogicCharacter character = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(data, this.m_level, this.m_villageType);

            character.SetUpgradeLevel(upgLevel);
            character.SetDuplicate(true, this.GetSpellData().GetDuplicateLifetime(this.m_upgradeLevel) / 64 + 1);
            character.SetInitialPosition(x, y);

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

            if (data.IsUnderground())
            {
                LogicCombatComponent combatComponent = character.GetCombatComponent();

                combatComponent.SetUndergroundTime(3600000);
                combatComponent.RefreshTarget(true);
            }

            if (LogicDataTables.IsSkeleton(data))
            {
                LogicCombatComponent combatComponent = character.GetCombatComponent();

                if (combatComponent != null)
                {
                    combatComponent.SetSkeletonSpell();
                }
            }

            this.GetGameObjectManager().AddGameObject(character, -1);
            // Listener.
            return(character);
        }
Exemplo n.º 2
0
        public void SpawnSummon(int x, int y)
        {
            LogicSpellData     data       = this.GetSpellData();
            LogicCharacterData summonData = data.GetSummonTroop();
            LogicVector2       position   = new LogicVector2();

            int summonCount        = data.GetUnitsToSpawn(this.m_upgradeLevel);
            int spawnDuration      = data.GetSpawnDuration(this.m_upgradeLevel);
            int totalSpawnDuration = -(spawnDuration * data.GetSpawnFirstGroupSize());

            for (int i = 0, k = 0, angle = y + 7 * x; i < summonCount; i++, k += 7, angle += 150, totalSpawnDuration += spawnDuration)
            {
                if (!summonData.IsFlying())
                {
                    if (!this.m_level.GetTileMap().GetNearestPassablePosition(this.GetX(), this.GetY(), position, 1536))
                    {
                        return;
                    }
                }
                else
                {
                    position.m_x = x + LogicMath.GetRotatedX(summonData.GetSecondarySpawnOffset(), 0, angle);
                    position.m_y = y + LogicMath.GetRotatedY(summonData.GetSecondarySpawnOffset(), 0, angle);
                }

                LogicCharacter summon = (LogicCharacter)LogicGameObjectFactory.CreateGameObject(summonData, this.m_level, this.m_villageType);

                summon.GetHitpointComponent().SetTeam(0);
                summon.SetInitialPosition(position.m_x, position.m_y);

                LogicRandom random = new LogicRandom(k + this.m_globalId);

                int rnd = ((random.Rand(150) << 9) + 38400) / 100;

                position.Set(LogicMath.Cos(angle, rnd),
                             LogicMath.Sin(angle, rnd));

                int pushBackSpeed = summonData.GetPushbackSpeed() > 0 ? summonData.GetPushbackSpeed() : 1;
                int pushBackTime  = 2 * rnd / (3 * pushBackSpeed);
                int spawnDelay    = pushBackTime + totalSpawnDuration / summonCount;

                if (data.GetSpawnFirstGroupSize() > 0)
                {
                    spawnDelay = LogicMath.Max(200, spawnDelay);
                }

                summon.SetSpawnTime(spawnDelay);
                summon.GetMovementComponent().GetMovementSystem().PushTrap(position, pushBackTime, 0, false, false);

                if (summon.GetCharacterData().IsJumper())
                {
                    summon.GetMovementComponent().EnableJump(3600000);
                    summon.GetCombatComponent().RefreshTarget(true);
                }

                LogicCombatComponent combatComponent = summon.GetCombatComponent();

                if (combatComponent != null)
                {
                    combatComponent.SetSkeletonSpell();
                }

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