public bool BuyLand(int x, int y) { if (EconomyValueCall.Balance < LandArray[(x * TopValue.TopValueSingleton.MapSize) + y].LandValue) { if (CompanyManagerCall.PlayerCompanyName == CompanyValueCall.CompanyName) { // GameObject.Find("NotificationManager").GetComponent<NotificationManager>().SetNote("Lack of money", true, new Color(1f,0f,0f)); } return(false); } EconomyValueCall.AddHistory(TimeManagerCall.TimeValue, "Real Estate", "Buy a " + LandArray[(x * TopValue.TopValueSingleton.MapSize) + y].LandStatus, x + "," + y + " " + LandArray[(x * TopValue.TopValueSingleton.MapSize) + y].LandStatus, -LandArray[(x * TopValue.TopValueSingleton.MapSize) + y].LandValue); EconomyValueCall.ModifyPersistHistory("Land Tax", -LandArray[(x * TopValue.TopValueSingleton.MapSize) + y].LandValue / 100); ChangeLandStatus(x, y, "Factory", -1000); ActivatedLandCount++; if (ActivatedLandCount == 1) { GetFactoryAffectLandIndex(x, y); } return(true); }
public List <float> BuyItem(string Name, string BuyerName, int Num) { List <float> result = new List <float>(); int Index = getSalesIndex(Name); if (Index == -1) { Debug.Log("No Info of " + Name + ". Try from " + BuyerName); result.Add(-1f); return(result); } SalesInfo TargetItem = SalesItemArray[Index]; GoodsValue SellerGoodsValueCall = CompanyManagerCall.GetCompanyValue(TargetItem.Seller).GetGoodsValue().GetComponent <GoodsValue>(); EconomyValue SellerEconomyCall = CompanyManagerCall.GetCompanyValue(TargetItem.Seller).GetEconomyValue().GetComponent <EconomyValue>(); int Limit = 0; if (TargetItem.ItemCount >= Num) { Limit = Num; } else if (TargetItem.ItemCount > 0) { Limit = TargetItem.ItemCount; } else { // Debug.Log("Lack of stock " + TargetItem.ItemCount + " " + Num); result.Add(-2f); return(result); } float TotalQualityValue = TargetItem.QualityEvaluation * TargetItem.SoldCount; for (int i = 0; i < Limit; i++) { int GoodsID = SellerGoodsValueCall.FindGoodsID(Name, false); if (GoodsID == -1) { Debug.Log("No Info of " + TargetItem.Seller + "'s " + Name + ". Try from " + BuyerName); result.Add(-1f); return(result); } if (BuyerName != "Consumer") { GoodsValue BuyerGoodsValueCall = CompanyManagerCall.GetCompanyValue(BuyerName).GetGoodsValue().GetComponent <GoodsValue>(); EconomyValue BuyerEconomyCall = CompanyManagerCall.GetCompanyValue(BuyerName).GetEconomyValue().GetComponent <EconomyValue>(); if (BuyerEconomyCall.Balance < TargetItem.Price) { result.Add(0f); return(result); } BuyerGoodsValueCall.AddGoodsArray(Name, SellerGoodsValueCall.CheckQuality(GoodsID)); BuyerEconomyCall.AddHistory(TimeManagerCall.TimeValue, "Buy", Name, "Buy " + Name + " from " + TargetItem.Seller, -TargetItem.Price); } result.Add(SellerGoodsValueCall.CheckQuality(GoodsID)); SellerGoodsValueCall.DeleteGoodsArray(GoodsID); SellerEconomyCall.AddHistory(TimeManagerCall.TimeValue, "Sell", Name, TargetItem.Seller + " Sells " + Name + " to " + BuyerName, TargetItem.Price); if (TargetItem.Seller == CompanyManagerCall.PlayerCompanyName && TargetItem.SoldCount == 0) { NotificationManagerCall.AddNews("Award", "Your first shipment of " + Name + " products has been made!"); } TargetItem.ItemCount--; TargetItem.SoldCount++; } foreach (var quality in result) { TotalQualityValue += quality; } TargetItem.QualityEvaluation = TotalQualityValue / TargetItem.SoldCount; if (PanelControllerCall.CurrentSidePanel != null) { if (PanelControllerCall.CurrentSidePanel.name == "ContractPanel") { ContractPanelController PanelComponent = PanelControllerCall.CurrentSidePanel.GetComponent <ContractPanelController>(); PanelComponent.UpdateRemainQuantityText(); if (PanelComponent.CurrentItem == TargetItem.RecipeInfo.Recipe.OutputName) { PanelComponent.UpdateSalesInfo(); } } } return(result); }