Exemple #1
0
 public FinishState()
 {
     hud               = GameWorld.GameStateManager.GetGameState("hud");
     exitMenu          = new Button("button", "buttonFont", "font", 0, "Return to menu");
     exitMenu.Position = new Vector2((GameSettings.GameWidth / 2), GameSettings.GameHeight - (exitMenu.Height * 3.0f));
     this.Add(exitMenu);
 }
Exemple #2
0
    public HUD()
    {
        playingState = GameWorld.GameStateManager.GetGameState("playing");

        //HUD
        hud = new GameObjectList(0, "HUD");
    }
Exemple #3
0
 public void SwitchTo(string name)
 {
     if (gameStates.ContainsKey(name))
     {
         CurrentGameState = gameStates[name];
     }
 }
 /// <summary>Create the level finished state.</summary>
 public LevelFinishedState()
 {
     playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
     SpriteGameObject overlay = new SpriteGameObject("Overlays/spr_welldone");
     overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
     Add(overlay);
 }
Exemple #5
0
    public void SwitchTo(string name)
    {
        if (gameStates.ContainsKey(name))
        {
            currentGameState = gameStates[name];

            if (name == "playingState")
            {
                GameEnvironment.camera.Reset();
                PlayingState PS = currentGameState as PlayingState;
                PS.setFocus();
            }
            else if (name == "gameOverState")
            {
                GameOverState PS = currentGameState as GameOverState;
                PS.setFocus();
            }
            else if (name == "levelFinishedState")
            {
                LevelFinishedState PS = currentGameState as LevelFinishedState;
                PS.setFocus();
            }
            else
            {
                GameEnvironment.camera.Reset();
            }
        }
        else
        {
            throw new KeyNotFoundException("Could not find game state: " + name);
        }
    }
 public GameOverState()
 {
     playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
     overlay = new SpriteGameObject("Overlays/spr_gameover");
     overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
     this.Add(overlay);
 }
 public void SwitchTo(string name)
 {
     if (gameStates.ContainsKey(name))
         currentGameState = gameStates[name];
     else
         throw new KeyNotFoundException("Could not find game state: " + name);
 }
Exemple #8
0
    public GameOverState()
    {
        PlayingState = GameEnvironment.GameStateManager.Get("PlayingState");
        SpriteGameObject Overlay = new SpriteGameObject("Overlays/spr_gameover");

        Overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - Overlay.Sprite.SheetCenter;
        this.Add(Overlay);
    }
        public LevelFinishedState()
        {
            playingState = GameEnvironment.GameStateManager.GetGameState(GameState.PlayingState);
            SpriteGameObject overlay = new SpriteGameObject("Sprites/spr_level_finished", 1, "you_win");

            overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
            Add(overlay);
        }
Exemple #10
0
    public LevelFinishedState()
    {
        playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
        SpriteGameObject overlay = new SpriteGameObject("Overlays/spr_welldone");

        overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
        this.Add(overlay);
    }
    /// <summary>Create the game over state.</summary>
    public GameOverState()
    {
        playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
        SpriteGameObject overlay = new SpriteGameObject("Overlays/spr_gameover");

        overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
        Add(overlay);
    }
Exemple #12
0
 /// <summary>
 /// Clears the entire gamestate list.
 /// </summary>
 public void Clear()
 {
     foreach (KeyValuePair <string, IGameLoopObject> state in gameStates)
     {
         state.Value.UnLoad();
     }
     gameStates.Clear();
     currentGameState = null;
 }
 public void SwitchTo(string name)
 {
     if (gameStates.ContainsKey(name))
     {
         currentGameState = gameStates[name];
     }
     else
     {
         throw new KeyNotFoundException("Could not find game state: " + name);
     }
 }
