// Generates an Item // Pass in item taken from Open(); public static ItemScriptableObject Generate(ItemScriptableObject iso) { GenerateSprite generateSprite = new GenerateSprite(); RandomManager randomManager = new RandomManager(); StatFactory statFactory = new ConcreteStatFactory(); ItemScriptableObject itemScriptableObject = ScriptableObject.CreateInstance <ItemScriptableObject>(); randomManager.SetAnimationCurve(); itemScriptableObject.itemSprite = iso.itemSprite; itemScriptableObject.itemName = iso.itemName; itemScriptableObject.itemType = iso.itemType; itemScriptableObject.itemTypeName = iso.itemType.ToString().ToLower(); itemScriptableObject.rarity = (ItemObject.Rarity)Mathf.RoundToInt(randomManager.CurveWeightedRandom(randomManager.cumulativeProbability)); itemScriptableObject.keyword = (ItemObject.Keywords)Mathf.RoundToInt(randomManager.CurveWeightedRandom(randomManager.cumulativeProbability)); itemScriptableObject.statCount = statFactory.GenerateStatAmountForObject(itemScriptableObject.rarity); itemScriptableObject.modifierList = new List <Stat>(); for (int i = 0; i < itemScriptableObject.statCount; i++) { Stat.StatType statType = statFactory.GenerateStatType(); Stat stat = statFactory.GetStatObject(statType, itemScriptableObject); int statIndex = DetectStatInList(itemScriptableObject.modifierList, statType); if (statIndex != -1) { itemScriptableObject.modifierList[statIndex].StatValue += stat.StatValue; itemScriptableObject.statCount--; } else { itemScriptableObject.modifierList.Add(stat); } } itemScriptableObject.itemBackgroundSprite = GenerateSpriteType(BackgroundSprites.backgroundSprites, itemScriptableObject.rarity); return(itemScriptableObject); }
public static int DetectStatInList(List <Stat> statList, Stat.StatType statType) { foreach (Stat stat in statList) { if (stat.statType == statType) { return(statList.IndexOf(stat)); } } return(-1); }
public override Stat GetStat(Stat.StatType statType, Item item) { switch (statType) { case Stat.StatType.LUCK: return(new Luck("Luck", Stat.StatType.LUCK, Stat.Rarity.EPIC, Stat.AffectedStat.RARITY, GenerateStatValue(GetItemRarity(item)))); case Stat.StatType.STRENGTH: return(new Strength("Strength", Stat.StatType.STRENGTH, Stat.Rarity.COMMON, Stat.AffectedStat.LOOT_AMOUNT, GenerateStatValue(GetItemRarity(item)))); case Stat.StatType.DEXTERITY: return(new Dexterity("Dexterity", Stat.StatType.DEXTERITY, Stat.Rarity.RARE, Stat.AffectedStat.ACCUMULATION, GenerateStatValue(GetItemRarity(item)))); case Stat.StatType.INTELLIGENCE: return(new Intelligence("Intelligence", Stat.StatType.INTELLIGENCE, Stat.Rarity.COMMON, Stat.AffectedStat.THEME, GenerateStatValue(GetItemRarity(item)))); } throw new System.NotImplementedException(); }
public Stat GetStat(Stat.StatType stat) { return(this.stats.Find(x => x.Type == stat)); }
public abstract Stat GetStatObject(Stat.StatType statType, ItemScriptableObject item);
public abstract Stat GetStat(Stat.StatType statType, Item item);
public StatAdditive(int value, Stat.StatType stat, string source) { this.Value = value; this.AffectedStat = stat; this.Source = source; }
public StatMultiplier(int value, Stat.StatType stat, string source) { this.Value = value; this.AffectedStat = stat; this.Source = source; }