本文整理汇总了C#中Facing.ToVector2方法的典型用法代码示例。如果您正苦于以下问题:C# Facing.ToVector2方法的具体用法?C# Facing.ToVector2怎么用?C# Facing.ToVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facing
的用法示例。
在下文中一共展示了Facing.ToVector2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanMove
public bool CanMove(Facing dir, int amount) {
int tileX = (int) this.Position.X / 16;
int tileY = (int) this.Position.Y / 16;
Vector2 directionalVector = dir.ToVector2();
tileX += (int) directionalVector.X * amount;
tileY += (int) directionalVector.Y * amount;
//GameConsole.WriteLine("CanMove at xt: {0}, yt: {0}", tileX, tileY);
return this.CanMove(tileX, tileY);
}
示例2: MoveDirection
public IEnumerator MoveDirection(Facing direction, float dist)
{
return MoveDirection(direction.ToVector2(), dist);
}
示例3: ForceMove
public virtual void ForceMove(Facing dir, MovementSpeed speed) {
if (MovementState == MovementState.None) {
this.Initialize();
BeginMoving.SafeInvoke(this, EventArgs.Empty);
if (this.Facing != dir) FacingChanged.SafeInvoke(this, new FacingChangedArgs(this.Facing, dir));
this.Facing = dir;
switch (dir) {
case Facing.Up:
if (speed == MovementSpeed.Walking)
Animator.Play("walking-up");
else if (speed == MovementSpeed.Running)
Animator.Play("running-up");
break;
case Facing.Down:
if (speed == MovementSpeed.Walking)
Animator.Play("walking-down");
else if (speed == MovementSpeed.Running)
Animator.Play("running-down");
break;
case Facing.Left:
if (speed == MovementSpeed.Walking)
Animator.Play("walking-left");
else if (speed == MovementSpeed.Running)
Animator.Play("running-left");
break;
case Facing.Right:
if (speed == MovementSpeed.Walking)
Animator.Play("walking-right");
else if (speed == MovementSpeed.Running)
Animator.Play("running-right");
break;
}
this.movement = -(dir.ToVector2() * new Vector2(16, 16));
this.MovementSpeed = speed;
this.MovementState = MovementState.Walking;
this.Position -= this.movement;
}
}