Пример #1
0
        private bool CheckClick(float position, int noteID)
        {
            float minDis = 10f;
            int   index  = -1;

            for (int i = 0; i < m_lstStarElement.Count; i++)
            {
                if (m_lstStarElement[i].m_nNoteID == noteID)
                {
                    var dis = Mathf.Abs(m_lstStarElement[i].m_Root.transform.position.y - position);
                    if (dis < m_fTargetRange)
                    {
                        if (dis < minDis)
                        {
                            minDis = dis;
                            index  = i;
                        }
                    }
                }
            }
            if (index != -1)
            {
                StarElementStruct star = m_lstStarElement[index];
                star.m_Controller.Clear();
                m_poolStarElement.Store(star);
                m_lstStarElement.RemoveAt(index);
                return(true);
            }
            return(false);
        }
Пример #2
0
        private void GuideSucess()
        {
            if (m_lstStarElement.Count > 0)
            {
                StarElementStruct star = m_lstStarElement[0];
                star.m_Controller.StopShinging();
                star.m_Controller.Clear();
                m_poolStarElement.Store(star);
                m_lstStarElement.RemoveAt(0);
            }
            m_IsGuideShowPointing = false;
            m_BackgroundMaskController.SetActive(false);
            m_MusicPlayer.Reset();
            m_IsGuide = false;

            m_bIsReloading = true;
            // start game
            PlayHintAudio(HINTAUDIO_SUCCESS, (aa) =>
            {
                PlayHintAudio(HINTAUDIO_END, (b) =>
                {
                    m_bIsReloading = false;
                    ReLoadGame();
                    ReLoadScene();
                });
            });
            PlayerManager.Instance.GetCharCounterData().SetFlag(6, true);
        }
Пример #3
0
 private void GameEndLogic()
 {
     if (m_nLifeRemain > 0)
     {
         GameWin();
     }
     else
     {
         m_Health--;
         //healthbar.RemoveOneHealthIcon();
         if (m_Health <= 0)
         {
             GameLose();
         }
         else
         {
             GameLosePoint();
         }
     }
     Block.SetActive(true);
     m_BackButton.enabled = false;
     m_MusicPlayer.Reset();
     for (int i = 0; i < m_lstStarElement.Count; i++)
     {
         StarElementStruct star = m_lstStarElement[i];
         star.m_Controller.StopFall(() =>
         {
             m_poolStarElement.Store(star);
         });
     }
     m_lstStarElement.Clear();
 }
Пример #4
0
 private void InitStarElement(StarElementStruct elem)
 {
     elem.m_Root = GameObject.Instantiate(MusicGameManager.Instance.m_ElementTemplate);
     ComponentTool.Attach(MusicGameManager.Instance.m_StarElementRoot.transform, elem.m_Root.transform);
     elem.m_Root.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
     elem.m_Controller = elem.m_Root.GetComponent <MusicGameTool_StarController>();
     if (elem.m_Controller == null)
     {
         Debug.LogError("MusicGameTool_StarController not found!");
         return;
     }
     elem.m_Controller.StartFall();
 }
Пример #5
0
        private void GenerateStar(int noteID)
        {
            StarElementStruct star = m_poolStarElement.New();

            star.m_nNoteID = noteID;
            if (m_LaunchPositions.Count < noteID)
            {
                Debug.LogError("the noteID of star element does not exist");
                return;
            }
            star.m_Root.transform.position = m_LaunchPositions[noteID - 1].transform.position;
            m_lstStarElement.Add(star);
            //PlayAudio(noteID);
        }
Пример #6
0
 private void GuideFail()
 {
     if (m_lstStarElement.Count > 0)
     {
         StarElementStruct star = m_lstStarElement[0];
         star.m_Controller.StopShinging();
         star.m_Controller.Clear();
         m_poolStarElement.Store(star);
         m_lstStarElement.RemoveAt(0);
     }
     m_IsGuideShowPointing = false;
     m_BackgroundMaskController.SetActive(false);
     Block.SetActive(true);
     PlayHintAudio(HINTAUDIO_FAIL, (a) =>
     {
         m_MusicPlayer.ResumeGuide();
     });
 }
Пример #7
0
 private void ResetStarElement(StarElementStruct elem)
 {
     elem.m_Controller.StartFall();
 }
