Esempio n. 1
0
        internal void ClearingFinished()
        {
            Player Player = this.Level.Player;

            if (this.VillageType == 0)
            {
                Player.AddDiamonds(this.GemDrops[this.Level.GameObjectManager.ObstacleClearCounter++]);

                if (this.Level.GameObjectManager.ObstacleClearCounter >= this.GemDrops.Length)
                {
                    this.Level.GameObjectManager.ObstacleClearCounter = 0;
                }

                this.Level.WorkerManager.DeallocateWorker(this);
            }
            else
            {
                if (!this.ObstacleData.TallGrass)
                {
                    Player.AddDiamonds(this.GemDrops[this.Level.GameObjectManager.ObstacleClearCounterV2++]);

                    if (this.Level.GameObjectManager.ObstacleClearCounterV2 >= this.GemDrops.Length)
                    {
                        this.Level.GameObjectManager.ObstacleClearCounterV2 = 0;
                    }

                    this.Level.WorkerManagerV2.DeallocateWorker(this);
                }
            }

            // LogicAchievementManager::obstacleCleared();

            Player.AddExperience(GamePlayUtil.TimeToXp(this.ObstacleData.ClearTimeSeconds));
            Player.ObstacleCleaned++;

            this.ClearTimer = null;
            this.Destructed = true;
            this.Level.GameObjectManager.RemoveGameObject(this, this.VillageType);
        }
Esempio n. 2
0
        /// <summary>
        /// Finishes the construction of building.
        /// </summary>
        internal void FinishConstruction()
        {
            if (this.Level.GameMode.State == State.Home)
            {
                BuildingData Data = this.BuildingData;

                if (this.UpgradeLevel + 1 > Data.MaxLevel)
                {
                    Logging.Error(this.GetType(), "Unable to upgrade the building because the level is out of range! - " + Data.Name + ".");
                    this.SetUpgradeLevel(Data.MaxLevel);
                }
                else
                {
                    this.SetUpgradeLevel(this.UpgradeLevel + 1);
                }

                this.Level.WorkerManager.DeallocateWorker(this);
                this.Level.Player.AddExperience(GamePlayUtil.TimeToXp(Data.GetBuildTime(this.UpgradeLevel)));

                this.ConstructionTimer = null;
            }
        }
Esempio n. 3
0
        internal void FinishConstruction()
        {
            BuildingData Data = this.BuildingData;

            if (this.Gearing)
            {
                this.Gearing = false;

                this.CombatComponent.GearUp = 1;

                if (this.CombatComponent.AltAttackMode)
                {
                    this.CombatComponent.AttackMode      = true;
                    this.CombatComponent.AttackModeDraft = true;
                }

                this.Level.WorkerManagerV2.DeallocateWorker(this);
            }
            else
            {
                if (this.UpgradeLevel + 1 > Data.MaxLevel)
                {
                    Logging.Error(this.GetType(), "Unable to upgrade the building because the level is out of range! - " + Data.Name + ".");
                    this.SetUpgradeLevel(Data.MaxLevel);
                }
                else
                {
                    this.SetUpgradeLevel(this.UpgradeLevel + 1);
                }

                if (this.Locked)
                {
                    this.Locked = false;
                    if (this.VillageType == 1)
                    {
                        this.Level.WorkerManagerV2.DeallocateWorker(this);
                    }
                }
                else
                {
                    if (this.VillageType == 0)
                    {
                        this.Level.WorkerManager.DeallocateWorker(this);
                    }
                    else
                    {
                        this.Level.WorkerManagerV2.DeallocateWorker(this);
                    }
                }
            }

            if (!Data.IsTroopHousingV2)
            {
                this.Level.Player.AddExperience(GamePlayUtil.TimeToXp(Data.GetBuildTime(this.UpgradeLevel)));
            }
            else
            {
                int troopHousing = this.Level.GameObjectManager.Filter.GetGameObjectCount(this.BuildingData);

                if (troopHousing >= 0)
                {
                    int Time;
                    switch (troopHousing)
                    {
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        Time = Globals.TroopHousingV2BuildTimeSeconds[troopHousing - 1];
                        break;

                    default:
                        Time = Globals.TroopHousingV2BuildTimeSeconds[4];
                        break;
                    }

                    this.Level.Player.AddExperience(GamePlayUtil.TimeToXp(Time));
                }
                else
                {
                    Logging.Error(this.GetType(), "TroopHousingV2 count is below zero when trying to get build time");
                }
            }

            if (this.HeroBaseComponent != null)
            {
                var data = CSV.Tables.Get(Gamefile.Heroes).GetData(this.BuildingData.HeroType);
                if (data is HeroData)
                {
                    HeroData HeroData = (HeroData)data;

                    this.Level.Player.HeroUpgrades.Set(HeroData, 0);
                    this.Level.Player.HeroStates.Set(HeroData, 3);
                    if (HeroData.HasAltMode)
                    {
                        this.Level.Player.HeroModes.Set(HeroData, 0);
                    }
                }
            }

            this.ConstructionTimer = null;
        }