private void SetSpawners()
    {
        _spawner1Prefab = GameObject.Find("GhostSpawnerFinal1");
        _spawner2Prefab = GameObject.Find("GhostSpawnerFinal2");
        _spawner3Prefab = GameObject.Find("GhostSpawnerFinal3");
        _spawner4Prefab = GameObject.Find("GhostSpawnerFinal4");

        _spawner1 = _spawner1Prefab.GetComponent <GhostSpawner>();
        _spawner2 = _spawner2Prefab.GetComponent <GhostSpawner>();
        _spawner3 = _spawner3Prefab.GetComponent <GhostSpawner>();
        _spawner4 = _spawner4Prefab.GetComponent <GhostSpawner>();
    }
    // Start is called before the first frame update
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        InitSpawn();
    }
Exemple #3
0
    void Update()
    {
        if (timeRemaining > 0)
        {
            timeRemaining   -= Time.deltaTime;
            timer.text       = Mathf.Round(timeRemaining).ToString();
            score.text       = scoreValue.ToString();
            level.text       = levelValue.ToString();
            enemiesLeft.text = enemiesRemaining.ToString();

            if (Time.time > nextWarning && timeRemaining <= 5)
            {
                nextWarning = Time.time + warningRate;
                timeWarningAudio.Play(0);
            }

            if (enemiesRemaining == 0)
            {
                ClearEnemies();

                levelValue++;
                levelUpAudio.Play(0);

                enemiesRemaining = 5;
                timeRemaining    = 60;

                Ghost.speed *= 1.05f;

                GhostSpawner.resetTimer();
                WitchSpawner.resetTimer();

                if (levelValue == 100)
                {
                    levelValue = 1;
                    Ghost.resetSpeed();
                }
            }
        }
        else
        {
            if (!gameOver)
            {
                gameOverAudio.Play(0);
                pumpkin.SetActive(true);
            }

            gameOver             = true;
            gameOverText.enabled = true;
            ClearEnemies();
        }
    }
Exemple #4
0
        public void StartGame()
        {
            gameState = GameState.Playing;

            SM = new ShotManager(this);
            this.Components.Add(SM);

            input = new InputHandler(this);
            this.Components.Add(input);

            spawner = new GhostSpawner(this);
            this.Components.Add(spawner);

            PS = new PlayerShoot(this);
            this.Components.Add(PS);

            score = new ScoreManager(this);
            this.Components.Add(score);
        }
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            backgound           = new ScrollingBackgound.ScrollingBackground(this);
            backgound.DrawOrder = 0;
            this.Components.Add(backgound);

            spawner = new Spawner.GhostSpawner(this);
            this.Components.Add(spawner);

            pac           = new PacMan(this);
            pac.DrawOrder = 1;
            this.Components.Add(pac);

            timer           = new Timer.Timer(this);
            timer.DrawOrder = 2;
            this.Components.Add(timer);
        }