Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        /*if (Input.GetKeyUp(KeyCode.P)) {
         *      AddGameTimeCtrl.GetInstance().PlayAddGameTime(AddTimeVal);
         * }*/

        if (GameCtrlXK.PlayerTran == null)
        {
            GameCtrlXK.GetInstance().FindPlayerTran();
            return;
        }

        if (Time.realtimeSinceStartup - TimeVal < 0.1f)
        {
            return;
        }
        TimeVal = Time.realtimeSinceStartup;

        Vector3 vecA = TriggerTran.position;
        Vector3 vecB = GameCtrlXK.PlayerTran.position;

        vecA.y = vecB.y = 0f;
        float dis = Vector3.Distance(vecA, vecB);

        if (dis <= 15f)
        {
            vecA   = TriggerTran.forward;
            vecB   = TriggerTran.position - GameCtrlXK.PlayerTran.position;
            vecA.y = vecB.y = 0f;
            float cosAB = Vector3.Dot(vecA, vecB);
            if (cosAB <= 0f)
            {
                gameObject.SetActive(false);
                StartBtCtrl.GetInstanceP1().ActivePlayerOne();
                GameDaoJiShiCtrl.GetInstance().StopDaoJiShi();
                AddGameTimeCtrl.GetInstance().PlayAddGameTime(AddTimeVal);
                AudioListCtrl.PlayAudio(AudioListCtrl.GetInstance().AudioTimeJiaShiDian);
            }
        }
    }
    IEnumerator PlayGameTime()
    {
        if (FinishPanelCtrl.GetInstance() != null && FinishPanelCtrl.GetInstance().CheckIsActiveFinish())
        {
            StopRunGameTime();
            yield break;
        }

        if (Time.timeScale != 1f)
        {
            yield return(new WaitForSeconds(1.0f));

            yield return(StartCoroutine(PlayGameTime()));
        }

        SetTimeValToImg();

        if (GameTimeValCur <= 0 && !AddGameTimeCtrl.GetInstance().GetIsActiveAddTime())
        {
            InsertCoinCtrl.GetInstanceP2().HiddenInsertCoin();
            StartBtCtrl.GetInstanceP2().CloseStartBtCartoon();
            HeadCtrlPlayer.GetInstanceP1().SetHeadColor();
            HeadCtrlPlayer.GetInstanceP2().SetHeadColor();

            ResetTimeHMvalToImg();
            StopCoroutine(SetTimeHMvalToImg());
            StopCoroutine(PlayGameTime());
            IsInitPlayTime = false;
            StartBtCtrl.GetInstanceP1().ResetIsActivePlayer();
            StartBtCtrl.GetInstanceP2().ResetIsActivePlayer();

            if (GlobalData.GetInstance().gameMode == GameMode.OnlineMode)
            {
                gameObject.SetActive(false);
                RankingCtrl.GetInstance().StopCheckPlayerRank();

                //FinishPanelCtrl.GetInstancePlayer().ShowFinishPanel();

                if (WaterwheelPlayerNetCtrl.GetInstance().GetPlayerRankNo() == 1)
                {
                    FinishPanelCtrl.GetInstance().ShowFinishPanel();
                }
                else
                {
                    FinishPanelCtrl.GetInstancePlayer().ShowFinishPanel();
                }
            }
            else
            {
                GameOverCtrl.GetInstance().ShowContinueGame();
                DaoJiShiCtrl.GetInstance().InitPlayDaoJiShi();
            }
            yield break;
        }
        yield return(new WaitForSeconds(1.0f));

        if (GameTimeValCur <= 10 && GameTimeValCur >= 1 && !TimeTTran.enabled)
        {
            TimeTTran.ResetToBeginning();
            TimeTTran.enabled = true;
            TimeTTran.PlayForward();
            if (GameTimeValCur == 10)
            {
                GameDaoJiShiCtrl.GetInstance().StartPlayDaoJiShi();
                CreateAudioSourceTime();
                AudioSourceTime.Play();
            }
        }

        if (!AddGameTimeCtrl.GetInstance().GetIsActiveAddTime())
        {
            GameTimeValCur--;
        }

        if (GameTimeValCur <= 0 && TimeTTran.enabled)
        {
            TimeTTran.enabled = false;
            if (AudioSourceTime != null && AudioSourceTime.isPlaying)
            {
                AudioSourceTime.Stop();
            }
        }
        yield return(StartCoroutine(PlayGameTime()));
    }