本文整理汇总了C#中GameStateManager.CreateTimestamp方法的典型用法代码示例。如果您正苦于以下问题:C# GameStateManager.CreateTimestamp方法的具体用法?C# GameStateManager.CreateTimestamp怎么用?C# GameStateManager.CreateTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameStateManager
的用法示例。
在下文中一共展示了GameStateManager.CreateTimestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
//.........这里部分代码省略.........
bool waitingForServer = true;
while (waitingForServer)
{
// check for messages as long the incoming messages queue has messages stored
while ((msg = networkManager.getMessage()) != null)
{
switch (msg.MessageType)
{
case NetIncomingMessageType.Data:
string msgStr = msg.ReadString();
// check if the message is the response to the request
string[] clients = msgStr.Split(';');
if (clients[0] == "getPlayers")
{
int i = 1;
foreach (string player in clients)
{
if (player != "" && player != "getPlayers")
{
string[] values = player.Split('/');
int localUID = networkManager.getUID();
int remoteUID = Convert.ToInt32(values[0]);
switch (values[1])
{
case "1": // Player is a PacMan
// Check if it is a local or remote controlled gameobject
if (localUID == remoteUID) // local controlled
{
PlayerController playerController = new PlayerController(
Direction.None, values[0], remoteUID, PlayerIndex.One,
MovObjType.LocalPacMan, ScreenManager.Input);
NetworkController networkController =
new NetworkController(playerController.ID, playerController,
networkManager);
gameStateManager.AddPlayers(new PacMan(@"Sprites\PacMan",
gameStateManager.Level.getCell(1, 1), gameStateManager.Level, networkController, Direction.None, 1.3f, new Point(50, 50)));
}
else // remote controlled
{
EmptyController emptyController = new EmptyController(Direction.None,
values[0],
remoteUID,
MovObjType.
NetPacMan);
gameStateManager.AddPlayers(new PacMan(@"Sprites\PacMan",
gameStateManager.Level.getCell(1, 1), gameStateManager.Level,
new NetworkController(emptyController.ID, emptyController, networkManager),
Direction.None, 1.3f, new Point(50, 50)));
}
GUIString stringElement = new GUIString(gameStateManager.MovableObjects.Last(), Color.White, new Vector2(0, 0), new Vector2(10, i * 10));
guiElements.Add(stringElement);
break;
case "2": // Player is a Ghost
Blinky blinky = new Blinky(gameStateManager.GetAllOfType<PacMan>()[0],
new Point(0, 0), new Point(15, 15),
new Point(17, 17));
GhostController ghostController = new GhostController(level,
blinky,
remoteUID);
NetworkGhostController ghostNetworkController =
new NetworkGhostController(networkManager, ghostController,
ghostController.ID);
gameStateManager.AddPlayers(new Ghost(@"Sprites\GhostBase", gameStateManager.Level.getCell(26, 1), gameStateManager.Level,
Direction.Down, 0.8f, new Point(50, 50), Color.Crimson, ghostNetworkController));
// else
// {
//
//
// gameStateManager.AddPlayers(new Ghost(@"Sprites\GhostBase", gameStateManager.Level.getCell(26, 1), gameStateManager.Level,
// Direction.Down, 0.8f, new Point(50, 50), Color.Crimson, new NetworkController(Direction.None, values[0], Convert.ToInt32(values[0]),
// PlayerIndex.One, MovObjType.NetGhost, ScreenManager.Input, networkManager)));
// }
break;
}
i += 10;
}
}
// All mvable objects are initialized, start game
waitingForServer = false;
}
break;
}
}
}
gameStateManager.CreateTimestamp(0);
}
示例2: OnFinishedSimulation
private void OnFinishedSimulation(GameStateManager gameStateManager, IGameTime gameTime)
{
this.simulationState = SimulationState.Idling;
gameStateManager.CreateTimestamp(gameTime.TotalGameTime.TotalMilliseconds);
EventArgs e = new EventArgs();
if(FinishedSimulation != null)
{
FinishedSimulation(this, e);
}
}