当前位置: 首页>>代码示例>>C#>>正文


C# MoveDirection类代码示例

本文整理汇总了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;
        }
开发者ID:FacepunchProgrammers,项目名称:ded,代码行数:32,代码来源:Cursor.cs

示例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]);

            }
        }
开发者ID:golergka,项目名称:genetic-ants,代码行数:25,代码来源:LookSystem.cs

示例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;
            }
        }
开发者ID:golergka,项目名称:genetic-ants,代码行数:25,代码来源:FieldObject.cs

示例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);
    }
开发者ID:pwentrys,项目名称:unity3d_inventory_gather_example,代码行数:39,代码来源:Movement.cs

示例5: Move

 private void Move(MoveDirection direction)
 {
     MoveCommand moveCommand = new MoveCommand(moveCommandReciever, direction, moveDistance, objectToMove);
     moveCommand.Execute();
     commands.Add(moveCommand);
     currentCommandNum++;
 }
开发者ID:CaminhoneiroHell,项目名称:unity-design-patterns,代码行数:7,代码来源:InputHandler.cs

示例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;
              }
        }
开发者ID:CrappySolutions,项目名称:firstgame,代码行数:26,代码来源:Projectile.cs

示例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;
        }
开发者ID:rawrohit,项目名称:hungry-birds,代码行数:30,代码来源:GamePiece.cs

示例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 );
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:27,代码来源:Player.cs

示例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;
        }
开发者ID:guylr,项目名称:Console-Battleships-CSHARP,代码行数:31,代码来源:SelectedBlocks.cs

示例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;
 }
开发者ID:CaminhoneiroHell,项目名称:unity-design-patterns,代码行数:8,代码来源:MoveCommand.cs

示例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;
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:34,代码来源:MoveDirectionToPointConverter.cs

示例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;
        }
开发者ID:CrappySolutions,项目名称:firstgame,代码行数:31,代码来源:AnimatedPlayer.cs

示例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;
        }
开发者ID:neofitov,项目名称:game-fifteen,代码行数:34,代码来源:GameFifteen.cs

示例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;
        }
开发者ID:kmorcinek,项目名称:hello_wars,代码行数:27,代码来源:LocationService.cs

示例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;
        }
开发者ID:shnogeorgiev,项目名称:XNAProject,代码行数:63,代码来源:CollisionHandler.cs


注:本文中的MoveDirection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。