Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        // Only allow these controls on the ship to be used if the race has started and the racer hasn't finished racing
        if (gm.raceStarted && !finished)
        {
            // This code is held in update instead of fixed update so that there is 0 delay on the action taking place.
            // Button to shift to other side of track.
            if (Input.GetButtonDown(playerInput + "Y_Button") && grounded && gravityShiftReady && !respawning)
            {
                if (shipGravityCharges >= 1)
                {
                    camera.CameraWhiteFlash();
                    StartCoroutine("GravityShift");
                }
                else
                {
                    shipCollider.isTrigger = true;
                    shipCollider.isTrigger = false;
                }
            }

            // Button to respawn (self-destruct) ship
            if (Input.GetButtonDown(playerInput + "Back_Button") && !invincible && !finished)
            {
                RespawnShip();
            }

            // Button to fire current weapon
            if (Input.GetButtonDown(playerInput + "A_Button") && grounded && !respawning)
            {
                if (currentWeapon != "NO WEAPON")
                {
                    pm.FireWeapon(gameObject, currentWeapon, weaponLevel);
                }
            }

            // Apply proper catch up speed based on position and number of players present
            if (currentPosition == 4)
            {
                catchupSpeed = 1.15f;
            }
            else if (currentPosition == 3)
            {
                catchupSpeed = 1.10f;
            }
            else if (currentPosition == 2)
            {
                catchupSpeed = 1.05f;
            }
            else if (currentPosition == 1)
            {
                catchupSpeed = 1f;
            }
        }
    }