Esempio n. 1
0
 void Start()
 {
     if (id == -1)
     {
         id = Ruratae.CreateParticle(this);
     }
 }
Esempio n. 2
0
 void Start()
 {
     if (id == -1)
     {
         id = Ruratae.CreateSpring(this);
     }
 }
Esempio n. 3
0
 public void Initialize()
 {
     // Initialize the system.
     particles = GameObject.FindObjectsOfType <Particle>();
     springs   = GameObject.FindObjectsOfType <Spring>();
     Ruratae.InitializeSystem(particles.Length, springs.Length);
     // Initialize particles.
     for (int particle = 0; particle < particles.Length; ++particle)
     {
         particles[particle].Initialize();
     }
     // Initialize springs.
     for (int spring = 0; spring < springs.Length; ++spring)
     {
         if (springs[spring].enabled)
         {
             springs[spring].Initialize();
         }
     }
     for (int i = 0; i < particles.Length; ++i)
     {
         if (particles[i].recipMass > 0.0f)
         {
             movables.Add(particles[i]);
         }
     }
     movables.Sort(CompareParticle);
     MidiJack.MidiMaster.noteOnDelegate += OnNoteOn;
 }
 // Implements |IPointerDownHandler.OnPointerDown|.
 public void OnPointerDown(PointerEventData eventData)
 {
     if (GameManager.editMode)
     {
         // Set position.
         Vector3 position = WorldFromScreenPosition(eventData.pressEventCamera,
                                                    eventData.pressPosition);
         pressOffset = transform.position - position;
     }
     else
     {
         // Strike!
         if (Input.GetMouseButtonDown(0))
         {
             Ruratae.ImpulseParticle(this, new Vector3(Random.Range(-1.0f, 1.0f),
                                                       Random.Range(-1.0f, 1.0f),
                                                       Random.Range(-1.0f, 1.0f)));
         }
         else if (Input.GetMouseButtonDown(1))
         {
             Ruratae.PluckParticle(this, 4.0f * new Vector3(Random.Range(-1.0f, 1.0f),
                                                            Random.Range(-1.0f, 1.0f),
                                                            Random.Range(-1.0f, 1.0f)));
         }
     }
 }
Esempio n. 5
0
 void OnDisable()
 {
     if (id != -1)
     {
         Ruratae.DestroyParticle(this);
         id = -1;
     }
 }
 public void Initialize()
 {
     if (id == -1)
     {
         GetComponent <CapsuleCollider>().enabled = false;
         id = Ruratae.CreateSpring(this);
     }
 }
 public void Initialize()
 {
     if (id == -1)
     {
         editPosition = transform.position;
         id           = Ruratae.CreateParticle(this);
     }
 }
Esempio n. 8
0
 void OnDisable()
 {
     if (id != -1)
     {
         Ruratae.DestroySpring(this);
         id = -1;
     }
 }
 public void Shutdown()
 {
     if (id != -1)
     {
         Ruratae.DestroyParticle(this);
         transform.position = editPosition;
         id = -1;
     }
 }
 public void Shutdown()
 {
     if (id != -1)
     {
         GetComponent <CapsuleCollider>().enabled = true;
         Ruratae.DestroySpring(this);
         id = -1;
     }
 }
 void Update()
 {
     // Update scale.
     transform.GetComponent <Renderer>().material = recipMass > 0.0f ? movable : stationary;
     if (!GameManager.editMode && id != -1)
     {
         transform.position = Vector3.Lerp(transform.position, Ruratae.UpdateParticlePosition(this),
                                           16 * Time.deltaTime);
     }
 }
Esempio n. 12
0
    void OnNoteOn(MidiJack.MidiChannel channel, int note, float velocity)
    {
        int     index         = note - keyNote;
        int     numOctavs     = index / 12;
        int     particleIndex = 7 * numOctavs + inverseMajorScale[(index + 60) % inverseMajorScale.Length];
        Vector3 direction     = new Vector3(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f));
        float   strength      = velocity < 0.95f ? Mathf.Min(Mathf.Max(2 * velocity, 0.5f), 1.5f) : Mathf.Pow(2 * velocity, 2.0f);

        Ruratae.ImpulseParticle(movables[particleIndex % movables.Count], 0.05f * direction * strength);//2 * Vector3.one * Mathf.Pow(velocity, 2.0f));
    }
Esempio n. 13
0
 void Awake()
 {
     if (source == null)
     {
         source = gameObject.AddComponent <AudioSource>();
         int numFrames = AudioSettings.GetConfiguration().dspBufferSize;
         monoData = new float[numFrames];
     }
     Ruratae.InitializeSystem(maxParticles, maxSprings);
 }
Esempio n. 14
0
 void OnAudioFilterRead(float[] data, int channels)
 {
     Ruratae.Process(monoData);
     for (int frame = 0; frame < monoData.Length; ++frame)
     {
         for (int ch = 0; ch < channels; ++ch)
         {
             data[channels * frame + ch] = monoData[frame];
         }
     }
 }
Esempio n. 15
0
 void Update()
 {
     // Update scale.
     //transform.localScale = Vector3.Lerp(transform.localScale, radius * Vector3.one,
     //                                    4 * Time.deltaTime);
     transform.GetComponent <Renderer>().material.color = (0.5f + recipMass) * Color.white;
     if (Input.GetMouseButton(0))
     {
         // Update parameters.
         // TODO(anokta): Handle this properly to get the position from ruratae otherwise.
         Ruratae.SetParticleParams(this);
     }
 }
Esempio n. 16
0
 // Implements |IPointerUpHandler.OnPointerUp|.
 public void OnPointerUp(PointerEventData eventData)
 {
     if (Input.GetMouseButtonUp(1))
     {
         recipMass = 1.0f - recipMass;
         velocity  = recipMass * Vector3.up;
         Ruratae.SetParticleParams(this);
     }
     else if (!eventData.dragging)
     {
         GameObject.Destroy(gameObject);
     }
 }
Esempio n. 17
0
 void OnAudioFilterRead(float[] data, int channels)
 {
     if (GameManager.editMode)
     {
         return;
     }
     // Process the next buffer block.
     Ruratae.Process(monoData);
     for (int frame = 0; frame < monoData.Length; ++frame)
     {
         for (int ch = 0; ch < channels; ++ch)
         {
             data[channels * frame + ch] = monoData[frame];
         }
     }
 }
Esempio n. 18
0
 public void Shutdown()
 {
     MidiJack.MidiMaster.noteOnDelegate -= OnNoteOn;
     // Shutdown particles.
     for (int particle = 0; particle < particles.Length; ++particle)
     {
         if (particles[particle] != null)
         {
             particles[particle].Shutdown();
         }
     }
     // Shutdown springs.
     for (int spring = 0; spring < springs.Length; ++spring)
     {
         if (springs[spring] != null && springs[spring].enabled)
         {
             springs[spring].Shutdown();
         }
     }
     Ruratae.ShutdownSystem();
 }
Esempio n. 19
0
 void OnEnable()
 {
     id = Ruratae.CreateSpring(this);
 }
Esempio n. 20
0
 void OnEnable()
 {
     id = Ruratae.CreateParticle(this);
 }
Esempio n. 21
0
 void Update()
 {
     Ruratae.SetListenerPosition(listener);
     Ruratae.SetGravity(gravity);
 }
Esempio n. 22
0
 void OnDestroy()
 {
     Ruratae.ShutdownSystem();
     monoData = null;
 }