Esempio n. 1
0
    public GoodsCollection HandleBuildingsOnEndTurn(GoodsCollection inventory)
    {
        int incomeGold = 0;
        int culture    = 0;
        var prevGoods  = new GoodsCollection(inventory);

        foreach (var kvp in _dictionary)
        {
            for (int i = 0; i < kvp.Value.Count; i++)
            {
                Building b = kvp.Value[i];
                b.HandleGoods(inventory);
                incomeGold -= b.GetUpkeep(inventory);
                culture    += b.Culture;

                CheckBuildingConstruction(b);
            }
        }

        Globals.CityManager.AddCoin(incomeGold);
        Globals.CityManager.SetIncome(incomeGold);
        Globals.CityManager.SetCulture(culture);

        //calculate the difference in resources
        var incomeInventory = new GoodsCollection(inventory);

        incomeInventory.Subtract(prevGoods);
        return(incomeInventory);
    }
Esempio n. 2
0
    public override bool HandleGoods(GoodsCollection inventory)
    {
        Building b = GetHighestLevelHouse(inventory);

        //+- goods
        foreach (Good good in inventory.Keys.ToArray())
        {
            if (b.MaterialsRequired.ContainsKey(good))
            {
                inventory[good] -= b.MaterialsRequired[good];
            }

            if (b.MaterialsProduced.ContainsKey(good))
            {
                inventory[good] += b.MaterialsProduced[good];
            }
        }

        if (BuildingEffect != null)
        {
            BuildingEffect(inventory);
        }

        return(true);
    }
Esempio n. 3
0
    public virtual bool HandleGoods(GoodsCollection inventory)
    {
        for (int i = 0; i < Workers; i++)
        {
            //check required materials
            foreach (Good good in MaterialsRequired.Keys)
            {
                if (inventory[good] < MaterialsRequired[good])
                {
                    return(false);
                }
            }

            //+- goods
            foreach (Good good in inventory.Keys.ToArray())
            {
                if (MaterialsRequired.ContainsKey(good))
                {
                    inventory[good] -= MaterialsRequired[good];
                }

                if (MaterialsProduced.ContainsKey(good))
                {
                    inventory[good] += MaterialsProduced[good];
                }
            }

            BuildingEffect?.Invoke(inventory);
        }

        return(true);
    }
Esempio n. 4
0
    private Building GetHighestLevelHouse(GoodsCollection inventory)
    {
        House b = GetHouseStats(Level);

        //find the highest level of House we can support with our goods
        for (int i = Level; i > 0; i--)
        {
            bool canSupport = true;
            b = GetHouseStats(i);
            foreach (Good good in b.MaterialsRequired.Keys)
            {
                if (inventory[good] < b.MaterialsRequired[good])
                {
                    canSupport = false;
                }
            }

            if (b.CultureRequirement > Globals.CityManager.Culture)
            {
                canSupport = false;
            }

            if (canSupport)
            {
                //we have the highest level of House we can support
                break;
            }
        }

        CoinUpkeep        = b.CoinUpkeep;
        BuildingCost      = b.BuildingCost;
        MaterialsRequired = b.MaterialsRequired;
        MaterialsProduced = b.MaterialsProduced;
        return(b);
    }
Esempio n. 5
0
    /// <summary> Decrement BuildingCost from Inventory, otherwise return GoodsCollection of missing goods </summary>
    public virtual GoodsCollection TryStartConstruction(GoodsCollection inventory)
    {
        var missingGoods = new GoodsCollection();

        //check required materials
        foreach (Good good in BuildingCost.Keys)
        {
            var foo = inventory[good] - BuildingCost[good];
            if (foo < 0)
            {
                missingGoods.Add(good, -foo);
            }
        }

        if (missingGoods.Count > 0)
        {
            return(missingGoods);
        }

        //+- goods
        foreach (Good good in inventory.Keys.ToArray())
        {
            if (BuildingCost.ContainsKey(good))
            {
                inventory[good] -= BuildingCost[good];
            }
        }

        return(missingGoods);
    }
Esempio n. 6
0
 private void TaxPolicy(GoodsCollection goods)
 {
     MaterialsRequired = new GoodsCollection {
         { Good.PAPER, 2 }
     };
     CoinUpkeep = 20;
     _materialsProducedString = "tax+";
 }
Esempio n. 7
0
 private void ConscriptionPolicy(GoodsCollection goods)
 {
     MaterialsRequired = new GoodsCollection {
         { Good.PAPER, 3 }
     };
     CoinUpkeep = 15;
     _materialsProducedString = "military upkeep-";
 }
Esempio n. 8
0
 private void Architects(GoodsCollection goods)
 {
     MaterialsRequired = new GoodsCollection {
         { Good.TOOL, 3 }, { Good.PAPER, 5 }
     };
     CoinUpkeep = 20;
     _materialsProducedString = "upkeep+, culture+";
 }
