예제 #1
0
    private IEnumerator CheckCollision()
    {
        while (m_IsStart)
        {
            //Check collide with anything in section
            for (int i = 0; i < m_Sections.Count; ++i)
            {
                if (!m_Sections[i].gameObject.activeSelf)
                {
                    continue;
                }

                int result = m_Sections[i].IsCollide(m_Bird.transform);
                if (result == 1)
                {
                    m_Score++;
                    Utilities.Instance.DispatchEvent(Shell.Event.PlayAudio, "play_one", 3);
                    Utilities.Instance.DispatchEvent(Shell.Event.OnUpdateScore, "score", m_Score);
                    break;
                }

                if (result == -1)
                {
                    Debug.Log("death");
                    m_Bird.Hit(result);
                    OnGameOver();
                    break;
                }
            }

            //Check Floor
            float distance = Mathf.Pow(m_Floor.transform.position.y - m_Bird.transform.position.y, 2);
            if (distance <= 1.5f)
            {
                Debug.Log("Drop death");
                m_Bird.Hit(-2);
                OnGameOver();
            }

            yield return(new WaitForSeconds(0.3f));
        }


        yield break;
    }