示例#1
0
        public override int Execute(LogicLevel level)
        {
            LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId);

            if (gameObject != null)
            {
                if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING)
                {
                    LogicBuilding        building        = (LogicBuilding)gameObject;
                    LogicBuildingData    buildingData    = building.GetBuildingData();
                    LogicCombatComponent combatComponent = building.GetCombatComponent(false);

                    if (combatComponent != null && combatComponent.GetAttackerItemData().GetTargetingConeAngle() != 0)
                    {
                        if (this.m_baseLayout == -1)
                        {
                            combatComponent.ToggleAimAngle(buildingData.GetAimRotateStep(), this.m_layout, this.m_draftLayout);
                        }
                        else
                        {
                            int draftAngle   = combatComponent.GetAimAngle(this.m_baseLayout, this.m_baseDraftLayout);
                            int currentAngle = combatComponent.GetAimAngle(this.m_layout, this.m_draftLayout);

                            combatComponent.ToggleAimAngle(draftAngle - currentAngle, this.m_layout, this.m_draftLayout);
                        }

                        return(0);
                    }
                }
                else if (gameObject.GetGameObjectType() == LogicGameObjectType.TRAP)
                {
                    LogicTrap trap = (LogicTrap)gameObject;

                    if (trap.GetTrapData().GetDirectionCount() > 0)
                    {
                        if (this.m_baseLayout == -1)
                        {
                            trap.ToggleDirection(this.m_layout, this.m_draftLayout);
                        }
                        else
                        {
                            trap.SetDirection(this.m_layout, this.m_draftLayout, trap.GetDirection(this.m_baseLayout, this.m_baseDraftLayout));
                        }

                        return(0);
                    }

                    return(-21);
                }
            }

            return(-1);
        }