Mini-Games-Game/Assets/Scripts/Sorting/Colours.cs

34 lines
1.1 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Unity.VisualScripting;
using UnityEngine;
//* General Comments or Finished Tasks
//TODO Tasks left to be done for game
//! Bugs or Issues
//? Questions or Suggestions
public class Colours : MonoBehaviour
{
public GameObject Box;
public GameObject[] containers;
public List<Material> materials = new List<Material>();
private GameObject currentBox;
private int num;
//* Start is called before the first frame update
void Start()
{
//* Instantiate 8 containers with random colours at the start of the game
for (int i = 0; i < containers.Length; i++)
{
currentBox = Instantiate(Box, new Vector3(Random.Range(10, -10), 15, Random.Range(-10, 10)), Quaternion.identity);
num = Random.Range(0, materials.Count);
currentBox.GetComponent<Renderer>().material = materials[num];
containers[i].GetComponent<Renderer>().material = materials[num];
materials.RemoveAt(num);
}
}
}