本文整理汇总了C#中Map.getWidth方法的典型用法代码示例。如果您正苦于以下问题:C# Map.getWidth方法的具体用法?C# Map.getWidth怎么用?C# Map.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.getWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Move
/// <summary>
/// Poruszanie - ustalenie aktualnego kierunku ruchu
/// </summary>
/// <param name="map">Mapa obiektów</param>
public void Move(Map.Map map)
{
List<Game.direction> available_dir = new List<Game.direction>();
if (x > 1 && map.getObject(x - 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
available_dir.Add(Game.direction.left);
if (x < map.getWidth() - 1 && map.getObject(x + 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
available_dir.Add(Game.direction.right);
if (y > 1 && map.getObject(x, y - 1).GetType() == typeof(NonDestroyableObjects.Puste))
available_dir.Add(Game.direction.up);
if (x < map.getHeight() - 1 && map.getObject(x, y + 1).GetType() == typeof(NonDestroyableObjects.Puste))
available_dir.Add(Game.direction.down);
if (available_dir.Capacity > 0)
{
int rand_dir = rand.Next(0, available_dir.Capacity - 1);
current_direction = (Game.direction)(rand_dir);
}
else current_direction = Game.direction.none;
}
示例2: isPointAccesible
/// <summary>
/// Sprawdzenie czy punkt jest dostepny ze wzgledu na poruszanie w danym kierunku
/// </summary>
/// <param name="map">Mapa obiektów</param>
/// <param name="dir">Kierunek ruchu</param>
/// <returns>Czy jest możliwość ruchu w danym kierunku</returns>
private bool isPointAccesible(Map.Map map, int dir)
{
switch ((Game.direction)dir)
{
case Game.direction.down:
if (y + 1 < map.getHeight() - 1)
{
if (map.getObject(x, y + 1).GetType() == typeof(NonDestroyableObjects.Puste))
return true;
} break;
case Game.direction.left:
if (x > 0)
{
if (map.getObject(x - 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
return true;
}
break;
case Game.direction.right:
if (x + 1 < map.getWidth() - 1)
{
if (map.getObject(x + 1, y).GetType() == typeof(NonDestroyableObjects.Puste))
return true;
}
break;
case Game.direction.up:
if (y > 0)
{
if (map.getObject(x, y - 1).GetType() == typeof(NonDestroyableObjects.Puste))
return true;
} break;
}
return false;
}
示例3: isVandalInSight
/* public Point Move(Map.Map map)
{
Point is_in_sight = isVandalInSight(map);
if (is_in_sight.X == 0 && is_in_sight.Y == 0)
{//nie ma w zasiegu wzroku Vandala - moze poruszac sie losowo, bardzo wolno
updateFrequency = 800;
List<Point> available_points = new List<Point>();
Map.MapObject collision_obj;
collision_obj = map.getObject(this.x+1,this.y);
if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
available_points.Add(new Point(1, 0));
collision_obj = map.getObject(this.x - 1, this.y);
if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
available_points.Add(new Point( - 1, 0));
collision_obj = map.getObject(this.x , this.y+1);
if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
available_points.Add(new Point(0 , 1));
collision_obj = map.getObject(this.x, this.y-1);
if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
available_points.Add(new Point(0, -1));
if (available_points.Capacity != 0)
{
return available_points[rand.Next(0, available_points.Capacity - 1)];
}
}
else
{
//goni - porusza sie szybciej
updateFrequency = 800;
return(new Point(0,0));
}
return is_in_sight;
}*/
public void Move(Map.Map map)
{
List<Game.direction> available_dir = new List<Game.direction>();
if (x > 1 && (map.getObject(x - 1, y).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x - 1, y).GetType() == typeof(DestroyableObjects.Ziemia)))
available_dir.Add(Game.direction.left);
if (x < map.getWidth() - 1 && (map.getObject(x + 1, y).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x + 1, y).TypeTag ==AIHelper.ElementType.ZIEMIA))
available_dir.Add(Game.direction.right);
if (y > 1 &&( map.getObject(x, y - 1).GetType() == typeof(NonDestroyableObjects.Puste)|| map.getObject(x, y - 1).GetType() == typeof(DestroyableObjects.Ziemia)))
available_dir.Add(Game.direction.up);
if (x < map.getHeight() - 1 &&( map.getObject(x, y + 1).GetType() == typeof(NonDestroyableObjects.Puste)||map.getObject(x, y + 1).GetType()== typeof(DestroyableObjects.Ziemia)))
available_dir.Add(Game.direction.down);
if (available_dir.Capacity > 0)
{
int rand_dir = rand.Next(0, available_dir.Capacity - 1);
current_direction = (Game.direction)(rand_dir);
}
else
{
MessageBox.Show(map.getObject(x - 1, y).GetType().ToString());
current_direction = Game.direction.none;
}
}
示例4: Update
/// <summary>
/// Aktualizacja stanu Ameby
/// </summary>
/// <param name="gametime">czas gry</param>
/// <param name="map">mapa obiektow</param>
public override void Update(GameTime gametime, Map.Map map)
{
if (create_ameba)
{
available_tiles = new List<Map.MapObject>();
if (x > 0 && y > 0 && map.getObject(x - 1, y - 1) is Features.Slaby)
available_tiles.Add(map.getObject(x - 1, y - 1));
if (x > 0 && map.getObject(x - 1, y) is Features.Slaby)
available_tiles.Add(map.getObject(x - 1, y));
if (x > 0 && y < map.getHeight() - 1 && map.getObject(x - 1, y + 1) is Features.Slaby)
available_tiles.Add(map.getObject(x - 1, y + 1));
if (y > 0 && map.getObject(x, y - 1) is Features.Slaby)
available_tiles.Add(map.getObject(x, y - 1));
if (y < map.getHeight() - 1 && map.getObject(x, y + 1) is Features.Slaby)
available_tiles.Add(map.getObject(x, y + 1));
if (x < map.getWidth() - 1 && y > 0 && map.getObject(x + 1, y - 1) is Features.Slaby)
available_tiles.Add(map.getObject(x + 1, y - 1));
if (x<map.getWidth()-1&&map.getObject(x + 1, y) is Features.Slaby)
available_tiles.Add(map.getObject(x + 1, y));
if (x<map.getWidth()-1&&y<map.getHeight()-1&&map.getObject(x + 1, y + 1) is Features.Slaby)
available_tiles.Add(map.getObject(x + 1, y + 1));
CreateNewAmeba(map);
create_ameba = false;
}
}
示例5: Move
/// <summary>
/// Poruszanie - ustalenie aktualnego kierunku ruchu
/// </summary>
/// <param name="map">mapa obiektów</param>
public void Move(Map.Map map)
{
Point p = isVandalInSight(map);
if ((p.X != 0 && p.Y == 0) || (p.X == 0 && p.Y != 0))
{
//gonitwa
move_frequency = 40;
if ((this.x - map.GetVandal().x) < 0)
{
current_direction=Game.direction.right;
}
else if ((this.x - map.GetVandal().x) > 0)
{
current_direction = Game.direction.left;
}
else if ((this.y - map.GetVandal().y) > 0)
{
current_direction = Game.direction.up;
}
else if ((this.y - map.GetVandal().y) < 0)
{
current_direction = Game.direction.down;
}
}
else//ruch losowy
{
move_frequency = 80;
List<Game.direction> available_dir = new List<Game.direction>();
if (x > 1 && (map.getObject(x - 1, y).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x - 1, y).GetType() == typeof(DestroyableObjects.Ziemia)))
available_dir.Add(Game.direction.left);
if (x < map.getWidth() - 1 && (map.getObject(x + 1, y).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x + 1, y).TypeTag == Map.ElementType.ZIEMIA))
available_dir.Add(Game.direction.right);
if (y > 1 && (map.getObject(x, y - 1).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x, y - 1).GetType() == typeof(DestroyableObjects.Ziemia)))
available_dir.Add(Game.direction.up);
if (x < map.getHeight() - 1 && (map.getObject(x, y + 1).GetType() == typeof(NonDestroyableObjects.Puste) || map.getObject(x, y + 1).GetType() == typeof(DestroyableObjects.Ziemia)))
available_dir.Add(Game.direction.down);
if (available_dir.Capacity > 0)
{
int rand_dir = rand.Next(0, available_dir.Capacity - 1);
current_direction = (Game.direction)(rand_dir);
}
else
{
current_direction = Game.direction.none;
}
}
}