public float SellItems(ItemContainer sitem, int quant) { TradeItem titem = retrieveFromStock(sitem.getName()); if (titem != null) { money += titem.currentBuyPrice * sitem.quantity * 0.05f; titem.addStock(sitem.quantity); return(titem.currentSellPrice * quant * 0.95f); } else { return(0.0f); } }
public void ticker() { if (localPops != null && localPops.Count > 0) { foreach (Pop p in localPops) { if (p != null && p.workplace == null) { industries = p.lookingForJob(industries); } if (p != null && p.type == 5) { ((Merchant)p).analyzeMarket(stock); } } } if (industries.Any()) { foreach (Industry ind in industries) { // Debug.Log("FILL " + ind); stock = ind.fillStock(stock); List <StockItem> prod = ind.process(); if (prod != null) { foreach (StockItem item in prod) { TradeItem titem = stock.Find(x => x.getName() == item.getName()); titem.addStock(item.quantity); } } } } if (foodStock >= 10 && prosperity >= 100) { popGrowth++; if (popGrowth >= 100) { localPops.Add(WorldGenerator.generatePop(1, this)); popGrowth -= 100; // Debug.Log("New Péon spawn"); } } economyStack++; if (economyStack >= economySpeed) { economyStack = 0; EconomicTurn(); } if (foodStock < 100 * tier) { foreach (TradeItem item in stock) { while (item.getFoodValue() > 0 && foodStock < 100 * tier && item.quantity > 0) { foodStock += item.takeStock(1) * item.getFoodValue(); } } } foreach (Pop l in leavingPops) { localPops.Remove(l); } leavingPops = new List <Pop>(); }