コード例 #1
0
        internal void RefreshResourceCaps()
        {
            if (this.Level.Player != null)
            {
                Player Player = this.Level.Player;

                for (int i = 0; i < Player.ResourceCaps.Count; i++)
                {
                    Player.ResourceCaps[i].Count = 0;
                }

                for (int i = 0; i < this.Components[0].Count; i++)
                {
                    if (this.Components[0][i].Type == 6)
                    {
                        ResourceStorageComponent StorageComponent = (ResourceStorageComponent)this.Components[0][i];

                        foreach (ResourceData Data in CSV.Tables.Get(Gamefile.Resources).Datas)
                        {
                            Player.ResourceCaps.Add(Data, StorageComponent.GetMax(Data.GetId()));
                        }
                    }
                }
            }
            else
            {
                Logging.Info(this.GetType(), "Unable to refresh resource caps. Player is NULL.");
            }
        }
コード例 #2
0
        internal void SetUpgradeLevel(int UpgradeLevel)
        {
            this.UpgradeLevel = UpgradeLevel;

            if (this.Level.Player != null)
            {
                if (BuildingData.IsAllianceCastle)
                {
                    if (!this.Locked)
                    {
                        this.Level.Player.SetAllianceCastleLevel(UpgradeLevel);
                    }
                }
                else if (BuildingData.IsTownHall)
                {
                    this.Level.Player.TownHallLevel = UpgradeLevel;
                }
                else if (BuildingData.IsTownHall2)
                {
                    this.Level.Player.TownHallLevel2 = UpgradeLevel;
                }
                else if (BuildingData.IsBarrack2)
                {
                    this.Level.Player.Variables.Village2BarrackLevel = UpgradeLevel;
                }
            }

            ResourceProductionComponent ResourceProductionComponent = this.ResourceProductionComponent;

            ResourceProductionComponent?.SetProduction();

            ResourceStorageComponent ResourceStorageComponent = this.ResourceStorageComponent;

            if (ResourceStorageComponent != null)
            {
                if (UpgradeLevel > -1)
                {
                    ResourceStorageComponent.SetMaxArray(this.BuildingData.GetResourceMaxArray(UpgradeLevel));
                    if (!this.Level.AI)
                    {
                        this.Level.ComponentManager.RefreshResourceCaps();
                    }
                }
            }

            UnitStorageComponent UnitStorageComponent = this.UnitStorageComponent;

            if (UnitStorageComponent != null)
            {
                if (UpgradeLevel > -1)
                {
                    UnitStorageComponent.SetStorage();
                }
            }
        }