示例#1
0
        public override void Execute(Level level)
        {
            ClientAvatar ca = level.GetPlayerAvatar();
            GameObject   go = level.GameObjectManager.GetGameObjectByID(BuildingId);

            if (go != null)
            {
                Building          b   = (Building)go;
                HeroBaseComponent hbc = b.GetHeroBaseComponent();
                if (hbc != null)
                {
                    if (hbc.CanStartUpgrading())
                    {
                        HeroData     hd           = ObjectManager.DataTables.GetHeroByName(b.GetBuildingData().HeroType);
                        int          currentLevel = ca.GetUnitUpgradeLevel(hd);
                        ResourceData rd           = hd.GetUpgradeResource(currentLevel);
                        int          cost         = hd.GetUpgradeCost(currentLevel);
                        if (ca.HasEnoughResources(rd, cost))
                        {
                            if (level.HasFreeWorkers())
                            {
                                hbc.StartUpgrading();
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        internal override void Execute()
        {
            GameObject gameObject = this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjectById(this.BuildingId);

            if (gameObject != null)
            {
                if (gameObject is Building)
                {
                    Building          building          = (Building)gameObject;
                    HeroBaseComponent HeroBaseComponent = building.HeroBaseComponent;

                    if (HeroBaseComponent != null)
                    {
                        HeroBaseComponent.SpeedUpUpgrade();
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to speed up the hero upgrade. The game object doesn't contain a UnitUpgradeComponent.");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Unable to speed up the hero upgrade. The game object is not a building.");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to speed up the hero upgrade. The game object is null");
            }
        }
示例#3
0
        //00 00 02 10 1D CD 65 09 00 01 03 B7

        public override void Execute(Level level)
        {
            ClientAvatar ca = level.GetPlayerAvatar();
            GameObject   go = level.GameObjectManager.GetGameObjectByID(m_vBuildingId);

            if (go != null)
            {
                Building          b   = (Building)go;
                HeroBaseComponent hbc = b.GetHeroBaseComponent();
                if (hbc != null)
                {
                    hbc.SpeedUpUpgrade();
                }
            }
        }
        public override void Execute(Level level)
        {
            GameObject gameObjectById = level.GameObjectManager.GetGameObjectByID(m_vBuildingId);

            if (gameObjectById == null)
            {
                return;
            }
            HeroBaseComponent heroBaseComponent = ((ConstructionItem)gameObjectById).GetHeroBaseComponent(false);

            if (heroBaseComponent == null)
            {
                return;
            }
            heroBaseComponent.SpeedUpUpgrade();
        }
示例#5
0
        //00 00 02 13 1D CD 65 06 00 01 8B 0F
        public override void Execute(Level level)
        {
            GameObject go = level.GameObjectManager.GetGameObjectByID(m_vBuildingId);

            if (go != null)
            {
                if (go.ClassId == 0)
                {
                    var b = (Building)go;
                    HeroBaseComponent hbc = b.GetHeroBaseComponent();
                    if (hbc != null)
                    {
                        hbc.CancelUpgrade();
                    }
                }
            }
        }
示例#6
0
        internal override void Execute()
        {
            Level      level      = this.Device.GameMode.Level;
            GameObject gameObject = level.GameObjectManager.Filter.GetGameObjectById(this.BuildingId);

            if (gameObject != null)
            {
                if (gameObject is Building)
                {
                    Building          building          = (Building)gameObject;
                    HeroBaseComponent HeroBaseComponent = building.HeroBaseComponent;
                    if (HeroBaseComponent != null)
                    {
                        HeroData HeroData = HeroBaseComponent.HeroData;
                        if (HeroData != null)
                        {
                            if (HeroData.HasAltMode)
                            {
                                level.Player.HeroModes.Set(HeroData, this.State);
                            }
                            else
                            {
                                Logging.Error(this.GetType(), "Unable to change hero mode. Hero doesn't have another mode .");
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Unable to change hero mode. Hero data is null.");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to change hero mode. The HeroBaseComponent is null.");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Unable to change hero mode. The game object is not a building.");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to change hero mode. The game object is null.");
            }
        }
        internal override void Execute()
        {
            Level      Level      = this.Device.GameMode.Level;
            GameObject GameObject = Level.GameObjectManager.Filter.GetGameObjectById(this.BuildingId);

            if (GameObject != null)
            {
                if (GameObject is Building)
                {
                    Building          Building          = (Building)GameObject;
                    HeroBaseComponent HeroBaseComponent = Building.HeroBaseComponent;
                    if (HeroBaseComponent != null)
                    {
                        if (!HeroBaseComponent.Upgrading)
                        {
                            Logging.Error(this.GetType(), $"Tried to cancel the upgrade of a hero which is not in upgrading with game ID {this.BuildingId}.");
                        }
                        else
                        {
                            HeroBaseComponent.CancelUpgrade();
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to change hero mode. The HeroBaseComponent is null.");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Unable to change hero mode. The game object is not a building.");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to change hero mode. The game object is null.");
            }
        }
示例#8
0
        internal override void Execute()
        {
            Level      level      = this.Device.GameMode.Level;
            GameObject gameObject = level.GameObjectManager.Filter.GetGameObjectById(this.BuildingId);

            if (gameObject != null)
            {
                if (gameObject is Building)
                {
                    Building          building          = (Building)gameObject;
                    HeroBaseComponent HeroBaseComponent = building.HeroBaseComponent;
                    if (HeroBaseComponent != null)
                    {
                        if (HeroBaseComponent.UpgradeAvailable)
                        {
                            HeroData HeroData  = HeroBaseComponent.HeroData;
                            int      heroLevel = level.Player.GetHeroUpgradeLevel(HeroData);

                            ResourceData resourceData = HeroData.UpgradeResourceData;
                            int          upgradeCost  = HeroData.UpgradeCost[heroLevel];

                            if (resourceData != null)
                            {
                                if (level.Player.Resources.GetCountByData(resourceData) >= upgradeCost)
                                {
                                    if (HeroData.VillageType == 0
                                        ? level.WorkerManager.FreeWorkers > 0
                                        : level.WorkerManagerV2.FreeWorkers > 0)
                                    {
                                        level.Player.Resources.Remove(resourceData, upgradeCost);
                                        HeroBaseComponent.StartUpgrade();
                                    }
                                    else
                                    {
                                        Logging.Error(this.GetType(),
                                                      "Unable to upgrade the hero. There is no free worker.");
                                    }
                                }
                                else
                                {
                                    Logging.Error(this.GetType(),
                                                  "Unable to upgrade the hero. The player doesn't have enough resources.");
                                }
                            }
                            else
                            {
                                Logging.Error(this.GetType(), "Unable to upgrade the hero. Resource data is null.");
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Unable to upgrade the hero. Upgrade is not available.");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to upgrade the hero. The HeroBaseComponent is null.");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Unable to upgrade the hero. The game object is not a building.");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to upgrade the hero. The game object is null.");

                StringBuilder Error   = new StringBuilder();
                GameObject    Precise = this.Device.GameMode.Level.GameObjectManager.Filter.GetGameObjectByPreciseId(this.BuildingId);
                if (Precise != null)
                {
                    Error.AppendLine($"Building Id :  {this.BuildingId}");
                    Error.AppendLine($"Building Name :  {Precise.Data.Name}");
                    Error.AppendLine($"Building still null with precise id : {false}");

                    Error.AppendLine($"Player Id :  {this.Device.GameMode.Level.Player.UserId}");
                    Error.AppendLine($"Player current village :  {this.Device.GameMode.Level.GameObjectManager.Map}");
                    Error.AppendLine($"Player town hall level :  {this.Device.GameMode.Level.Player.TownHallLevel}");
                    Error.AppendLine($"Player town hall2 level :  {this.Device.GameMode.Level.Player.TownHallLevel2}");
                }
                else
                {
                    Error.AppendLine($"Precise building : null");
                    Error.AppendLine($"Building Id :  {this.BuildingId}");

                    Error.AppendLine($"Player Id :  {this.Device.GameMode.Level.Player.UserId}");
                    Error.AppendLine($"Player current village :  {this.Device.GameMode.Level.GameObjectManager.Map}");
                    Error.AppendLine($"Player town hall level :  {this.Device.GameMode.Level.Player.TownHallLevel}");
                    Error.AppendLine($"Player town hall2 level :  {this.Device.GameMode.Level.Player.TownHallLevel2}");
                }

                Resources.Logger.Debug(Error);
            }
        }