Hi, I am making a card game that needs to be limited to two sets of decks of cards. How do I limit the set to n decks of cards? Currently in the code sample, im able to spawn a amount of gameobjects based on the amount of material in the list * 2 . Any help would be appreciated.
public class CardControl : MonoBehaviour
{
public List<Material> materialList;
public GameObject prefab;
private Vector3 pos;
private Quaternion rot = Quaternion.identity;
private bool Same;
private float XPosition = 0f;
private float YPosition = 0f;
private float ZPosition = 0f;
private void Awake()
{
pos = new Vector3(XPosition, YPosition, ZPosition);
Same = false;
for (int i = 0; i < (materialList.Count * 2); i++)
{
Material mat = RandomMaterial(materialList);
InstantiateWithMaterial(prefab, pos, rot, mat);
}
}
public Material RandomMaterial(List<Material>_List_)
{
return _List_[Random.Range(0, _List_.Count)];
}
public void InstantiateWithMaterial(GameObject _prefab_, Vector3 _pos_, Quaternion _rot_, Material _mat_)
{
GameObject obj_ = Instantiate(_prefab_, _pos_, _rot_);
obj_.gameObject.GetComponent<MeshRenderer>().material = _mat_;
obj_.name = _mat_.name + "1";
}
}