本文整理汇总了C#中Direction.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Direction.Equals方法的具体用法?C# Direction.Equals怎么用?C# Direction.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Direction
的用法示例。
在下文中一共展示了Direction.Equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Robot
/// <summary>
/// Instantiates a Robot object
/// </summary>
/// <param name="img">Image</param>
/// <param name="imgOr">Cardinal direction</param>
public Robot(Image img, Direction imgOr = Direction.North)
{
RoboImg = img;
RoboImg.RotateFlip(RotateFlipType.Rotate180FlipNone);
FaceDirection = imgOr;
if (FaceDirection.Equals(Direction.East)) {
RoboImg.RotateFlip(RotateFlipType.Rotate270FlipNone);
}
if (FaceDirection.Equals(Direction.South)) {
RoboImg.RotateFlip(RotateFlipType.Rotate180FlipNone);
}
if (FaceDirection.Equals(Direction.West)) {
RoboImg.RotateFlip(RotateFlipType.Rotate90FlipNone);
}
}
示例2: GetRandomInterval
/// <summary>
/// Return a pair of random integers, where the first is always lower than
/// the second, and there is not more than maxDistance between the returned integers.
/// Keeping this interval close is because the main usecase is a musical interval test
/// where a large distance would not help with aural training.
/// It helps if the Random passed in has been used in previous calls, to help entropy.
/// Unison is not supported, as it is too easy to spot, unless there is a large time gap between the 2 notes.
///
/// Note that Random.Next returns an integer that is LESS than the upper limit argument,
/// whereas the returned integer is > OR EQUAL TO the lower limit argument.
/// https://msdn.microsoft.com/en-us/library/2dx6wyd4(v=vs.110).aspx
///
/// </summary>
public static List<int> GetRandomInterval(int lowerLimit, int upperLimit, int maxDistance,
Random rand, Direction directionRequested = 0) {
var direction = directionRequested.Equals(Direction.Random) ? GetRandomDirection() : (int)directionRequested;
if (rand == null) {
throw new ArgumentNullException(nameof(rand));
}
// This is effectively asking for unison. todo - decide what to do. If it was explicitly requested, then
// probably the caller knew what they wanted
if (lowerLimit.Equals(upperLimit)) {
return SortArrayBasedOnDirection(new List<int> { lowerLimit, upperLimit }, (Direction)direction);
}
const int maxIterations = 100;
var lowerAndUpperLimit = new List<int> { rand.Next(lowerLimit, upperLimit) };
var nextNote = rand.Next(lowerLimit, upperLimit);
var count = 0;
while (Math.Abs(lowerAndUpperLimit[0] - nextNote) > maxDistance || lowerAndUpperLimit[0].Equals(nextNote)) {
if (count++ > maxIterations) {
throw new Exception("Too many iterations");
}
nextNote = rand.Next(lowerLimit, upperLimit + 1);
}
lowerAndUpperLimit.Add(nextNote);
return SortArrayBasedOnDirection(lowerAndUpperLimit, (Direction)direction);
}
示例3: locationAt
public XYLocation locationAt(Direction direction)
{
if (direction.Equals(Direction.North))
{
return north();
}
if (direction.Equals(Direction.South))
{
return south();
}
if (direction.Equals(Direction.East))
{
return east();
}
if (direction.Equals(Direction.West))
{
return west();
}
else
{
throw new ApplicationException("Unknown direction " + direction);
}
}
示例4: shoot
public void shoot(Direction direction)
{
if (cooldown > 0f) return;
cooldown = 1f / fireRate;
anim.SetTrigger("Shoot");
shipSounds.PlayGunshot ();
Vector2 playerDirection = rigidbody2D.velocity;
float curveDapening = (maxSpeed * 3);
Vector3 playerDirectionx = new Vector3 (playerDirection.x, 0, 0) / curveDapening;
Vector3 playerDirectiony = new Vector3 (0, playerDirection.y, 0) / curveDapening;
Vector3 shot2 = new Vector3(0, 0.04f, 0);
Vector3 shot3 = new Vector3(0, -0.04f, 0);
Vector3 bulletDirection = Vector3.down + playerDirectionx;
if (direction.Equals (Direction.LEFT))
{
bulletDirection = Vector3.left + playerDirectiony;
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection, true, damage);
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + shot2, true, damage);
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + shot3, true, damage);
if(has5Shot)
{
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + 2*shot2, true, damage);
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + 2*shot3, true, damage);
}
if(facingRight)
Flip();
}
else if (direction.Equals (Direction.RIGHT))
{
bulletDirection = Vector3.right + playerDirectiony;
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection, true, damage);
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + shot2, true, damage);
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + shot3, true, damage);
if(has5Shot)
{
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + 2*shot2, true, damage);
bulletManager.spawnBullet (getBulletSpawnPoint().position, bulletDirection + 2*shot3, true, damage);
}
if(!facingRight)
Flip();
}
spawnGunshotPaticleEffect ();
}
示例5: getEntryLocationFrom
private Vector2 getEntryLocationFrom(Direction d, Vector2 Pos)
{
if (d.Equals(Direction.North))
return new Vector2(Pos.X, RoomSize.Top + 30);
else if (d.Equals(Direction.East))
return new Vector2(RoomSize.Right - 30, Pos.Y);
else if (d.Equals(Direction.South))
return new Vector2(Pos.X, RoomSize.Bottom - 30);
else if (d.Equals(Direction.West))
return new Vector2(RoomSize.Left + 30, Pos.Y);
else
return new Vector2(RoomSize.Center.X, RoomSize.Center.Y);
}
示例6: onMoveCursor
public override void onMoveCursor(Direction dir)
{
if (this.entries.Count == 0)
return;
int oldCursor = this.cursor;
if (dir.Equals(Direction.North))
{
if (this.rowFirst)
{
this.cursor -= this.cols;
if (this.cursor < 0) this.cursor += this.rows * this.cols;
while (this.cursor >= this.entries.Count) this.cursor -= this.cols;
}
else
{
this.cursor -= 1;
if ((this.cursor + 1) % this.rows == 0) this.cursor += this.rows;
while (this.cursor >= this.entries.Count) this.cursor -= 1;
}
}
if (dir.Equals(Direction.East))
{
if (this.rowFirst)
{
this.cursor += 1;
if (this.cursor >= this.entries.Count) this.cursor = (this.rows - 1) * this.cols;
//else if (this.cursor % this.cols == 0) this.cursor -= this.cols;
}
else
{
this.cursor += this.rows;
if (this.cursor >= this.rows * this.cols) this.cursor %= (this.rows * this.cols);
else if (this.cursor >= this.entries.Count) this.cursor %= this.rows;
}
}
if (dir.Equals(Direction.South))
{
if (this.rowFirst)
{
this.cursor += this.cols;
if (this.cursor >= this.rows * this.cols) this.cursor %= (this.rows * this.cols);
else if (this.cursor >= this.entries.Count) this.cursor %= this.cols;
}
else
{
this.cursor += 1;
if (this.cursor >= this.entries.Count) this.cursor = (this.cols - 1) * this.rows;
else if (this.cursor % this.rows == 0) this.cursor -= this.rows;
}
}
if (dir.Equals(Direction.West))
{
if (this.rowFirst)
{
this.cursor -= 1;
if (this.cursor < 0) this.cursor += this.cols;
//if ((this.cursor + 1) % this.cols == 0) this.cursor += this.cols;
//while (this.cursor >= this.entries.Count) this.cursor -= 1;
}
else
{
this.cursor -= this.rows;
if (this.cursor < 0) this.cursor += this.rows * this.cols;
while (this.cursor >= this.entries.Count) this.cursor -= this.rows;
}
}
if (this.isScrolling())
{
if (this.cursor >= (this.scrollTopRow + this.scrollRowsOnPanel) * this.cols
|| this.cursor < this.scrollTopRow * this.cols)
{
int oldScrollCurrentRow = this.scrollTopRow;
int newScrollCurrentRow = this.cursor / this.cols;
if (newScrollCurrentRow > oldScrollCurrentRow)
{
if (newScrollCurrentRow - (this.scrollRowsOnPanel - 1) >= 0)
this.scrollTopRow = newScrollCurrentRow - (this.scrollRowsOnPanel - 1);
else
this.scrollTopRow = 0;
}
else
this.scrollTopRow = newScrollCurrentRow;
this.scrollBar.adjustY(this.scrollTopRow, this.rows);
foreach (MenuEntry entry in this.entries)
{
entry.setY(entry.getY() - (this.scrollTopRow - oldScrollCurrentRow) * scrollOffsetBetweenEntries);
}
}
}
if (this.cursor != oldCursor)
{
this.entries[oldCursor].onUnhover();
this.entries[this.cursor].onHover();
}
}
示例7: MoveHero
public bool MoveHero(Direction direction)
{
if(gameState.Equals("defeat"))
{
Console.WriteLine("You cannot move your hero. He is dead!");
return false;
}
if(direction.Equals(Direction.Down))
{
if(!MoveDown())
{
return false;
}
}
else if(direction.Equals(Direction.Up))
{
if(!MoveUp())
{
return false;
}
}
else if(direction.Equals(Direction.Left))
{
if(!MoveLeft())
{
return false;
}
}
else
{
if(!MoveRight())
{
return false;
}
}
if(gameState.Equals("defeat"))
{
map[heroListPosition][heroArrPosition] = 'L';
return false;
}
hero.TakeMana();
return true;
}
示例8: setDirection
/// <summary>
/// Sets the direction of this Character and updates which row on the
/// spritesheet to animate
/// </summary>
/// <param name="dir">Direction of this Character</param>
public void setDirection(Direction dir)
{
if (dir.Equals(Direction.Undefined)) return;
//we should have a standard convention for spritesheets
//i.e. each row is a direction
if (this.getImageRows() >= 4)
{
switch (dir)
{
case Direction.NorthEast:
case Direction.NorthWest:
case Direction.North: this.setFrameRow(3);
this.direction = Direction.North; break;
case Direction.SouthEast:
case Direction.SouthWest:
case Direction.South: this.setFrameRow(0);
this.direction = Direction.South; break;
case Direction.East: this.setFrameRow(2);
this.direction = Direction.East; break;
case Direction.West: this.setFrameRow(1);
this.direction = Direction.West; break;
default: break;
}
}
}