-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractVehicles.cs
45 lines (38 loc) · 1.13 KB
/
AbstractVehicles.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using UnityEngine;
using System.Collections.Generic;
public abstract class AbstractVehicles : MonoBehaviour {
// Some colors for different vehicles
private static List<Color> colors = new List<Color> {
Color.red, Color.blue, Color.cyan,
Color.gray, Color.green, Color.magenta,
Color.yellow, Color.white, Color.black,
new Color(0.5f, 0.7f, 1.0f),
new Color(0.7f, 0.5f, 1.0f),
new Color(1.0f, 0.5f, 0.7f),
new Color(1.0f, 0.7f, 0.5f),
new Color(0.5f, 1.0f, 0.7f),
new Color(0.7f, 1.0f, 0.5f)
};
// List of vehicles
protected List<GameObject> vehicles;
protected GameObject vehicle;
// Nothing here
void Start() {
}
// Nothing here
void Update() {
}
// Generates vehicle objects in the scene
protected void GenerateVehicles(List<Vector3> positions) {
vehicles = new List<GameObject>();
System.Random rnd = new System.Random();
foreach (Vector3 pos in positions) {
GameObject obj = Instantiate(vehicle) as GameObject;
obj.transform.position = pos;
obj.transform.parent = transform;
obj.renderer.material.color = colors[rnd.Next(colors.Count)];
obj.SetActive(true);
vehicles.Add(obj);
}
}
}