Exemple #14
0
 public void SwitchTo(string name)
 {
     if (gameStates.ContainsKey(name))
     {
         currentGameState = gameStates[name];
         GameEnvironment.DefaultCamera.Position = Vector2.Zero;
     }
     else
     {
         throw new KeyNotFoundException("Could not find game state: " + name);
     }
 }
Exemple #15
0
 /// <summary>
 /// Removes the gamestate with the name from the list.
 /// </summary>
 /// <param name="name">Name of the gamestate to be removed.</param>
 public void RemoveGameState(string name)
 {
     if (gameStates.ContainsKey(name))
     {
         if (currentGameState == gameStates[name])
         {
             currentID        = null;
             currentGameState = null;
         }
         gameStates.Remove(name);
     }
 }
    /// <summary>
    /// Class that defines a Pause state
    /// </summary>
    public PauseState()
    {
        // find the playing state
        playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
        overlay      = GameEnvironment.AssetManager.GetSprite("Assets/Sprites/Paused/overlay");

        // make buttons for the different assignments, eg return to menu
        continueButton          = new Button("Assets/Sprites/Paused/Continue", 99);
        continueButton.Position = new Vector2(GameEnvironment.Screen.X / 2 - continueButton.Width / 2, 250);
        quitButton          = new Button("Assets/Sprites/Paused/ReturnToMenu", 99);
        quitButton.Position = new Vector2(GameEnvironment.Screen.X / 2 - quitButton.Width / 2, 500);
    }
Exemple #17
0
    public GameOverState()
    {
        playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
        SpriteGameObject overlay = new SpriteGameObject("Overlays/spr_gameover");

        overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
        score            = new TextGameObject("Sprites/SpelFont"); //makes a new score object
        score.Position   = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y + 100) / 2;
        score.Text       = Score.ToString();
        score.Color      = Color.Black;
        Add(overlay);
        //Add(score);
    }
Exemple #18
0
 /// <summary>
 /// Switches the gamestate to the new gamestate, if the gamestate is not found no gamestate is switched.
 /// </summary>
 /// <param name="name">Name of the new gamestate.</param>
 public void SwitchTo(string name)
 {
     if (name != null && gameStates.ContainsKey(name))
     {
         UnLoad();
         currentID        = name;
         currentGameState = gameStates[name];
         Load();
     }
     else
     {
         Console.WriteLine("Could not find game state: " + name);
     }
 }
Exemple #19
0
    public GameOverState()
    {
        playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
        SpriteGameObject overlay = new SpriteGameObject("Sprites/GameOver");

        overlay.Position = new Vector2(GameEnvironment.Screen.X, GameEnvironment.Screen.Y) / 2 - overlay.Center;
        this.Add(overlay);
        quitButton          = new Button("Sprites/spr_button_quit", 100);
        quitButton.Position = new Vector2(GameEnvironment.Screen.X - quitButton.Width - 10, 10);
        this.Add(quitButton);
        retryButton          = new Button("Sprites/spr_button_retry", 100);
        retryButton.Position = new Vector2(GameEnvironment.Screen.X - quitButton.Width - 10, 70);
        this.Add(retryButton);
    }
Exemple #20
0
 public void SwitchTo(string name)
 {
     // name = "gameOverState";
     if (name != string.Empty && char.IsUpper(name[0])) //for some reason the string gained a capital letter when passed to this function so I added this to make sure it works even with capital letter
     {
         name = char.ToLower(name[0]) + name.Substring(1);
     }
     if (gameStates.ContainsKey(name))
     {
         currentGameState = gameStates[name];
     }
     else
     {
         throw new KeyNotFoundException("Could not find game state: " + name);
     }
 }
Exemple #21
0
 public override void HandleInput(InputHelper inputHelper)
 {
     base.HandleInput(inputHelper);
     if (quitButton.Pressed)
     {
         IGameLoopObject playingStatu = GameEnvironment.GameStateManager.CurrentGameState;
         playingState.Reset();
         this.Reset();
         GameEnvironment.GameStateManager.SwitchTo("levelMenu");
     }
     if (nextButton.Pressed)
     {
         GameEnvironment.GameStateManager.SwitchTo("playingState");
         playingState.Reset();
         (playingState as PlayingState).NextLevel();
     }
 }
