Exemple #1
0
        private ResourceInt ChangeStorage(ResourceInt el, int changeAmount)
        {
            ResourceInt tempStorage = el;

            tempStorage.Number += changeAmount;
            return(tempStorage);
        }
 public void ExtractResources(Colony parentColony, Planet parentPlanet)
 {
     // Colony have enough food to work
     if (parentColony.ColonyWorks)
     {
         for (int i = 0; i < parentPlanet.GetResources().Count(); i++)
         {
             // if type of the building matches type of the resource building should extract resource
             if (parentPlanet.GetResources()[i].Type.TypeString == ResourceExtractionType.TypeString && parentPlanet.GetResources()[i].Amount > 0)
             {
                 parentPlanet.GetResources()[i].Amount -= Efficiency;
                 List <ResourceInt> storage = parentColony.GetStorage();
                 for (int j = 0; j < storage.Count(); j++)
                 {
                     if (storage[j].Type.TypeString == ResourceExtractionType.TypeString)
                     {
                         ResourceInt temp = storage[j];
                         temp.Number += Efficiency;
                         storage[j]   = temp;
                     }
                 }
                 //storage[ResourceExtractionType.TypeString].Amount += Efficiency;
                 parentColony.SetStorage(storage);
             }
         }
     }
 }
Exemple #3
0
        private List <ResourceInt> InitColonyStorage()
        {
            List <ResourceInt> list  = new List <ResourceInt>();
            ResourceInt        wood  = new ResourceInt(new Wood(), 100);
            ResourceInt        stone = new ResourceInt(new Stone(), 100);
            ResourceInt        food  = new ResourceInt(new Food(), 100);

            list.Add(wood);
            list.Add(stone);
            list.Add(food);
            return(list);
        }