示例#1
0
    void Update()
    {
        if (levelStarted)
        {
            levelIndicator.text = string.Format("Level: {0}", level);
            time += Time.deltaTime;

            if (shipFuel.GetFuelAmount() <= 0f)
            {
                fuelTimerGameOverDelay -= Time.deltaTime;
            }

            if (fuelTimerGameOverDelay <= 0f)
            {
                GameOver();

                fuelTimerGameOverDelay = 2.0f;
            }
        }

        if (shipFuel.GetFuelAmount() <= 0)
        {
            fuelText.enabled = true;
        }
        else
        {
            fuelText.enabled = false;
        }

        shipHealth.value = (shipMovement.GetShipHealth()) / shipMovement.maxShipHealth;
        healthText.text  = string.Format("Health: {0:#.0} %", ((shipMovement.GetShipHealth()) / shipMovement.maxShipHealth) * 100);
    }
示例#2
0
    float CalculateAngle()
    {
        float shipRemainingFuel = shipFuel.GetFuelAmount();

        float angleCoeff = GetAngleCorrespondance(shipFuel.initialFuel, 120f);

        float angle = shipRemainingFuel * angleCoeff; // 0.6f for 200f

        return(60.0f - angle);
    }
    void FixedUpdate()
    {
        // As long as there is enough fuel, one can control the ship
        if (shipFuel.GetFuelAmount() > 0f)
        {
            Ship_Movement();
        }

        // Check for ship health here
        CheckForShipHealth();

        if (shipFuel.GetFuelAmount() <= 0f)
        {
            shipPropulsionEffect.SetActive(false);
        }
        else
        {
            shipPropulsionEffect.SetActive(true);
        }
    }