Esempio n. 9
0
 private void Guilds(GoodsCollection goods)
 {
     MaterialsRequired = new GoodsCollection {
         { Good.WOOD, 3 }, { Good.STONE, 3 }, { Good.TOOL, 3 }
     };
     CoinUpkeep = 15;
     _materialsProducedString = "construction cost-";
 }
Esempio n. 10
0
 private void Research(GoodsCollection goods)
 {
     MaterialsRequired = new GoodsCollection {
         { Good.PAPER, 1 }
     };
     CoinUpkeep = 10;
     //research+
 }
Esempio n. 11
0
 private void HousingPolicy(GoodsCollection goods)
 {
     MaterialsRequired = new GoodsCollection {
         { Good.PAPER, 1 }
     };
     CoinUpkeep = 10;
     _materialsProducedString = "growth+";
 }
Esempio n. 12
0
 private void Carpenters(GoodsCollection goods)
 {
     MaterialsRequired = new GoodsCollection {
         { Good.WOOD, 3 }, { Good.TOOL, 1 }
     };
     CoinUpkeep = 10;
     _materialsProducedString = "production+";
     Globals.CityManager.SetProduction(2);
 }
Esempio n. 13
0
 public void ShowNextTurnModal(GoodsCollection goods, string text = null)    //TODO prob don't pass in text like this
 {
     gameObject.SetActive(true);
     foreach (var i in goods.Keys)
     {
         UpdateGoodIncomeText(i, goods[i]);
     }
     _eventText.text = text;
 }
Esempio n. 14
0
 private void ProduceBuildingMaterials(GoodsCollection goods)
 {
     Debug.Log("materials");
     MaterialsRequired = new GoodsCollection {
         { Good.IRON, 10 }, { Good.COAL, 4 }, { Good.TOOL, 8 }
     };
     MaterialsProduced = new GoodsCollection();
     CoinUpkeep        = 20;
     //production+
 }
Esempio n. 15
0
 private void ProduceTools(GoodsCollection goods)
 {
     Debug.Log("tools");
     MaterialsRequired = new GoodsCollection {
         { Good.IRON, 6 }, { Good.COAL, 3 }
     };
     MaterialsProduced = new GoodsCollection {
         { Good.TOOL, 12 }
     };
     CoinUpkeep = 15;
 }
Esempio n. 16
0
 private void ProduceSteel(GoodsCollection goods)
 {
     Debug.Log("steel");
     MaterialsRequired = new GoodsCollection {
         { Good.IRON, 7 }, { Good.COAL, 3 }
     };
     MaterialsProduced = new GoodsCollection {
         { Good.IRON, 12 }
     };
     CoinUpkeep = 10;
 }
Esempio n. 17
0
 private void ProduceWeapons(GoodsCollection goods)
 {
     Debug.Log("weapons");
     MaterialsRequired = new GoodsCollection {
         { Good.IRON, 10 }, { Good.COAL, 4 }
     };
     MaterialsProduced = new GoodsCollection {
         { Good.WEAPON, 10 }
     };
     CoinUpkeep = 20;
 }
Esempio n. 18
0
 public Products(GoodsCollection goods, AuthToken token)
 {
     Goods = new List <GoodsModel>();
     if (goods.goods is null)
     {
         return;
     }
     foreach (var item in goods.goods)
     {
         Goods.Add(new GoodsModel(item, token));
     }
 }
Esempio n. 19
0
    void OnClick()
    {
        Globals.BuildingManager.HandleBuildingsOnEndTurn();
        Globals.CityManager.AddTurns(1);

        //TODO: refactor this to somewhere else
        _collection.Add(Globals.BuildingManager.IncomeInventory);
        if (Globals.CityManager.Turns % 4 == 0)
        {
            Globals.NextTurnModal.ShowNextTurnModal(_collection, Globals.GameEventManager.GetText());
            _collection = new GoodsCollection(0);
        }
    }
Esempio n. 20
0
 public GoodsCollection(GoodsCollection goods)
 {
     foreach (KeyValuePair <Good, int> kvp in goods)
     {
         if (ContainsKey(kvp.Key))
         {
             this[kvp.Key] += kvp.Value;
         }
         else
         {
             Add(kvp.Key, kvp.Value);
         }
     }
 }
Esempio n. 21
0
 public House()
 {
     BuildingName   = "house";
     Tier           = 1;
     CoinCost       = 15;
     ProductionCost = 1;
     WorkerCapacity = 0;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 1 }
     };
     MaterialsRequired = new GoodsCollection();
     MaterialsProduced = new GoodsCollection();
     BuildingEffect    = null;
 }
Esempio n. 22
0
    public void Add(GoodsCollection b)
    {
        if (b == null)
        {
            return;
        }

        foreach (var key in b.Keys)
        {
            if (b[key] != 0)
            {
                this[key] += b[key];
            }
        }
    }