Exemple #22
0
 public void SwitchTo(string name)
 {
     if (gameStates.ContainsKey(name))
     {
         if (currentGameState is State)
         {
             (currentGameState as State).UnLoad();
         }
         currentGameState = gameStates[name];
         if (currentGameState is State)
         {
             (currentGameState as State).Load();
         }
         Reset();
     }
     else
     {
         throw new KeyNotFoundException("Could not find game state: " + name);
     }
 }
    public void Setup()
    {
        IGameLoopObject prevGameState = GameEnvironment.GameStateManager.PreviousGameState as IGameLoopObject;

        // draw over the playingstate if it was in playingstate
        if (prevGameState == GameEnvironment.GameStateManager.GetGameState("playingState"))
        {
            prevPlaying   = true;
            drawOverState = GameEnvironment.GameStateManager.GetGameState("playingState");
        }


        //draw over cutscene if previousstate was cutscene
        if ((GameEnvironment.GameStateManager.PreviousGameState as IGameLoopObject) == GameEnvironment.GameStateManager.GetGameState("cutscene"))
        {
            prevPlaying   = false;
            drawOverState = GameEnvironment.GameStateManager.GetGameState("cutscene");
        }

        // loads the conversation
    }
Exemple #24
0
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);
        if (quitButton.Pressed)
        {
            IGameLoopObject playingState = GameEnvironment.GameStateManager.CurrentGameState;
            playingState.Reset();
            this.Reset();
            GameEnvironment.GameStateManager.SwitchTo("levelMenu");
        }
        if (retryButton.Pressed)
        {
            GameEnvironment.GameStateManager.SwitchTo("playingState");
            IGameLoopObject playingState = GameEnvironment.GameStateManager.CurrentGameState;
            playingState.Reset();
        }
        UI ui = this.Find("ui") as UI;

        if ((inputHelper.MouseLeftButtonPressed() && (Math.Sqrt((inputHelper.MousePosition.X - 750) * (inputHelper.MousePosition.X - 750) + (inputHelper.MousePosition.Y - 105) * (inputHelper.MousePosition.Y - 105)) < 100) || inputHelper.KeyPressed(Keys.T)) && !holding && ui.Money >= 20)
        {
            Tower tower = new Tower();
            towerList.Add(tower);
            holding   = true;
            ui.Money -= 20;
        }
        if (ui.spawnVirus)
        {
            if ((inputHelper.MouseLeftButtonPressed() && inputHelper.MousePosition.X > 900 && inputHelper.MousePosition.X <= 1000 && inputHelper.MousePosition.Y > 16 && inputHelper.MousePosition.Y < 190) || inputHelper.KeyPressed(Keys.F) && !holding && ui.Money >= 20)
            {
                Firewall firewall = new Firewall();
                firewallList.Add(firewall);
                holding   = true;
                ui.Money -= 20;
            }
        }
        if (inputHelper.KeyPressed(Keys.M))
        {
            ui.Money += 1000;
        }
    }
 public void AddGameState(string name, IGameLoopObject state)
 {
     gameStates[name] = state;
 }
 public GameStateManager()
 {
     gameStates = new Dictionary<string, IGameLoopObject>();
     currentGameState = null;
 }
Exemple #27
0
 public GameStateManager()
 {
     gameStates       = new Dictionary <string, IGameLoopObject>();
     currentGameState = null;
 }
 public void Update(GameTime gameTime)
 {
     playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
 }
