本文整理汇总了C#中Game.GetPlayers方法的典型用法代码示例。如果您正苦于以下问题:C# Game.GetPlayers方法的具体用法?C# Game.GetPlayers怎么用?C# Game.GetPlayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.GetPlayers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Action
public bool Action(Game game, Player player, string args)
{
string online = "";
foreach (Player p in game.GetPlayers())
{
if (online.Length > 0)
{
online += ", ";
}
online += p.Name;
}
player.Connection.SendTextMessage(TextMessageType.EventDefault, "Online: " + online);
return false;
}
示例2: CreateGame_PlayersShouldBeInRandomOrder
public void CreateGame_PlayersShouldBeInRandomOrder()
{
string[] names = new string[] {"amy", "bill"};
game = gameFactory.BuildGame(names);
string nameOfFirstRoller = null;
string nameOfLastRoundsFirstRoller = null;
bool orderHasSwapped = false;
for (int i = 0; i < 100 ^ orderHasSwapped; i++)
{
nameOfLastRoundsFirstRoller = nameOfFirstRoller;
game = gameFactory.BuildGame(names);
nameOfFirstRoller = game.GetPlayers()[0].Name;
orderHasSwapped = nameOfFirstRoller != nameOfLastRoundsFirstRoller && i > 2;
}
Assert.True(orderHasSwapped);
}
示例3: SendAddRoom
public void SendAddRoom(Game.Server.Rooms.BaseRoom room)
{
GSPacketIn pkg = new GSPacketIn((int)eFightPackageType.ROOM_CREATE);
pkg.WriteInt(room.RoomId);
pkg.WriteInt((int)room.GameType);
pkg.WriteInt(room.GuildId);
List<GamePlayer> players = room.GetPlayers();
pkg.WriteInt(players.Count);
foreach (GamePlayer p in players)
{
pkg.WriteInt(p.PlayerCharacter.ID);//改为唯一ID
pkg.WriteString(p.PlayerCharacter.NickName);
pkg.WriteBoolean(p.PlayerCharacter.Sex);
pkg.WriteInt(p.PlayerCharacter.Hide);
pkg.WriteString(p.PlayerCharacter.Style);
pkg.WriteString(p.PlayerCharacter.Colors);
pkg.WriteString(p.PlayerCharacter.Skin);
pkg.WriteInt(p.PlayerCharacter.Offer);
pkg.WriteInt(p.PlayerCharacter.GP);
pkg.WriteInt(p.PlayerCharacter.Grade);
pkg.WriteInt(p.PlayerCharacter.Repute);
pkg.WriteInt(p.PlayerCharacter.ConsortiaID);
pkg.WriteString(p.PlayerCharacter.ConsortiaName);
pkg.WriteInt(p.PlayerCharacter.ConsortiaLevel);
pkg.WriteInt(p.PlayerCharacter.ConsortiaRepute);
pkg.WriteInt(p.PlayerCharacter.Attack);
pkg.WriteInt(p.PlayerCharacter.Defence);
pkg.WriteInt(p.PlayerCharacter.Agility);
pkg.WriteInt(p.PlayerCharacter.Luck);
pkg.WriteDouble(p.GetBaseAttack());
pkg.WriteDouble(p.GetBaseDefence());
pkg.WriteDouble(p.GetBaseAgility());
pkg.WriteDouble(p.GetBaseBlood());
pkg.WriteInt(p.MainWeapon.TemplateID);
pkg.WriteBoolean(p.CanUseProp);
if (p.SecondWeapon != null)
{
pkg.WriteInt(p.SecondWeapon.TemplateID);
pkg.WriteInt(p.SecondWeapon.StrengthenLevel);
}
else
{
pkg.WriteInt(0);
pkg.WriteInt(0);
}
pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate) * AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.GPAddPlus == 0 ? 1 : p.GPAddPlus));
pkg.WriteDouble(AntiAddictionMgr.GetAntiAddictionCoefficient(p.PlayerCharacter.AntiAddiction) * (p.OfferAddPlus == 0 ? 1 : p.OfferAddPlus));
pkg.WriteDouble(RateMgr.GetRate(eRateType.Experience_Rate));
pkg.WriteInt(GameServer.Instance.Configuration.ServerID);
List<AbstractBuffer> infos = p.BufferList.GetAllBuffer();
pkg.WriteInt(infos.Count);
foreach (AbstractBuffer bufferInfo in infos)
{
BufferInfo info = bufferInfo.Info;
pkg.WriteInt(info.Type);
pkg.WriteBoolean(info.IsExist);
pkg.WriteDateTime(info.BeginDate);
pkg.WriteInt(info.ValidDate);
pkg.WriteInt(info.Value);
pkg.WriteInt(info.ValidCount);
}
pkg.WriteInt(p.EquipEffect.Count);
foreach (int i in p.EquipEffect)
{
pkg.WriteInt(i);
}
}
SendTCP(pkg);
}
示例4: ReadFieldState
private void ReadFieldState(Peer peer, NetIncomingMessage message)
{
game = new Game(MultiplayerMode.Client);
SetupField(settings.scheme);
ReadFieldState(message);
m_localPlayer = null;
List<Player> players = game.GetPlayers().list;
for (int i = 0; i < players.Count; ++i)
{
if (players[i].input == null)
{
m_localPlayer = players[i];
m_localPlayer.SetPlayerInput(InputMapping.CreatePlayerInput(InputType.Keyboard1));
m_localPlayer.input.IsActive = true; // TODO: handle console
break;
}
}
Debug.Assert(m_localPlayer != null);
m_localPlayer.connection = peer.RemoteConnection;
m_localPlayer.IsReady = true;
m_localPlayer.needsFieldState = false;
}
示例5: Play20Rounds_EveryPlayerShouldHaveTaken20Turns
public void Play20Rounds_EveryPlayerShouldHaveTaken20Turns()
{
game = gameFactory.BuildGame(5);
for (int i = 0; i < 20; i++)
{
game.DoRound();
}
foreach(IPlayer player in game.GetPlayers())
{
Assert.AreEqual(20, player.RoundsPlayed);
}
}