本文整理汇总了C#中IGame.createPlayer方法的典型用法代码示例。如果您正苦于以下问题:C# IGame.createPlayer方法的具体用法?C# IGame.createPlayer怎么用?C# IGame.createPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGame
的用法示例。
在下文中一共展示了IGame.createPlayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: connectToGame
/// <summary>
/// Connect to game method - configures the endpoint details then activates the remote object
/// Enables and disables tools depending on if the user is spectating or not
/// Paints the arena gray
/// </summary>
public void connectToGame()
{
try
{
// Configure the Endpoint details
DuplexChannelFactory<IGame> channel = new DuplexChannelFactory<IGame>(this, "Game");
// Activate a remote game object
gameInstance = channel.CreateChannel();
if(callbackId == 0)
callbackId = gameInstance.CallbackRegister();
if (!spectating)
{
_player = gameInstance.createPlayer(txtName.Text);
if (_player == 0)
{
gameInstance.Spectator++;
spectating = true;
txtName.Text = "";
txtName.IsEnabled = true;
cmdConnect.IsEnabled = false;
cmdSpectate.IsEnabled = false;
lblColorText.Visibility = Visibility.Hidden;
lblColor.Visibility = Visibility.Hidden;
}
else
this.KeyDown += new KeyEventHandler(buttonDown);
lblColorText.Visibility = Visibility.Visible;
lblColor.Visibility = Visibility.Visible;
colorCode++;
}
else
{
gameInstance.Spectator++;
lblColorText.Visibility = Visibility.Hidden;
lblColor.Visibility = Visibility.Hidden;
}
gameBoard.Background = new SolidColorBrush(Colors.Gray);
}
catch (Exception ex)
{
MessageBox.Show("Error communicating with server: " + ex.Message);
}
}