本文整理汇总了C#中Player.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Player.Move方法的具体用法?C# Player.Move怎么用?C# Player.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.Move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPositionTest_After_Three_Moves_ToLeft
public void GetPositionTest_After_Three_Moves_ToLeft()
{
Direction direction = Direction.Left;
Player player = new Player();
player.Move(direction);
player.Move(direction);
player.Move(direction);
int actual = player.GetPosition.Row;
int expected = 3;
Assert.AreEqual(expected, actual);
}
示例2: Update
public override void Update(Engine engine, Player player)
{
if (engine.inputManager.IsKeyDown(InputManager.KeyRight))
player.Walk(engine, Vector3.UnitX);
else if (engine.inputManager.IsKeyDown(InputManager.KeyLeft))
player.Walk(engine, -Vector3.UnitX);
else if (engine.inputManager.IsKeyDown(InputManager.KeyForward))
player.Walk(engine, Vector3.UnitY);
else if (engine.inputManager.IsKeyDown(InputManager.KeyBackward))
player.Walk(engine, -Vector3.UnitY);
else if (engine.inputManager.IsKeyDown(InputManager.KeyFall))
{
// If auto control is on, it moves to the only spot you can't get to with the arrow keys.
if (player.AutoControl)
{
// Push off of a surface.
if (player.LadderVector != Vector3.Zero)
{
// If the pushed spot can be reached by ladder grab, fall instead.
if (Cube.IsMoveLadderGrab(engine, player.GridPosition + player.LadderVector))
{
if (player.Move(engine, player.GridPosition - Vector3.UnitZ))
player.Falling();
}
// If it can't be reached by a ladder grab, then jump there.
else
{
if (player.Move(engine, player.GridPosition + player.LadderVector))
if (player.LadderVector == -Vector3.UnitZ)
player.Falling();
}
}
// If on the ground, jump!
else
{
if (player.Move(engine, player.GridPosition + Vector3.UnitZ))
player.Falling();
}
}
// Otherwise, it is just a fall/jump button.
else
if (player.Move(engine, player.GridPosition - Vector3.UnitZ))
player.Falling();
else
if (player.Move(engine, player.GridPosition + Vector3.UnitZ))
player.Falling();
}
}
示例3: landing_on_a_property
public void landing_on_a_property()
{
Utility util = new Utility();
//Create two players
Player p1 = new Player("Bill");
Player p2 = new Player("Fred", 1500);
string msg;
//test landon normally with no rent payable
msg = util.LandOn(ref p1);
Console.WriteLine(msg);
//set owner to p1
util.SetOwner(ref p1);
//move p2 so that utility rent can be calculated
p2.Move();
//p2 lands on util and should pay rent
msg = util.LandOn(ref p2);
Console.WriteLine(msg);
//check that correct rent has been paid
decimal balance = 1500 - (6 * p2.GetLastMove());
Assert.AreEqual(balance, p2.GetBalance());
}
示例4: InitAndLoadGame
public static void InitAndLoadGame()
{
GameField playersGameField = GameField.InitGameField();
GameField.DrawGameField(playersGameField._cells);
Console.SetCursorPosition(0, 0);
//Match3GameManager.DeleteAndShift(playersGameField._cells);
Player pl = new Player() { playersGameField = playersGameField };
pl.Move();
}
示例5: CheckCombatCollisions
public static void CheckCombatCollisions(Player player, Room room)
{
// check collisions of projectiles
foreach (Projectile p in room.projectileList)
{
// mob attack hits player
if (p.Alive && p.Owner != player && p.Box.CheckIntersect(player.box))
{
player.ResolveDamage(p.Damage);
p.Alive = false;
}
foreach (Mob mob in room.mobList)
{
// player attack hit mob
if (p.Alive && p.Owner == player && p.Box.CheckIntersect(mob.box))
{
mob.ResolveDamage(p.Damage);
p.Alive = false;
}
}
// projectile hit wall or other non mob entity
foreach (CollisionBox box in room.NonMobCollidables)
{
if (p.Alive && box.active && p.Box.CheckIntersect(box.box)) p.Alive = false;
}
}
// check collisions player to mob (point blank)
foreach (Mob mob in room.mobList)
{
if (mob.Alive && mob.box.CheckIntersect(player.box))
{
mob.ResolveDamage(1);
player.ResolveDamage(1);
// get vector2 of collision
Vector2 colV = (new Vector2(mob.x - player.x, mob.y - player.y));
colV.Normalize();
// push both in opposite directions of collision
int power = 15;
mob.Move(colV.x * power, colV.y * power);
player.Move(-(colV.x * power), -(colV.y * power));
}
}
CheckForDeadProjectiles(room);
CheckForDeadMobs(room);
}
示例6: paying_rent
public void paying_rent()
{
var u = new Utility();
var p = new Player("John", 1500);
//move p so that utility rent can be calculated
p.Move();
u.PayRent(ref p);
//get p last move
int i = p.GetLastMove();
//check that p has played correct rent of 6 times last move
decimal balance = 1500 - (6 * i);
Assert.AreEqual(balance, p.GetBalance());
}
示例7: Process
protected override bool Process(Player player, RealmTime time, string[] args)
{
if (player.Quest == null)
{
player.SendError("Player does not have a quest!");
return false;
}
player.Move(player.Quest.X + 0.5f, player.Quest.Y + 0.5f);
if (player.Pet != null)
player.Pet.Move(player.Quest.X + 0.5f, player.Quest.Y + 0.5f);
player.UpdateCount++;
player.Owner.BroadcastPacket(new GotoPacket
{
ObjectId = player.Id,
Position = new Position
{
X = player.Quest.X,
Y = player.Quest.Y
}
}, null);
player.SendInfo("Success!");
return true;
}
示例8: Execute
public void Execute(Player player, string[] args)
{
int x, y;
try
{
x = int.Parse(args[0]);
y = int.Parse(args[1]);
}
catch
{
player.Client.SendPacket(new TextPacket()
{
BubbleTime = 0,
Stars = -1,
Name = "",
Text = "Invalid coordinates!"
});
return;
}
player.Move(x + 0.5f, y + 0.5f);
player.SetNewbiePeriod();
player.UpdateCount++;
player.Owner.BroadcastPacket(new GotoPacket()
{
ObjectId = player.Id,
Position = new Position()
{
X = player.X,
Y = player.Y
}
}, null);
}
示例9: Main
static void Main()
{
if (File.Exists(@"..\..\input.txt"))
{
Console.SetIn(new StreamReader(@"..\..\input.txt"));
}
string[] inputDimensions = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int startX = int.Parse(inputDimensions[0]) + 1;
int startZ = int.Parse(inputDimensions[1]) + 1;
int startY = int.Parse(inputDimensions[2]) + 1;
string redMoves = Console.ReadLine();
string blueMoves = Console.ReadLine();
Player Red = new Player(startX / 2 + startZ, startY / 2 + 1, redMoves, 'R');
Player Blue = new Player(startX / 2 + 2 * startZ, startY / 2 + 1, blueMoves, 'L'); // може да има проблем с y заради допълнителните редове в полето
startX = 2 * startX + 2 * startZ; // трансформираме игралното поле в 2D
gameField = new bool[startX, startY + 2]; // допалнителна граница която ще ни казва ако сме преминали в забранена територия
for (int row = 0; row < gameField.GetLength(0); row++)
{
gameField[row, gameField.GetLength(1) - 1] = true;
gameField[row, 0] = true;
}
for (int cycle = 0; cycle < redMoves.Length; cycle++)
{
if (Red.LostGame || Blue.LostGame)
{
break;
}
Red.Move(cycle);
Blue.Move(cycle);
}
if (Red.LostGame && Blue.LostGame)
{
Console.WriteLine("DRAW");
}
else if (Red.LostGame)
{
Console.WriteLine("BLUE");
}
else if (Blue.LostGame)
{
Console.WriteLine("RED");
}
int distanceX = Math.Abs(Red.x - (startX / 2));
int distanceY = Math.Abs(Blue.y - (startY / 2));
if (distanceY > gameField.GetLength(1) / 2)
{
distanceY = gameField.GetLength(1) - distanceY;
}
Console.WriteLine(distanceX + distanceY);
}
示例10: Process
protected override bool Process(Player player, RealmTime time, string args)
{
string[] coordinates = args.Split(' ');
if (coordinates.Length != 2)
{
player.SendError("Invalid coordinates!");
return false;
}
int x, y;
if (!int.TryParse(coordinates[0], out x) ||
!int.TryParse(coordinates[1], out y))
{
player.SendError("Invalid coordinates!");
return false;
}
player.Move(x + 0.5f, y + 0.5f);
player.SetNewbiePeriod();
player.UpdateCount++;
player.Owner.BroadcastPacket(new GotoPacket()
{
ObjectId = player.Id,
Position = new Position()
{
X = player.X,
Y = player.Y
}
}, null);
return true;
}
示例11: Points_Test_With_Four_Moves_ToLeft
public void Points_Test_With_Four_Moves_ToLeft()
{
Direction directionToLeft = Direction.Left;
Direction directionToRight = Direction.Right;
Player player = new Player();
player.Move(directionToLeft);
player.Move(directionToLeft);
player.Move(directionToLeft);
player.Move(directionToRight);
int actual = player.Points;
int expected = 4;
Assert.AreEqual(expected, actual);
}
示例12: Commands
private static bool Commands(char[] playerMoves, Player player, bool playerCrashed, ref int playerCounter)
{
if (playerMoves[playerCounter] == 'R')
{
player.TurnRight();
playerCounter++;
}
else if (playerMoves[playerCounter] == 'L')
{
player.TurnLeft();
playerCounter++;
}
if (playerMoves[playerCounter] == 'M')
{
//var previousPositionX = player.X;
var previousPositionY = player.Y;
if (!playerCrashed)
player.Move();
//exited playfield
if (player.Y >= playfield.GetLength(0) || player.Y < 0)
{
player.Y = previousPositionY;
return true;
}
//spin
if (player.X >= playfield[player.Y].GetLength(0))
{
player.X = 0;
}
if (player.X < 0)
{
player.X = playfield[player.Y].GetLength(0) - 1;
}
//crash into trail
if (playfield[player.Y][player.X])
{
return true;
}
playfield[player.Y][player.X] = true;
return false;
}
return false;
}
示例13: MovePlayer
private void MovePlayer(Player player, Dice firstDice, Dice secondDice, Board board)
{
int spaces = firstDice.Roll() + secondDice.Roll();
int newPosition = player.Position + spaces;
if (newPosition >= board.Size)
{
newPosition -= board.Size;
player.AddMoney(200);
}
player.Move(newPosition);
}
示例14: ToString_Name_Pesho_Points_2
public void ToString_Name_Pesho_Points_2()
{
Direction directionToLeft = Direction.Left;
Direction directionToRight = Direction.Right;
Player player = new Player();
player.Move(directionToLeft);
player.Move(directionToRight);
player.Name = "Pesho";
string actual = player.ToString();
string expected = "Pesho -> 2";
Assert.AreEqual(expected, actual);
}
示例15: Execute
public void Execute(Player player, string[] args)
{
if (args.Length == 0 || args.Length == 1)
{
player.SendHelp("Usage: /tp <X coordinate> <Y coordinate>");
}
else
{
int x, y;
try
{
x = int.Parse(args[0]);
y = int.Parse(args[1]);
}
catch
{
player.SendError("Invalid coordinates!");
return;
}
player.Move(x + 0.5f, y + 0.5f);
player.SetNewbiePeriod();
player.UpdateCount++;
player.Owner.BroadcastPacket(new GotoPacket
{
ObjectId = player.Id,
Position = new Position
{
X = player.X,
Y = player.Y
}
}, null);
}
}