Exemplo n.º 1
0
        /// <summary>
        /// Loop to go through the Song Notes.
        /// If the audio source time is smaller than the delay,
        /// we use the Note delay for spawning Food.
        /// If the audio source time is greater than the delay,
        /// we use audio sources time to spwan Food based on the Note time.
        /// </summary>
        private IEnumerator PlayNext()
        {
            //Loop until the current index is smaller than the note count.
            while (m_current < m_song.Nodes.Count)
            {
                //Decide between spawing with delay and time.
                if (m_source.time < Delay)
                {
                    //Wait for the delay time and spawn note.
                    yield return(new WaitForSeconds(NoteDelay));

                    Mouth.Create(m_song.Nodes[m_current].Direction);
                }
                else
                {
                    //Wait for the Note time match with audio sources time.
                    if (CurrentTime >= m_song.Nodes[m_current].Time)
                    {
                        Mouth.Create(m_song.Nodes[m_current].Direction);
                        m_current++;
                    }
                    yield return(new WaitForEndOfFrame());
                }
            }
        }
Exemplo n.º 2
0
        /*
         * Mono Behaviour Functions.
         */

        private void Awake()
        {
            //Make sure there is only one Instance.
            if (Instance != null)
            {
                Debug.LogError("Multiple Mouth Instances", this.gameObject);
                return;
            }
            //set the instance.
            Instance = this;
            //Cache the Tooth components from child objects.
            InitializeTeeth();
            //Create object pool for the Food objects.
            CreatePool();
        }
Exemplo n.º 3
0
        /*
         * Mono Behaviour Functions.
         */

        private void Update()
        {
            if (Input.GetButtonDown("Left"))
            {
                Mouth.PressDirection(Direction.Left);
            }

            if (Input.GetButtonDown("Right"))
            {
                Mouth.PressDirection(Direction.Right);
            }

            if (Input.GetButtonDown("Down"))
            {
                Mouth.PressDirection(Direction.Down);
            }

            if (Input.GetButtonDown("Up"))
            {
                Mouth.PressDirection(Direction.Up);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sends the Mouth a remove request for the Tooth's direction.
 /// </summary>
 public void Remove() => Mouth.Remove(m_direction);