Car customization should fully work

This commit is contained in:
2024-04-23 13:03:15 +02:00
parent 5eb69aaa38
commit 83ae0f6e22
14 changed files with 2118 additions and 273 deletions

View File

@@ -8,6 +8,7 @@ using UnityEngine.UI;
public class Garage : MonoBehaviour
{
GameObject CurrentCar;
string currentColor = "Default";
public Button[] CarButtons;
public GameObject[] Garages;
public GameObject[] CarBodies;
@@ -15,6 +16,7 @@ public class Garage : MonoBehaviour
public Material[] Colors;
quaternion currentRotation;
public Button startButton;
public GameObject carData;
void Start()
{
CarButtons[0].onClick.AddListener(SelectHotrod);
@@ -64,11 +66,14 @@ public class Garage : MonoBehaviour
Garages[i].SetActive(true);
CurrentCar = CarBodies[i];
CurrentCar.transform.rotation = currentRotation;
currentColor = "Default";
}
void startGame()
{
SceneManager.LoadScene("Racetrack mini");
carData.GetComponent<CarData>().carType = CurrentCar.name;
carData.GetComponent<CarData>().carColor = currentColor;
}
void SelectHotrod()
@@ -115,71 +120,83 @@ public class Garage : MonoBehaviour
{
Material color = Colors[0];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Black";
}
void SelectBlue()
{
Material color = Colors[1];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Blue";
}
void SelectBrown()
{
Material color = Colors[2];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Brown";
}
void SelectGray()
{
Material color = Colors[3];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Gray";
}
void SelectGreen()
{
Material color = Colors[4];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Green";
}
void SelectOrange()
{
Material color = Colors[5];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Orange";
}
void SelectPink()
{
Material color = Colors[6];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Pink";
}
void SelectRed()
{
Material color = Colors[7];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Red";
}
void SelectTurquoise()
{
Material color = Colors[8];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Turquoise";
}
void SelectViolet()
{
Material color = Colors[9];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Violet";
}
void SelectWhite()
{
Material color = Colors[10];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "White";
}
void SelectYellow()
{
Material color = Colors[11];
CurrentCar.GetComponent<ChangeCarColor>().ChangeColor(color);
currentColor = "Yellow";
}
}