Merge branch 'master' of ooftooft.net:Racesm

# Conflicts:
#	Assets/Imported Assets/SimpleNaturePack/SimpleNaturePack_2020.3_HDRP_v1.24.unitypackage.meta
#	Assets/Imported Assets/SimpleNaturePack/SimpleNaturePack_2020.3_URP_v1.24.unitypackage.meta
#	Assets/ML-Agents/Timers/Car Customization_timers.json
#	Assets/ML-Agents/Timers/City racesm_timers.json.meta
#	Assets/ML-Agents/Timers/Racetrack mini_timers.json
#	Assets/ML-Agents/Timers/WinScreen_timers.json.meta
#	Assets/Prefabs/Cars/Cars LLLLL.prefab.meta
#	Assets/Scenes/WinScreen.unity.meta
This commit is contained in:
2024-04-25 15:16:46 +02:00
40 changed files with 3908 additions and 1110 deletions

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class BackToStart : MonoBehaviour
{
public void returnToStart()
{
Destroy(GameObject.Find("Car Data"));
Destroy(GameObject.Find("SkyboxManager"));
Destroy(GameObject.Find("GameManager"));
SceneManager.LoadScene(0);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3e3f507f50d340f468852b068fedb6fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,7 +5,7 @@ using Unity.VisualScripting;
using UnityEngine;
//script from FREAKINGREX, but minor changes to integrate it proberly
//script from FREAKINGREX, but changes to integrate it proberly/ work how we want it to work
//https://assetstore.unity.com/packages/templates/systems/arcade-car-controller-lite-version-145489
public class CameraControl :MonoBehaviour
@@ -68,6 +68,7 @@ public class CameraControl :MonoBehaviour
transform.position = Vector3.LerpUnclamped (transform.position, TargetPoint, Time.deltaTime * ActivePreset.SetPositionSpeed);
if (Input.GetKeyDown (SetCameraKey))
{
SetNextCamera ();
@@ -111,6 +112,7 @@ public class CameraControl :MonoBehaviour
public void UpdateActiveCamera ()
{
if (ActivePreset != null)
{
ActivePreset.CameraHolder.SetActive(false);

View File

@@ -71,7 +71,7 @@ public class Garage : MonoBehaviour
void startGame()
{
SceneManager.LoadScene("Racetrack mini");
SceneManager.LoadScene(1);
carData.GetComponent<CarData>().carType = CurrentCar.name;
carData.GetComponent<CarData>().carColor = currentColor;
}

View File

@@ -13,49 +13,42 @@ public class GameController :MonoBehaviour
[SerializeField] UnityEngine.UI.Button NextCarButton;
public static GameController Instance;
public GameObject PlayerCar;
public GameObject cam;
public static bool RaceIsStarted { get { return true; } }
public static bool RaceIsEnded { get { return false; } }
PlayerController m_PlayerCar;
List<PlayerController> Cars = new List<PlayerController>();
//PlayerController m_PlayerCar;
//List<PlayerController> Cars = new List<PlayerController>();
public List<GameObject> cars;
int CurrentCarIndex = 0;
protected virtual void Awake ()
{
Instance = this;
//Find all cars in current game.
Cars.AddRange (GameObject.FindObjectsOfType<PlayerController> ());
Cars = Cars.OrderBy (c => c.name).ToList();
// foreach (var car in cars)
// {
// var userControl = car.GetComponent<PlayerController>();
// var audioListener = car.GetComponent<AudioListener>();
foreach (var car in Cars)
{
var userControl = car.GetComponent<PlayerController>();
var audioListener = car.GetComponent<AudioListener>();
// if (userControl == null)
// {
// userControl = car.gameObject.AddComponent<PlayerController> ();
// }
if (userControl == null)
{
userControl = car.gameObject.AddComponent<PlayerController> ();
}
// if (audioListener == null)
// {
// audioListener = car.gameObject.AddComponent<AudioListener> ();
// }
if (audioListener == null)
{
audioListener = car.gameObject.AddComponent<AudioListener> ();
}
// userControl.enabled = false;
// audioListener.enabled = false;
// }
userControl.enabled = false;
audioListener.enabled = false;
}
m_PlayerCar = Cars[0];
m_PlayerCar.GetComponent<PlayerController> ().enabled = true;
m_PlayerCar.GetComponent<AudioListener> ().enabled = true;
if (NextCarButton)
{
NextCarButton.onClick.AddListener (NextCar);
}
// cars[CurrentCarIndex].GetComponent<PlayerController>().enabled = true;
// cars[CurrentCarIndex].GetComponent<AudioListener>().enabled = true;
}
void Update ()
@@ -69,14 +62,20 @@ public class GameController :MonoBehaviour
private void NextCar ()
{
m_PlayerCar.GetComponent<PlayerController> ().enabled = false;
m_PlayerCar.GetComponent<AudioListener> ().enabled = false;
// cars[CurrentCarIndex].GetComponent<PlayerController> ().enabled = false;
// cars[CurrentCarIndex].GetComponent<AudioListener> ().enabled = false;
CurrentCarIndex = LoopClamp (CurrentCarIndex + 1, 0, Cars.Count);
CurrentCarIndex = LoopClamp (CurrentCarIndex + 1, 0, cars.Count);
m_PlayerCar = Cars[CurrentCarIndex];
m_PlayerCar.GetComponent<PlayerController> ().enabled = true;
m_PlayerCar.GetComponent<AudioListener> ().enabled = true;
// cars[CurrentCarIndex].GetComponent<PlayerController>().enabled = true;
// cars[CurrentCarIndex].GetComponent<AudioListener>().enabled = true;
PlayerCar = cars[CurrentCarIndex];
cam.GetComponent<CameraControl>().getCar(PlayerCar);
print(PlayerCar.name);
}
public static int LoopClamp (int value, int minValue, int maxValue)

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class TestScripts : MonoBehaviour
{
public void Start()
{
SceneManager.LoadScene(4);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6353d73605631bb4ba84158bbcdec189
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SkyboxLoader : MonoBehaviour
{
public Material skyboxDay;
public Material skyboxNight;
string skyboxToLoad;
void Awake()
{
skyboxToLoad = GameObject.Find("SkyboxManager").GetComponent<TimeOfDay>().skyboxMaterial;
Debug.Log("Skybox: " + skyboxToLoad);
if (skyboxToLoad == "Day")
{
RenderSettings.skybox = skyboxDay;
}
else
{
RenderSettings.skybox = skyboxNight;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56ccdf5df0a83eb4091e7eeb634e5d5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class TimeOfDay : MonoBehaviour
{
public string skyboxMaterial = "not selected";
public static TimeOfDay Instance;
public TextMeshProUGUI MainText;
public void ChangeToDayTime()
{
skyboxMaterial = "Day";
}
public void ChangeToNightTime()
{
skyboxMaterial = "Night";
}
private void Awake()
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
private void Update()
{
MainText.text = "Selected time of day: \n" + skyboxMaterial;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ab14f81283cca7e4c91a272a9773809d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: