コード例 #1
0
    void ControlSpeedLimit()
    {
        Road current = gameManager.speedLimitController.IsInsideRoadBoundaries(player.transform.position.z);

        if (current != null && gameManager.activeRoadIndex != gameManager.speedLimitController.activeIndex)
        {
            // show UI (inside road bounds)
            ToggleUI(true);

            // store current road index on list
            gameManager.activeRoadIndex = gameManager.speedLimitController.activeIndex;

            // store road speed
            //TODO: maybe change this index and speed to a Road object. Makes more sense
            gameManager.speedLimitController.currentRoadSpeed = current.speedlimit;

            // change new road speed
            speedLimitUI.text = VehicleController.GetCurrentSpeedIndicator((int)current.speedlimit);
        }
        else if (current == null)
        {
            // Hide UI (outisde a road)
            ToggleUI(false);
        }
    }