Exemplo n.º 1
0
        public static LogicSpell CastSpell(LogicAvatar avatar, LogicSpellData spellData, bool allianceSpell, int upgLevel, LogicLevel level, int x, int y)
        {
            if (allianceSpell)
            {
                avatar.RemoveAllianceUnit(spellData, upgLevel);
            }
            else
            {
                avatar.CommodityCountChangeHelper(0, spellData, -1);
            }

            if (!allianceSpell)
            {
                upgLevel = avatar.GetUnitUpgradeLevel(spellData);
            }

            LogicSpell spell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(spellData, level, level.GetVillageType());

            spell.SetUpgradeLevel(upgLevel);
            spell.SetInitialPosition(x, y);
            level.GetGameObjectManager().AddGameObject(spell, -1);
            level.GetGameListener().AttackerPlaced(spellData);

            LogicBattleLog battleLog = level.GetBattleLog();

            if (battleLog != null)
            {
                battleLog.IncrementCastedSpells(spellData, 1);
                battleLog.SetCombatItemLevel(spellData, upgLevel);
            }

            return(spell);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Casts the specified spell.
        /// </summary>
        public static LogicSpell CastSpell(LogicAvatar avatar, LogicSpellData spellData, bool allianceSpell, int upgLevel, LogicLevel level, int x, int y)
        {
            if (allianceSpell)
            {
                avatar.RemoveAllianceUnit(spellData, upgLevel);
            }
            else
            {
                avatar.CommodityCountChangeHelper(0, spellData, -1);
            }

            LogicSpell spell = (LogicSpell)LogicGameObjectFactory.CreateGameObject(spellData, level, level.GetVillageType());

            spell.SetUpgradeLevel(upgLevel);
            return(spell);
        }
Exemplo n.º 3
0
        private void SimulateEndAttackState()
        {
            LogicLevel                       level              = this.m_logicGameMode.GetLevel();
            LogicGameObjectManager           gameObjectManager  = level.GetGameObjectManager();
            LogicArrayList <LogicGameObject> characterList      = gameObjectManager.GetGameObjects(LogicGameObjectType.CHARACTER);
            LogicArrayList <LogicGameObject> projectileList     = gameObjectManager.GetGameObjects(LogicGameObjectType.PROJECTILE);
            LogicArrayList <LogicGameObject> spellList          = gameObjectManager.GetGameObjects(LogicGameObjectType.SPELL);
            LogicArrayList <LogicGameObject> alliancePortalList = gameObjectManager.GetGameObjects(LogicGameObjectType.ALLIANCE_PORTAL);

            this.m_logicWatch.Start();

            while (!this.m_logicGameMode.IsBattleOver())
            {
                bool canStopBattle = !this.m_logicGameMode.GetConfiguration().GetBattleWaitForProjectileDestruction() || projectileList.Size() == 0;

                for (int i = 0; i < characterList.Size(); i++)
                {
                    LogicCharacter         character         = (LogicCharacter)characterList[i];
                    LogicHitpointComponent hitpointComponent = character.GetHitpointComponent();

                    if (hitpointComponent != null && hitpointComponent.GetTeam() == 0)
                    {
                        LogicAttackerItemData data = character.GetAttackerItemData();

                        if (data.GetDamage(0, false) > 0 &&
                            (hitpointComponent.GetHitpoints() > 0 || this.m_logicGameMode.GetConfiguration().GetBattleWaitForDieDamage() && character.GetWaitDieDamage()))
                        {
                            canStopBattle = false;
                        }
                    }
                }

                for (int i = 0; i < spellList.Size(); i++)
                {
                    LogicSpell spell = (LogicSpell)spellList[i];

                    if (!spell.GetHitsCompleted() && (spell.GetSpellData().IsDamageSpell() || spell.GetSpellData().GetSummonTroop() != null))
                    {
                        canStopBattle = false;
                    }
                }

                for (int i = 0; i < alliancePortalList.Size(); i++)
                {
                    LogicAlliancePortal alliancePortal = (LogicAlliancePortal)alliancePortalList[i];

                    if (alliancePortal.GetBunkerComponent().GetTeam() == 0 && !alliancePortal.GetBunkerComponent().IsEmpty())
                    {
                        canStopBattle = false;
                    }
                }

                bool isEnded = canStopBattle || this.m_logicWatch.ElapsedMilliseconds >= 10000;

                if (isEnded)
                {
                    LogicEndCombatCommand logicEndCombatCommand = new LogicEndCombatCommand();
                    logicEndCombatCommand.SetExecuteSubTick(this.m_logicGameMode.GetLevel().GetLogicTime().GetTick());
                    this.m_logicGameMode.GetCommandManager().AddCommand(logicEndCombatCommand);
                }

                this.m_logicGameMode.UpdateOneSubTick();

                if (isEnded)
                {
                    break;
                }
            }

            this.m_logicWatch.Reset();

            if (!this.m_logicGameMode.IsBattleOver())
            {
                this.m_logicGameMode.SetBattleOver();
            }
            if (this.m_liveReplayId != null)
            {
                this.UpdateLiveReplay(this.m_logicGameMode.GetLevel().GetLogicTime().GetTick(), null);
            }
        }