Esempio n. 23
0
 public Chapel()
 {
     SpriteSize     = new Vector2(2, 1);
     BuildingType   = BuildingEnum.CHAPEL;
     BuildingName   = "chapel";
     Tier           = 1;
     CoinCost       = 10;
     CoinUpkeep     = 1;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 5 }, { Good.STONE, 2 }, { Good.TOOL, 3 }
     };
     MaterialsRequired = new GoodsCollection();
     MaterialsProduced = new GoodsCollection();
     BuildingEffect    = null;
 }
Esempio n. 24
0
 public HuntingLodge()
 {
     SpriteSize     = new Vector2(2, 1);
     BuildingType   = BuildingEnum.HUNTING_LODGE;
     BuildingName   = "hunting_lodge";
     Tier           = 1;
     CoinCost       = 15;
     CoinUpkeep     = 2;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 1 }, { Good.STONE, 3 }, { Good.IRON, 1 }, { Good.TOOL, 2 }
     };
     MaterialsRequired = new GoodsCollection();
     MaterialsProduced = new GoodsCollection();
     BuildingEffect    = null;
 }
Esempio n. 25
0
 public PigFarm()
 {
     SpriteSize     = new Vector2(2, 1);
     BuildingType   = BuildingEnum.PIG_FARM;
     BuildingName   = "pig_farm";
     Tier           = 1;
     CoinCost       = 15;
     CoinUpkeep     = 2;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 3 }, { Good.STONE, 1 }, { Good.TOOL, 2 }
     };
     MaterialsRequired = new GoodsCollection();
     MaterialsProduced = new GoodsCollection {
         { Good.MEAT, 1 }
     };
     BuildingEffect = null;
 }
Esempio n. 26
0
 public WheatFarm()
 {
     SpriteSize     = new Vector2(4, 2);
     BuildingType   = BuildingEnum.WHEAT_FARM;
     BuildingName   = "wheat_farm";
     Tier           = 1;
     CoinCost       = 15;
     CoinUpkeep     = 2;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 1 }, { Good.TOOL, 1 }
     };
     MaterialsRequired = new GoodsCollection();
     MaterialsProduced = new GoodsCollection {
         { Good.GRAIN, 1 }
     };
     BuildingEffect = null;
 }
Esempio n. 27
0
 public Castle()
 {
     SpriteSize     = new Vector2(3, 2);
     BuildingType   = BuildingEnum.CASTLE;
     BuildingName   = "castle";
     Tier           = 1;
     CoinCost       = 10;
     CoinUpkeep     = 1;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 5 }, { Good.STONE, 2 }, { Good.TOOL, 3 }
     };
     MaterialsRequired = new GoodsCollection();
     MaterialsProduced = new GoodsCollection {
         { Good.WOOD, 1 }, { Good.STONE, 1 }, { Good.IRON, 1 }, { Good.TOOL, 1 }, { Good.GRAIN, 1 }, { Good.MEAT, 1 }, { Good.CLAY, 1 }, { Good.COAL, 1 }, { Good.FLAX, 1 }, { Good.HERB, 1 }, { Good.GOLD, 1 }, { Good.CERAMIC, 1 }, { Good.CLOTH, 1 }, { Good.ALE, 1 }, { Good.PAPER, 1 }, { Good.WEAPON, 1 }, { Good.ARTISAN, 1 },
     };
     BuildingEffect = null;
 }
Esempio n. 28
0
 public Lighthouse()
 {
     SpriteSize     = new Vector2(1, 2);
     BuildingType   = BuildingEnum.LIGHTHOUSE;
     BuildingName   = "lighthouse";
     Tier           = 1;
     CoinCost       = 10;
     CoinUpkeep     = 1;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 6 }, { Good.STONE, 8 }, { Good.IRON, 3 }, { Good.TOOL, 6 }
     };
     MaterialsRequired = new GoodsCollection {
         { Good.PAPER, 1 }
     };
     MaterialsProduced = new GoodsCollection();
     BuildingEffect    = null;
 }
Esempio n. 29
0
 public Barracks()
 {
     SpriteSize     = new Vector2(2, 1);
     BuildingType   = BuildingEnum.BARRACKS;
     BuildingName   = "barracks";
     Tier           = 3;
     CoinCost       = 10;
     CoinUpkeep     = 1;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 5 }, { Good.STONE, 2 }, { Good.TOOL, 3 }
     };
     MaterialsRequired = new GoodsCollection {
         { Good.FLAX, 1 }
     };
     MaterialsProduced = new GoodsCollection();
     BuildingEffect    = null;
 }
Esempio n. 30
0
 public Shipyard()
 {
     SpriteSize     = new Vector2(2, 1);
     BuildingType   = BuildingEnum.SHIPYARD;
     BuildingName   = "shipyard";
     Tier           = 1;
     CoinCost       = 15;
     CoinUpkeep     = 2;
     ProductionCost = 3;
     BuildingCost   = new GoodsCollection {
         { Good.WOOD, 1 }, { Good.TOOL, 3 }
     };
     MaterialsRequired = new GoodsCollection();
     MaterialsProduced = new GoodsCollection {
         { Good.STONE, 1 }
     };
     BuildingEffect = null;
 }