|
@@ -3,9 +3,10 @@ using UnityEngine;
|
|
|
|
|
|
namespace Controller
|
|
|
{
|
|
|
+ [RequireComponent(typeof(IBicycleController))]
|
|
|
public class KeyboardBikeController : MonoBehaviour
|
|
|
{
|
|
|
- private WcBicycleController wcBicycleController;
|
|
|
+ private IBicycleController bicycleController;
|
|
|
|
|
|
public bool steer = true;
|
|
|
public bool lean = true;
|
|
@@ -19,7 +20,7 @@ namespace Controller
|
|
|
|
|
|
private void Start()
|
|
|
{
|
|
|
- wcBicycleController = GetComponent<WcBicycleController>();
|
|
|
+ bicycleController = GetComponent<IBicycleController>();
|
|
|
}
|
|
|
|
|
|
private void Update()
|
|
@@ -28,18 +29,18 @@ namespace Controller
|
|
|
{
|
|
|
if (Input.GetKey(KeyCode.T))
|
|
|
{
|
|
|
- wcBicycleController.CurrentSpeed += speedIncreasePerSecond * Time.deltaTime;
|
|
|
+ bicycleController.CurrentSpeed += speedIncreasePerSecond * Time.deltaTime;
|
|
|
}
|
|
|
- else if (wcBicycleController.CurrentSpeed > 0)
|
|
|
+ else if (bicycleController.CurrentSpeed > 0)
|
|
|
{
|
|
|
- wcBicycleController.CurrentSpeed = Mathf.Max(0,
|
|
|
- wcBicycleController.CurrentSpeed - speedDecreasePerSecond * Time.deltaTime);
|
|
|
+ bicycleController.CurrentSpeed = Mathf.Max(0,
|
|
|
+ bicycleController.CurrentSpeed - speedDecreasePerSecond * Time.deltaTime);
|
|
|
}
|
|
|
|
|
|
if (Input.GetKey(KeyCode.G))
|
|
|
{
|
|
|
- wcBicycleController.CurrentSpeed = Mathf.Max(0,
|
|
|
- wcBicycleController.CurrentSpeed - brakeIncreasePerSecond * Time.deltaTime);
|
|
|
+ bicycleController.CurrentSpeed = Mathf.Max(0,
|
|
|
+ bicycleController.CurrentSpeed - brakeIncreasePerSecond * Time.deltaTime);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -47,17 +48,17 @@ namespace Controller
|
|
|
{
|
|
|
if (Input.GetKey(KeyCode.F))
|
|
|
{
|
|
|
- wcBicycleController.CurrentSteerAngle -= steeringAngleIncreasePerSecond * Time.deltaTime;
|
|
|
+ bicycleController.CurrentSteerAngle -= steeringAngleIncreasePerSecond * Time.deltaTime;
|
|
|
}
|
|
|
|
|
|
if (Input.GetKey(KeyCode.H))
|
|
|
{
|
|
|
- wcBicycleController.CurrentSteerAngle += steeringAngleIncreasePerSecond * Time.deltaTime;
|
|
|
+ bicycleController.CurrentSteerAngle += steeringAngleIncreasePerSecond * Time.deltaTime;
|
|
|
}
|
|
|
|
|
|
if (Input.GetKeyUp(KeyCode.F) || Input.GetKeyUp(KeyCode.H))
|
|
|
{
|
|
|
- wcBicycleController.CurrentSteerAngle = 0f;
|
|
|
+ bicycleController.CurrentSteerAngle = 0f;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -65,17 +66,17 @@ namespace Controller
|
|
|
{
|
|
|
if (Input.GetKey(KeyCode.R))
|
|
|
{
|
|
|
- wcBicycleController.CurrentLeaningAngle -= leaningAngleIncreasePerSecond * Time.deltaTime;
|
|
|
+ bicycleController.CurrentLeaningAngle -= leaningAngleIncreasePerSecond * Time.deltaTime;
|
|
|
}
|
|
|
|
|
|
if (Input.GetKey(KeyCode.Z))
|
|
|
{
|
|
|
- wcBicycleController.CurrentLeaningAngle += leaningAngleIncreasePerSecond * Time.deltaTime;
|
|
|
+ bicycleController.CurrentLeaningAngle += leaningAngleIncreasePerSecond * Time.deltaTime;
|
|
|
}
|
|
|
|
|
|
if (Input.GetKeyUp(KeyCode.R) || Input.GetKeyUp(KeyCode.Z))
|
|
|
{
|
|
|
- wcBicycleController.CurrentLeaningAngle = 0f;
|
|
|
+ bicycleController.CurrentLeaningAngle = 0f;
|
|
|
}
|
|
|
}
|
|
|
}
|