Пример #8
0
        void Update()
        {
            if (m_MusicPlayer == null)
            {
                return;
            }
            m_MusicPlayer.Update();

            // Check Input
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, 200f))
                {
                    var monster = hit.transform.GetComponent <MusicGameTool_MonsterController>();
                    if (monster != null)
                    {
                        int noteID = monster.OnClicked();
                        //Debug.Log("Click Monster : " + noteID.ToString());
                        if (!m_IsAutoMusic)
                        {
                            PlayMusicAudio(noteID);
                        }
                        //Check Click
                        if (CheckClick(hit.transform.position.y, noteID)) //Success
                        {
                            if (m_IsAutoMusic && !m_IsGuide)
                            {
                                PlayMusicAudio(noteID);
                            }
                            monster.PlayAnim(true);
                            // GUIDE
                            if (m_IsGuide)
                            {
                                GuideSucess();
                                return;
                            }
                            // User Talent Report
                            m_nCorrectCount++;
                            m_nMissCount = 0;
                            if (m_nCorrectCount >= 5)
                            {
                                MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Correct5);
                            }
                            else if (m_nCorrectCount >= 3)
                            {
                                MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Correct3);
                            }
                            else
                            {
                                MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Correct);
                            }
                        }
                        else //Fail
                        {
                            monster.PlayAnim(false);
                            // GUIDE
                            if (m_IsGuide)
                            {
                                GuideFail();
                                return;
                            }
                            m_nLifeRemain--;
                            if (m_nLifeRemain <= 0)
                            {
                                GameEndLogic();
                            }
                            // User Talent Report
                            m_nMissCount++;
                            m_nCorrectCount = 0;
                            if (m_nMissCount >= 3)
                            {
                                MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Wrong3);
                            }
                            else if (m_nMissCount >= 2)
                            {
                                MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Wrong2);
                            }
                            else
                            {
                                MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Wrong);
                            }
                        }
                    }
                }
            }

            // Check Star Pos
            for (int i = 0; i < m_lstStarElement.Count; i++)
            {
                // GUIDE Check Points
                if (m_IsGuide && m_lstStarElement.Count > 0)
                {
                    if (m_lstStarElement[0].m_Root.transform.position.y < -5 && !m_IsGuideShowPointing)
                    {
                        m_lstStarElement[0].m_Controller.PauseFall();
                        m_MusicPlayer.PauseGuide();
                        m_IsGuideShowPointing = true;
                        m_BackgroundMaskController.SetActive(true);
                        m_BackgroundMaskController.SetMaskPos(m_lstStarElement[0].m_Root.transform.position);
                        m_lstStarElement[0].m_Controller.Shinging();
                        PlayHintAudio(HINTAUDIO_REACH, (a) =>
                        {
                            m_ThrowGuideSprite.SetActive(true);
                            PlayHintAudio(HINTAUDIO_POINTMONSTER, (b) =>
                            {
                                m_ThrowGuideSprite.SetActive(false);
                                Block.SetActive(false);
                            });
                        });
                    }
                    else if (m_lstStarElement[0].m_Root.transform.position.y < 0 && !m_IsGuideShowHint)
                    {
                        m_IsGuideShowHint = true;
                        m_lstStarElement[0].m_Controller.PauseFall();
                        m_MusicPlayer.PauseGuide();
                        m_BackgroundMaskController.SetActive(true);
                        m_BackgroundMaskController.SetMaskPos(m_lstStarElement[0].m_Root.transform.position);
                        m_lstStarElement[0].m_Controller.Shinging();
                        PlayHintAudio(HINTAUDIO_FALLING, (a) =>
                        {
                            m_lstStarElement[0].m_Controller.StopShinging();
                            m_BackgroundMaskController.SetActive(false);
                            m_lstStarElement[0].m_Controller.ResumeFall();
                            m_MusicPlayer.ResumeGuide();
                        });
                    }
                }

                if (m_lstStarElement[i].m_Root.transform.position.y < -7)
                {
                    StarElementStruct star = m_lstStarElement[i];
                    star.m_Controller.StopFall(() =>
                    {
                        m_poolStarElement.Store(star);
                        // GUIDE
                        if (m_IsGuide)
                        {
                            return;
                        }
                        m_nLifeRemain--;
                        if (m_nLifeRemain <= 0)
                        {
                            GameEndLogic();
                        }
                    });
                    m_lstStarElement.RemoveAt(i);
                    // GUIDE
                    if (m_IsGuide)
                    {
                        return;
                    }
                    // User Talent Report
                    m_nMissCount++;
                    m_nCorrectCount = 0;
                    if (m_nMissCount >= 3)
                    {
                        MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Wrong3);
                    }
                    else if (m_nMissCount >= 2)
                    {
                        MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Wrong2);
                    }
                    else
                    {
                        MusicGameHelper.ReportEvent(MusicGameHelper.MusicGameEventType.Wrong);
                    }
                }
            }

            // Update Life UI
            if (m_nLifeRemain >= 0)
            {
                //m_LifeRemainLabel.text = m_nLifeRemain.ToString();
                if (m_nLifeRemain >= 10)
                {
                    m_LifeRemainTen.sprite = m_SpritesLifeNum[m_nLifeRemain / 10 % 10];
                }
                else
                {
                    m_LifeRemainTen.sprite = m_SpritesLifeNum[0];
                }
                m_LifeRemainOne.sprite = m_SpritesLifeNum[m_nLifeRemain % 10];
            }

            // Test
            //testMethod();
        }