Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.Media;
- using Microsoft.Xna.Framework.Audio;
- namespace GameTemplate
- {
- public enum GameState
- {
- MainMenu,
- Game,
- GameOver,
- Credits,
- Options,
- }
- public class GameManager
- {
- public Camera2d Tehcamera;
- public GameState CurrentState;
- public SpriteBatch spriteBatch;
- public List<GameObject> MainMenuGO;
- public LevelManager TheLevelManager;
- public List<GameObject> GameGO;
- public List<GameObject> GameOverGO;
- Song Gm;
- public GameManager(SpriteBatch TheSpriteBatch, ContentManager Content)
- {
- CurrentState = GameState.MainMenu;
- spriteBatch = TheSpriteBatch;
- MainMenuGO = new List<GameObject>();
- GameObject MenuBack = new GameObject(Vector2.Zero, Content.Load<Texture2D>("mainMenu"));
- MainMenuGO.Add(MenuBack);
- TheLevelManager = new LevelManager(Content);
- GameGO = new List<GameObject>();
- Gm = Content.Load<Song>("SuperHero_original");
- GameOverGO = new List<GameObject>();
- }
- public void SewtCamera(Camera2d cam)
- {
- Tehcamera = cam;
- if (TheLevelManager != null)
- {
- TheLevelManager.SewtCamera(cam);
- }
- }
- public void Update(float DT)
- {
- if (CurrentState == GameState.MainMenu)
- {
- MediaPlayer.Play(Gm);
- if (Keyboard.GetState().IsKeyDown(Keys.Enter))
- {
- CurrentState = GameState.Game;
- }
- for (int i = 0; i < MainMenuGO.Count; ++i)
- {
- MainMenuGO[i].Update(DT);
- }
- }
- else if(CurrentState == GameState.Game)
- {
- TheLevelManager.Update(DT);
- for (int i = 0; i < GameGO.Count; ++i)
- {
- GameGO[i].Update(DT);
- }
- }
- else if (CurrentState == GameState.GameOver)
- {
- for (int i = 0; i < GameOverGO.Count; ++i)
- {
- GameOverGO[i].Update(DT);
- }
- }
- else if(CurrentState == GameState.Credits)
- {
- }
- else if (CurrentState == GameState.Options)
- {
- }
- }
- public void Draw(SpriteBatch spriteBatch)
- {
- if (CurrentState == GameState.MainMenu)
- {
- for (int i = 0; i < MainMenuGO.Count; ++i)
- {
- MainMenuGO[i].Draw(spriteBatch);
- }
- }
- else if (CurrentState == GameState.Game)
- {
- TheLevelManager.Draw(spriteBatch);
- for (int i = 0; i < GameGO.Count; ++i)
- {
- GameGO[i].Draw(spriteBatch);
- }
- }
- else if (CurrentState == GameState.GameOver)
- {
- for (int i = 0; i < GameOverGO.Count; ++i)
- {
- GameOverGO[i].Draw(spriteBatch);
- }
- }
- else if (CurrentState == GameState.Credits)
- {
- }
- else if (CurrentState == GameState.Options)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement