public static void Update(float deltaTime, ContentManager Content, GUIManager guiManager, EnemySpawner enemySpawner)
        {
            if (resumingGame)
            {
                resumeGameDelay += deltaTime;
                if (resumeGameDelay >= 100)
                {
                    resumeGameDelay = 0;
                    state           = GameState.Game;
                }
            }

            if (state == GameState.Game)
            {
                UpdateEntities(deltaTime);
            }

            if (GameOver)
            {
                if (!guiManager.WindowOpen(typeof(GameOverWindow)))
                {
                    guiManager.AddWindow(new GameOverWindow(Content, guiManager, enemySpawner));
                    guiManager.DisplayMessage("GAME OVER!", 0);
                }
            }
        }
Beispiel #2
0
        protected override void LoadContent()
        {
            spriteBatch   = new SpriteBatch(GraphicsDevice);
            UIspriteBatch = new SpriteBatch(GraphicsDevice);

            //Utility
            Debug.LoadContent(Content);

            //Base
            GameManager.Background      = Content.Load <Texture2D>("background");
            GameManager.StartBackground = Content.Load <Texture2D>("startBackground");
            GameManager.Ground          = new Ground(Content);
            GameManager.AddEntity(new Base(Content, GameManager.Ground.Top));
            GameManager.AddEntity(new Turret(Content, GameManager.Ground.Top, Enemy.EnemyDirection.ToLeft), false);
            GameManager.AddEntity(new Turret(Content, GameManager.Ground.Top, Enemy.EnemyDirection.ToRight), true);
            GameManager.AddEntity(new Forcefield(Content, GameManager.Ground.Top));

            //GUI
            guiManager = new GUIManager(Content);
            guiManager.AddWindow(new MainMenu(Content, guiManager));

            //Sound
            SoundManager.LoadContent(Content);
            SoundManager.PlayMusic();

            //Enemies
            EnemyFactory.LoadContent(Content);
            enemySpawner = new EnemySpawner(guiManager);

            Debug.Log("Content Loaded");

            GameManager.State = GameState.StartMenu;
        }
