IEnumerator teachLineFill() { MagicLine.SetActive(true); current = teachingPhase.Running; blocking = true; yield return(new WaitUntil(() => Input.GetMouseButtonDown(0))); blocking = false; MagicLine.SetActive(false); StartCoroutine(teachCasting()); }
void Update() { // If game is paused, prevent any interaction if (GetGameState() != GameState.Running && GetGameState() != GameState.Pregame) return; // Make decision on which state is currently active switch (_currentLineDrawState) { case LineDrawState.Neutral: // We only select a draw state when current state is neutral if (Input.GetMouseButtonDown(0)) { _currentLineDrawState = LineDrawState.Drawing; // Preserve active line, because GetComponent is relatively expensive var __o = (GameObject)(Instantiate(linePrefab)); __o.transform.parent = _lineContainer.transform; _line = __o.GetComponent<MagicLine>(); // Set starting position Vector3 __t = Camera.main.ScreenToWorldPoint(Input.mousePosition); _line.SetStartingPosition(new Vector2(__t.x, __t.y)); } else if (Input.GetMouseButtonDown(1)) { _currentLineDrawState = LineDrawState.Erasing; } break; case LineDrawState.Drawing: // Reset to neutral state if (Input.GetMouseButtonUp(0)) { _currentLineDrawState = LineDrawState.Neutral; _line = null; } break; case LineDrawState.Erasing: // Reset to neutral state if (Input.GetMouseButtonUp(1)) { _currentLineDrawState = LineDrawState.Neutral; } break; } // Handle draw state _HandleDrawState(_currentLineDrawState); }