本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}