Beispiel #3
0
    public static GUIWindowBase Create(GameObject origin, Transform parent)
    {
        GUIWindowBase window = Instantiate(origin).GetComponent <GUIWindowBase> ();

        window.transform.SetParent(parent, false);
        GUIManager.AddWindow(window);
        return(window);
    }
 public override void Update(Game game, ContentManager Content, GUIManager guiManager, EnemySpawner spawner)
 {
     if (!guiManager.WindowOpen(typeof(InformationWindow)))
     {
         base.Update(game, Content, guiManager, spawner);
         if (ButtonPressed(0))
         {
             Disabled = true;
             GameManager.Restart(Content, guiManager, spawner);
             GameManager.State = GameState.Game;
             SoundManager.PlayMusic();
         }
         else if (ButtonPressed(1))
         {
             guiManager.AddWindow(new InformationWindow(Content, "about", guiManager));
         }
         else if (ButtonPressed(2))
         {
             game.Exit();
         }
     }
 }
        public override void Update(Game game, ContentManager Content, GUIManager guiManager, EnemySpawner spawner)
        {
            base.Update(game, Content, guiManager, spawner);

            if (ButtonPressed(0))
            {
                if (!guiManager.WindowOpen(typeof(UpgradeMenu)))
                {
                    GameManager.State = GameState.Game;
                }
                Disabled = true;
            }
            else if (ButtonPressed(1))
            {
                SoundManager.MuteSound();
            }
            else if (ButtonPressed(2))
            {
                SoundManager.MuteMusic();
            }
            else if (ButtonPressed(3))
            {
                GameManager.Restart(Content, guiManager, spawner);
                GameManager.State = GameState.Game;
                Disabled          = true;
            }
            else if (ButtonPressed(4))
            {
                GameManager.Restart(Content, guiManager, spawner);
                GameManager.State = GameState.StartMenu;
                guiManager.AddWindow(new MainMenu(Content, guiManager));
                Disabled = true;
            }
            else if (ButtonPressed(5))
            {
                game.Exit();
            }
        }
        public override void Update(Game game, ContentManager Content, GUIManager guiManager, EnemySpawner spawner)
        {
            base.Update(game, Content, guiManager, spawner);

            if (ButtonPressed(0))
            {
                GameManager.GameOver = false;
                GameManager.Restart(Content, guiManager, spawner);
                GameManager.State = GameState.Game;
                Disabled          = true;
            }
            else if (ButtonPressed(1))
            {
                GameManager.GameOver = false;
                GameManager.State    = GameState.StartMenu;
                guiManager.AddWindow(new MainMenu(Content, guiManager));
                Disabled = true;
            }
            else if (ButtonPressed(2))
            {
                game.Exit();
            }
        }
        public void Update(float totalGameTime, float deltaTime, GUIManager guiManager, ContentManager content)
        {
            spawnTime += deltaTime;

            if (enemiesSpawned == enemiesToSpawn)
            {
                waveFinished = true;
            }

            if (!waveFinished)
            {
                waveDelayTime += deltaTime;

                if (waveDelayTime >= WAVE_DELAY)
                {
                    timeSinceLastSpawn += deltaTime;
                }

                if (waveDelayTime >= WAVE_DELAY && spawnTime >= SPAWN_CYCLE)
                {
                    spawnTime = 0;
                    bool spawnedNow   = false;
                    bool forceSpawn   = false;
                    bool triedToSpawn = true;

                    if (timeSinceLastSpawn / 1000 > 1 / totalSpawnChance[wave - 1] * 2f)
                    {
                        forceSpawn = true;
                    }

                    if (timeSinceLastSpawn / 1000 < 1 / totalSpawnChance[wave - 1] * 0.5f)
                    {
                        return;
                    }

                    while (forceSpawn || triedToSpawn)
                    {
                        triedToSpawn = false;

                        if (Roll(spawnChances[0] * totalSpawnChance[wave - 1] / 6) && spawned[0] < spawnTable[0, wave - 1])
                        {
                            SpawnEnemy("crawler");
                            spawned[0]++;
                            spawnedNow = true;
                        }
                        else if (Roll(spawnChances[1] * totalSpawnChance[wave - 1] / 6) && spawned[1] < spawnTable[1, wave - 1])
                        {
                            SpawnEnemy("steelroach");
                            spawned[1]++;
                            spawnedNow = true;
                        }
                        else if (Roll(spawnChances[2] * totalSpawnChance[wave - 1] / 6) && spawned[2] < spawnTable[2, wave - 1])
                        {
                            SpawnEnemy("reptilian");
                            spawned[2]++;
                            spawnedNow = true;
                        }
                        else if (Roll(spawnChances[6] * totalSpawnChance[wave - 1] / 6) && spawned[6] < spawnTable[6, wave - 1])
                        {
                            SpawnEnemy("reptiliansaucer");
                            spawned[6]++;
                            spawnedNow = true;
                        }
                        else if (Roll(spawnChances[5] * totalSpawnChance[wave - 1] / 6) && spawned[5] < spawnTable[5, wave - 1])
                        {
                            SpawnEnemy("demolitionroverunit");
                            spawned[5]++;
                            spawnedNow = true;
                        }
                        else if (Roll(spawnChances[3] * totalSpawnChance[wave - 1] / 6) && spawned[3] < spawnTable[3, wave - 1])
                        {
                            SpawnEnemy("mwat");
                            spawned[3]++;
                            spawnedNow = true;
                        }
                        else if (Roll(spawnChances[4] * totalSpawnChance[wave - 1] / 6) && spawned[4] < spawnTable[4, wave - 1])
                        {
                            SpawnEnemy("murderbot");
                            spawned[4]++;
                            spawnedNow = true;
                        }
                        else if (Roll(spawnChances[7] * totalSpawnChance[wave - 1] / 6) && spawned[7] < spawnTable[7, wave - 1])
                        {
                            SpawnEnemy("tarantularsaucer");
                            spawned[7]++;
                            spawnedNow = true;
                        }
                        else if (wave == 30 && (enemiesToSpawn - enemiesSpawned == 1))
                        {
                            SpawnEnemy("emag");
                            spawnedNow = true;
                        }

                        if (spawnedNow)
                        {
                            //Debug.Log("Time since last spawn: " + (timeSinceLastSpawn / 1000).ToString());
                            enemiesSpawned++;
                            timeSinceLastSpawn = 0;
                            forceSpawn         = false;
                        }
                    }
                }
            }
            else if (GameManager.Enemies.Count == 0)
            {
                waveDelayTime     = 0;
                waveDelayTimeFin += deltaTime;
                if (waveDelayTimeFin >= WAVE_DELAY)
                {
                    waveDelayTimeFin = 0;
                    if (wave < 30)
                    {
                        guiManager.AddWindow(new GUI.Menus.UpgradeMenu(content, guiManager, this));
                    }
                    else
                    {
                        guiManager.AddWindow(new GUI.Menus.GameOverWindow(content, guiManager, this));
                        GameManager.GameOver = false;
                    }

                    GameManager.State = GameState.Paused;
                    SetWave(wave + 1, guiManager);
                    GameManager.projectilesShot = 0;
                    GameManager.landedHits      = 0;
                    if (((Forcefield)GameManager.Buildings["forcefield"]).Activated)
                    {
                        GameManager.Buildings["forcefield"].Alive = true;
                    }
                }
            }
        }
