Compare commits
4 Commits
DevMax
...
TestProjec
Author | SHA1 | Date | |
---|---|---|---|
1040da0484 | |||
ce43ecdef8 | |||
50ec58d9a8 | |||
dca0c8d0c1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8da3d18c927872e4b864603a84d0ea82
|
||||
guid: 9719638f26e556f4fbe1f0c12718f710
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
4279
Assets/Prefab/UI/Fonts/LBNOutline.asset
Normal file
4279
Assets/Prefab/UI/Fonts/LBNOutline.asset
Normal file
File diff suppressed because one or more lines are too long
@ -1,7 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf9226b08aa0ce5478c6235342946f5f
|
||||
DefaultImporter:
|
||||
guid: 4991592a1585c3846afa91f8858d0d12
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3551cb8d7e21e3845a8d3cfe36c54b0f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02ea98c3753d4f747af367d8689d0ec8
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 971b6871508fb1948a1ab6da1786c941
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d878fa6a02700e64dbcce46c96c7c238
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -24,7 +24,6 @@ namespace RootMotion
|
||||
|
||||
[Header("Position")]
|
||||
public bool smoothFollow; // If > 0, camera will smoothly interpolate towards the target
|
||||
public Vector3 offset = new Vector3(0, 1.5f, 0.5f); // The offset from target relative to camera rotation
|
||||
public float followSpeed = 10f; // Smooth follow speed
|
||||
|
||||
[Header("Rotation")]
|
||||
@ -45,7 +44,6 @@ namespace RootMotion
|
||||
public float blockingRadius = 1f;
|
||||
public float blockingSmoothTime = 0.1f;
|
||||
public float blockingOriginOffset;
|
||||
[Range(0f, 1f)] public float blockedOffset = 0.5f;
|
||||
|
||||
public float x { get; private set; } // The current x rotation of the camera
|
||||
public float y { get; private set; } // The current y rotation of the camera
|
||||
@ -59,7 +57,6 @@ namespace RootMotion
|
||||
private float fixedDeltaTime;
|
||||
private Quaternion r = Quaternion.identity;
|
||||
private Vector3 lastUp;
|
||||
private float blockedDistance = 10f, blockedDistanceV;
|
||||
|
||||
//Rotation
|
||||
|
||||
@ -79,31 +76,19 @@ namespace RootMotion
|
||||
// Initiate, set the params to the current transformation of the camera relative to the target
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Vector3 angles = transform.eulerAngles;
|
||||
x = angles.y;
|
||||
y = angles.x;
|
||||
//Vector3 angles = transform.eulerAngles;
|
||||
//x = angles.y;
|
||||
//y = angles.x;
|
||||
|
||||
distanceTarget = distance;
|
||||
smoothPosition = transform.position;
|
||||
|
||||
cam = GetComponent<Camera>();
|
||||
|
||||
//_rotate = new Controller();
|
||||
//_rotate.Player.CameraRotation.performed += context => UpdateInput();
|
||||
|
||||
|
||||
//lastUp = rotationSpace != null ? rotationSpace.up : Vector3.up;
|
||||
|
||||
}
|
||||
|
||||
//private void OnEnable()
|
||||
//{
|
||||
// _rotate.Enable();
|
||||
//}
|
||||
|
||||
//private void OnDisable()
|
||||
//{
|
||||
// _rotate.Disable();
|
||||
//}
|
||||
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
@ -174,33 +159,11 @@ namespace RootMotion
|
||||
// Distance
|
||||
distance += (distanceTarget - distance) * zoomSpeed * deltaTime;
|
||||
|
||||
// Smooth follow
|
||||
if (!smoothFollow) smoothPosition = target.position;
|
||||
else smoothPosition = Vector3.Lerp(smoothPosition, target.position, deltaTime * followSpeed);
|
||||
|
||||
// Position
|
||||
Vector3 t = smoothPosition + rotation * offset;
|
||||
Vector3 f = rotation * -Vector3.forward;
|
||||
|
||||
if (blockingLayers != -1)
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.SphereCast(t - f * blockingOriginOffset, blockingRadius, f, out hit, blockingOriginOffset + distanceTarget - blockingRadius, blockingLayers))
|
||||
{
|
||||
blockedDistance = Mathf.SmoothDamp(blockedDistance, hit.distance + blockingRadius * (1f - blockedOffset) - blockingOriginOffset, ref blockedDistanceV, blockingSmoothTime);
|
||||
}
|
||||
else blockedDistance = distanceTarget;
|
||||
|
||||
distance = Mathf.Min(distance, blockedDistance);
|
||||
}
|
||||
|
||||
position = t + f * distance;
|
||||
|
||||
// Translating the camera
|
||||
transform.position = position;
|
||||
|
||||
|
||||
}
|
||||
|
||||
transform.rotation = rotation;
|
||||
//transform.rotation = rotation;
|
||||
}
|
||||
|
||||
// Zoom input
|
||||
|
@ -1,5 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2de7c7d4447069b4087e08a59a1132f7
|
||||
guid: ed3d101d8fa2b3941a4531458ec57175
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
119
Assets/Scripts/UI/DriftScore.cs
Normal file
119
Assets/Scripts/UI/DriftScore.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class DriftScore : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Rigidbody playerRB;
|
||||
[SerializeField] private TMP_Text totalScoreText;
|
||||
[SerializeField] private TMP_Text currentScoreText;
|
||||
[SerializeField] private TMP_Text factorText;
|
||||
[SerializeField] private TMP_Text driftAngleText;
|
||||
|
||||
private float speed = 0;
|
||||
private float driftAngle = 0;
|
||||
private float driftFactor = 1;
|
||||
private float currentScore;
|
||||
private float totalScore;
|
||||
|
||||
private bool isDrifting = false;
|
||||
|
||||
[SerializeField] private float minimumSpeed = 5;
|
||||
[SerializeField] private float minimumAngle = 10;
|
||||
[SerializeField] private float driftingDelay = 0.2f;
|
||||
[SerializeField] private GameObject driftingObject;
|
||||
[SerializeField] private Color normalDriftColor;
|
||||
[SerializeField] private Color nearStopColor;
|
||||
[SerializeField] private Color driftEndedColor;
|
||||
|
||||
private IEnumerator stopDriftingCoroutine = null;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
driftingObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
ManagerDrift();
|
||||
ManageUI();
|
||||
}
|
||||
void ManagerDrift()
|
||||
{
|
||||
speed = playerRB.velocity.magnitude;
|
||||
driftAngle = Vector3.Angle(playerRB.transform.forward, (playerRB.velocity + playerRB.transform.forward).normalized);
|
||||
if (driftAngle > 120)
|
||||
{
|
||||
driftAngle = 0;
|
||||
}
|
||||
if (driftAngle >= minimumAngle && speed > minimumSpeed)
|
||||
{
|
||||
if (!isDrifting || stopDriftingCoroutine != null)
|
||||
{
|
||||
StartDrift();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isDrifting && stopDriftingCoroutine == null)
|
||||
{
|
||||
StopDrift();
|
||||
}
|
||||
}
|
||||
if (isDrifting)
|
||||
{
|
||||
currentScore += Time.deltaTime * driftAngle * driftFactor;
|
||||
driftFactor += Time.deltaTime;
|
||||
driftingObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
async void StartDrift()
|
||||
{
|
||||
if (!isDrifting)
|
||||
{
|
||||
await Task.Delay(Mathf.RoundToInt(1000 * driftingDelay));
|
||||
driftFactor = 1;
|
||||
}
|
||||
if (stopDriftingCoroutine != null)
|
||||
{
|
||||
StopCoroutine(stopDriftingCoroutine);
|
||||
stopDriftingCoroutine = null;
|
||||
}
|
||||
currentScoreText.color = normalDriftColor;
|
||||
isDrifting = true;
|
||||
|
||||
}
|
||||
void StopDrift()
|
||||
{
|
||||
stopDriftingCoroutine = StoppingDrift();
|
||||
StartCoroutine(stopDriftingCoroutine);
|
||||
|
||||
}
|
||||
private IEnumerator StoppingDrift()
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
currentScoreText.color = Color.yellow;
|
||||
|
||||
yield return new WaitForSeconds(driftingDelay * 4f);
|
||||
totalScore += currentScore;
|
||||
isDrifting = false;
|
||||
currentScoreText.color = Color.red;
|
||||
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
currentScore = 0;
|
||||
driftingObject.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
void ManageUI()
|
||||
{
|
||||
totalScoreText.text = "<22><><EFBFBD><EFBFBD>: " + (totalScore).ToString("###,###, ##0");
|
||||
factorText.text = driftFactor.ToString("###,###,##0.0") + "X";
|
||||
currentScoreText.text = currentScore.ToString("###,###,000");
|
||||
driftAngleText.text = driftAngle.ToString("###,##0");
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/DriftScore.cs.meta
Normal file
11
Assets/Scripts/UI/DriftScore.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb93655aa55fc7644b1844ee83011ba7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Reference in New Issue
Block a user