コード例 #1
0
    private void FixedUpdate()
    {
        cooldown -= Time.fixedDeltaTime;

        if (cooldown > 0.0f)
        {
            return;
        }

        if (tank.IsEmpty())
        {
            return;
        }

        if (!GameController.Instance.IsGameActive())
        {
            return;
        }

        if ((Input.GetMouseButton(0) || Input.GetKey(KeyCode.Space)) && body.velocity.y <= maxSpeed)
        {
            body.AddForce(new Vector2(0.0f, upwardForce));
            tank.Burn(upwardForce * fuelConsumptionPerNewton);
        }

        var height = transform.position.y;

        if (height > shutdownHeight)
        {
            cooldown = shutdownDuration;
        }
    }
コード例 #2
0
    private void TryShowGameOver()
    {
        if (gameOverPlate.activeSelf)
        {
            return;
        }

        if (player == null || !health.Alive() || tank.IsEmpty())
        {
            ShowGameOver();
        }
    }
コード例 #3
0
    private void FixedUpdate()
    {
        if (!GameController.Instance.IsGameActive())
        {
            return;
        }

        var speed = body.velocity.x;
        var force = Mathf.Min(relativeForce * (targetSpeed - speed), maxForce);

        var delta = Time.fixedDeltaTime;

        if (!tank.IsEmpty())
        {
            body.AddForce(new Vector2(force * delta, 0.0f));
            tank.Burn(fuelConsumptionPerNewton * force * delta);
        }
    }