public void Add(Element element, bool negative = false) { if (negative) { Negatives = Negatives.Concat(Items(element)); } else { Positives = Positives.Concat(Items(element)); } }
private void FindAppropriateCollectionForEachNumber(int[] data) { foreach (var number in data) { if (number.IsNegative()) { Negatives.Add(number); } if (number.IsPositive()) { Positives.Add(number); } if (number == 0) { ZeroPresent = true; } } }
public SavedData(AllCharacterStats characterStats, Inventory inventory) { // player position/rotation position = new float[3]; position[0] = characterStats.transform.position.x; position[1] = characterStats.transform.position.y; position[2] = characterStats.transform.position.z; rotation = new float[4]; rotation[0] = characterStats.transform.rotation.x; rotation[1] = characterStats.transform.rotation.y; rotation[2] = characterStats.transform.rotation.z; rotation[3] = characterStats.transform.rotation.w; // player stats balance = characterStats.Balance; health = characterStats.Health; protection = characterStats.Protection; speed = characterStats.Speed; damage = characterStats.Damage; // player inventory inventorySlots = inventory.InventoryItems.Count; inventoryItems = new List <InventoryItem>(); inventoryEquipment = new List <InventoryEquipment>(); for (int i = 0; i < inventorySlots; i++) { Debug.Log("checking inventory slot at index" + i); if (inventory.GetInventory()[i] != null) { Debug.Log("found item at index " + i); if (inventory.GetInventory()[i].item is EquipmentBlueprint) { InventoryEquipment item = new InventoryEquipment(); EquipmentBlueprint equipBP = inventory.GetInventory()[i].item.equipBP; EquipmentSlots equipmentSlots = equipBP.EquipSlot; item.EquipSlot = equipmentSlots; List <Positives> positives = new List <Positives>(); for (int j = 0; j < equipBP.PositiveTraits.Count; j++) { Positives posTrait = new Positives(); posTrait.traitLevel = equipBP.PositiveTraits[j].traitLevel; posTrait.traits = equipBP.PositiveTraits[j].traits; positives.Add(posTrait); } List <Negatives> negatives = new List <Negatives>(); for (int j = 0; j < equipBP.NegativeTraits.Count; j++) { Negatives negTrait = new Negatives(); negTrait.traitLevel = equipBP.NegativeTraits[j].traitLevel; negTrait.traits = equipBP.NegativeTraits[j].traits; negatives.Add(negTrait); } item.ItemName = equipBP.ItemName; Texture2D tex = equipBP.ItemIcon.texture; exportObj.x = tex.width; exportObj.y = tex.height; exportObj.bytes = ImageConversion.EncodeToPNG(tex); string icon = JsonUtility.ToJson(exportObj, false); item.ItemIcon = icon; item.isDefault = equipBP.isDefault; item.StackUntil = equipBP.StackUntil; item.Bundle = equipBP.Bundle; item.AssetName = equipBP.AssetName; item.ItemDescription = equipBP.ItemDescription; inventoryEquipment.Add(item); } else { InventoryItem item = new InventoryItem(); ItemBlueprint itemBP = inventory.GetInventory()[i].item; item.ItemName = itemBP.ItemName; Texture2D tex = itemBP.ItemIcon.texture; exportObj.x = tex.width; exportObj.y = tex.height; exportObj.bytes = ImageConversion.EncodeToPNG(tex); string icon = JsonUtility.ToJson(exportObj, false); item.ItemIcon = icon; item.isDefault = itemBP.isDefault; item.StackUntil = itemBP.StackUntil; item.Bundle = itemBP.Bundle; item.AssetName = itemBP.AssetName; item.ItemDescription = itemBP.ItemDescription; inventoryItems.Add(item); } } } }
public void Add(CharClassSet set, bool invert = false) { Positives = Positives.Concat(!invert ? set.Positives : set.Negatives); Negatives = Negatives.Concat(!invert ? set.Negatives : set.Positives); }
private void SortCollections() { Negatives.Sort(); // We want positives in descending order because logic uses it that way Positives.SortDescending(); }