private void ActivateLinesOfOtherMarkersOnSameBeat(bool v) { int currentBeat = m_tokenPosition.GetTactPosition(m_fiducial.transform.position); //deactiveates colors from other markers on oldBeat if (oldBeat != currentBeat) { foreach (LinesForOrientation linesFromOtherMarker in otherMarkersOnSameBeat) { linesFromOtherMarker.ActivateColoredLinesForOrientation(false); } otherMarkersOnSameBeat = new List <LinesForOrientation>(); oldBeat = currentBeat; } List <GameObject[]> allActiveMarkers = m_lastComeLastServe.GetAllActiveMarkers(); foreach (GameObject[] guitarString in allActiveMarkers) { if (guitarString[currentBeat] != null && guitarString[currentBeat].name != m_fiducial.gameObject.name) { LinesForOrientation linesFromOtherMarker = GameObject.Find(guitarString[currentBeat].name + "_lines").GetComponent <LinesForOrientation>(); //adds current lines from other marker to list (for color deactivation purpose) if (!otherMarkersOnSameBeat.Contains(linesFromOtherMarker)) { otherMarkersOnSameBeat.Add(linesFromOtherMarker); } //sets color to other marker on same beat to it's own color linesFromOtherMarker.ActivateColoredLinesForOrientation(v); } } }
//removes markers saved in activeMarkersOnGrid array if they are not on the position they got saved in the array private void RemoveActiveMarkersIfTheySwitchedPosition(List <GameObject> markerList, GameObject[] activeMarkersArray) { for (int i = 0; i < activeMarkersArray.Length; i++) { if (activeMarkersArray[i] != null) { int width = (int)(m_settings.GetMarkerWidthMultiplier(activeMarkersArray[i].GetComponent <FiducialController>().MarkerID) * 2); if ((i != m_tokenPosition.GetTactPosition(activeMarkersArray[i].transform.position) - Mathf.Floor(width / 2)))//1/4 { activeMarkersArray[i] = null; } //if chords are enabled and the color of the current marker is not the color of the current string being checked if (enableChords && activeMarkersArray[i] != null && !markerList.Contains(activeMarkersArray[i])) { activeMarkersArray[i] = null; } if (width > 1 && activeMarkersArray[i + 1] != null && activeMarkersArray[i + 1] != activeMarkersArray[i])//1/2 { activeMarkersArray[i + 1] = null; } if (width > 2 && activeMarkersArray[i + 2] != null && activeMarkersArray[i + 2] != activeMarkersArray[i])//3/4 { activeMarkersArray[i + 2] = null; } if (width > 3 && activeMarkersArray[i + 3] != null && activeMarkersArray[i + 3] != activeMarkersArray[i])//4/4 { activeMarkersArray[i + 3] = null; } i += width - 1; //otherwise it would check e.g. the second beat of a 3/4 marker and the if queries (and their indices) above would be wrong } } }
void FixedUpdate() { locationBarOffset = m_settings.locationBarOffset; int tactPosWithOffset = m_tokenposition.GetTactPosition(this.m_locationBar.position - locationBarOffset); int startBarTactPosition = m_tokenposition.GetTactPosition(GameObject.Find(m_settings.startBarLoop).transform.position); int endBarTactPosition = m_tokenposition.GetTactPosition(GameObject.Find(m_settings.endtBarLoop).transform.position); // TODO: if beat Debug.Log(GameObject.Find(m_settings.startBarLoop).transform.position.x + "," + GameObject.Find(m_settings.locationBarName).transform.position.x); Debug.Log("Is Appr?: " + Mathf.Approximately(GameObject.Find(m_settings.startBarLoop).transform.position.x, GameObject.Find(m_settings.locationBarName).transform.position.x)); if (tactPosWithOffset >= startBarTactPosition && (tactPosWithOffset != oldTactPos || (endBarTactPosition - startBarTactPosition == 1 && locationBarIsNearStartBar(0.07f)))) { lastSentNote = tactPosWithOffset; int nextBeat = tactPosWithOffset < (m_settings.beats - 1) ? tactPosWithOffset + 1 : 0; //reads active markers dependend on enabled chords or not if (!enableChords) { activeMarkers = m_lastComeLastServe.GetActiveMarkers(Color.white); GameObject[] arrayToSend = new GameObject[3]; //calculates string on guitar which will be played and sets the tune to be played on the position of the array assigned to the string arrayToSend[m_tokenposition.GetNote(activeMarkers[tactPosWithOffset].transform.position) / tunesPerString] = activeMarkers[tactPosWithOffset]; if (tactPosWithOffset > 0) { lastSentIDs[0] = activeMarkers[tactPosWithOffset - 1] != null ? activeMarkers[tactPosWithOffset - 1].GetComponent <FiducialController>().MarkerID : -1; } else { lastSentIDs[0] = -1; } this.SendNote(arrayToSend, new bool[] { activeMarkers[nextBeat] == null }, lastSentIDs, tactPosWithOffset); } else { activeRedNotes = m_lastComeLastServe.GetActiveMarkers(m_settings.red); activeGreenNotes = m_lastComeLastServe.GetActiveMarkers(m_settings.green); activeBlueNotes = m_lastComeLastServe.GetActiveMarkers(m_settings.blue); if (tactPosWithOffset > m_tokenposition.GetTactPosition(GameObject.Find(m_settings.startBarLoop).transform.position)) // TODO don'T use > 0 use > min tact { lastSentIDs[0] = activeRedNotes[tactPosWithOffset - 1] != null ? activeRedNotes[tactPosWithOffset - 1].GetComponent <FiducialController>().MarkerID : -1; lastSentIDs[1] = activeGreenNotes[tactPosWithOffset - 1] != null ? activeGreenNotes[tactPosWithOffset - 1].GetComponent <FiducialController>().MarkerID : -1; lastSentIDs[2] = activeBlueNotes[tactPosWithOffset - 1] != null ? activeBlueNotes[tactPosWithOffset - 1].GetComponent <FiducialController>().MarkerID : -1; } else { lastSentIDs[0] = -1; lastSentIDs[1] = -1; lastSentIDs[2] = -1; } this.SendNote(new GameObject[] { activeRedNotes[tactPosWithOffset], activeGreenNotes[tactPosWithOffset], activeBlueNotes[tactPosWithOffset] }, new bool[] { activeRedNotes[nextBeat] == null, activeGreenNotes[nextBeat] == null, activeBlueNotes[nextBeat] == null }, lastSentIDs, tactPosWithOffset); } oldTactPos = tactPosWithOffset; } }