Exemple #29
0
 public void AddGameState(string name, IGameLoopObject state)
 {
     gameStates[name] = state;
 }
 public LevelFinishedState()
 {
     overlay      = GameEnvironment.AssetManager.GetSprite("Assets/Sprites/Level_Finished/brown_overlay");
     plaque       = GameEnvironment.AssetManager.GetSprite("Assets/Sprites/Level_Finished/level_completed");
     playingState = GameEnvironment.GameStateManager.GetGameState("playingState");
 }
Exemple #31
0
 /// <summary>
 /// Switch to a state.
 /// </summary>
 /// <param name="name">The name of the state to switch to.</param>
 public void SwitchTo(string name)
 {
     activeState = states[name];
 }
Exemple #32
0
 /// <summary>
 /// Add a state.
 /// </summary>
 /// <param name="name">The name of the state.</param>
 /// <param name="state">The state IGameLoopObject.</param>
 public void AddState(string name, IGameLoopObject state)
 {
     states.Add(name, state);
 }
Exemple #33
0
    public SettingsMenuOverlay(IGameLoopObject state)
    {
        titleMenuState = state;
        this.Add(new Cursor());
        //Create button list
        settings = new GameObjectList(0, "buttons");

        //Scroll
        scroll       = new DropDown("scroll", new Vector2(600, -1000));
        scroll.Drop  = true;
        scroll.Speed = 600;
        settings.Add(scroll);

        //Menu text
        options          = new TextGameObject("buttonFont", 1);
        options.Text     = "Options";
        options.Position = scroll.Position + new Vector2(150, 50);
        settings.Add(options);

        //Music Slider
        musicSlider          = new SliderButton("sliderBack", "sliderFront", 1, "Music Volume:");
        musicSlider.Position = scroll.Position + new Vector2(150, 150);
        musicSlider.Value    = GameSettings.MusicVolume;
        settings.Add(musicSlider);

        //SoundEffect Slider
        soundEffectSlider          = new SliderButton("sliderBack", "sliderFront", 1, "Sound Volume:");
        soundEffectSlider.Position = scroll.Position + new Vector2(150, 250);
        soundEffectSlider.Value    = GameSettings.SoundVolume;
        settings.Add(soundEffectSlider);

        //VoiceOver Slider
        voiceOverSlider          = new SliderButton("sliderBack", "sliderFront", 1, "Voice Volume:");
        voiceOverSlider.Position = scroll.Position + new Vector2(150, 350);
        voiceOverSlider.Value    = GameSettings.VoiceVolume;
        settings.Add(voiceOverSlider);

        //Fullscreen CheckBox
        fullscreen          = new CheckBox("checkBox", "buttonFont", 0, "Toggle Fullscreen:");
        fullscreen.Position = scroll.Position + new Vector2(150, 450);
        fullscreen.Check    = GameSettings.Fullscreen;
        settings.Add(fullscreen);

        //VSync CheckBox
        vsync          = new CheckBox("checkBox", "buttonFont", 0, "Toggle VSync:");
        vsync.Position = scroll.Position + new Vector2(150, 570);
        vsync.Check    = GameSettings.VSync;
        settings.Add(vsync);

        //Resolution DropDown
        resolution          = new DropMenu("dropMenu", "buttonFont", 3, 0, "Resolution:");
        resolution.Position = scroll.Position + new Vector2(150, 690);

        switch (GameSettings.Resolution.X)
        {
        case 1920:
            resolution.Options[0].Text = "1900px X 1080px";
            break;

        case 1600:
            resolution.Options[0].Text = "1600px X 900px";
            break;

        case 1280:
            resolution.Options[0].Text = "1280px X 720px";
            break;

        default:
            break;
        }

        resolution.Options[1].Text = "1920px X 1080px";
        resolution.Options[2].Text = "1600px X 900px";
        resolution.Options[3].Text = "1280px X 720px";

        settings.Add(resolution);

        //Apply button
        apply          = new Button("smallButton", "font", "smallFont", 0, "Apply");
        apply.Position = scroll.Position + new Vector2(850, 750);
        settings.Add(apply);

        this.Add(settings);
    }