Exemple #1
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;
                    UnitUpgradeComponent unitUpgradeComponent = building.UnitUpgradeComponent;

                    if (unitUpgradeComponent != null)
                    {
                        unitUpgradeComponent.SpeedUp();
                    }
                    else
                    {
                        Logging.Error(this.GetType(),
                                      "Unable to speed up the unit upgrade. The game object doesn't contain a UnitUpgradeComponent.");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(),
                                  "Unable to speed up the unit upgrade. The game object is not a building.");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to speed up the unit upgrade. The game object is null");
            }
        }
Exemple #2
0
        public override void Execute(Level level)
        {
            GameObject gameObjectById = level.GameObjectManager.GetGameObjectByID(m_vBuildingId);

            if (gameObjectById == null || gameObjectById.ClassId != 0)
            {
                return;
            }
            UnitUpgradeComponent upgradeComponent = ((ConstructionItem)gameObjectById).GetUnitUpgradeComponent(false);

            if ((upgradeComponent != null ? upgradeComponent.GetCurrentlyUpgradedUnit() : (CombatItemData)null) == null)
            {
                return;
            }
            upgradeComponent.SpeedUp();
        }
Exemple #3
0
        public override void Execute(Level level)
        {
            ClientAvatar         ca  = level.GetPlayerAvatar();
            GameObject           go  = level.GameObjectManager.GetGameObjectByID(BuildingId);
            Building             b   = (Building)go;
            UnitUpgradeComponent uuc = b.GetUnitUpgradeComponent();
            int unitLevel            = ca.GetUnitUpgradeLevel(this.UnitData);

            if (uuc.CanStartUpgrading(this.UnitData))
            {
                int          cost = this.UnitData.GetUpgradeCost(unitLevel);
                ResourceData rd   = this.UnitData.GetUpgradeResource(unitLevel);
                if (ca.HasEnoughResources(rd, cost))
                {
                    ca.SetResourceCount(rd, ca.GetResourceCount(rd) - cost);
                    uuc.StartUpgrading(this.UnitData);
                }
            }
        }
Exemple #4
0
        //00 00 02 05 1D CD 65 13 00 00 53 8F

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

            if (go != null)
            {
                if (go.ClassId == 0)
                {
                    Building             b   = (Building)go;
                    UnitUpgradeComponent uuc = b.GetUnitUpgradeComponent();
                    if (uuc != null)
                    {
                        if (uuc.GetCurrentlyUpgradedUnit() != null)
                        {
                            uuc.SpeedUp();
                        }
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Refreshes the <see cref="Building"/>.
        /// </summary>
        /// <param name="Tick">The tick</param>
        public void Refresh(float Tick)
        {
            if (this.ConstructionTime.HasValue)
            {
                this.ConstructionTime -= Tick;

                if (this.ConstructionTime <= 0f)
                {
                    this.ConstructionEnded();
                    this.ConstructionTime = null;
                }
            }

            if (this.ResourceTime.HasValue)
            {
                this.ResourceTime -= Tick;

                if (this.ResourceTime <= 0f)
                {
                    this.ResourceTime = 0;
                }
            }

            if (this.BoostTime.HasValue && (!this.BoostPause ?? true))
            {
                this.BoostTime -= Tick;

                if (this.BoostTime <= 0f)
                {
                    this.BoostTime = null;
                }
            }

            if (this.ClanMailTime.HasValue)
            {
                this.ClanMailTime -= Tick;

                if (this.ClanMailTime <= 0f)
                {
                    this.ClanMailTime = null;
                }
            }

            if (this.UnitRequestTime.HasValue)
            {
                this.UnitRequestTime -= Tick;

                if (this.UnitRequestTime <= 0f)
                {
                    this.UnitRequestTime = null;
                }
            }

            if (this.ShareReplayTime.HasValue)
            {
                this.ShareReplayTime -= Tick;

                if (this.ShareReplayTime <= 0f)
                {
                    this.ShareReplayTime = null;
                }
            }

            if (this.ChallengeTime.HasValue)
            {
                this.ChallengeTime -= Tick;

                if (this.ChallengeTime <= 0f)
                {
                    this.ChallengeTime = null;
                }
            }

            if (this.ElderKickTime.HasValue)
            {
                this.ElderKickTime -= Tick;

                if (this.ElderKickTime <= 0f)
                {
                    this.ElderKickTime = null;
                }
            }

            if (this.Hitpoints.HasValue)
            {
                this.Hitpoints += this.Csv.Hitpoints[this.Level] * 1f / this.Csv.RegenTime[this.Level] * Tick;

                if (this.Hitpoints <= 0f)
                {
                    this.Hitpoints = null;
                }
            }

            if (this.Csv.UpgradesUnits)
            {
                if (this.UnitUpgrade != null)
                {
                    this.UnitUpgrade.Refresh(Tick);
                }
                else
                {
                    this.UnitUpgrade = new UnitUpgradeComponent(this.Objects);
                }
            }

            if (this.Csv.HeroType != null)
            {
                if (this.HeroUpgrade != null)
                {
                    this.HeroUpgrade.Refresh(Tick);
                }
                else
                {
                    this.HeroUpgrade = new HeroUpgradeComponent(this.Objects);
                }
            }
        }
Exemple #6
0
        internal override void Execute()
        {
            Level level = this.Device.GameMode.Level;

            if (this.Unit != null)
            {
                GameObject gameObject = level.GameObjectManager.Filter.GetGameObjectById(this.BuildingId);
                if (gameObject != null)
                {
                    if (gameObject is Building)
                    {
                        Building             building             = (Building)gameObject;
                        UnitUpgradeComponent unitUpgradeComponent = building.UnitUpgradeComponent;

                        if (unitUpgradeComponent != null)
                        {
                            int unitLevel = level.Player.GetUnitUpgradeLevel(this.Unit);

                            ResourceData resourceData = this.UnitType == 1 ? ((SpellData)this.Unit).UpgradeResourceData : ((CharacterData)this.Unit).UpgradeResourceData;
                            int          upgradeCost  = this.UnitType == 1 ? ((SpellData)this.Unit).UpgradeCost[unitLevel] : ((CharacterData)this.Unit).UpgradeCost[unitLevel];

                            if (resourceData != null)
                            {
                                if (level.Player.Resources.GetCountByData(resourceData) >= upgradeCost)
                                {
                                    if (unitUpgradeComponent.CanStartUpgrading(this.Unit))
                                    {
                                        level.Player.Resources.Remove(resourceData, upgradeCost);
                                        unitUpgradeComponent.StartUpgrading(this.Unit);
                                    }
                                    else
                                    {
                                        Logging.Error(this.GetType(),
                                                      "Unable to upgrade the unit. The UnitUpgradeComponent probably training other unit.");
                                    }
                                }
                                else
                                {
                                    Logging.Error(this.GetType(),
                                                  "Unable to upgrade the unit. The player doesn't have enough resources.");
                                }
                            }
                            else
                            {
                                Logging.Error(this.GetType(),
                                              "Unable to upgrade the unit. The resources data is null.");
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(),
                                          "Unable to upgrade the unit. The game object doesn't contain a UnitUpgradeComponent.");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(),
                                      "Unable to upgrade the unit. The game object is not valid or not exist");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Unable to upgrade the unit. The game object is null");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to to upgrade the unit. The unit data is null");
            }
        }