1
0
Fork 0

Fixed braking

This commit is contained in:
Piegames 2018-04-23 23:30:32 +02:00
parent 144c16f424
commit 1aa488732b
2 changed files with 9 additions and 4 deletions

View file

@ -432,7 +432,7 @@ public class DungeonGenerator {
r.tiles[pos].type = Room.TileType.ROCK; r.tiles[pos].type = Room.TileType.ROCK;
continue; continue;
} }
float prob2 = 0.04f; float prob2 = 0.004f;
if (UnityEngine.Random.value > 1 - prob2) if (UnityEngine.Random.value > 1 - prob2)
{ {
r.spawnpoints.Add(pos); r.spawnpoints.Add(pos);

View file

@ -15,7 +15,7 @@ public class PlayerMovement : MonoBehaviour {
[SerializeField] [SerializeField]
public float brake = 2f; public float brake = 2f;
[SerializeField] [SerializeField]
public float maxBrakeTime = 30f; public float maxBrakeTime = 5f;
// The time of the acceleration/deceleration sounds in seconds // The time of the acceleration/deceleration sounds in seconds
[SerializeField] [SerializeField]
@ -69,12 +69,15 @@ public class PlayerMovement : MonoBehaviour {
Vector3 speedVec = new Vector3(rb.velocity.x, rb.velocity.y, 0); Vector3 speedVec = new Vector3(rb.velocity.x, rb.velocity.y, 0);
float speed = speedVec.magnitude; float speed = speedVec.magnitude;
maxBrakeTime = 5f;
bool braking = Input.GetAxis("Vertical") < 0; bool braking = Input.GetAxis("Vertical") < 0;
if (brakeTime > maxBrakeTime) { if (braking && brakeTime >= maxBrakeTime) {
brakeTime = maxBrakeTime; brakeTime = maxBrakeTime;
braking = false; braking = false;
} else if (!braking) {
brakeTime -= (Time.time - lastFrame) * 0.1f;
} }
//Debug.Log(state + " " + braking + " " + (Time.time - changeTime) + " " + accelerationTime); Debug.Log(braking + " " + brakeTime);
if (braking) { if (braking) {
brakeTime += Time.time - lastFrame; brakeTime += Time.time - lastFrame;
GameController.instance.GetAudioControl().SfxStop(AudioControl.Sfx.driving); GameController.instance.GetAudioControl().SfxStop(AudioControl.Sfx.driving);
@ -103,6 +106,8 @@ public class PlayerMovement : MonoBehaviour {
break; break;
} }
} else { } else {
if (brakeTime < 0)
brakeTime = 0;
GameController.instance.GetAudioControl().SfxStop(AudioControl.Sfx.slowdriving); GameController.instance.GetAudioControl().SfxStop(AudioControl.Sfx.slowdriving);
switch (state) switch (state)
{ {