-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericGame.cs
100 lines (84 loc) · 3.29 KB
/
GenericGame.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using Dungeon.Utilities;
using DungeonGame;
using DungeonGame.Entities;
using DungeonGame.Item;
using DungeonGame.Levels;
using DungeonGame.UI;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.Screens;
using System;
using System.Collections.Generic;
using System.Text;
namespace Dungeon
{
public abstract class GenericGame : Game
{
public static Items Items;
public int ScreenHeight { get; set; }
public int ScreenWidth { get; set; }
protected ContentManager contentManager;
protected GraphicsDeviceManager graphics;
protected SpriteBatch spriteBatch;
protected MouseHelper mouseHelper;
protected World currentWorld;
protected Camera mainCamera;
protected Gui currentScreen;
protected Entity currentPlayer;
// Getters
public Camera GetCamera() { return mainCamera; }
public World GetWorld() { return currentWorld; }
public MouseHelper GetMouseHelper() { return mouseHelper; }
public ContentManager GetContentManager() { return contentManager; }
public GraphicsDeviceManager GetGraphics() { return graphics; }
public SpriteBatch GetSpriteBatch() { return spriteBatch; }
public Gui GetCurrentScreen() { return currentScreen; }
public Entity GetPlayer() { return currentPlayer; }
public SpriteFont GetFont() { return font; }
// Setters
public void SetWorld(World world) { currentWorld = world; }
public void SetPlayer(Entity entity) { currentPlayer = entity; }
public void SetCurrentScreen(Gui screen) { currentScreen = screen; }
// Timer Variables
protected int timeSteps = 60;
protected float millisecond_interval;
protected float elapsed_delta = 0.0f;
// Rendering Variables
protected SpriteFont font;
public Settings settings;
public GenericGame()
{
this.graphics = new GraphicsDeviceManager(this);
this.Content.RootDirectory = "Content";
this.IsMouseVisible = false;
this.contentManager = this.Content;
this.millisecond_interval = 1.0f / timeSteps;
}
protected override void Initialize()
{
this.graphics.IsFullScreen = false;
this.graphics.PreferredBackBufferWidth = 1200;
this.graphics.PreferredBackBufferHeight = 800;
this.ScreenHeight = this.graphics.PreferredBackBufferHeight;
this.ScreenWidth = this.graphics.PreferredBackBufferWidth;
this.graphics.ApplyChanges();
base.Initialize();
}
protected override void LoadContent()
{
this.LoadAssets();
}
protected virtual void LoadAssets()
{
this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
this.font = this.Content.Load<SpriteFont>("Arial");
//_blur = this.Content.Load<Effect>("Blur");
Game1.Items = new Items();
//worldGenerator = new WorldGenerator(50, 50);
//this.currentWorld = worldGenerator.Generate();
this.settings = new Settings();
this.mouseHelper = new MouseHelper(this);
}
}
}