コード例 #1
0
        public void UpdatePushBack()
        {
            int startSpeed = this.m_pushTime * this.m_pushTime / this.m_pushInitTime;
            int endSpeed   = this.m_pushInitTime - startSpeed;
            int pushBackX  = (startSpeed * this.m_pushBackStartPosition.m_x + endSpeed * this.m_pushBackEndPosition.m_x) / this.m_pushInitTime;
            int pushBackY  = (startSpeed * this.m_pushBackStartPosition.m_y + endSpeed * this.m_pushBackEndPosition.m_y) / this.m_pushInitTime;

            if (this.m_parent == null || this.m_parent.IsFlying() || this.m_parent.GetParent().GetLevel().GetTileMap().IsPassablePathFinder(pushBackX >> 8, pushBackY >> 8) ||
                this.m_ignorePush)
            {
                this.SetPosition(pushBackX, pushBackY);
            }
            else
            {
                this.m_pushBackStartPosition.m_x = this.m_position.m_x;
                this.m_pushBackStartPosition.m_y = this.m_position.m_y;
                this.m_pushBackEndPosition.m_x   = this.m_position.m_x;
                this.m_pushBackEndPosition.m_y   = this.m_position.m_y;
            }

            this.m_pushTime = LogicMath.Max(this.m_pushTime - 16, 0);

            if (this.m_pushTime == 0)
            {
                LogicGameObject      parent          = this.m_parent.GetParent();
                LogicCombatComponent combatComponent = parent.GetCombatComponent();

                if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER)
                {
                    LogicCharacter character = (LogicCharacter)parent;

                    if (character.GetCharacterData().GetPickNewTargetAfterPushback() || this.m_ignorePush)
                    {
                        if (combatComponent != null)
                        {
                            combatComponent.ForceNewTarget();
                        }
                    }
                }

                this.m_parent.NewTargetFound();

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

                this.m_ignorePush = false;
            }
        }
