// Tap down event void OnTapDown(int id, Vector2 position) { if (common.gameOver) { common.OnTapDown(id, position); } else { // Collision check via raycast Ray ray = Camera.main.ScreenPointToRay(position); RaycastHit hit; // If hit if (Physics.Raycast(ray, out hit)) { // Check tag GameObject hitObject = hit.collider.gameObject; if (hitObject.tag.Equals(Tags.NOTE)) { NotesScript note = hitObject.GetComponent <NotesScript>(); if (note.state == NotesScript.NotesState.ACTIVE) { common.OnNoteHit(note); } } } } }
// Tap down event void OnTapDown(int id, Vector2 position) { if (!touchMap.ContainsKey(id)) // Protect against double counts { if (common.gameOver) { common.OnTapDown(id, position); } else { // Collision check via raycast Ray ray = Camera.main.ScreenPointToRay(position); RaycastHit hit; // If hit if (Physics.Raycast(ray, out hit)) { // Check tag GameObject hitObject = hit.collider.gameObject; if (hitObject.tag.Equals(Tags.TAPBOX)) { TapboxScript tapbox = hitObject.GetComponent <TapboxScript>(); // Animation tapbox.PlayDownAnim(); // Add to dictionary touchMap.Add( id, tapbox ); // Check for notes OnTapboxTap(tapbox); } } } } }