Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Intro_Scritping/0_Game_Submission_Builds/Roguelike2d/GameManager.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
56 lines (40 sloc)
1.76 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
namespace Completed | |
{ | |
using System.Collections.Generic; //Allows us to use Lists. | |
public class GameManager : MonoBehaviour | |
{ | |
public static GameManager instance = null; //Static instance of GameManager which allows it to be accessed by any other script. | |
private BoardManager boardScript; //Store a reference to our BoardManager which will set up the level. | |
private int level = 3; //Current level number, expressed in game as "Day 1". | |
//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 | |
boardScript = GetComponent<BoardManager>(); | |
//Call the InitGame function to initialize the first level | |
InitGame(); | |
} | |
//Initializes the game for each level. | |
void InitGame() | |
{ | |
//Call the SetupScene function of the BoardManager script, pass it current level number. | |
boardScript.SetupScene(level); | |
} | |
//Update is called every frame. | |
void Update() | |
{ | |
} | |
} | |
} |