// private references & variables // public functions public void AddNewNote(TrebleNoteType type) { if (activeNoteList != null && type != TrebleNoteType._Default) { foreach (var n in activeNoteList) { n.GetComponent <RectTransform>().anchoredPosition += new Vector2(-columnInterval, 0); } if (activeNoteList.Count >= maxColumn) { var firstNote = activeNoteList[0]; activeNoteList.RemoveAt(0); // TEMP Destroy(firstNote.gameObject); } var newColumn = Instantiate(columnPrefab); newColumn.transform.SetParent(transform); var column = newColumn.GetComponent <FreeColumn>(); column.Init(lineInterval, type); newColumn.SetActive(true); activeNoteList.Add(column); } }
// customize initialization public void Init(int id = -1) { _columnID = id; _currenetNoteType = TrebleNoteType._Default; if (noteSlotList == null) { noteSlotList = new List <GameObject>(); } if (noteSlotList.Count > 0) { foreach (var n in noteSlotList) { Destroy(n); } noteSlotList.Clear(); } if (noteSlotPrefab != null) { for (var i = 0; i < _noteCount; i++) { var newSlot = Instantiate(noteSlotPrefab); newSlot.transform.SetParent(this.transform); newSlot.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, i * _noteInterval); var slot = newSlot.GetComponent <NoteSlot>(); slot.Init(this, (TrebleNoteType)i); newSlot.SetActive(true); noteSlotList.Add(newSlot); } } }
// customize Initialization public void Init(float li = 25f, TrebleNoteType nt = TrebleNoteType.C4) { lineInterval = li; noteType = nt; GetComponent <RectTransform>().anchoredPosition = new Vector2(0, lineInterval * (int)noteType); noteBottom.SetActive(false); noteBottomSlash.SetActive(false); noteTop.SetActive(false); switch (noteType) { case TrebleNoteType.C4: noteBottomSlash.SetActive(true); break; case TrebleNoteType.D4: case TrebleNoteType.E4: case TrebleNoteType.F4: case TrebleNoteType.G4: case TrebleNoteType.A4: noteBottom.SetActive(true); break; case TrebleNoteType.B4: case TrebleNoteType.C5: noteTop.SetActive(true); break; default: break; } }
public static void _AddNewNote(TrebleNoteType type) { instance.AddNewNote(type); }
public void SetCurrentNote(TrebleNoteType t) { _currenetNoteType = t; }