Example #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();

                    if (buildingData.GetGearUpBuildingData() == null || building.GetGearLevel() != 0)
                    {
                        if (building.GetAttackerItemData().HasAlternativeAttackMode())
                        {
                            LogicCombatComponent combatComponent = building.GetCombatComponent(false);

                            if (combatComponent != null)
                            {
                                combatComponent.ToggleAttackMode(this.m_layout, this.m_draftMode);

                                if (this.m_updateListener)
                                {
                                }

                                return(0);
                            }
                        }

                        return(-1);
                    }

                    return(-95);
                }

                if (gameObject.GetGameObjectType() == LogicGameObjectType.TRAP)
                {
                    LogicTrap trap = (LogicTrap)gameObject;

                    if (trap.HasAirMode())
                    {
                        trap.ToggleAirMode(this.m_layout, this.m_draftMode);

                        if (this.m_updateListener)
                        {
                        }

                        return(0);
                    }
                }
            }

            return(-1);
        }
Example #2
0
        public override int Execute(LogicLevel level)
        {
            LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId);

            if (gameObject != null && gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING)
            {
                LogicBuilding     building     = (LogicBuilding)gameObject;
                LogicBuildingData buildingData = building.GetBuildingData();

                if (buildingData.GetVillageType() == level.GetVillageType())
                {
                    if (!level.IsBuildingGearUpCapReached(buildingData, true))
                    {
                        if (building.GetGearLevel() == 0)
                        {
                            int upgLevel   = building.GetUpgradeLevel();
                            int gearUpCost = buildingData.GetGearUpCost(upgLevel);

                            if (gearUpCost > 0)
                            {
                                if (upgLevel >= buildingData.GetMinUpgradeLevelForGearUp())
                                {
                                    if (level.GetGameObjectManagerAt(1).GetHighestBuildingLevel(buildingData.GetGearUpBuildingData()) <
                                        buildingData.GetGearUpLevelRequirement())
                                    {
                                        return(-1);
                                    }

                                    LogicResourceData gearUpResource = buildingData.GetGearUpResource();

                                    if (gearUpResource != null)
                                    {
                                        LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

                                        if (playerAvatar.HasEnoughResources(gearUpResource, gearUpCost, true, this, false))
                                        {
                                            if (level.HasFreeWorkers(this, 1))
                                            {
                                                playerAvatar.CommodityCountChangeHelper(0, gearUpResource, -gearUpCost);
                                                building.StartUpgrading(true, true);

                                                return(0);
                                            }
                                        }
                                    }

                                    return(-1);
                                }

                                return(-37);
                            }

                            return(-36);
                        }

                        return(-35);
                    }

                    return(-31);
                }

                return(-32);
            }

            return(-1);
        }