void PrintSOs() { string printString = "ScriptableObjects:\n--ContainerFillers--\n"; ContainerFiller[] toListi = ContainerFiller.GetAll(); foreach (ContainerFiller s in toListi) { printString += s.GetDebugString() + "\n"; } printString += "--Effects--\n"; SOEffect[] toListe = SOEffect.GetAll(); foreach (SOEffect s in toListe) { printString += s.GetDebugString() + "\n"; } printString += "--Items--\n"; SOItem[] toListit = SOItem.GetAll(); foreach (SOItem s in toListit) { printString += s.GetDebugString() + "\n"; } printString += "--Recipes--\n"; SORecipe[] toListre = SORecipe.GetAll(); foreach (SORecipe s in toListre) { printString += s.GetDebugString() + "\n"; } printString += "End of ScriptableObjects"; Debug.Log(printString); }
private void OnEnable() { recipe = target as SORecipe; if (recipe.themes?.Length == 0) { InitializeThemes(); } }
public override bool AddToContainer(ContainerFiller item) { if (item == null) { return(false); } if (IsFull()) { return(false); } switch (item.thistype) { case ContainerFiller.INGREDIENTTYPE.LIQUID: contents.Add(item); break; case ContainerFiller.INGREDIENTTYPE.SOLID: if (IContainLiquid()) { // can add a solid if liquid is there already; contents.Add(item); } else { return(false); } break; default: return(false); } // Do we now match a recipe? if (contents.Count > 1) { // best check SORecipe nowcontents = SORecipe.findMatchingRecipe(contents.ToArray()); if (nowcontents != null) { //by jove we've done it calculateMixPotency(); ContainerFiller newContens = nowcontents.result; newContens.potency = mixPotency; int curContents = contents.Count; contents.Clear(); for (int i = 0; i < curContents; i++) { contents.Add(newContens); } } } refreshContentGraphic(); return(true); }
private void UpdateSlots(int x) { Debug.Log($"UPDATE SLOTS {x}"); currentRecipe = recipes[x]; for (int i = 0; i < slots.Count; i++) { if (i < currentRecipe.slots.Count) { print(currentRecipe.slots[i]); slots[i].SetActive(true); Vector3 position = slots[i].transform.position; Quaternion rotation = slots[i].transform.rotation; if (slots[i].GetComponent <UISlotScript>() != null) { if (slots[i].GetComponent <UISlotScript>().Container != null) { slots[i].GetComponent <UISlotScript>().Container.AddOne(); } } Destroy(slots[i]); switch (currentRecipe.slots[i].type) { case SlotType.STONE: slots[i] = Instantiate(stoneSlot, position, rotation, canvas.transform); break; case SlotType.WOOD: slots[i] = Instantiate(woodSlot, position, rotation, canvas.transform); break; case SlotType.DECORATION: slots[i] = Instantiate(decorationSlot, position, rotation, canvas.transform); break; case SlotType.INSPIRATION: slots[i] = Instantiate(inspirationSlot, position, rotation, canvas.transform); if (crafter != null) { slots[i].GetComponent <UISlotScript>().Fill(crafter); } break; } } else { slots[i].SetActive(false); } } }
void TestSOs() { //test ContainerFiller { ContainerFiller[] toCheck = ContainerFiller.GetAll(); Dictionary <int, string> potionIDs = new Dictionary <int, string>(); foreach (ContainerFiller s in toCheck) { if (potionIDs.ContainsKey(s.ID)) { Debug.LogError("ERROR: ContainerFiller " + s.name + " has the same ID as " + potionIDs[s.ID] + " = " + s.ID); } else { potionIDs.Add(s.ID, s.name); } // Check for null parameters if (s.color == null) { Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL Color"); } if (s.onConsumeEffect == null) { Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL onConsumeEffect"); } if (s.onGroundModel == null) { Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL onGroundModel"); } if (s.texture == null) { Debug.LogError("ERROR: ContainerFiller " + s.name + " has a NULL Texture"); } } } { //test effects SOEffect[] toCheck = SOEffect.GetAll(); Dictionary <int, string> effectIDs = new Dictionary <int, string>(); foreach (SOEffect s in toCheck) { if (effectIDs.ContainsKey(s.ID)) { Debug.LogError("ERROR: SOEffect " + s.name + " has the same ID as " + effectIDs[s.ID] + " = " + s.ID); } else { effectIDs.Add(s.ID, s.name); } } } { //test items SOItem[] toCheck = SOItem.GetAll(); Dictionary <int, string> itemIDs = new Dictionary <int, string>(); foreach (SOItem s in toCheck) { if (itemIDs.ContainsKey(s.ID)) { Debug.LogError("ERROR: SOItem " + s.name + " has the same ID as " + itemIDs[s.ID] + " = " + s.ID); } else { itemIDs.Add(s.ID, s.name); } if (s.model == null) { Debug.LogError("ERROR: SOItem " + s.name + " has a NULL model"); } } } { //test Recipes SORecipe[] toCheck = SORecipe.GetAll(); Dictionary <int, string> itemIDs = new Dictionary <int, string>(); foreach (SORecipe s in toCheck) { if (itemIDs.ContainsKey(s.ID)) { Debug.LogError("ERROR: SORecipe " + s.name + " has the same ID as " + itemIDs[s.ID] + " = " + s.ID); } else { itemIDs.Add(s.ID, s.name); } if (s.result == null) { Debug.LogError("ERROR: SORecipe " + s.name + " has a NULL result"); } if (s.ingredients == null) { Debug.LogError("ERROR: SORecipe " + s.name + " has a NULL ingredients"); } else if (s.ingredients.Length < 2) { Debug.LogError("ERROR: SORecipe " + s.name + " has a less than 2 ingredients"); } else { foreach (ContainerFiller c in s.ingredients) { if (c == null) { Debug.LogError("ERROR: SORecipe " + s.name + " contains a NULL ingredient in it's list."); break; } } } } } }
public override void OnInspectorGUI() { recipe = target as SORecipe; if (recipe.themes == null) { InitializeThemes(); } if (recipe.themes?.Length == 0) { recipe.themes = new ThemeSet[15]; for (int i = 0; i < 16; i++) { switch (i) { case 0: case 1: case 2: case 3: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)i } }; break; case 4: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)0, (Theme)1 } }; break; case 5: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)0, (Theme)2 } }; break; case 6: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)0, (Theme)3 } }; break; case 7: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)1, (Theme)2 } }; break; case 8: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)1, (Theme)3 } }; break; case 9: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)2, (Theme)3 } }; break; case 10: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)0, (Theme)1, (Theme)2 } }; break; case 11: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)0, (Theme)2, (Theme)3 } }; break; case 12: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)0, (Theme)1, (Theme)3 } }; break; case 13: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)1, (Theme)2, (Theme)3 } }; break; case 14: recipe.themes[i] = new ThemeSet { themes = new Theme[] { (Theme)0, (Theme)1, (Theme)2, (Theme)3 } }; break; } } } if (recipe.slots == null) { recipe.slots = new List <Slot>(); } EditorGUILayout.BeginVertical("Box"); foreach (Slot slot in recipe.slots) { EditorGUILayout.BeginHorizontal(); slot.type = (SlotType)EditorGUILayout.EnumPopup("", slot.type); if (GUILayout.Button("X")) { recipe.slots.Remove(slot); } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add Slot")) { recipe.slots.Add(new Slot()); } EditorGUILayout.EndVertical(); if (recipe.results == null || NumberOfVariables() != variableNumber) { switch (NumberOfVariables()) { case 0: recipe.results = new GameObject[1]; break; case 1: recipe.results = new GameObject[4]; break; case 2: recipe.results = new GameObject[10]; break; case 3: recipe.results = new GameObject[14]; break; case 4: recipe.results = new GameObject[15]; break; } variableNumber = NumberOfVariables(); } EditorGUILayout.BeginVertical("Box"); for (int i = 0; i < recipe.results.Length; i++) { EditorGUILayout.BeginHorizontal(); string labelText = ""; switch (NumberOfVariables()) { case 0: labelText = "Base"; break; case 1: labelText = recipe.themes[i].themes[0].ToString(); break; case 2: if (i < 4) { labelText = recipe.themes[i].themes[0].ToString(); } else { labelText = $"{recipe.themes[i].themes[0].ToString()}, {recipe.themes[i].themes[1].ToString()}"; } break; case 3: if (i < 4) { labelText = recipe.themes[i].themes[0].ToString(); } else if (i < 10) { labelText = $"{recipe.themes[i].themes[0].ToString()}, {recipe.themes[i].themes[1].ToString()}"; } else { labelText = $"{recipe.themes[i].themes[0].ToString()}, {recipe.themes[i].themes[1].ToString()}, {recipe.themes[i].themes[2].ToString()}"; } break; case 4: if (i < 4) { labelText = recipe.themes[i].themes[0].ToString(); } else if (i < 10) { labelText = $"{recipe.themes[i].themes[0].ToString()}, {recipe.themes[i].themes[1].ToString()}"; } else if (i < 14) { labelText = $"{recipe.themes[i].themes[0].ToString()}, {recipe.themes[i].themes[1].ToString()}, {recipe.themes[i].themes[2].ToString()}"; } else { labelText = $"{recipe.themes[i].themes[0].ToString()}, {recipe.themes[i].themes[1].ToString()}, {recipe.themes[i].themes[2].ToString()}, {recipe.themes[i].themes[3].ToString()}"; } break; default: labelText = "Default"; break; } EditorGUILayout.LabelField(labelText); recipe.results[i] = (GameObject)EditorGUILayout.ObjectField(recipe.results[i], typeof(GameObject), false); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); //base.OnInspectorGUI(); EditorUtility.SetDirty(target); }