/// <summary> /// Creates a beam connecting the first and last item in this beam. /// This method should be used when the max values for these items are not at the same height. /// Mesh vertices are generated as opposed to a sprite as in the straight beam. /// </summary> public bool CreateAngledBeam(List <Vector3> vertices) { if (type != Type.Angle) { return(false); } float offsetY = 0.0f; ABC.Length length = (items[0] as ABC.Duration).length; for (ABC.Length l = ABC.Length.Eighth; l >= length; l--) { if (noteDirection == NoteCreator.NoteDirection.Up) { vertices.Add(new Vector3(first.max.x, first.max.y - offsetY, 0.0f)); vertices.Add(new Vector3(last.max.x, last.max.y - offsetY, 0.0f)); vertices.Add(new Vector3(first.max.x, first.max.y - offsetY - beamHeight, 0.0f)); vertices.Add(new Vector3(last.max.x, last.max.y - offsetY - beamHeight, 0.0f)); } else { vertices.Add(new Vector3(first.min.x, first.min.y + offsetY + beamHeight, 0.0f)); vertices.Add(new Vector3(last.min.x, last.min.y + offsetY + beamHeight, 0.0f)); vertices.Add(new Vector3(first.min.x, first.min.y + offsetY, 0.0f)); vertices.Add(new Vector3(last.min.x, last.min.y + offsetY, 0.0f)); } offsetY += beamHeight + defaultBeamSpacer; } return(true); }
private string GetNoteSpriteName(ABC.Length note, bool beam, NoteDirection noteDirection) { if (beam) { return($"Note_Quarter_{noteDirection}"); } else { return(note == ABC.Length.Whole ? "Note_Whole" : $"Note_{note}_{noteDirection}"); } }
private Bounds AddChordNoteHead(ABC.Pitch value, ABC.Length length, ABC.Clef clef, NoteDirection noteDirection, GameObject container, Vector3 offset, ref Vector3 notePos) { int stepCount = value - clefZero[clef]; notePos = offset + new Vector3(0.0f, noteStep * stepCount, 0.0f); var spriteName = length == ABC.Length.Whole ? "Note_Whole" : $"Chord_{length}"; var dot = spriteCache.GetSpriteObject(spriteName); dot.transform.parent = container.transform; dot.transform.localPosition = notePos; return(dot.bounds); }
/// <summary> /// Creates a basic straight beam connecting the first and last item in this beam. /// Note that this method should be used when the first and last items have the same max Y bounding value. /// </summary> public bool CreateBasicBeam(SpriteCache cache, GameObject container) { if (type != Type.Basic && type != Type.Straight) { return(false); } float offsetY = 0.0f; ABC.Length length = (items[0] as ABC.Duration).length; for (ABC.Length l = ABC.Length.Eighth; l >= length; l--) { var beam = cache.GetSpriteObject($"Note_Beam_{noteDirection}"); beam.transform.parent = container.transform; float distX; if (noteDirection == NoteCreator.NoteDirection.Up) { var beamPos = first.max; beam.transform.localPosition = new Vector3(beamPos.x, beamPos.y - offsetY, 0.0f); distX = last.max.x - beamPos.x; } else { var beamPos = first.min; beam.transform.localPosition = new Vector3(beamPos.x, beamPos.y + offsetY, 0.0f); distX = last.min.x - beamPos.x; } beam.transform.localScale = new Vector3(distX, 1.0f, 1.0f); offsetY += beamHeight + defaultBeamSpacer; } return(true); }