// Update is called once per frame void Update() { if (currentlyInteracting) { if (Input.GetKeyDown(KeyCode.Return)) { if (!currentReaction.NextStep()) { if (!currentReactionCollection.TryNextReaction()) { Debug.Log("Free to go"); currentReaction = null; currentReactionCollection = null; currentlyInteracting = false; reactionDisplayArea.gameObject.SetActive(false); Destroy(reactionDisplayArea.transform.GetChild(0).gameObject); allowMovement.Raise(); } else { currentReaction = currentReactionCollection.GetNextReaction(); Destroy(reactionDisplayArea.transform.GetChild(0).gameObject); var reactionInstance = Instantiate(currentReaction.getReactionObject(), reactionDisplayArea.transform); currentReaction.React(reactionInstance); } } } } }
public void TriggerReaction(ReactionCollection reactionCollection) { if (!currentlyInteracting) { reactionDisplayArea.SetActive(true); currentlyInteracting = true; currentReactionCollection = reactionCollection; currentReaction = reactionCollection.GetNextReaction(); var reactionInstance = Instantiate(currentReaction.getReactionObject(), reactionDisplayArea.transform); currentReaction.React(reactionInstance); } else { Debug.LogError("Can't run multiple reactions at once"); } }