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); } } }
public float CalculateYPosition(Vector3 pos, FiducialController fiducialController, int currentBeat) { //only does something, if the marker lays still if (fiducialController.MovementDirection == Vector2.zero) { //if marker is not in the recognised jokerMarker dictionary - set y Position if (oldPosition.x != pos.x) { Debug.Log("Joker Marker " + fiducialController.MarkerID + " has been set."); realOldYPosition = pos.y; //checks which pentatonic tunes are not occupied List <GameObject[]> allActiveMarkers = m_lastComeLastServe.GetAllActiveMarkers(); List <int> freePentatonicTuneHeights = new List <int>(); int i = 0; bool isInRangeOfString = false; //Gets current tune of marker and thereby knows on which string it must calc free tune if (m_lastComeLastServe.enableChords) { i = m_tokenPosition.GetNote(Camera.main.ScreenToWorldPoint(pos)); i = i < m_settings.tunesPerString ? 0 : (i < (m_settings.tunesPerString * 2) ? 1 : 2); } for (int j = 0; j < pentatonicTunes.Length; j++) { //if chords are not enabled, jump between strings if (!m_lastComeLastServe.enableChords && (i + 1) * m_settings.tunesPerString < pentatonicTunes[j]) { i++; } //else if chords are enabled, check if current pentatonic tune is in range of current string else if (m_lastComeLastServe.enableChords && i * m_settings.tunesPerString < pentatonicTunes[j] && pentatonicTunes[j] < (i + 1) * m_settings.tunesPerString) { isInRangeOfString = true; } else { isInRangeOfString = false; } if ((m_lastComeLastServe.enableChords ? isInRangeOfString : 1 == 1) && (allActiveMarkers[i][currentBeat] == null || m_tokenPosition.GetNote(allActiveMarkers[i][currentBeat].transform.position) + 1 != pentatonicTunes[j])) { freePentatonicTuneHeights.Add(pentatonicTunes[j]); } } //Gets random pentatonic tune and calculates y position based on said tune pos.y = heightOffSet_bottom + freePentatonicTuneHeights[(int)Random.Range(0, freePentatonicTuneHeights.Count)] * cellHeightInPx - cellHeightInPx / 2; oldPosition = pos; return(pos.y); } else { return(oldPosition.y); } } //marker is moving return(pos.y); }