本文整理汇总了C#中Directions类的典型用法代码示例。如果您正苦于以下问题:C# Directions类的具体用法?C# Directions怎么用?C# Directions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Directions类属于命名空间,在下文中一共展示了Directions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AxisEdge
internal AxisEdge(VisibilityVertex source, VisibilityVertex target)
: base(source, target){
RightBound = double.PositiveInfinity;
LeftBound = double.NegativeInfinity;
Direction = CompassVector.DirectionsFromPointToPoint(source.Point, target.Point);
Debug.Assert(Direction == Directions.East || Direction == Directions.North);
}
示例2: GetSurroundingPosition
public Position GetSurroundingPosition(Position start, Directions direction)
{
Position position;
switch (direction)
{
case Directions.North:
position = new Position(start.X, start.Y - 1);
break;
case Directions.South:
position = new Position(start.X, start.Y + 1);
break;
case Directions.West:
position = new Position(start.X - 1, start.Y);
break;
case Directions.East:
position = new Position(start.X + 1, start.Y);
break;
case Directions.NorthEast:
position = new Position(start.X + 1, start.Y - 1);
break;
case Directions.NorthWest:
position = new Position(start.X - 1, start.Y - 1);
break;
case Directions.SouthWest:
position = new Position(start.X - 1, start.Y + 1);
break;
default:
position = new Position(start.X + 1, start.Y + 1);
break;
}
return position;
}
示例3: AdjacentSquare
/// <summary>
/// Returns the square at the specified side of the specified square. If there is no square at that side (for example, if side isUpRight and the square is at the top of the board) then returns null.
/// </summary>
/// <param name="square"></param>
/// <param name="side"></param>
/// <returns></returns>
private static Square AdjacentSquare(Square[,] board, Square square, Directions side)
{
switch (side) {
case Directions.UpRight:
//If there is a square to the up right and square is not on the right or top sides of the board. If not then returns null.
if (square.Left < 7 && square.Top > 0)
return board[square.Left + 1, square.Top - 1];
break;
case Directions.UpLeft:
//If there is a square to the up left of square and square is not on the left side or the top side.
if (square.Left > 0 && square.Top > 0)
return board[square.Left - 1, square.Top - 1];
break;
case Directions.DownRight:
//If there is a square to the down right of square and square is not on the right or bottom sides of the board.
if (square.Left < 7 && square.Top < 7)
return board[square.Left + 1, square.Top + 1];
break;
case Directions.DownLeft:
//If there is a square to the down left of square and square is not on the left or bottom sides of the board.
if (square.Left > 0 && square.Top < 7)
return board[square.Left - 1, square.Top + 1];
break;
//If there is no such square because square is on the wrong side of the board and the appropriate condition was false (otherwise, the function would no longer be running) then return null.
}
return null;
}
示例4: SetDirection
public void SetDirection(Directions dir)
{
int index = (int)dir;
for (int i = 0; i < 4; i++) {
directions [i].material = (i == index) ? selected : normal;
}
}
示例5: PrintDirections
private static void PrintDirections(Directions directions, string origin, string destination)
{
Console.WriteLine("Directions: {0} to {1}", origin, destination);
Console.WriteLine(directions.copyrights);
for (var r = 0; r < directions.Routes.Count(); r++)
{
var route = directions.Routes.ElementAt(r);
Console.WriteLine();
Console.WriteLine("Route {0}: {1} [Distiance={2}, Duration={3}]",
r + 1, route.summary, route.distance, route.duration);
for (var l = 0; l < route.Legs.Count(); l++)
{
var leg = route.Legs.ElementAt(l);
Console.WriteLine("");
Console.WriteLine("Leg #{0}", l + 1);
for (var s = 0; s < leg.Steps.Count(); s++)
{
var step = leg.Steps.ElementAt(s);
Console.WriteLine("[{0} - {1} - {2}]: {3}",
step.travel_mode, step.duration.text,
step.distance.text,
step.html_instructions);
}
}
}
}
示例6: OnCollisionEnter2D
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.CompareTag("world")){
direction = Directions.NONE;
animator.Play("cdman_stand");
}
if (col.gameObject.CompareTag ("point")) {
audioPoint.Play();
Destroy(col.gameObject);
Score+=100;
}
if (col.gameObject.CompareTag ("point_super")) {
audioPoint.Play();
Destroy(col.gameObject);
Score+=500;
}
if (col.gameObject.CompareTag ("enemy")) {
respounter.On=false;
Instantiate(dieAnimation, transform.position,Quaternion.Euler(0,0,0));
Destroy(gameObject);
//удаляем всех врагов
foreach(GameObject enemy in GameObject.FindGameObjectsWithTag("enemy"))
{
Destroy(enemy);
}
}
}
示例7: Movement
void Movement ()
{
//getaxisraw has binary left right as opposed to the more analogue getaxis
Vector2 movementVector = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
if (movementVector != Vector2.zero)
{
anim.SetBool("isWalking", true);
anim.SetFloat("inputX", movementVector.x);
anim.SetFloat("inputY", movementVector.y);
if (movementVector.x == 1)
direction = Directions.East;
else if (movementVector.x == -1)
direction = Directions.West;
else if (movementVector.y == 1)
direction = Directions.North;
else if (movementVector.y == -1)
direction = Directions.South;
}
else
{
anim.SetBool("isWalking", false);
}
rBody.MovePosition(rBody.position + movementVector * Time.deltaTime);
}
示例8: Update
public void Update(Directions direction, int position)
{
// Sets Direction so the gap created when turning can be filled
Direction = direction;
if (direction == Directions.Up)
{
Border.Width = 20;
int y = Border.Y;
Border.Height += y - position;
Border.Y = position;
}
if (direction == Directions.Down)
{
Border.Width = 20;
Border.Height = position - Border.Y;
}
// Records the value of x before updating then sets the new
// width by adding the distance between x and the new position
// of x. Finally sets the new value of x.
if (direction == Directions.Left)
{
int x = Border.X;
Border.Width += x - position;
Border.X = position;
}
// Expands the width by subtracting the position of the left
// side of the bar from the new position giving it its width
if (direction == Directions.Right)
Border.Width = position - Border.X;
}
示例9: ScriptEntityMove
public ScriptEntityMove(Entity entity, Directions direction, int distance)
{
this.direction = direction;
this.distance = distance;
this.entity = entity;
this.entity.OnMoveFinished += new Entity.EventHandler(moveFinished);
}
示例10: SetDirection
public void SetDirection(Directions direction)
{
float x = 0f;
float y = 0f;
switch (direction)
{
case Directions.Up:
y = 1f;
break;
case Directions.Down:
y = -1f;
break;
case Directions.Left:
x = -1f;
break;
case Directions.Right:
x = 1f;
break;
}
if (anim != null)
{
anim.SetFloat("InputX", x);
anim.SetFloat("InputY", y);
}
}
示例11: CheckCollision
public override bool CheckCollision(GameObject two, out Directions direction, out Vector2 diffVector)
{
direction = Directions.Up; //Default direction value
diffVector = Vector2.Zero; //Default vector value
//Get the center point circle
Vector2 center = new Vector2(this.Position.X + this.Radius, this.Position.Y + this.Radius);
//Calculate AABB info (center, half-extents)
Vector2 aabbHalf = new Vector2(two.Size.X / 2, two.Size.Y / 2);
Vector2 aabbCenter = two.Position + aabbHalf;
//Get difference vector between both centers
Vector2 diff = center - aabbCenter;
Vector2 clamped = new Vector2(clamp(diff.X, -aabbHalf.X, aabbHalf.X), clamp(diff.Y, -aabbHalf.Y, aabbHalf.Y));
//Add clamped value to AABB Center and get the value of point closest to cirlce
Vector2 closest = aabbCenter + clamped;
diff = closest - center;
if (diff.Length <= this.Radius)
{
direction = VectorDirection(diff);
diffVector = diff;
return true;
}
return false;
}
示例12: Move
public void Move(Directions direction)
{
switch (direction)
{
case Directions.Up:
if (!DetectSelfCollision(0, -1))
{
Move(XMultiplier(direction), YMultiplier(direction));
}
break;
case Directions.Down:
if (!DetectSelfCollision(0, 1))
{
Move(XMultiplier(direction), YMultiplier(direction));
}
break;
case Directions.Right:
if (!DetectSelfCollision(1, 0))
{
Move(XMultiplier(direction), YMultiplier(direction));
}
break;
case Directions.Left:
if (!DetectSelfCollision(-1, 0))
{
Move(XMultiplier(direction), YMultiplier(direction));
}
break;
default:
break;
}
}
示例13: command
public void command(CharacterCommands command, params object[] args)
{
switch(command)
{
case CharacterCommands.SetEntityQuery:
eq = (IEntityQuery)args[0];
return;
case CharacterCommands.Face:
System.Console.WriteLine("face");
state = 0;
d = (Directions)args[0];
return;
case CharacterCommands.Walk:
System.Console.WriteLine("walk");
state = 1;
if(d == (Directions)args[0]) step = step==0?1:0;
else step = 0;
d = (Directions)args[0];
counter = 0;
break;
case CharacterCommands.Stop:
System.Console.WriteLine("stop");
state = 0;
return;
case CharacterCommands.Step:
System.Console.WriteLine("step");
state = 2;
if(d == (Directions)args[0]) step = (step+1)&1;
else step = 0;
d = (Directions)args[0];
counter = 0;
return;
}
}
示例14: setFacingDirection
//This only works assuming the cultist starts facing left before calling this function.
//Contains hack-y code )=
public void setFacingDirection(Directions.Direction dir)
{
switch(dir)
{
case Directions.Direction.UP:
transform.rotation = normalRotation;
transform.Rotate(new Vector3(0, 0, 90));
canvas.transform.Rotate(new Vector3(0, 0, 90)); //To rotate it back to where it should be...
transform.localScale = new Vector3(-1 * normalScale.x, normalScale.y, normalScale.z);
canvas.transform.localScale = new Vector3(-1 * canvas.transform.localScale.x, canvas.transform.localScale.y, canvas.transform.localScale.z); //To flip it back to how it should be...
break;
case Directions.Direction.DOWN:
transform.rotation = normalRotation;
transform.Rotate(new Vector3(0, 0, 90));
canvas.transform.Rotate(new Vector3(0, 0, -90)); //To rotate it back to where it should be...
transform.localScale = normalScale;
break;
case Directions.Direction.LEFT:
transform.rotation = normalRotation;
transform.localScale = normalScale;
break;
case Directions.Direction.RIGHT:
transform.rotation = normalRotation;
transform.localScale = new Vector3(-1 * normalScale.x, normalScale.y, normalScale.z);
canvas.transform.localScale = new Vector3(-1 * canvas.transform.localScale.x, canvas.transform.localScale.y, canvas.transform.localScale.z); //To flip it back to how it should be...
break;
default:
break;
}
}
示例15: CanTankMove
public bool CanTankMove(Tank tank, List<Tank> enemies, Directions direction)
{
NewPosition newTankPosition = new NewPosition(tank, direction);
bool collides = false;
if (newTankPosition.Row >= 2 && newTankPosition.Row < Data.GetWindowHeight() - 4 &&
newTankPosition.Column >= 0 && newTankPosition.Column < Data.GetWindowWidth() - 3)
{
collides = true;
}
for (int elemRow = 0; elemRow < mapElements.GetLength(0); elemRow++)
{
for (int elemCol = 0; elemCol < mapElements.GetLength(1); elemCol++)
{
if (mapElements[elemRow, elemCol] != null)
{
if (DoesItCollideTank(mapElements[elemRow, elemCol], tank, newTankPosition.Row, newTankPosition.Column))
{
collides = false;
}
}
}
}
if (collides)
{
collides = TankIsOnAtherTank(tank, enemies, newTankPosition);
}
return collides;
}