private void SellResourcesButton_Click(int amount, Colony tempColony, MarketStorageElement resource) { List <ResourceInt> storage = tempColony.GetStorage(); for (int i = 0; i < storage.Count(); i++) { if (storage[i].Type.TypeString == resource.ResType.TypeString) { if (storage[i].Number < amount) { Console.WriteLine(storage[i].Number + " " + resource.Amount); ShowStatus("Excuse me this f*cking colony doesn't have enough resources to sell them"); return; } } } //double before = resource["amount"]; double price = resource.Sell * amount; tempColony.SellResource(resource, amount, price); resource.Amount += amount; //double after = resource["amount"]; //resource["sell"] *= before / after; _market.SetNewResourceData(resource); }
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); } } } }
private void ShowColoniesData(Colony colony) { string data = ""; string nameData = "Name : " + colony.Name + "\n"; string moneyData = "Money : " + colony.Money + "\n"; string buildingsData = "Number of buildings : " + colony.GetBuildings().Count() + "\n"; string resourcesData = "Resources : \n"; List <ResourceInt> tempList = colony.GetStorage(); for (int i = 0; i < tempList.Count(); i++) { resourcesData += tempList[i].Number + " of " + tempList[i].Type.TypeString + "\n"; } data = nameData + moneyData + buildingsData + resourcesData; ColonyInfoData.Text = data; }