本文整理汇总了C#中IGame.Setup方法的典型用法代码示例。如果您正苦于以下问题:C# IGame.Setup方法的具体用法?C# IGame.Setup怎么用?C# IGame.Setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGame
的用法示例。
在下文中一共展示了IGame.Setup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(IGame game)
{
if (_game != null)
throw new InvalidOperationException("A game is already running.");
if (_device == null)
throw new InvalidOperationException("Setup must be called before Run.");
Current = this;
Show();
_game = game;
try
{
var sw = Stopwatch.StartNew();
_game.Setup(_device, this);
while (_game != null)
{
Application.DoEvents();
if (!IsDeviceLost())
{
var deltaTime = sw.Elapsed;
sw.Restart();
if (game.Process(_device, deltaTime))
game.Paint(_device);
else
{
Close();
break;
}
}
}
}
catch
{
Close();
throw;
}
game.ShutDown(_device);
Current = null;
}
示例2: Setup
public void Setup(IHost host, IGame game)
{
IsDebugEnabled = true;
_host = host;
_game = game;
_host.SetGameCore(this);
_game.Setup();
// Create assets
var drawables = _game.Entities.Cast<Entity>().Where(e => e.IsDrawable).OrderBy(d => d.ZIndex).Cast<IDrawable>().ToList();
drawables.ForEach(d =>
{
_host.GraphicsProvider.RegisterImageResource(d.ResourceUrl, d.ResourceUrl);
_host.GraphicsProvider.LoadImageResource(d.ResourceUrl);
});
}