Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case GameState.GameStart:
            defaultCamera.SetActive(true);
            uxInstance.isSwitchScreenPossible(UIscreens.HomeScreenUI);
            gameStartTime = Time.time;

            break;

        case GameState.Ongame:
            uxInstance.isSwitchScreenPossible(UIscreens.HUDScreenUI);
            mainGameObject.SetActive(true);
            defaultCamera.SetActive(false);
            GameLostRules();
            break;

        case GameState.GameLose:
            uxInstance.isSwitchScreenPossible(UIscreens.PopUpScreenUI);
            defaultCamera.SetActive(true);
            break;

        case GameState.Reset:
            platformInstance.ResetGame();
            break;

        case GameState.GameWin:
            uxInstance.isSwitchScreenPossible(UIscreens.PopUpScreenUI);

            break;
        }
    }
Exemple #2
0
    void ProcessKeyBoard()
    {
        // Applying drive force to move forward
        if (bikeHit == false)
        {
            if (Input.GetKey(KeyCode.UpArrow) || upArrow)
            {
                FuelSlider.value -= 0.05f;
                score            += .1f;
                if (rb.velocity.x < maxVelocity.x)
                {
                    rb.AddForce(transform.forward * thrust);
                }
            }
//			if (Input.GetKeyUp (KeyCode.UpArrow)||upArrow) {
//				speedText.text = rb.velocity.magnitude.ToString();
//				rb.AddForce(-transform.forward * thrust);
//			}
            //Applying negative force to stop
            if (Input.GetKey(KeyCode.DownArrow) || downArrow)
            {
                if (rb.velocity.x > 3f)
                {
                    rb.AddForce(-transform.forward * thrust);
                }
            }

            // Applying lateral force to left
            if (Input.GetKey(KeyCode.LeftArrow) || leftArrow)
            {
                TiltBike(15f, 14.5f);
            }

            // Applying lateral force to right
            if (Input.GetKey(KeyCode.RightArrow) || rightArrow)
            {
                TiltBike(-15f, 345.5f);
            }
        }
        //Reset Button!!
        if (Input.GetKey(KeyCode.R))
        {
            bikeHit = false;
            platformInstance.ResetGame();
        }

//		 To return to normal angle if no lateral force applied.
        if (!lateralForceApplied)
        {
            if (rb.velocity.x > driveVelocity.x)
            {
                int zAngle = (int)transform.eulerAngles.z;
                if (zAngle <= 15 && zAngle >= 0)
                {
                    Quaternion tiltRotationAngle = Quaternion.AngleAxis(-15f, rotationAxis) * transform.rotation;
                    rb.transform.rotation = Quaternion.Lerp(transform.rotation, tiltRotationAngle, rotationSpeed * Time.deltaTime);
                }
                if (zAngle <= 360 && zAngle >= 345)
                {
                    Quaternion tiltRotationAngle = Quaternion.AngleAxis(15f, rotationAxis) * transform.rotation;
                    rb.transform.rotation = Quaternion.Lerp(transform.rotation, tiltRotationAngle, rotationSpeed * Time.deltaTime);
                }
            }
        }

        ReCorrectAngle();
    }    //ProcessKeyBoard