Exemple #1
0
        private List <Vector3> gridPositions = new List <Vector3> ();           //A list of possible locations to place enemies.

        void Awake()
        {
            //Check if there is already an instance of KrampsSpawn
            if (instance == null)
            {
                //if not, set it to this.
                instance = this;
            }
            //If instance already exists:
            else if (instance != this)
            {
                //Destroy this, this enforces our singleton pattern so there can only be one instance of KrampsSpawn.
                Destroy(gameObject);
            }

            //Set KrampsSpawn to DontDestroyOnLoad so that it won't be destroyed when reloading our scene.
            DontDestroyOnLoad(gameObject);
        }
Exemple #2
0
        //This is called each time a scene is loaded.
        void OnLevelWasLoaded(int index)
        {
            if (end == true || gameOver == true)
            {
                enabled = false;
                return;
            }
            //Add one to our level number.
            level++;

            if (level == 5 || level == 9 || level == 12)
            {
                levelStartDelay = 15f;
            }
            else
            {
                levelStartDelay = 2f;
            }

            if (level > 0 && level < 5)
            {
                if (SoundManager.instance.musicSource.clip == levelOne)
                {
                }
                else
                {
                    SoundManager.instance.musicSource.clip = levelOne;
                    SoundManager.instance.musicSource.Play();
                }
            }
            else if (level > 3 && level < 8)
            {
                if (SoundManager.instance.musicSource.clip == levelFive)
                {
                }
                else
                {
                    SoundManager.instance.musicSource.clip = levelFive;
                    SoundManager.instance.musicSource.Play();
                }
            }
            else if (level > 8 && level < 13)
            {
                if (SoundManager.instance.musicSource.clip == levelEight)
                {
                }
                else
                {
                    SoundManager.instance.musicSource.clip = levelEight;
                    SoundManager.instance.musicSource.Play();
                }
            }


            //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>();

            krampusScript = GetComponent <KrampsSpawn>();

            //playerScript = GetComponent<Player>();

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

            ResetExit();
        }