mirror of
https://github.com/Memorix101/UnityXNA/
synced 2024-12-30 15:25:35 +01:00
132 lines
2.9 KiB
C#
132 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Microsoft.Xna.Framework.Content;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
namespace Microsoft.Xna.Framework
|
|
{
|
|
public class Game : IDisposable
|
|
{
|
|
private GameComponentCollection _components;
|
|
Content.ContentManager content;
|
|
GraphicsDevice graphicsDevice;
|
|
DrawQueue drawQueue;
|
|
long totalTicks = 0;
|
|
|
|
public DrawQueue DrawQueue {
|
|
get {
|
|
return this.drawQueue;
|
|
}
|
|
set {
|
|
drawQueue = value;
|
|
}
|
|
}
|
|
public ContentManager Content
|
|
{
|
|
get { return this.content; }
|
|
set { this.content = value; }
|
|
}
|
|
|
|
public GraphicsDevice GraphicsDevice
|
|
{
|
|
get
|
|
{
|
|
if(graphicsDevice == null)
|
|
graphicsDevice = new GraphicsDevice(DrawQueue);
|
|
|
|
return graphicsDevice;
|
|
}
|
|
}
|
|
|
|
public Game()
|
|
{
|
|
content = new ContentManager(null, "");
|
|
|
|
_components = new GameComponentCollection();
|
|
}
|
|
|
|
protected virtual void Initialize()
|
|
{
|
|
}
|
|
|
|
protected virtual void Update(GameTime gameTime)
|
|
{
|
|
}
|
|
|
|
protected virtual void UnloadContent()
|
|
{
|
|
}
|
|
|
|
public GameComponentCollection Components
|
|
{
|
|
get
|
|
{
|
|
return this._components;
|
|
}
|
|
}
|
|
|
|
protected virtual void Draw(GameTime gameTime)
|
|
{
|
|
}
|
|
protected virtual void LoadContent()
|
|
{
|
|
}
|
|
protected virtual void Exit()
|
|
{
|
|
}
|
|
|
|
public GameWindow Window
|
|
{
|
|
get
|
|
{
|
|
// TODO
|
|
return new UnityGameWindow();
|
|
}
|
|
}
|
|
|
|
public GameServiceContainer Services
|
|
{
|
|
get
|
|
{
|
|
// TODO
|
|
return null;
|
|
}
|
|
}
|
|
|
|
internal void Run()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
protected virtual void Dispose(bool disposing)
|
|
{
|
|
}
|
|
public void Dispose()
|
|
{
|
|
UnloadContent();
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
internal void Begin()
|
|
{
|
|
Initialize();
|
|
LoadContent();
|
|
// XNA's first update call has a zero elapsed time, so do one now.
|
|
GameTime gameTime = new GameTime(new TimeSpan(0), new TimeSpan(0), new TimeSpan(0, 0, 0, 0, 0), new TimeSpan(0, 0, 0, 0, 0));
|
|
Update(gameTime);
|
|
}
|
|
|
|
internal void Tick(float deltaTime)
|
|
{
|
|
long microseconds = (int)(deltaTime * 1000000);
|
|
long ticks = microseconds * 10;
|
|
totalTicks += ticks;
|
|
GameTime gameTime = new GameTime(new TimeSpan(0), new TimeSpan(0), new TimeSpan(totalTicks), new TimeSpan(ticks));
|
|
Update(gameTime);
|
|
Draw(gameTime);
|
|
}
|
|
}
|
|
}
|