using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace DataDrivenExample
{
///
/// This is the main type for your game
///
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch mSpriteBatch;
World mWorld;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
DebugText.initialize(this);
Components.Add(DebugText.GetInstance());
Content.RootDirectory = "Content";
mWorld = new World(Content);
Scripting.GetInstance().initialize(mWorld);
graphics.PreferredBackBufferHeight = Constants.GetInstance().ScreenHeight;
graphics.PreferredBackBufferWidth = Constants.GetInstance().ScreenWidth;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
mWorld.LoadWorld("Content/world.xml");
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
mSpriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
Scripting.GetInstance().Update(gameTime);
mWorld.Update(gameTime);
base.Update(gameTime);
}
///
/// This is called when the game should draw itself.
///
/// Provides a snapshot of timing values.
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
mSpriteBatch.Begin();
mWorld.Draw(mSpriteBatch);
mSpriteBatch.End();
base.Draw(gameTime);
}
}
}