Inheritance: UnityEngine.MonoBehaviour
コード例 #1
0
		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
ファイル: GameMan.cs プロジェクト: karriereat/hackathon-2018
    private int level = 5;                              //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 <Completed.BoardManager>();

        //Call the InitGame function to initialize the first level
        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
 // Use this for initialization
 void Start()
 {
     resources = gameObject.GetComponent<ResourcesManager> ();
     board = gameObject.GetComponent<BoardManager> ();
 }
コード例 #5
0
ファイル: GameManager.cs プロジェクト: GeorgeJCleary/CMSC425
        //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
ファイル: GameManager.cs プロジェクト: DesViv/AIGAME
        /*
         *	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();
        }
コード例 #7
0
        // Use this for initialization
        void Start()
        {
            knownFacts = new List<string> ();
            unknownFacts = new List<string> (possibleFacts);

            boardManager = GameObject.Find ("GameManager").GetComponent<BoardManager> ();
            notifManager = GameObject.Find ("Notifications").GetComponent<NotificationsManager> ();

            statsRT = statsCanvas.GetComponent<RectTransform> ();

            int randomFirstIdx = Random.Range (0, firstNames.Length);
            int randomLastIdx = Random.Range (0, lastNames.Length);

            monsterName = firstNames [randomFirstIdx] + lastNames [randomLastIdx];

            appetite = Random.Range (appetiteMinMax.x, appetiteMinMax.y);

            InvokeRepeating ("Tick", 0f, 5f);
        }