• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MoveDirection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MoveDirection的典型用法代码示例。如果您正苦于以下问题:C# MoveDirection类的具体用法?C# MoveDirection怎么用?C# MoveDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MoveDirection类属于命名空间,在下文中一共展示了MoveDirection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Shoot

 public override Projectile[] Shoot( MoveDirection direction, Microsoft.Xna.Framework.Vector2 startPos )
 {
     if ( fireRate-- > 0 )
         return new Projectile[0];
     fireRate = FireRate;
     return new[] { new Bullet( startPos, direction ) };
 }
开发者ID:Gilnaa,项目名称:NotMario,代码行数:7,代码来源:Pistol.cs


示例17: Jump

    public void Jump(MoveDirection inputDirection)
    {
        if (isOnGround)
        {
          Vector2 force;

          if (inputDirection == MoveDirection.Right)
          {
        force.x = Vector2.right.x * jumpForce.x;
          }
          else if (inputDirection == MoveDirection.Left)
          {
        force.x = Vector2.left.x * jumpForce.x;
          }
          else
          {
        force.x = 0;
          }

          force.y = jumpForce.y;

          m_Body.AddForce(force);

          m_AnimationController.SetFloat("JumpDirection", force.x);

          m_AnimationController.SetTrigger("Jump");
        }
    }
开发者ID:juanwinsor,项目名称:FightingGame,代码行数:28,代码来源:CharController.cs


示例18: MoveAccountElement

 /// <summary>
 /// アカウントの並び順を変更します。
 /// </summary>
 /// <param name="elem">対象アカウント</param>
 /// <param name="dir">移動先</param>
 public static void MoveAccountElement(string id, MoveDirection dir)
 {
     var elem = GetAccountElement(id);
     if(elem==null)return;
     var idx = accountModels.IndexOf(elem);
     if (idx < 0) return;
     switch (dir)
     {
         case MoveDirection.Up:
             if (idx > 0)
             {
                 accountModels.RemoveAt(idx);
                 accountModels.Insert(idx - 1, elem);
             }
             break;
         case MoveDirection.Down:
             if (idx < accountModels.Count - 1)
             {
                 accountModels.RemoveAt(idx);
                 accountModels.Insert(idx + 1, elem);
             }
             break;
         default:
             throw new ArgumentException("移動方向指定がちゃんちゃらおかしい :" + dir.ToString());
     }
     AccountsChanged();
 }
开发者ID:karno,项目名称:Lycanthrope,代码行数:32,代码来源:AccountModel.cs


示例19: RequestMove

  public void RequestMove(MoveDirection direction)
  {
    //-- get the tile in the direction
    TileScript nextTile = levelManager.GetTile(direction, m_CurrentTile.myLaneNumber, m_CurrentTile.myElevation);
    //if( nextTile.myTileType != TileType.Blocker )
    if (nextTile != null)
    {
      if (direction == MoveDirection.MoveUp)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Up);
        levelManager.MoveTiles(MoveDirection.MoveUp, playerMoveTime);
      }
      if (direction == MoveDirection.MoveDown)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Down);
        levelManager.MoveTiles(MoveDirection.MoveDown, playerMoveTime);
      }
      if (direction == MoveDirection.MoveLeft)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Left);
      }
      if (direction == MoveDirection.MoveRight)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Right);
      }

      //-- let the player controller know we are preparing to switch ik targets
      m_PlayerController.SetNextIKSet(nextTile.ikTarget);

      //-- cache the current tile
      m_CurrentTile = nextTile;

    }
  }
开发者ID:juanwinsor,项目名称:BackPacker,代码行数:34,代码来源:GameplayManager.cs


示例20: Move

 public void Move(MoveDirection direction)
 {
     if(this.OnMoveReceived != null)
     {
         this.OnMoveReceived(direction, new MoveEventArgs());
     }
 }
开发者ID:gvallejo,项目名称:2048,代码行数:7,代码来源:GameInput.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MoveType类代码示例发布时间:2022-05-24
下一篇:
C# MoveDelegate类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap