private void ToggleBreakpointAndColliderOnPotions() { // clear breakpoints on all potions GameObject[] potions = GameObject.FindGameObjectsWithTag("Potion"); foreach (GameObject gameObject in potions) { ExecutePotionScript ep = gameObject.GetComponent <ExecutePotionScript> (); ep.ClearBreakpoint(); ep.HideBreakpointText(); ep.HideFormula(); } // disable box collider on potions not involved in this path // enable box collider on potions involved in this path (in case it has been disabled previously) //!!!!!!!!!!!!!! do not disable collider - show dialogue instead - 16/09/18 /*foreach (GameObject potion in potions){ * if (!currentPathObjects.Contains (potion)) { * potion.GetComponent<BoxCollider2D> ().enabled = false; * } else { * potion.GetComponent<BoxCollider2D> ().enabled = true; * } * }*/ }
private void PopulatePreviousOutputs(ExecutePotionScript potion, int index) { //previousOutputs.Clear (); Debug.Log("index is : " + index); PotionScript.ListWrapper actualOutputs = potion.actualOutputs [index]; previousOutputs.Add(actualOutputs.GetSpriteList()); }
private void ChangePipeColour(List <GameObject> pathObjects, Color colour) { foreach (GameObject pathObject in pathObjects) { ExecutePotionScript potion = pathObject.GetComponent <ExecutePotionScript> (); List <GameObject> pipes = potion.pipes; foreach (GameObject pipe in pipes) { pipe.GetComponent <SpriteRenderer> ().color = colour; } } }
public static int GetAllBreakpoints() { GameObject[] potions = GameObject.FindGameObjectsWithTag("Potion"); int count = 0; foreach (GameObject gameObject in potions) { ExecutePotionScript eps = gameObject.GetComponent <ExecutePotionScript> (); if (eps.PotionHasBreakpoint()) { count++; } } return(count); }
private void HideOriginalInputOutput(ExecutePotionScript potion, int index) { List <GameObject> originalInputs = potion.inputs [index].list; foreach (GameObject originalInput in originalInputs) { originalInput.SetActive(false); } List <GameObject> originalOutputs = potion.outputs [index].list; foreach (GameObject originalOutput in originalOutputs) { originalOutput.SetActive(false); } }
public void RunOneStep() { GameObject pathObject = currentPathObjects [potionStepCount]; ExecutePotionScript potion = pathObject.GetComponent <ExecutePotionScript> (); int matchingIndex = -1; // non-first potions only receive one input when executed which can be determined by matching previous output List <PotionScript.ListWrapper> actualInputs = potion.actualInputs; matchingIndex = MatchInputOutput(actualInputs); // increase step count and check if further steps are allowed potionStepCount++; PopulatePreviousOutputs(potion, matchingIndex); Debug.Log("matching index : " + matchingIndex); if (potion.PotionHasBreakpoint()) { // hide original inputs and outputs HideOriginalInputOutput(potion, matchingIndex); // display actual inputs and outputs AND formula DisplayActualInputOutputAndFormula(potion, matchingIndex); // change breakpoint text colour to indicate it has been executed //potion.ChangeBreakpointTextColour(); // instead of changing colour, show potion formula potion.HideBreakpointText(); potion.ClearBreakpoint(); // add cost for displaying actual inputs and outputs LevelData.addCost(-1); LevelData.addExecutedPotion(new PotionPathIndexPair(potion.gameObject.name, currentPathIndex, matchingIndex)); if (!StillHasBreakpoints()) { // all potions do not have anymore breakpoints runOneStepBtn.interactable = false; potionStepCount = 0; } return; } else { RunOneStep(); } }
private void DisplayActualInputOutputAndFormula(ExecutePotionScript potion, int index) { Debug.Log("potion to display: " + potion.gameObject.name); //show actual input List <GameObject> actualInputs = potion.actualInputs [index].list; foreach (GameObject actualInput in actualInputs) { actualInput.SetActive(true); //actualInput.GetComponent<SpriteRenderer>().color = new Color (1f, 1f, 1f, 1f); // reset to non-transparent } //show actual output List <GameObject> actualOutputs = potion.actualOutputs [index].list; foreach (GameObject actualOutput in actualOutputs) { actualOutput.SetActive(true); //actualOutput.GetComponent<SpriteRenderer>().color = new Color (1f, 1f, 1f, 1f); // reset to non-transparent } //show actual formula potion.ShowFormula(currentPathIndex); }
private bool StillHasBreakpoints() { return(ExecutePotionScript.GetAllBreakpoints() > 0); }