示例#1
0
    void resetDynamicData()
    {
        PropellerProduct _propellerProductScript = getPropellerProductClass();

        gameTimerValue = (float)_propellerProductScript.getGameTime();
        int   _gearShapeType = _propellerProductScript.getGearShapeType();
        float _gearFriction  = _propellerProductScript.getGearFriction();

        GameObject _gearAction       = GameObject.Find("GearProxy1");
        gearAction _gearActionScript = _gearAction.GetComponent <gearAction>();

        _gearActionScript.Reset(_gearShapeType, _gearFriction);
    }
示例#2
0
    void Update()
    {
        switch (mGameState)
        {
        case eGameState.Init:
        {
            scoreValue     = 0;
            gameTimerValue = 10.0f;

            resetDynamicData();
            InitTextMeshObjs();

            mGameState = eGameState.Ready;
        }
        break;

        case eGameState.Ready:
        {
            //waiting for first tap
        }
        break;

        case eGameState.FirstTap:
        {
            GameObject _tapsCounter = GameObject.Find("TapsCounter");
            Animator   _Animator    = _tapsCounter.GetComponent <Animator>();
            _Animator.Play("tapCountDisplayAnim2");

            _tapsCounter = GameObject.Find("MPSCounter");
            _Animator    = _tapsCounter.GetComponent <Animator>();
            _Animator.Play("tapCountDisplayAnim2");

            mGameState = eGameState.Running;
        }
        break;



        case eGameState.Running:
        {
            //update gameTimer
            gameTimerValue -= Time.deltaTime;


            GameObject _gearAction       = GameObject.Find("GearProxy1");
            gearAction _gearActionScript = _gearAction.GetComponent <gearAction>();

            if (gameTimerValue <= 0)
            {
                mGameState     = eGameState.Done;
                gameTimerValue = 0.0f;

                hideStartButtonText();

                int maxspeed = (int)_gearActionScript.maxspinvelocity;

                PropellerProduct _propellerProductScript = getPropellerProductClass();
                _propellerProductScript.SetMatchScore(scoreValue, maxspeed);

                GameObject _backObj = GameObject.Find("backButton");
                _backObj.GetComponent <Renderer>().enabled = true;


                //reset animations
                GameObject _tapsCounter = GameObject.Find("TapsCounter");
                Animator   _Animator    = _tapsCounter.GetComponent <Animator>();
                _Animator.Play("tapCountDisplayAnim");

                _tapsCounter = GameObject.Find("MPSCounter");
                _Animator    = _tapsCounter.GetComponent <Animator>();
                _Animator.Play("tapCountDisplayAnim");


                //bring the system to a grinding halt
                _gearActionScript.SetFriction(0.96f);
                _gearActionScript.ClearActiveBonuses();

                GameOverSFX.Play();

                //Timeup Popup
                GameObject _timeup = GameObject.Find("TimeUpPopup");
                _timeup.GetComponent <Renderer>().enabled = true;

                updateFinalScoreText(scoreValue.ToString());
                _timeup = GameObject.Find("finalScore");
                _timeup.GetComponent <Renderer>().enabled = true;


                //another complete game session
                if (PlayerPrefs.HasKey("numSessions"))
                {
                    int numSessions = PlayerPrefs.GetInt("numSessions");
                    numSessions++;
                    PlayerPrefs.SetInt("numSessions", numSessions);
                }
            }

            //update game timer
            if (_gearActionScript.Check5secBonus() == true)
            {
                gameTimerValue += 5.0f;
            }

            updateGameTimerText(gameTimerValue.ToString("0") + " sec");

            updateScoreText(scoreValue.ToString());


            GameObject spinTextObj = GameObject.Find("speedTextMesh");
            TextMesh   tmesh       = (TextMesh)spinTextObj.GetComponent(typeof(TextMesh));
            tmesh.text = _gearActionScript.velocityStr;
        }
        break;

        case eGameState.Done:
        {
            //timeout to return to main menu

            gameoverTimer += Time.deltaTime;
            if (gameoverTimer >= gameoverTimeout)
            {
                InitMainMenu.sComingFromGame = true;
                Application.LoadLevel("MainMenu");

                mGameState = eGameState.Exit;
            }
        }
        break;

        case eGameState.Exit:
        {
        }
        break;
        }
    }