コード例 #1
0
    public void SelectKey(int key)
    {
        sounds.PlayNote(key, 95, 1.0f);
        PianoSoundItem item = itemPool.GetObject();

        item.Initialize(0.0f, 0.0f, key, 0, this);
        items.Add(item);
    }
コード例 #2
0
 public void Initialize()
 {
     while (pooledObjects.Count < pooledAmount)
     {
         GameObject     newObject  = Instantiate(prefab, parent);
         PianoSoundItem itemObject = newObject.GetComponent <PianoSoundItem>();
         pooledObjects.Add(itemObject);
         objectAvailable.Add(true);
         newObject.SetActive(false);
     }
 }
コード例 #3
0
 public void Activate(EditorController edit, List <PianoSound> sounds)
 {
     editor = edit;
     CurrentState.ignoreAllInput = true;
     foreach (PianoSound sound in sounds)
     {
         PianoSoundItem item = itemPool.GetObject();
         item.Initialize(sound.duration, sound.delay, sound.pitch, sound.volume, this);
         items.Add(item);
     }
 }
コード例 #4
0
 public void ReturnObject(PianoSoundItem returnObject)
 {
     for (int i = 0; i < pooledObjects.Count; i++)
     {
         if (pooledObjects[i] == returnObject)
         {
             returnObject.gameObject.SetActive(false);
             objectAvailable[i] = true;
             return;
         }
     }
     Debug.LogError("Try to return an object that's not from the pool. Destroying the object.");
     Destroy(returnObject.gameObject);
     return;
 }
コード例 #5
0
    public PianoSoundItem GetObject()
    {
        for (int i = 0; i < pooledObjects.Count; i++)
        {
            if (objectAvailable[i])
            {
                objectAvailable[i] = false;
                return(pooledObjects[i]);
            }
        }
        GameObject     newObject  = Instantiate(prefab, parent);
        PianoSoundItem itemObject = newObject.GetComponent <PianoSoundItem>();

        pooledObjects.Add(itemObject);
        newObject.SetActive(false);
        objectAvailable.Add(false);
        return(itemObject);
    }
コード例 #6
0
 public void DeleteItem(PianoSoundItem item)
 {
     items.Remove(item);
 }