private bool doingSetup = true;							//Boolean to check if we're setting up board, prevent Player from moving during setup.
		
		
		
		//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);
			
			//Assign enemies to a new List of Enemy objects.
			enemies = new List<Enemy>();
			
			//Get a component reference to the attached BoardManager script
			boardScript = GetComponent<BoardManager>();
			
			//Call the InitGame function to initialize the first level 
			InitGame();
		}
예제 #2
0
        // Awake is always called before any Start functions
        // Only called once.
        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);

            keepLoadedStars = new List<GameObject>();

            if (lastKnownPosition == Vector2.zero)  // no last known position
                instance.virtualPosition = PlayerData.instance.lastPosition;    // TODO: update to respond to server call
            else
                instance.virtualPosition = lastKnownPosition;

            virtualPosition = instance.virtualPosition;

            //virtualPosition = instance.virtualPosition;

            //Call the InitGame function to initialize the starting level 
            if (SceneManager.GetActiveScene().buildIndex == SectorLevel)
                InitGame();
                        
        }
예제 #3
0
		public bool storyMode = true; //~Z 16.01.31 | Currently setting strictly from code - as this is generated in Runtime
		
		
		//Awake is always called before any Start functions ~Z 16.01.30 | Not 100% clear whether this is done on each Scene reload?
		void Awake()
		{
			Debug.Log ("GameManager is Awake!");
			//~Z 16.01.30 | Setting up this singleton - important since we're using this with persistent DontDestroyOnLoad
			//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 - or loading a new scene.
			DontDestroyOnLoad(gameObject);
			
			//Assign enemies to a new List of Enemy objects.
			enemies = new List<Enemy>();
			enemies2 = new List<Enemy>(); //~Z 16.01.30 | assuming this is only run once per game session.
			enemies3 = new List<Enemy>();
			enemies4 = new List<Enemy>();
			enemies5 = new List<Enemy>();
			
			//Get a component reference to the attached BoardManager script
			boardScript = GetComponent<BoardManager>();
			currentIRCListener = GetComponent<TwitchIrcListener> ();
			
			//Call the InitGame function to initialize the first level 
			InitGame();
		} //End.Awake()
예제 #4
0
        //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);

            //Call the InitGame function to initialize the first level
            InitGame();
        }
예제 #5
0
        //Awake is always called before any Start functions
        void Awake()
        {
            doingSetup = true;
            //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);

            //Assign enemies to a new List of Enemy objects.
            enemies = new List<MovingObject>();

            //Assign bullets to a new List of Projectile objects.
            bullets = new List<Projectile>();

            //Get a component reference to the attached BoardManager script
            boardScript = GetComponent<BoardManager>();

            //Call the InitGame function to initialize the first level
            InitGame();

            // it is the first turn of this level
            firstTurn = true;

            //Start the phase changing routine
            StartCoroutine("phaseShifter");
        }
예제 #6
0
        //Awake is always called before any Start functions
        void Awake()
        {
            observers = new List<IObserver> ();

            levelText = GameObject.Find ("LevelText").GetComponent<Text>();
            levelText.text = "Level: " + level;

            //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
            columnedRoomGeneration = GetComponent<BlockMapGeneration>();
            drunkardWalk = GetComponent<DrunkardWalk> ();
            binarySpacePartioning = GetComponent<BinarySpacePartioning> ();

            //Call the InitGame function to initialize the first level
            InitGame();
        }
예제 #7
0
 void Start()
 {
     gameManager = GameObject.Find ("GameManager").GetComponent<Completed.GameManager>();
 }
예제 #8
0
        /*
         *	Called when the scene is loaded; performs setup.
         */
        void OnLevelWasLoaded(int index)
        {
            if (instance == null)
                instance = this;
            else if (instance != this)
                Destroy(gameObject);		// destroy this if one already exists, to preserve singleton.

            DontDestroyOnLoad(gameObject);	// don't destroy this when reloading scene
            mode = BoardManager.mode;

            // assign enemies to a new List of Enemy objects.
            if (mode == 1)
            {
                blueComp = new List<Enemy>();
            }
            else if (mode == 2)
            {
                redComp = new List<Enemy>();
            }

            // find and remember UI elements for use later
            ui_confirm = GameObject.Find("Confirmation");
            ui_confirmText = GameObject.Find("ConfirmPromptText").GetComponent<Text>();
            ui_confirm.SetActive(false);

            // get a component reference to the attached BoardManager script
            boardScript = GetComponent<BoardManager>();

            // initialize the rest of the game
            InitGame();
        }