コード例 #1
0
    // 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);
        }
    }
コード例 #2
0
    // 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);
            }
        }
    }
コード例 #3
0
    // 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;
        }
    }
コード例 #4
0
 public static void _AddNewNote(TrebleNoteType type)
 {
     instance.AddNewNote(type);
 }
コード例 #5
0
 public void SetCurrentNote(TrebleNoteType t)
 {
     _currenetNoteType = t;
 }