I have a level in my game where you operate a crane and drop off different shipping containers. There are 3 different colored containers and each color is measured with a score (ex: Blue containers: 3, Red Containers: 3, etc) My score code works properly BUT i want to end the game once all of the scores hit zero. I haven’t found any other questions on the forums personally that ask how to end a game when multiple score values all equal the same thing.
Here’s my code, i’m not the best at coding but if it works great then i’m not gonna fight it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ContDropoff : MonoBehaviour
{
public GameObject contb;
public GameObject contr;
public GameObject conty;
public GameObject spotlight;
public int BlueCount;
public int RedCount;
public int YellowCount;
public Text BlueText;
public Text RedText;
public Text YellowText;
public Text VictoryScreen;
void Start ()
{
BlueCount = 3;
RedCount = 3;
YellowCount = 3;
BlueText.text = "Blue Containers left: " + BlueCount;
RedText.text = "Red Containers left: " + RedCount;
YellowText.text = "Yellow Containers left: " + YellowCount;
}
void Update()
{
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name == "Blue Goal")
{
BlueCount -= 1;
contb.SetActive(false);
spotlight.SetActive(true);
BlueText.text = "Blue Conteiners left: " + BlueCount;
}
if (col.gameObject.name == "Red Goal")
{
RedCount -= 1;
contr.SetActive(false);
spotlight.SetActive(true);
RedText.text = "Red Containers left: " + RedCount;
}
if (col.gameObject.name == "Yellow Goal")
{
YellowCount -= 1;
conty.SetActive(false);
spotlight.SetActive(true);
YellowText.text = "Yellow Containers left: " + YellowCount;
}
}
}