public override int MoveInto(BuildingInventory receiver, int count)
        {
            BuildingInventory sender = this;
            int startCount           = count;

            bool transmittedARessource = true;

            while (count > 0 && transmittedARessource)
            {
                transmittedARessource = false;
                foreach (RessourceType ressourceType in sender.Outgoing)
                {
                    if (count <= 0)
                    {
                        break;
                    }
                    if (receiver.Incoming.Contains(ressourceType))
                    {
                        int senderAmount = sender.GetRessourceAmount(ressourceType);

                        int received = receiver.AddRessource(ressourceType, Mathf.Min(senderAmount, 1));
                        count -= received;
                        if (received > 0)
                        {
                            transmittedARessource = true;
                        }
                        sender.RemoveRessource(ressourceType, received);
                    }
                }
            }
            return(startCount - count);
        }
        public virtual bool FillCart(Cart cart, InventoryBuilding origin)
        {
            cart.Inventory.RessourceLimit = this.ConnectedInventories[origin].Item2;
            BuildingInventory destination = this.Inventory;
            bool ressourceAdded           = true;

            while (ressourceAdded)
            {
                ressourceAdded = false;
                foreach (RessourceType ressourceType in destination.Incoming)
                {
                    if (origin.Inventory.Outgoing.Contains(ressourceType) && origin.AllowedRessources[this][ressourceType])
                    {
                        if (origin.Inventory.Outgoing.Contains(ressourceType))
                        {
                            if (cart.Inventory.AvailableSpace() > 0)
                            {
                                if (origin.Inventory.GetRessourceAmount(ressourceType) > 0)
                                {
                                    cart.Inventory.AddRessource(ressourceType, 1);
                                    origin.Inventory.RemoveRessource(ressourceType, 1);
                                    ressourceAdded = true;
                                }
                            }
                        }
                    }
                }
            }
            return(!cart.Inventory.IsEmpty());
        }
Example #3
0
        public virtual int MoveInto(BuildingInventory receiver, int count)
        {
            Inventory sender     = this;
            int       startCount = count;

            bool transmittedARessource = true;

            while (count > 0 && transmittedARessource)
            {
                transmittedARessource = false;
                List <RessourceType> iterList = new List <RessourceType>(sender.Storage.Keys);
                foreach (RessourceType ressourceType in iterList)
                {
                    if (count <= 0)
                    {
                        break;
                    }
                    if (receiver.Incoming.Contains(ressourceType))
                    {
                        int senderAmount = sender.GetRessourceAmount(ressourceType);
                        int received     = receiver.AddRessource(ressourceType, Mathf.Min(senderAmount, 1));
                        count -= received;
                        if (received > 0)
                        {
                            transmittedARessource = true;
                        }
                        sender.RemoveRessource(ressourceType, received);
                    }
                }
            }
            return(startCount - count);
        }
Example #4
0
 public Headquarter() : base()
 {
     this.Inventory.Storage  = BuildingInventory.GetDictionaryForAllRessources();
     this.Inventory.Incoming = BuildingInventory.GetListOfAllRessources();
     this.Inventory.Outgoing = BuildingInventory.GetListOfAllRessources();
     this.Inventory.UpdateRessourceLimits(new Dictionary <RessourceType, int> {
         { RessourceType.WOOD, 40 }, { RessourceType.STONE, 20 }, { RessourceType.IRON, 20 }, { RessourceType.COAL, 10 }
     });
 }
Example #5
0
 public Headquarter(
     HexCell Cell,
     byte Tribe,
     byte Level,
     byte Health,
     TroopInventory TroopInventory,
     BuildingInventory Inventory
     ) : base(Cell, Tribe, Level, Health, TroopInventory, Inventory)
 {
 }
Example #6
0
 public ProductionBuilding(
     HexCell Cell,
     byte Tribe,
     byte Level,
     byte Health,
     TroopInventory TroopInventory,
     BuildingInventory Inventory,
     int Progress
     ) : base(Cell, Tribe, Level, Health, TroopInventory, Inventory, Progress)
 {
 }
Example #7
0
 public Woodcutter(
     HexCell Cell,
     byte Tribe,
     byte Level,
     byte Health,
     TroopInventory TroopInventory,
     BuildingInventory Inventory,
     int Progress
     ) : base(Cell, Tribe, Level, Health, TroopInventory, Inventory, Progress)
 {
 }
Example #8
0
 public ProgressBuilding(
     HexCell Cell,
     byte Tribe,
     byte Level,
     byte Health,
     TroopInventory TroopInventory,
     BuildingInventory Inventory,
     int Progress
     ) : base(Cell, Tribe, Level, Health, TroopInventory, Inventory)
 {
     this.Progress = Progress;
 }
 public InventoryBuilding() : base()
 {
     this.Inventory = new BuildingInventory();
     this.Inventory.RessourceLimit = this.RessourceLimit;
     this.ConnectedInventories     = new Dictionary <InventoryBuilding, Tuple <HexDirection, int, int> >();
     this.AllowedRessources        = new Dictionary <InventoryBuilding, Dictionary <RessourceType, bool> >();
     this.Carts = new List <Cart>();
     for (int i = 0; i < this.MaxCartCount; i++)
     {
         this.Carts.Add(new Cart(this));
     }
 }
 public InventoryBuilding(
     HexCell Cell,
     byte Tribe,
     byte Level,
     byte Health,
     TroopInventory TroopInventory,
     BuildingInventory Inventory
     ) : base(Cell, Tribe, Level, Health, TroopInventory)
 {
     this.Inventory            = Inventory;
     this.ConnectedInventories = new Dictionary <InventoryBuilding, Tuple <HexDirection, int, int> >();
     this.Carts = new List <Cart>();
 }
Example #11
0
 public Market(
     HexCell Cell,
     byte Tribe,
     byte Level,
     byte Health,
     TroopInventory TroopInventory,
     BuildingInventory Inventory,
     int Progress,
     RessourceType TradeInput,
     RessourceType TradeOutput
     ) : base(Cell, Tribe, Level, Health, TroopInventory, Inventory, Progress)
 {
     this.TradeInput  = TradeInput;
     this.TradeOutput = TradeOutput;
 }
Example #12
0
 public Storage() : base()
 {
     this.Inventory.Storage  = BuildingInventory.GetDictionaryForAllRessources();
     this.Inventory.Incoming = BuildingInventory.GetListOfAllRessources();
     this.Inventory.Outgoing = BuildingInventory.GetListOfAllRessources();
 }