//Get the actual stat value of a stat. public float GetComponentValue(EquipComponent c) { //Items start with 1% potential. float r = (c.value * 0.01f);// * (float)level; //The remaining 99% is as follows. float p = (c.value * 0.99f); r += p * ((level * level) * 0.0001f); r = Mathf.CeilToInt(r); return(r); }
//Generate substats for equipment. public static Equipment GenerateSubstats(Equipment r) { //Roll substats. while (r.SubStats.Count < Mathf.FloorToInt((float)r.level / 10f) && r.SubStats.Count < r.substatCount) { //Get a new substat. EquipComponent c = r.SubStatsChoices[Random.Range(0, r.SubStatsChoices.Count)]; //If we don't already have a substat with this. if (r.SubStats.Find(n => n.stat == c.stat) == null || c.stat == EquipStats.EXP) // Known bug: Duplicate rolls of a stat like EXP always have the same value for some reason. { Vector2 v = r.GetSubstatVectorGroup(c.statGroup); c.value = Mathf.Round(Random.Range(v.x, v.y)); r.SubStats.Add(c); } } return(r); }
protected override void OnUpdate() { for (int i = 0; i < EquipEntities.Length; i++) { InventoryComponent inventory = EquipEntities.InventoryComponents[i]; EquipComponent equipment = EquipEntities.EquipComponents[i]; if (!inventory.dirty) { return; } int length = Mathf.Min(inventory.inventory.Count, equipment.equipSlots.Count); // Indexing for inventory should correspond with equipment slots for (int j = 0; j < length; j++) { if (inventory.inventory[j] != Entity.Null) { // Drop any previously equipped items for (int x = 0; x < equipment.equipSlots[j].childCount; x++) { equipment.equipSlots[j].GetChild(x).SetParent(null); } EntityManager.GetComponentObject <Transform>(inventory.inventory[j]).SetParent(equipment.equipSlots[j]); EntityManager.GetComponentObject <Transform>(inventory.inventory[j]).localPosition = Vector3.zero; } else // If item slot is null item is dropped { for (int x = 0; x < equipment.equipSlots[j].childCount; x++) { equipment.equipSlots[j].GetChild(x).SetParent(null); } } } } }