// Start is called before the first frame update void Start() { lines = txt.text.Split('\n'); lineInd = 0; isStartShowEnd = false; teachState = TeachState.NotTeaching; StartCoroutine(startShow(lines[lineInd++])); }
// Update is called once per frame void Update() { blockController[] Controllers = pickupBoard.GetComponentsInChildren <blockController>(); foreach (var controller in Controllers) { if (controller.type == blockType.mouse) { mouseController = controller; } } switch (teachState) { case TeachState.NotTeaching: if (Input.anyKeyDown && isStartShowEnd) { if (lineInd != lines.Length) { ShowLines(lines[lineInd++]); } else { isEnd = true; panel.SetActive(false); } } break; case TeachState.TeachingCatScareMouse: if (mouseController.isChanged) { teachState = TeachState.NotTeaching; panel.SetActive(true); if (lineInd != lines.Length) { ShowLines(lines[lineInd++]); } else { isEnd = true; panel.SetActive(false); } } break; case TeachState.TeachingMouseAvoidCat: if (mouseController.isAtJigsawBoard) { teachState = TeachState.NotTeaching; panel.SetActive(true); if (lineInd != lines.Length) { ShowLines(lines[lineInd++]); } else { isEnd = true; panel.SetActive(false); } } break; default: break; } }
void Teach(TeachState state) { teachState = state; panel.SetActive(false); }