public void setSlot(ItemShopSlot slot) { SelectecSlot = slot; GuiBuyBuilding BuyGUI = Window.GetComponent<GuiBuyBuilding>(); BuyGUI.Title.text = slot.text.text; BuyGUI.BuildingImage.sprite = slot.Slot_Image.sprite; BuyGUI.ShopGameItem = slot.ShopItem; BuyGUI.Description.text = slot.ShopItem.GetComponent<Text>().text; if (DoAfford(slot, BuyGUI) == true) UnLock(BuyGUI); else Lock(BuyGUI); }
public bool DoAfford(ItemShopSlot slot , GuiBuyBuilding BuyGui) { bool ErrorFlag = false; ItemShop item = slot.ShopItem; setPrice(item, BuyGui); if (BuyGui.Wood.get() < item.Wood) { ErrorFlag = true; BuyGui.setColor(BuyGui.WoodText, BuyGui.ErrorResourceColor); } else BuyGui.setColor(BuyGui.WoodText, BuyGui.NormarResourceColor); if (BuyGui.Stone.get() < item.Stone) { ErrorFlag = true; BuyGui.setColor(BuyGui.StoneText, BuyGui.ErrorResourceColor); } else BuyGui.setColor(BuyGui.StoneText, BuyGui.NormarResourceColor); if (BuyGui.ObsydianBrick.get() < item.ObsydianBrick) { ErrorFlag = true; BuyGui.setColor(BuyGui.ObsydianText, BuyGui.ErrorResourceColor); } else BuyGui.setColor(BuyGui.ObsydianText, BuyGui.NormarResourceColor); if (item.Recipe.CheckAfford() == false) { ErrorFlag = true; BuyGui.setColor(BuyGui.RecipeText, BuyGui.ErrorResourceColor); } else BuyGui.setColor(BuyGui.RecipeText, BuyGui.NormarResourceColor); if (ErrorFlag == true) return false; else return true; }
public static void RunStats(MT19337 rng, IItemPlacementFlags flags, IncentiveData incentivesData, ItemShopSlot caravanItemLocation, OverworldMap overworldMap) { Dictionary <MapLocation, Tuple <List <MapChange>, AccessRequirement> > fullLocationRequirements = overworldMap.FullLocationRequirements; var placedItems = new List <IRewardSource>(); var treasurePool = ItemLocations.AllTreasures.Where(x => !x.IsUnused).Select(x => x.Item) .Concat(ItemLists.AllNonTreasureChestItems).ToList(); var requirementChecks = ItemLists.AllQuestItems.ToDictionary(x => x, x => 0); requirementChecks[Item.Ribbon] = 0; var requirementsToCheck = new List <Item> { Item.Crown, Item.Crystal, Item.Herb, Item.Tnt, Item.Adamant, Item.Slab, Item.Ruby, Item.Bottle, Item.Floater, Item.Ship, Item.Bridge, Item.Canal }; const int maxIterations = 255; var forcedIceCount = 0; var itemPlacementStats = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <int>()); itemPlacementStats[Item.Ribbon] = new List <int>(); var itemPlacementZones = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <string>()); itemPlacementZones[Item.Ribbon] = new List <string>(); long iterations = 0; var timeElapsed = new Stopwatch(); while (iterations < maxIterations) { iterations++; // When Enemy Status Shuffle is turned on Coneria is reduced to 11% chance with other shops spliting the remaining 89% var shopTownSelected = ItemShops.PickRandom(rng); var itemShopItem = new ItemShopSlot(ItemLocations.CaravanItemShop1.Address, $"{Enum.GetName(typeof(MapLocation), shopTownSelected)}Shop", shopTownSelected, Item.Bottle); timeElapsed.Start(); placedItems = ItemPlacement.PlaceSaneItems(rng, flags, incentivesData, treasurePool, itemShopItem, overworldMap); timeElapsed.Stop(); var outputIndexes = placedItems.ToLookup(x => x.Item, x => x); foreach (Item item in itemPlacementStats.Keys) { itemPlacementStats[item].AddRange(outputIndexes[item].Select(x => x.Address).ToList()); } var outputZones = placedItems .ToLookup(x => x.Item, x => Enum.GetName(typeof(MapLocation), x.MapLocation)); foreach (Item item in itemPlacementZones.Keys) { if (!outputZones[item].Any()) { continue; } itemPlacementZones[item].AddRange(outputZones[item]); } var matoyaShip = placedItems.Any(x => x.Address == ItemLocations.Matoya.Address && x.Item == Item.Ship); var crystalIceCave = placedItems.Any(x => x.Item == Item.Crystal && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyIceCave = placedItems.Any(x => x.Item == Item.Key && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyLockedCrystal = placedItems.Any(x => x.Item == Item.Crystal && x.AccessRequirement.HasFlag(AccessRequirement.Key)); var keyLockedShip = placedItems.Any(x => x.Item == Item.Ship && x.AccessRequirement.HasFlag(AccessRequirement.Key)); if ((keyLockedShip && keyIceCave) || (matoyaShip && crystalIceCave) || (matoyaShip && keyLockedCrystal && keyIceCave)) { forcedIceCount++; } foreach (Item item in requirementsToCheck) { if (!ItemPlacement.CheckSanity(placedItems.Where(x => x.Item != item).ToList(), fullLocationRequirements, new Flags { OnlyRequireGameIsBeatable = true })) { requirementChecks[item]++; } } } if (iterations > 10) { Debug.WriteLine(PrintStats(maxIterations, itemPlacementStats, itemPlacementZones, requirementChecks)); Debug.WriteLine($"Forced Early Ice Cave for Ship: {forcedIceCount} out of {maxIterations}"); Debug.WriteLine($"Time per iteration: {1.0 * timeElapsed.ElapsedMilliseconds / iterations}"); } }
public static void RunStats(MT19337 rng, ITreasureShuffleFlags flags, IncentiveData incentivesData) { var forcedItems = ItemLocations.AllOtherItemLocations.ToList(); if (!flags.NPCItems) { forcedItems = ItemLocations.AllNonTreasureItemLocations.ToList(); } var placedItems = new List <IRewardSource>(); var treasurePool = ItemLocations.AllTreasures.Where(x => !x.IsUnused).Select(x => x.Item).ToList(); var requirementChecks = ItemLists.AllQuestItems.ToDictionary(x => x, x => 0); requirementChecks[Item.Ribbon] = 0; var requirementsToCheck = new List <Item> { Item.Crown, Item.Crystal, Item.Herb, Item.Tnt, Item.Adamant, Item.Slab, Item.Ruby, Item.Bottle, Item.Canal }; const int maxIterations = 10000; var forcedIceCount = 0; var itemPlacementStats = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <int>()); itemPlacementStats[Item.Ribbon] = new List <int>(); var itemPlacementZones = ItemLists.AllQuestItems.ToDictionary(x => x, x => new List <string>()); itemPlacementZones[Item.Ribbon] = new List <string>(); var mapLocationRequirements = ItemLocations.MapLocationRequirements.ToDictionary(x => x.Key, x => x.Value.ToList()); long iterations = 0; while (iterations < maxIterations) { iterations++; // When Enemy Status Shuffle is turned on Coneria is reduced to 11% chance with other shops spliting the remaining 89% var shopTownSelected = ItemShops.PickRandom(rng); var itemShopItem = new ItemShopSlot(ItemLocations.CaravanItemShop1.Address, $"{Enum.GetName(typeof(MapLocation), shopTownSelected)}Shop", shopTownSelected, Item.Bottle); placedItems = ItemPlacement.PlaceSaneItems(rng, flags, incentivesData, treasurePool, itemShopItem, mapLocationRequirements); var outputIndexes = placedItems.ToLookup(x => x.Item, x => x); foreach (Item item in itemPlacementStats.Keys) { itemPlacementStats[item].AddRange(outputIndexes[item].Select(x => x.Address).ToList()); } var outputZones = placedItems .ToLookup(x => x.Item, x => Enum.GetName(typeof(MapLocation), x.MapLocation)); foreach (Item item in itemPlacementZones.Keys) { if (!outputZones[item].Any()) { continue; } itemPlacementZones[item].AddRange(outputZones[item]); } var matoyaShip = placedItems.Any(x => x.Address == ItemLocations.Matoya.Address && x.Item == Item.Ship); var crystalIceCave = placedItems.Any(x => x.Item == Item.Crystal && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyIceCave = placedItems.Any(x => x.Item == Item.Key && x.Address >= ItemLocations.IceCave1.Address && x.Address <= ItemLocations.IceCaveMajor.Address); var keyLockedCrystal = placedItems.Any(x => x.Item == Item.Crystal && x.AccessRequirement.HasFlag(AccessRequirement.Key)); var keyLockedShip = placedItems.Any(x => x.Item == Item.Ship && x.AccessRequirement.HasFlag(AccessRequirement.Key)); if ((keyLockedShip && keyIceCave) || (matoyaShip && crystalIceCave) || (matoyaShip && keyLockedCrystal && keyIceCave)) { forcedIceCount++; } foreach (Item item in requirementsToCheck) { if (!ItemPlacement.CheckSanity(placedItems.Where(x => x.Item != item).ToList(), flags, mapLocationRequirements)) { requirementChecks[item]++; } } } if (iterations > 10) { Debug.WriteLine(PrintStats(maxIterations, itemPlacementStats, itemPlacementZones, requirementChecks)); Debug.WriteLine($"Forced Early Ice Cave for Ship: {forcedIceCount} out of {maxIterations}"); } }