aboutsummaryrefslogtreecommitdiff
path: root/V3/V3Game.cs
blob: ea7abbfd6f1f1b94679fb92b78abd46437deca52 (plain)
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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Ninject;
using V3.Data;
using V3.Screens;

namespace V3
{
    /// <summary>
    /// This is the main type for your game.
    /// </summary>
    public sealed class V3Game : Game
    {
        private readonly IKernel mKernel;
        private SpriteBatch mSpriteBatch;
        private IScreenManager mScreenManager;
        private IScreen mMainScreen;
        //private float mReculate = 1.0f;
        /// <summary>
        /// Creates a new V3 game instance.
        /// </summary>
        public V3Game()
        {
            mKernel = new StandardKernel(new Bindings(this, new GraphicsDeviceManager(this)));
            IsMouseVisible = true;
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Content.RootDirectory = "Content";
            mKernel.Get<IPathManager>().CreateMissingDirectories();
            mScreenManager = mKernel.Get<IScreenManager>();
            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            mSpriteBatch = new SpriteBatch(GraphicsDevice);
            mMainScreen = mKernel.Get<IScreenFactory>().CreateMainScreen();
            mScreenManager.AddScreen(mMainScreen);
            
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// It delegates the update to the screen manager.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            mScreenManager.Update(gameTime);
            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.  It delegates the
        /// drawing to the screen manager.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            mScreenManager.Draw(gameTime, mSpriteBatch);
            base.Draw(gameTime);
        }
    }
}