Driving UI
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEditor.SearchService;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -11,19 +12,28 @@ public class GameManager : MonoBehaviour
|
||||
public GameObject[] checkpoints;
|
||||
public GameObject[] players;
|
||||
[HideInInspector] public List<string> playersFinished;
|
||||
[HideInInspector] public List<string> playerTimes;
|
||||
|
||||
[HideInInspector] public float[] playerTimes;
|
||||
[HideInInspector] public string[] playerTimesStr;
|
||||
int[] playerLaps;
|
||||
public TextMeshProUGUI lapCounter;
|
||||
public TextMeshProUGUI timeCounter;
|
||||
void Start()
|
||||
{
|
||||
// reset laps
|
||||
playerLaps = new int[players.Count()];
|
||||
playerTimes = new float[players.Count()];
|
||||
|
||||
for (int i = 0; i < playerLaps.Count(); i++)
|
||||
{
|
||||
playerLaps[i] = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < playerTimes.Count(); i++)
|
||||
{
|
||||
playerTimes[i] = 0;
|
||||
playerTimesStr[i] = "DNF";
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
@@ -46,7 +56,7 @@ public class GameManager : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
playerTimes[i] += Time.deltaTime;
|
||||
|
||||
bool isAI = true;
|
||||
if (player.GetComponent<PlayerController>().enabled)
|
||||
@@ -70,7 +80,10 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
player.GetComponent<PlayerController>().checkpointsCollected = 0;
|
||||
playerLaps[i] += 1;
|
||||
lapCounter.text = "Lap count: " + playerLaps[i];
|
||||
}
|
||||
|
||||
timeCounter.text = playerTimes[i].ToString();
|
||||
}
|
||||
|
||||
if (playerLaps[i] > lapAmount)
|
||||
@@ -84,8 +97,7 @@ public class GameManager : MonoBehaviour
|
||||
playersFinished.Add(player.name + " (player)");
|
||||
player.GetComponent<PlayerController>().enabled = false;
|
||||
|
||||
float time = Random.Range(15f, 40f);
|
||||
playerTimes.Add(time.ToString());
|
||||
playerTimesStr[i] = playerTimes[i].ToString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,29 +4,28 @@ using UnityEngine;
|
||||
|
||||
public class LapTimer : MonoBehaviour
|
||||
{
|
||||
public float time = 0;
|
||||
private bool startTime = false;
|
||||
// public List<float> times;
|
||||
// private bool startTime = false;
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider other) {
|
||||
// private void OnTriggerEnter(Collider other) {
|
||||
|
||||
if (startTime)
|
||||
{
|
||||
startTime = false;
|
||||
print(time);
|
||||
} else {
|
||||
startTime = true;
|
||||
time=0;
|
||||
}
|
||||
// if (startTime)
|
||||
// {
|
||||
// startTime = false;
|
||||
// print(time);
|
||||
// } else {
|
||||
// startTime = true;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
// void FixedUpdate()
|
||||
// {
|
||||
|
||||
time +=1;
|
||||
// time +=1;
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
12
Assets/Scripts/SkyboxSaver.cs
Normal file
12
Assets/Scripts/SkyboxSaver.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SkyboxSaver : MonoBehaviour
|
||||
{
|
||||
public string skyboxMaterial;
|
||||
void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SkyboxSaver.cs.meta
Normal file
11
Assets/Scripts/SkyboxSaver.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c18c8390868ebd643b4f572d9a90e043
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user