コード例 #2
0
        public void ObjectClose(LogicGameObject gameObject)
        {
            LogicHitpointComponent hitpointComponent = gameObject.GetHitpointComponent();

            if (hitpointComponent == null || hitpointComponent.GetTeam() != 1)
            {
                if (gameObject.GetGameObjectType() == LogicGameObjectType.CHARACTER)
                {
                    LogicCharacter     character = (LogicCharacter)gameObject;
                    LogicCharacterData data      = character.GetCharacterData();

                    if (data.GetHousingSpace() < this.m_minTriggerHousingLimit)
                    {
                        return;
                    }
                }

                LogicCombatComponent combatComponent = gameObject.GetCombatComponent();

                if (combatComponent == null || combatComponent.GetUndergroundTime() <= 0)
                {
                    if ((!gameObject.IsFlying() || this.m_airTrigger) && (gameObject.IsFlying() || this.m_groundTrigger))
                    {
                        if (this.m_healerTrigger || combatComponent == null || !combatComponent.IsHealer())
                        {
                            int distanceX = gameObject.GetX() - this.m_parent.GetMidX();
                            int distanceY = gameObject.GetY() - this.m_parent.GetMidY();

                            if (LogicMath.Abs(distanceX) <= this.m_triggerRadius &&
                                LogicMath.Abs(distanceY) <= this.m_triggerRadius &&
                                distanceX * distanceX + distanceY * distanceY < (uint)(this.m_triggerRadius * this.m_triggerRadius))
                            {
                                this.Trigger();
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        public override int Execute(LogicLevel level)
        {
            if (this.m_inputLayoutId != 6)
            {
                if (this.m_outputLayoutId != 6)
                {
                    if (this.m_inputLayoutId != 7)
                    {
                        if (this.m_outputLayoutId != 7)
                        {
                            int townHallLevel = level.GetTownHallLevel(level.GetVillageType());

                            if (townHallLevel >= level.GetRequiredTownHallLevelForLayout(this.m_inputLayoutId, -1) &&
                                townHallLevel >= level.GetRequiredTownHallLevelForLayout(this.m_outputLayoutId, -1))
                            {
                                LogicGameObjectFilter            filter      = new LogicGameObjectFilter();
                                LogicArrayList <LogicGameObject> gameObjects = new LogicArrayList <LogicGameObject>(500);

                                filter.AddGameObjectType(LogicGameObjectType.BUILDING);
                                filter.AddGameObjectType(LogicGameObjectType.TRAP);
                                filter.AddGameObjectType(LogicGameObjectType.DECO);

                                level.GetGameObjectManager().GetGameObjects(gameObjects, filter);

                                if (this.m_outputLayoutId == level.GetActiveLayout())
                                {
                                    LogicMoveMultipleBuildingsCommand moveMultipleBuildingsCommand = new LogicMoveMultipleBuildingsCommand();

                                    for (int i = 0; i < gameObjects.Size(); i++)
                                    {
                                        LogicGameObject gameObject = gameObjects[i];
                                        LogicVector2    position   = gameObject.GetPositionLayout(this.m_inputLayoutId, false);

                                        moveMultipleBuildingsCommand.AddNewMove(gameObject.GetGlobalID(), position.m_x, position.m_y);
                                    }

                                    int result = moveMultipleBuildingsCommand.Execute(level);

                                    moveMultipleBuildingsCommand.Destruct();

                                    if (result != 0)
                                    {
                                        filter.Destruct();
                                        return(-2);
                                    }
                                }

                                for (int i = 0; i < gameObjects.Size(); i++)
                                {
                                    LogicGameObject gameObject       = gameObjects[i];
                                    LogicVector2    layoutPosition   = gameObject.GetPositionLayout(this.m_inputLayoutId, false);
                                    LogicVector2    editModePosition = gameObject.GetPositionLayout(this.m_inputLayoutId, true);

                                    gameObject.SetPositionLayoutXY(layoutPosition.m_x, layoutPosition.m_y, this.m_outputLayoutId, false);
                                    gameObject.SetPositionLayoutXY(editModePosition.m_x, editModePosition.m_y, this.m_outputLayoutId, true);

                                    if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING)
                                    {
                                        LogicCombatComponent combatComponent = gameObject.GetCombatComponent(false);

                                        if (combatComponent != null)
                                        {
                                            if (combatComponent.HasAltAttackMode())
                                            {
                                                if (combatComponent.UseAltAttackMode(this.m_inputLayoutId, false) ^ combatComponent.UseAltAttackMode(this.m_outputLayoutId, false))
                                                {
                                                    combatComponent.ToggleAttackMode(this.m_outputLayoutId, false);
                                                }

                                                if (combatComponent.UseAltAttackMode(this.m_inputLayoutId, true) ^ combatComponent.UseAltAttackMode(this.m_outputLayoutId, true))
                                                {
                                                    combatComponent.ToggleAttackMode(this.m_outputLayoutId, true);
                                                }
                                            }

                                            if (combatComponent.GetAttackerItemData().GetTargetingConeAngle() != 0)
                                            {
                                                int aimAngle1 = combatComponent.GetAimAngle(this.m_inputLayoutId, false);
                                                int aimAngle2 = combatComponent.GetAimAngle(this.m_outputLayoutId, false);

                                                if (aimAngle1 != aimAngle2)
                                                {
                                                    combatComponent.ToggleAimAngle(aimAngle1 - aimAngle2, this.m_outputLayoutId, false);
                                                }
                                            }
                                        }
                                    }
                                    else if (gameObject.GetGameObjectType() == LogicGameObjectType.TRAP)
                                    {
                                        LogicTrap trap = (LogicTrap)gameObject;

                                        if (trap.HasAirMode())
                                        {
                                            if (trap.IsAirMode(this.m_inputLayoutId, false) ^ trap.IsAirMode(this.m_outputLayoutId, false))
                                            {
                                                trap.ToggleAirMode(this.m_outputLayoutId, false);
                                            }

                                            if (trap.IsAirMode(this.m_inputLayoutId, true) ^ trap.IsAirMode(this.m_outputLayoutId, true))
                                            {
                                                trap.ToggleAirMode(this.m_outputLayoutId, true);
                                            }
                                        }
                                    }
                                }

                                filter.Destruct();
                                level.SetLayoutState(this.m_outputLayoutId, level.GetVillageType(), level.GetLayoutState(this.m_inputLayoutId, level.GetVillageType()));

                                LogicAvatar homeOwnerAvatar = level.GetHomeOwnerAvatar();

                                if (homeOwnerAvatar.GetTownHallLevel() >= LogicDataTables.GetGlobals().GetChallengeBaseCooldownEnabledTownHall())
                                {
                                    level.SetLayoutCooldownSecs(this.m_outputLayoutId, level.GetLayoutCooldown(this.m_inputLayoutId) / 15);
                                }

                                return(0);
                            }

                            return(-1);
                        }

                        return(-8);
                    }

                    return(-7);
                }

                return(-6);
            }

            return(-5);
        }