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


C# IMap.IsWalkable方法代码示例

本文整理汇总了C#中IMap.IsWalkable方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.IsWalkable方法的具体用法?C# IMap.IsWalkable怎么用?C# IMap.IsWalkable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMap的用法示例。


在下文中一共展示了IMap.IsWalkable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleInput

        public bool HandleInput(InputState inputState, IMap map) {
            var potential_new_x = X;
            var potential_new_y = Y;
            bool trying_to_move = false;

            if (inputState.IsLeft(PlayerIndex.One)) {
                potential_new_x = X - speed;
                trying_to_move = true;
            } else if (inputState.IsRight(PlayerIndex.One)) {
                potential_new_x = X + speed;
                trying_to_move = true;
            } else if (inputState.IsUp(PlayerIndex.One)) {
                potential_new_y = Y - speed;
                trying_to_move = true;
            } else if (inputState.IsDown(PlayerIndex.One)) {
                potential_new_y = Y + speed;
                trying_to_move = true;
            }


            if (trying_to_move) {
                if (map.IsWalkable(potential_new_x, potential_new_y)) {
                    var enemy = Global.CombatManager.EnemyAt(potential_new_x, potential_new_y);
                    if (enemy == null) {
                        X = potential_new_x;
                        Y = potential_new_y;
                    } else {
                        Global.CombatManager.Attack(this, enemy);
                    }

                    return true;
                }
            }
            return false;
        }
开发者ID:tyrelsouza,项目名称:roguesharp_learnin,代码行数:35,代码来源:Player.cs

示例2: HandleInput

		public bool HandleInput(InputState inputState, IMap map)
		{
			if (inputState.IsLeft(PlayerIndex.One))
			{
				int tempX = X - 1;
				if (map.IsWalkable(tempX, Y))
				{
					X = tempX;
					return true;
				}
			}
			else if (inputState.IsRight(PlayerIndex.One))
			{
				int tempX = X + 1;
				if (map.IsWalkable(tempX, Y))
				{
					X = tempX;
					return true;
				}
			}
			else if (inputState.IsUp(PlayerIndex.One))
			{
				int tempY = Y - 1;
				if (map.IsWalkable(X, tempY))
				{
					Y = tempY;
					return true;
				}
			}
			else if (inputState.IsDown(PlayerIndex.One))
			{
				int tempY = Y + 1;
				if (map.IsWalkable(X, tempY))
				{
					Y = tempY;
					return true;
				}
			}
			return false;
		}
开发者ID:rhockett94,项目名称:RogueTest,代码行数:40,代码来源:Player.cs

示例3: HandleInput

 public bool HandleInput(InputState inputState, IMap map)
 {
     if (inputState.IsLeft(PlayerIndex.One))
     {
         int tempX = X - 1;
         if (map.IsWalkable(tempX, Y))
         {
             // Check to see if there is an enemy at the location
             // that the player is attempting to move into
             var enemy = Global.CombatManager.EnemyAt(tempX, Y);
             if (enemy == null)
             {
                 // When there is not an enemy, move as normal
                 X = tempX;
             }
             else
             {
                 // When there is an enemy in the cell, make an
                 // attack against them by using the CombatManager
                 Global.CombatManager.Attack(this, enemy);
             }
             return true;
         }
     }
     else if (inputState.IsRight(PlayerIndex.One))
     {
         int tempX = X + 1;
         if (map.IsWalkable(tempX, Y))
         {
             // Check to see if there is an enemy at the location
             // that the player is attempting to move into
             var enemy = Global.CombatManager.EnemyAt(tempX, Y);
             if (enemy == null)
             {
                 // When there is not an enemy, move as normal
                 X = tempX;
             }
             else
             {
                 // When there is an enemy in the cell, make an
                 // attack against them by using the CombatManager
                 Global.CombatManager.Attack(this, enemy);
             }
             return true;
         }
     }
     else if (inputState.IsUp(PlayerIndex.One))
     {
         int tempY = Y - 1;
         if (map.IsWalkable(X, tempY))
         {
             // Check to see if there is an enemy at the location
             // that the player is attempting to move into
             var enemy = Global.CombatManager.EnemyAt(X, tempY);
             if (enemy == null)
             {
                 // When there is not an enemy, move as normal
                 Y = tempY;
             }
             else
             {
                 // When there is an enemy in the cell, make an
                 // attack against them by using the CombatManager
                 Global.CombatManager.Attack(this, enemy);
             }
             return true;
         }
     }
     else if (inputState.IsDown(PlayerIndex.One))
     {
         int tempY = Y + 1;
         if (map.IsWalkable(X, tempY))
         {
             // Check to see if there is an enemy at the location
             // that the player is attempting to move into
             var enemy = Global.CombatManager.EnemyAt(X, tempY);
             if (enemy == null)
             {
                 // When there is not an enemy, move as normal
                 Y = tempY;
             }
             else
             {
                 // When there is an enemy in the cell, make an
                 // attack against them by using the CombatManager
                 Global.CombatManager.Attack(this, enemy);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:Gloomshroud,项目名称:FateAscension,代码行数:92,代码来源:Player.cs

示例4: HandleInput

 internal bool HandleInput( InputState inputState, IMap map )
 {
     if ( inputState.IsLeft( PlayerIndex.One ) )
      {
     int tempX = X - 1;
     if ( map.IsWalkable( tempX, Y ) )
     {
        var enemy = Global.CombatManager.EnemyAt( tempX, Y );
        if ( enemy == null )
        {
           X = tempX;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      else if ( inputState.IsRight( PlayerIndex.One ) )
      {
     int tempX = X + 1;
     if ( map.IsWalkable( tempX, Y ) )
     {
        var enemy = Global.CombatManager.EnemyAt( tempX, Y );
        if ( enemy == null )
        {
           X = tempX;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      else if ( inputState.IsUp( PlayerIndex.One ) )
      {
     int tempY = Y - 1;
     if ( map.IsWalkable( X, tempY ) )
     {
        var enemy = Global.CombatManager.EnemyAt( X, tempY );
        if ( enemy == null )
        {
           Y = tempY;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      else if ( inputState.IsDown( PlayerIndex.One ) )
      {
     int tempY = Y + 1;
     if ( map.IsWalkable( X, tempY ) )
     {
        var enemy = Global.CombatManager.EnemyAt( X, tempY );
        if ( enemy == null )
        {
           Y = tempY;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      return false;
 }
开发者ID:SourceStep,项目名称:FirstRoguelike,代码行数:72,代码来源:Player.cs


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