using System.Collections; using System.Collections.Generic; using UnityEngine; /// <summary> /// Handles generation of the shop encounter type /// </summary> public class ShopEncounter : Encounter<Shop> { /// <summary> /// Collection of item information and state /// </summary> public Shop Shop { get; private set; } // Flag for which Encounter has been instanced private const int ShopValue = 0; // Max quantity of potential IDs to be generated private readonly int ShopStockMaxID = 7; public ShopEncounter(int encounterValue) { // TODO ---> Add different sections and methods for increasing levels of encounter values as well as // location differences based on weather int shopStock; if (Globals.AlexsShopCheat) shopStock = -1; else shopStock = Random.Range(0, ShopStockMaxID); // Picks a random stock to instance (Dictionary<ItemSO, int> items, string[] shopAspects) = JsonReader.AspectCollector<ItemSO>.GatherProductAspects(shopStock); // Sets up shop by inputting shop and owner names this.Shop = new Shop(shopAspects[0], shopAspects[1]); // Stocks the newly instanced shop foreach (KeyValuePair<ItemSO, int> item in items) { if (item.Key is WeaponSO weapSO) this.Shop.Add(Globals.TurnWeaponFromObject(weapSO), item.Value); else if (item.Key is ApparelSO appSO) this.Shop.Add(Globals.TurnApparelFromObject(appSO), item.Value); else if (item.Key is ConsumableSO conSO) this.Shop.Add(Globals.TurnConsumableFromObject(conSO), item.Value); else if (item.Key is RelicSO relicSO) this.Shop.Add(Globals.TurnRelicFromObject(relicSO), item.Value); else this.Shop.Add(Globals.TurnItemFromObject(item.Key), item.Value); } // Sets up the misc Encounter logic such as weather and location ClimateManager.Instance.DecipherLocation(encounterValue, this); this.SetEncounter(Shop); GameManager.Instance.IndicateEncounterType(ShopValue, this); } }