Beispiel #1
0
		private List <Vector3> gridPositions = new List <Vector3> ();   //A list of possible locations to place tiles.
		
		void Awake()
		{
			//Check if instance already exists
			if (instance == null)
				
				//if not, set instance to this
				instance = this;

			//If instance already exists and it's not this:
			else if (instance != this)
				Destroy (gameObject); 
		}
Beispiel #2
0
		private Level levelScript;                       //Store a reference to our BoardManager which will set up the level.
		
		//Awake is always called before any Start functions
		void Awake()
		{
			//Check if instance already exists
			if (instance == null)
				
				//if not, set instance to this
				instance = this;
			
			//If instance already exists and it's not this:
			else if (instance != this)
				
				//Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
				Destroy(gameObject);    
			
			//Sets this to not be destroyed when reloading scene
			DontDestroyOnLoad(gameObject);
			
			//Get a component reference to the attached BoardManager script
			levelScript = GetComponent<Level>();
			
			//Call the InitGame function to initialize the first level 
			InitGame();
		}