|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace GameExample.Reversi
{
public class GameManager
{
/// <summary>
/// The game host.
/// </summary>
private IGameHost _host;
/// <summary>
/// The default game options.
/// </summary>
private GameOptions _gameOptions = GameOptions.Default;
/// <summary>
/// The game render.
/// </summary>
private GameRender _gameRender;
/// <summary>
/// The current game.
/// </summary>
private Game _game;
public GameManager(IGameHost host)
{
if (host == null)
{
throw new ArgumentNullException("host");
}
_host = host;
// Set the screen to the main menu.
SetScreen(GameScreen.MainMenu);
}
/// <summary>
/// Sets the screen.
/// </summary>
/// <param name="screen">The screen.</param>
public void SetScreen(GameScreen screen)
{
_host.SetScreen(screen, this);
}
/// <summary>
/// Starts a new game.
/// </summary>
/// <param name="control">The control.</param>
public void StartGame(Control renderArea, Control statusArea)
{
_game = new Game(_gameOptions);
_gameRender = new GameRender(this,_gameOptions, _game, renderArea, statusArea);
}
/// <summary>
/// Quits the game.
/// </summary>
public void Quit()
{
_game = null;
_gameRender.Dispose();
_gameRender = null;
SetScreen(GameScreen.MainMenu);
}
public bool Active
{
get
{
return _game != null;
}
}
public void ResetSize()
{
_gameRender.ResetScreen();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.