Beispiel #8
0
        public void ReadKeyPresses()
        {
            if (GameManager.State == GameState.Game || GameManager.State == GameState.Paused)
            {
                if (InputManager.KeyPress(Keys.Escape) && !GameManager.GameOver)
                {
                    if (guiManager.WindowOpen(typeof(GameMenu)))
                    {
                        guiManager.CloseWindow(typeof(GameMenu));
                        if (!guiManager.WindowOpen(typeof(UpgradeMenu)))
                        {
                            GameManager.State = GameState.Game;
                        }
                    }
                    else
                    {
                        guiManager.AddWindow(new GameMenu(Content, guiManager));
                        GameManager.State = GameState.Paused;
                    }
                }

                if (InputManager.KeyPress(Keys.U) && GameManager.godMode > 0)
                {
                    if (GameManager.State == GameState.Game && !GameManager.GameOver)
                    {
                        guiManager.AddWindow(new UpgradeMenu(Content, guiManager, enemySpawner));
                        GameManager.State = GameState.Paused;
                    }
                }

                if (InputManager.KeyPress(Keys.D))
                {
                    //GameManager.godMode++;
                    //if (GameManager.godMode == 4)
                    //    GameManager.godMode = 0;

                    //switch (GameManager.godMode)
                    //{
                    //    case 0:
                    //        {
                    //            Debug.Log("Normal mode");
                    //            break;
                    //        }
                    //    case 1:
                    //        {
                    //            Debug.Log("Demigod mode");
                    //            break;
                    //        }
                    //    case 2:
                    //        {
                    //            Debug.Log("God mode");
                    //            break;
                    //        }
                    //    case 3:
                    //        {
                    //            Debug.Log("Chuck Norris mode");
                    //            break;
                    //        }
                    //}
                }

                if (InputManager.KeyPress(Keys.Right) && GameManager.godMode > 0)
                {
                    enemySpawner.SetWave(enemySpawner.Wave + 1, guiManager);
                    Debug.Log("Wave set to " + enemySpawner.Wave.ToString());
                }

                if (InputManager.KeyPress(Keys.Left) && GameManager.godMode > 0)
                {
                    enemySpawner.SetWave(enemySpawner.Wave - 1, guiManager);
                    Debug.Log("Wave set to " + enemySpawner.Wave.ToString());
                }
            }

            //if (InputManager.KeyPress(Keys.C))
            //{
            //    if(GameManager.FrameLimiting)
            //    {
            //        GameManager.SetFrameLimiting(this, false);
            //    }
            //    else
            //    {
            //        GameManager.SetFrameLimiting(this, true);
            //    }
            //    Debug.Log("Frame Limiting", GameManager.FrameLimiting);
            //}

            //if (InputManager.KeyPress(Keys.F))
            //{
            //    Debug.ToggleFPS();
            //    Debug.Log("Toggled FPS");
            //}
            //if (InputManager.KeyPress(Keys.M))
            //{
            //    SoundManager.MuteMusic();
            //    Debug.Log("Toggled Mute");
            //}

            //if (InputManager.KeyPress(Keys.B))
            //{
            //    Debug.ToggleRectangles();
            //    Debug.Log("Toggled Collision Boxes");
            //}
            //if (InputManager.KeyPress(Keys.L))
            //{
            //    Debug.ToggleDebugLog();
            //    Debug.Log("Toggled Debug Log");
            //}
        }