Esempio n. 1
0
    void Update()
    {
        updateUI();
        if (dead)
        {
            //Wait a second so the player can react to "Game Over"
            if (Time.time - deathTime < 1f)
            {
                return;
            }

            if (Input.GetButtonUp("Shoot"))
            {
                init();
                restarting = true;
            }
            return;
        }
        if (invincible)
        {
            if ((Time.time - invincibleStart) > invinciblePeriod)
            {
                invincible = false;
            }
        }
        Vector3 velocity = Vector3.zero;

        //Rotate around x-axis
        transform.Rotate(Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime, 0.0f, 0.0f);

        //Calculate velocity along local ship's y-axis
        velocity = transform.up * Input.GetAxis("Vertical") * speed;
        controller.Move(velocity * Time.deltaTime);
        checkBounds();

        if (Input.GetButtonUp("Shoot"))
        {
            weaponsSystem.shoot(projectile, transform);
        }
    }