本文整理汇总了C#中PlayerManager.GetAllPlayers方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerManager.GetAllPlayers方法的具体用法?C# PlayerManager.GetAllPlayers怎么用?C# PlayerManager.GetAllPlayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerManager
的用法示例。
在下文中一共展示了PlayerManager.GetAllPlayers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getNextCommand
// return next server command based on the current game data (Evaluation function)
public string getNextCommand(GridManager gridManager, PlayerManager playerManager, ItemManager itemManager)
{
this.grid = gridManager.GetGrid();
Point playerLocation = new Point(playerManager.OwnPlayer.X, playerManager.OwnPlayer.Y);
Cell playerCurrentCell = gridManager.GetGrid()[playerLocation.X, playerLocation.Y];
// Fire when enemy tank is in line of sight
if (!Global.IsPeaceful && playerManager.OwnPlayer.CurrentHealth > Global.CriticalHealth)
{
foreach (Player player in playerManager.GetAllPlayers())
{
if (player is PlayerAllied)
continue;
Point enemyTarget = new Point(player.X, player.Y);
if (player.CurrentHealth > 0 && isCellInRegion(playerLocation, enemyTarget, Global.LineOfSight))
{
if (playerManager.OwnPlayer.PlayerDirection == Direction.North && enemyTarget.Y < playerLocation.Y && enemyTarget.X == playerLocation.X)
return "SHOOT#";
else if (playerManager.OwnPlayer.PlayerDirection == Direction.East && enemyTarget.X > playerLocation.X && enemyTarget.Y == playerLocation.Y)
return "SHOOT#";
else if (playerManager.OwnPlayer.PlayerDirection == Direction.South && enemyTarget.Y > playerLocation.Y && enemyTarget.X == playerLocation.X)
return "SHOOT#";
else if (playerManager.OwnPlayer.PlayerDirection == Direction.West && enemyTarget.X < playerLocation.X && enemyTarget.Y == playerLocation.Y)
return "SHOOT#";
else
continue;
}
}
// find for low health target
if (Global.EnableKillSteal)
{
foreach (Player player in playerManager.GetAllPlayers())
{
if (player is PlayerAllied)
continue;
Point enemyTarget = new Point(player.X, player.Y);
if (player.CurrentHealth > 0 && player.CurrentHealth <= Global.KillStealHealth && isCellInRegion(playerLocation, enemyTarget, Global.KillStealRange))
{
List<Cell> optimumPath = findPath(playerCurrentCell, gridManager.GetGrid()[enemyTarget.X, enemyTarget.Y]);
Point nextneighborCellLocation = new Point(optimumPath[optimumPath.Count - 1].X, optimumPath[optimumPath.Count - 1].Y);
return getMovementMessage(playerLocation, nextneighborCellLocation);
}
}
}
}
// find and take coin piles and life packs when possible
if (itemManager.GetCoinPiles().Count > 0 || itemManager.GetLifePacks().Count > 0)
{
for (int region = 0; region < Global.ScanRange; region++)
{
if (playerManager.OwnPlayer.CurrentHealth > Global.CriticalHealth)
{
for (int i = 0; i < itemManager.GetCoinPiles().Count; i++)
{
Point tmpCoinLocation = new Point(itemManager.GetCoinPiles()[i].X, itemManager.GetCoinPiles()[i].Y);
if (isCellInRegion(playerLocation, tmpCoinLocation, region))
{
List<Cell> optimumPath = findPath(playerCurrentCell, gridManager.GetGrid()[tmpCoinLocation.X, tmpCoinLocation.Y]);
Point nextneighborCellLocation = new Point(optimumPath[optimumPath.Count - 1].X, optimumPath[optimumPath.Count - 1].Y);
return getMovementMessage(playerLocation, nextneighborCellLocation);
}
}
}
if (isTopPlace(playerManager) || playerManager.OwnPlayer.CurrentHealth < Global.MaxHealthTarget || itemManager.GetCoinPiles().Count == 0)
{
for (int i = 0; i < itemManager.GetLifePacks().Count; i++)
{
Point tmpLifeLocation = new Point(itemManager.GetLifePacks()[i].X, itemManager.GetLifePacks()[i].Y);
if (isCellInRegion(playerLocation, tmpLifeLocation, region))
{
List<Cell> optimumPath = findPath(playerCurrentCell, gridManager.GetGrid()[tmpLifeLocation.X, tmpLifeLocation.Y]);
Point nextneighborCellLocation = new Point(optimumPath[optimumPath.Count - 1].X, optimumPath[optimumPath.Count - 1].Y);
return getMovementMessage(playerLocation, nextneighborCellLocation);
}
}
}
}
}
else
{
// search for enemy target and follow
for (int region = 0; region < Global.ScanRange; region++)
{
for (int i = 0; i < playerManager.GetAllPlayers().Length; i++)
{
if (playerManager.GetAllPlayers()[i] is PlayerAllied || playerManager.GetAllPlayers()[i].CurrentHealth <= 0)
continue;
Point tmpEnemyLocation = new Point(playerManager.GetAllPlayers()[i].X, playerManager.GetAllPlayers()[i].Y);
if (isCellInRegion(playerLocation, tmpEnemyLocation, region))
{
List<Cell> optimumPath = findPath(playerCurrentCell, gridManager.GetGrid()[tmpEnemyLocation.X, tmpEnemyLocation.Y]);
Point nextneighborCellLocation = new Point(optimumPath[optimumPath.Count - 1].X, optimumPath[optimumPath.Count - 1].Y);
//.........这里部分代码省略.........
示例2: isTopPlace
// check if the own player is in 1st place
private bool isTopPlace(PlayerManager playerManager)
{
foreach (Player player in playerManager.GetAllPlayers())
{
if (playerManager.OwnPlayer.CurrentPoints < player.CurrentPoints)
return false;
}
return true;
}