本文整理汇总了C#中MoveDirection类的典型用法代码示例。如果您正苦于以下问题:C# MoveDirection类的具体用法?C# MoveDirection怎么用?C# MoveDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MoveDirection类属于命名空间,在下文中一共展示了MoveDirection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Move
public Cursor Move(Buffer buf, MoveDirection direction)
{
switch (direction)
{
case MoveDirection.Up:
if (AtFirstLine(buf))
return new Cursor(0, 0);
else
return new Cursor(Line - 1, Math.Min(Column, buf.Lines[Line - 1].Data.Length));
case MoveDirection.Down:
if (AtLastLine(buf))
return new Cursor(Line, buf.Lines[Line].Data.Length);
else
return new Cursor(Line + 1, Math.Min(Column, buf.Lines[Line + 1].Data.Length));
case MoveDirection.Left:
if (AtStart(buf))
return this;
else if (AtFirstColumn(buf))
return new Cursor(Line - 1, buf.Lines[Line - 1].Data.Length);
else
return new Cursor(Line, Column - 1);
case MoveDirection.Right:
if (AtEnd(buf))
return this;
else if (AtLastColumn(buf))
return new Cursor(Line + 1, 0);
else
return new Cursor(Line, Column + 1);
}
return this;
}
示例2: PrepareLookResult
private void PrepareLookResult(MoveDirection direction, int distance)
{
if (distance == 0) {
lookResult [direction].Clear ();
lookResult [direction].Add (lookable.Look (pov));
} else {
if (lookResult [direction].Count < distance)
PrepareLookResult (direction, distance - 1);
pointsInDirectionCache [direction] =
pov.LookInDirection (direction, distance, pointsInDirectionCache [direction]);
Point[] pointsToCount = pointsInDirectionCache [direction] [distance];
int result = 0;
foreach (Point p in pointsToCount)
result += lookable.Look (p);
lookResult [direction].Add (result + lookResult [direction] [distance - 1]);
}
}
示例3: Move
protected virtual void Move(MoveDirection direction)
{
switch (direction) {
case MoveDirection.Down:
MoveDown ();
break;
case MoveDirection.Left:
MoveLeft ();
break;
case MoveDirection.Right:
MoveRight ();
break;
case MoveDirection.Up:
MoveUp ();
break;
default:
// just chill!
break;
}
}
示例4: Move
private Vector2 _NewPosition; // So we don't have to redefine the variable each time. Player nicer with the Garbage Collect.
#endregion Fields
#region Methods
/// <summary>
/// Move Object
/// </summary>
/// <param name="Direction"></param>
private void Move(MoveDirection Direction)
{
// Assign appropriate movement base on input key.
switch (Direction)
{
case MoveDirection.Up:
_NewPosition = new Vector2(transform.position.x, transform.position.y + _MovementValue);
break;
case MoveDirection.Left:
_NewPosition = new Vector2(transform.position.x - _MovementValue, transform.position.y);
break;
case MoveDirection.Down:
_NewPosition = new Vector2(transform.position.x, transform.position.y - _MovementValue);
break;
case MoveDirection.Right:
_NewPosition = new Vector2(transform.position.x + _MovementValue, transform.position.y);
break;
default:
_NewPosition = transform.position;
break;
}
// Finally, update our position.
transform.position = Vector3.Lerp(transform.position, _NewPosition, Time.deltaTime);
}
示例5: Move
private void Move(MoveDirection direction)
{
MoveCommand moveCommand = new MoveCommand(moveCommandReciever, direction, moveDistance, objectToMove);
moveCommand.Execute();
commands.Add(moveCommand);
currentCommandNum++;
}
示例6: Fire
public void Fire(Vector2 theStartPosition, Vector2 theSpeed, Vector2 theDirection, MoveDirection playerDirection, TimeSpan gameTime)
{
_direction = playerDirection;
if (playerDirection == MoveDirection.Right)
Position = new Vector2(theStartPosition.X - 80, theStartPosition.Y);
else
Position = new Vector2(theStartPosition.X - 50, theStartPosition.Y);
StartPosition = theStartPosition;
mSpeed = theSpeed;
mDirection = theDirection;
if (Data.Effect == ProjectileEffect.Burn)
{
mSpeed.X = 0;
if (_direction == MoveDirection.Left)
{
int width = SpriteTexture.Width / Columns;
if (playerDirection == MoveDirection.Right)
Position = new Vector2(theStartPosition.X - 80, theStartPosition.Y);
else
Position = new Vector2(theStartPosition.X - 50 - width, theStartPosition.Y);
}
_burnStart = gameTime;
}
}
示例7: Move
public override void Move(MoveDirection dir)
{
Position to;
switch (dir)
{
case MoveDirection.UpLeft:
to = new Position(Pos.Row - 1, Pos.Col - 1);
break;
case MoveDirection.UpRight:
to = new Position(Pos.Row - 1, Pos.Col + 1);
break;
case MoveDirection.DownLeft:
to = new Position(Pos.Row + 1, Pos.Col - 1);
break;
case MoveDirection.DownRight:
to = new Position(Pos.Row + 1, Pos.Col + 1);
break;
default: // Should cover all cases
return;
}
if (!_board.IsValidPosition(to))
return;
Move m = new Move(Pos, to);
_board.Move(m);
Pos = to;
}
示例8: Move
public Vector2 Move( MoveDirection move ) {
switch( move ) {
case MoveDirection.Up:
this.playerPosition.Y--;
currentDirection = MoveDirection.Up;
break;
case MoveDirection.Down:
this.playerPosition.Y++;
currentDirection = MoveDirection.Down;
break;
case MoveDirection.Left:
this.playerPosition.X--;
currentDirection = MoveDirection.Left;
break;
case MoveDirection.Right:
this.playerPosition.X++;
currentDirection = MoveDirection.Right;
break;
default:
currentDirection = MoveDirection.Idle;
break;
}
center.X = playerPosition.X + 11;
center.Y = playerPosition.Y + 11;
return new Vector2( 0, 0 );
}
示例9: Move
public bool Move(MoveDirection movedirection)
{
bool moved = false;
if (!isOutsideOfSea(movedirection))
{
switch (movedirection)
{
case MoveDirection.Left:
foreach (Block b in this.blocks)
b.xPos -= 1;
break;
case MoveDirection.Right:
foreach (Block b in this.blocks)
b.xPos += 1;
break;
case MoveDirection.Up:
foreach (Block b in this.blocks)
b.yPos -= 1;
break;
case MoveDirection.Down:
foreach (Block b in this.blocks)
b.yPos += 1;
break;
default:
break;
}
}
return moved;
}
示例10: MoveCommand
//Constructor
public MoveCommand(MoveCommandReceiver reciever, MoveDirection direction, float distance, GameObject gameObjectToMove)
{
this._receiver = reciever;
this._direction = direction;
this._distance = distance;
this._gameObject = gameObjectToMove;
}
示例11: MoveDirectionConvertToPoint
public static Point MoveDirectionConvertToPoint(MoveDirection dire)
{
Point offsetPos = new Point();
switch (dire)
{
case MoveDirection.Left:
offsetPos = new Point(-1, 0);
break;
case MoveDirection.Right:
offsetPos = new Point(1, 0);
break;
case MoveDirection.Up:
offsetPos = new Point(0, -1);
break;
case MoveDirection.Down:
offsetPos = new Point(0, 1);
break;
case MoveDirection.LeftUp:
offsetPos = new Point(-1, -1);
break;
case MoveDirection.LeftDown:
offsetPos = new Point(-1, 1);
break;
case MoveDirection.RightUp:
offsetPos = new Point(1, -1);
break;
case MoveDirection.RightDown:
offsetPos = new Point(1, 1);
break;
default:
break;
}
return offsetPos;
}
示例12: CanMove
public MoveDirection CanMove(float gameWindowWidth, float gameWindowHeight, MoveDirection playerMoveDirection)
{
var _MaxX = gameWindowWidth - (Size.Width / Columns ) - 100;
var _MinX = 100;
var _MaxY = gameWindowHeight - Size.Height - 100;
var _MinY = 0;
// Check for bounce.
if (Position.X > _MaxX)
{
if (playerMoveDirection == MoveDirection.Right)
return MoveDirection.Stop;
}
else if (Position.X < _MinX)
{
if (playerMoveDirection == MoveDirection.Left)
return MoveDirection.Stop;
}
if (Position.Y > _MaxY)
{
if (playerMoveDirection == MoveDirection.Up)
return MoveDirection.Stop;
}
else if (Position.Y < _MinY)
{
if (playerMoveDirection == MoveDirection.Down)
return MoveDirection.Stop;
}
return playerMoveDirection;
}
示例13: CanMoveInDirection
private bool CanMoveInDirection(Position position, MoveDirection direction)
{
if (direction == MoveDirection.Up &&
position.Row <= 0)
{
return false;
}
if (direction == MoveDirection.Down &&
position.Row >= BOARD_SIZE - 1)
{
return false;
}
if (direction == MoveDirection.Left &&
position.Column <= 0)
{
return false;
}
if (direction == MoveDirection.Right &&
position.Column >= BOARD_SIZE - 1)
{
return false;
}
Position newPosition = CalculatePositionWithDirection(position, direction);
if (this.matrix[newPosition.Row, newPosition.Column] != " ")
{
return false;
}
return true;
}
示例14: GetNewLocation
public Point GetNewLocation(Point oldLocation, MoveDirection? direction)
{
var newLocation = new Point(oldLocation.X, oldLocation.Y);
if (direction == null)
{
return newLocation;
}
switch (direction)
{
case MoveDirection.Up:
newLocation.Y--;
break;
case MoveDirection.Down:
newLocation.Y++;
break;
case MoveDirection.Right:
newLocation.X++;
break;
case MoveDirection.Left:
newLocation.X--;
break;
}
return newLocation;
}
示例15: ObjectCollisionDetector
/// <summary>
/// All logic about collision and physics is kept here.
/// </summary>
public static bool ObjectCollisionDetector(IMoveable moveableObject, MoveDirection moveDirection, out GameObject collisionObj)
{
Vector2 currentPosition = moveableObject.Position;
float x = currentPosition.X;
float y = currentPosition.Y;
switch (moveDirection)
{
case MoveDirection.Up:
y -= moveableObject.Speed;
break;
case MoveDirection.Down:
y += moveableObject.Speed;
break;
case MoveDirection.Left:
x -= moveableObject.Speed;
break;
case MoveDirection.Right:
x += moveableObject.Speed;
break;
}
Rectangle futureBounds = new Rectangle((int)x, (int)y, moveableObject.Bounds.Width, moveableObject.Bounds.Height);
foreach (GameObject gameObject in ObjectFactory.AllObjects.Where(obj => !(obj is Player)))
{
if (futureBounds.Intersects(gameObject.Bounds))
{
if (moveableObject is Player)
{
collisionObj = gameObject;
Console.WriteLine("collision detected!");
return true;
}
if (moveableObject is NPC)
{
if (gameObject is NPC)
{
collisionObj = gameObject;
return false;
}
else if (gameObject is Player)
{
collisionObj = gameObject;
return true;
}
}
}
}
if (futureBounds.X <= 0 ||
!(futureBounds.X + futureBounds.Width <= Constants.WINDOW_DEFAULT_WIDTH) ||
futureBounds.Y <= 0 ||
futureBounds.Y + futureBounds.Height >= Constants.WINDOW_DEFAULT_HEIGHT)
{
collisionObj = ObjectFactory.PLAYER;
Console.WriteLine("Collision detected at ({0},{1})", futureBounds.X, futureBounds.Y);
return true;
}
collisionObj = null;
return false;
}