本文整理汇总了C#中Map.getObject方法的典型用法代码示例。如果您正苦于以下问题:C# Map.getObject方法的具体用法?C# Map.getObject怎么用?C# Map.getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
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;
}
}
示例2: Przesun
/// <summary>
/// Przesuwanie
/// </summary>
/// <param name="map"> Aktualna mapa obiektów</param>
/// <param name="x_vel">Predkość w poziomie</param>
/// <returns></returns>
public bool Przesun(Map.Map map, int x_vel)
{
if (map.vandal != null)
{
if (map.GetVandalDirection() == Game.direction.left && map.getObject((int)(x_vel / this.Rectangle.Width) - 1, (int)(map.getVandalRectangle().Y / map.getVandalRectangle().Height)).GetType() == typeof(NonDestroyableObjects.Puste))
{
if ((x_vel) % this.rectangle.Width == 0)
{
int x_ind = (int)(x_vel / this.Rectangle.Width);
int y_ind = (int)(this.Rectangle.Y / this.Rectangle.Height);
map.setObject(x_ind, y_ind, this);
map.setObject(x_ind + 1, y_ind, new NonDestroyableObjects.Puste(content, new Rectangle((x_ind + 1) * this.rectangle.Width, y_ind * this.Rectangle.Height, this.rectangle.Width, this.rectangle.Width), x_ind + 1, y_ind));
}
rectangle.X = x_vel;
return true;
}
if (map.GetVandalDirection() == Game.direction.right && map.getObject((int)(x_vel / this.Rectangle.Width), (int)(map.getVandalRectangle().Y / map.getVandalRectangle().Height)).GetType() == typeof(NonDestroyableObjects.Puste))
{
if ((x_vel) % this.rectangle.Width == 0)
{
int x_ind = (int)(x_vel / this.Rectangle.Width);
int y_ind = (int)(this.Rectangle.Y / this.Rectangle.Height);
map.setObject(x_ind - 1, y_ind, this);
map.setObject(x_ind, y_ind, new NonDestroyableObjects.Puste(content, new Rectangle((x_ind - 1) * this.rectangle.Width, y_ind * this.Rectangle.Height, this.rectangle.Width, this.rectangle.Width), x_ind, y_ind));
}
rectangle.X = x_vel;
return true;
}
}
return false;
}
示例3: 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;
}
示例4: MoveInDirection
/// <summary>
/// Poruszanie w określonym kierunku
/// </summary>
/// <param name="add_x">Zmiana indeksu x na tablicy obiektów</param>
/// <param name="add_y">Zmiana indeksu y na tablicy obiektów </param>
/// <param name="map">Mapa obiektów</param>
public void MoveInDirection(int add_x, int add_y, Map.Map map)
{
int new_x = x + add_x;
int new_y = y + add_y;
collision_obj = map.getObject(new_x, new_y);
if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste) || collision_obj.GetType() == typeof(DestroyableObjects.Ziemia))
{
map.setObject(new_x, new_y, this);
map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle(x * this.rectangle.Width, y * this.rectangle.Height, this.rectangle.Width, this.rectangle.Height),x,y));
x = new_x;
y = new_y;
}
}
示例5: isVandalInSight
/// <summary>
/// Funkcja dla AI szczura (sprawdza czy Vandal jest w zasiegu wzroku szczura - jesli tak - to wyznacza kierunk ruc)
/// </summary>
/// <param name="map">Mapa obiektów</param>
/// <returns>Punkt reprezentujacy kierunek poruszania Gigantycznego Szczura</returns>
public Point isVandalInSight(Map.Map map)
{
int x_move = 0;
int y_move = 0;
int vandal_x = map.GetVandal().x;
int vandal_y = map.GetVandal().y;
if (vandal_x == this.x)
{
int lower_ind = vandal_y<this.y?vandal_y:this.y;
int higher_ind = vandal_y<this.y?this.y:vandal_y;
for (int i = lower_ind + 1; i < higher_ind; i++)
{
if (map.getObject(this.x, i).GetType() != typeof(NonDestroyableObjects.Puste))
{
y_move = 0;
break;
}
// else y_move = lower_ind == this.y ? 1 : -1;
}
}
if (vandal_y == this.y)
{
int lower_ind = vandal_x < this.x ? vandal_x : this.x;
int higher_ind = vandal_x < this.x ? this.x : vandal_x;
for (int i = lower_ind + 1; i < higher_ind; i++)
{
if (map.getObject(i, this.y).GetType() != typeof(NonDestroyableObjects.Puste))
{
x_move = 0;
break;
}
// else x_move = lower_ind == this.x ? 1 : -1;
}
}
return new Point(x_move, y_move);
}
示例6: Update
/// <summary>
/// Aktualizacja stanu na mapie z uwzględnieniem spadania
/// </summary>
/// <param name="gametime"></param>
/// <param name="map"></param>
public override void Update(GameTime gametime, Map.Map map)
{
int x_index = rectangle.X / rectangle.Width;
int y_index = rectangle.Y / rectangle.Height;
if (y_index == map.getHeight() - 1)
{
if (is_falling)
{
map.setObject(x_index, y_index, this);
map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
is_falling = false;
return;
}
else return;
}
if (is_falling)
{
//nie spadl calkowice jeszcze na odpowiedni prosokat
if (rectangle.Y % rectangle.Height != 0)
{
Spadaj();
}
else
{
map.setObject(x_index, y_index, this);
map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
if (y_index < map.getHeight() - 1 && map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste))
{
Spadaj();
}
else is_falling = false;
}
}
else if (map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste) && !map.is_vandal_on_rectangle(x_index, y_index + 1))
{//rozpoczecie spadania
is_falling = true;
Spadaj();
}
else return;
}
示例7: Update
/// <summary>
/// Aktualizacja stanu na mapie z uwzględnieniem spadania
/// </summary>
/// <param name="gametime"></param>
/// <param name="map"></param>
public override void Update(GameTime gametime, Map.Map map)
{
if (explode)
{
if (current_frame == 16) { die = true; explode = false; }
else
src_rectangle = new Rectangle((current_frame++) * 64, 0, 64, 64);
}
else if (die)
{
map.setObject(x, y, new NonDestroyableObjects.Puste(content, this.Rectangle, x, y));
}
else
{
int x_index = rectangle.X / rectangle.Width;
int y_index = rectangle.Y / rectangle.Height;
//sprawdzenie wszytkich dookola pol
if (map.is_vandal_on_rectangle(x_index - 1, y_index) ||
map.is_vandal_on_rectangle(x_index + 1, y_index) ||
map.is_vandal_on_rectangle(x_index, y_index - 1) ||
map.is_vandal_on_rectangle(x_index, y_index + 1) ||
map.is_vandal_on_rectangle(x_index - 1, y_index - 1) ||
map.is_vandal_on_rectangle(x_index - 1, y_index + 1) ||
map.is_vandal_on_rectangle(x_index + 1, y_index + 1) ||
map.is_vandal_on_rectangle(x_index + 1, y_index - 1))
{
Zabij(map);
return;
}
if (y_index == map.getHeight() - 1)
{
if (is_falling)
{
map.setObject(x_index, y_index, this);
this.x = x_index;
this.y = y_index;
map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
is_falling = false;
return;
}
else return;
}
if (is_falling)
{
//nie spadl calkowice jeszcze na odpowiedni prosokat
if (rectangle.Y % rectangle.Height != 0)
{
Spadaj();
}
else
{
map.setObject(x_index, y_index, this);
this.x = x_index;
this.y = y_index;
map.setObject(x_index, y_index - 1, new NonDestroyableObjects.Puste(content, rectangle, x_index, y_index - 1));
if (y_index < map.getHeight() - 1 && map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste))
{
Spadaj();
}
else is_falling = false;
}
}
else if (map.getObject(x_index, y_index + 1).GetType() == typeof(NonDestroyableObjects.Puste) && !map.is_vandal_on_rectangle(x_index, y_index + 1))
{//rozpoczecie spadania
is_falling = true;
Spadaj();
}
else return;
}
}
示例8: Przesun
/// <summary>
/// Przesuwanie
/// </summary>
/// <param name="map"> Aktualna mapa obiektów</param>
/// <param name="x_vel">Predkość w poziomie</param>
/// <returns>czy moze byc przesuniety</returns>
public bool Przesun(Map.Map map, int x_vel)
{
if (map.getObject(x + x_vel, y).GetType() == typeof(NonDestroyableObjects.Puste))
{
map.setObject(x + x_vel, y, this);
this.x = x + x_vel;
this.y = y;
return true;
}
else return false;
}
示例9: Update
/// <summary>
/// Aktualizacja stanu Bloba na mapie
/// Poruszanie jeśli jest ustalony kierunek ruchu
/// </summary>
/// <param name="gametime">Czas gry</param>
/// <param name="map">Mapa obiektów</param>
public override void Update(GameTime gametime, Map.Map map)
{
if (gametime.TotalGameTime.Milliseconds % move_frequency == 0)
{
int add_x = 0;
int add_y =0 ;
Move(map);
if (!explode && !die)
{
switch (current_direction)
{
case Game.direction.down:
add_x = 0;
add_y = 1;
collision_obj = map.getObject(x, y + 1);
break;
case Game.direction.left:
add_x = -1;
add_y = 0;
collision_obj = map.getObject(x - 1, y);
break;
case Game.direction.right:
add_x = 1;
add_y = 0;
collision_obj = map.getObject(x + 1, y);
break;
case Game.direction.up:
add_x = 0;
add_y = -1;
collision_obj = map.getObject(x, y - 1);
break;
default:
break;
}
if (collision_obj.GetType() != typeof(NonDestroyableObjects.Puste) && collision_obj.GetType() != typeof(DestroyableObjects.Ziemia))
FireBomb(map);
if (collision_obj.GetType() == typeof(NonDestroyableObjects.Puste))
MoveInDirection(add_x, add_y, map);
}
else if (explode)
{
if (current_frame == 16) { die = true; explode = false; }
else
src_rectangle = new Rectangle((current_frame++) * 64, 0, 64, 64);
}
else if (die)
{
Die(map);
}
}
}
示例10: Update
/// <summary>
/// Aktualizacja stanu rakiety
/// </summary>
/// <param name="gametime">Czas gry</param>
/// <param name="map">Mapa obiektów</param>
public override void Update(GameTime gametime, Map.Map map)
{
if (gametime.TotalGameTime.Milliseconds % 20 == 0 && is_fired)
{
int collision_x = x;
int collision_y = y;
switch (direction)
{
case Game.direction.down:
texture = content.Load<Texture2D>("Textures\\racket_down");
collision_x = x;
collision_y = y + 1;
break;
case Game.direction.up:
texture = content.Load<Texture2D>("Textures\\racket_up");
collision_x = x;
collision_y = y - 1;
break;
case Game.direction.left:
texture = content.Load<Texture2D>("Textures\\racket_left");
collision_x = x - 1;
collision_y = y;
break;
case Game.direction.right:
texture = content.Load<Texture2D>("Textures\\racket_right");
collision_x = x + 1;
collision_y = y;
break;
}
if (map.getObject(collision_x, collision_y).GetType() != typeof(NonDestroyableObjects.Puste) && map.getObject(collision_x, collision_y) != this)
{
//explosion
SoundEffect explosion_sound = content.Load<SoundEffect>("Audio\\explosion_sound");
explosion_sound.Play();
int vandal_x = map.GetVandal().x;
int vandal_y = map.GetVandal().y;
//TODO: dodac sprawdzanie czy nie wykraczamy indeksow w mapie i czy obiekt nie jest niezniszczalny
//tak naprawde powinno sie to zmienic na wywolanie onDestroy dla kazdego z tych obiektow!!!!!!!!!!
if(x-1!=vandal_x&&y!=vandal_y&&map.getObject(x-1,y) is Zniszczalny)
map.setObject(x - 1, y, new NonDestroyableObjects.Puste(content, new Rectangle((x - 1) * rectangle.Width, y * rectangle.Height, rectangle.Width, rectangle.Height), x - 1, y));
if (x - 1 != vandal_x && y+1 != vandal_y && map.getObject(x - 1, y+1) is Zniszczalny)
map.setObject(x - 1, y + 1, new NonDestroyableObjects.Puste(content, new Rectangle((x - 1) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x - 1, y + 1));
if (x - 1 != vandal_x && y-1 != vandal_y && map.getObject(x - 1, y-1) is Zniszczalny)
map.setObject(x - 1, y - 1, new NonDestroyableObjects.Puste(content, new Rectangle((x - 1) * rectangle.Width, (y - 1) * rectangle.Height, rectangle.Width, rectangle.Height), x - 1, y - 1));
if (x != vandal_x && y-1 != vandal_y && map.getObject(x , y-1) is Zniszczalny)
map.setObject(x, y - 1, new NonDestroyableObjects.Puste(content, new Rectangle((x) * rectangle.Width, (y - 1) * rectangle.Height, rectangle.Width, rectangle.Height), x, y - 1));
if (x != vandal_x && y+1 != vandal_y && map.getObject(x , y+1) is Zniszczalny)
map.setObject(x, y + 1, new NonDestroyableObjects.Puste(content, new Rectangle((x) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x, y + 1));
if (x != vandal_x && y != vandal_y && map.getObject(x , y) is Zniszczalny)
map.setObject(x, y, new NonDestroyableObjects.Puste(content, new Rectangle((x) * rectangle.Width, y * rectangle.Height, rectangle.Width, rectangle.Height), x, y));
if (x + 1 != vandal_x && y != vandal_y && map.getObject(x + 1, y) is Zniszczalny)
map.setObject(x + 1, y, new NonDestroyableObjects.Puste(content, new Rectangle((x + 1) * rectangle.Width, y * rectangle.Height, rectangle.Width, rectangle.Height), x + 1, y));
if (x + 1 != vandal_x && y+1 != vandal_y && map.getObject(x + 1, y+1) is Zniszczalny)
map.setObject(x + 1, y + 1, new NonDestroyableObjects.Puste(content, new Rectangle((x + 1) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x + 1, y + 1));
if (x + 1 != vandal_x && y -1!= vandal_y && map.getObject(x + 1, y-1) is Zniszczalny)
map.setObject(x + 1, y - 1, new NonDestroyableObjects.Puste(content, new Rectangle((x + 1) * rectangle.Width, (y + 1) * rectangle.Height, rectangle.Width, rectangle.Height), x + 1, y - 1));
// if (x != vandal_x && y != vandal_y && map.getObject(x , y ) is Zniszczalny)
map.setObject(x, y, new NonDestroyableObjects.Puste(content, this.rectangle, x, y));
}
else
{
map.setObject(collision_x, collision_y, this);
map.setObject(x, y, new NonDestroyableObjects.Puste(content, this.rectangle, x, y));
this.x = collision_x;
this.y = collision_y;
}
}
}
示例11: Update
/// <summary>
/// aktualizacja stanu Vandala
/// </summary>
/// <param name="gametime">czas gry</param>
/// <param name="map">mapa obiektow</param>
public override void Update(GameTime gametime, Map.Map map)
{
if (!is_immortal)
{
//sprawdzenie czy styka sie z wrogiem
if (!map.GetVandal().is_immortal &&
map.getObject(x, y).GetType() == typeof(Characters.Enemy) || map.getObject(x, y) is Skazony)
{ is_alive = false; return; }
}
LoadCurrentTexture(map);
if(gametime.TotalGameTime.Milliseconds%20==0)
switch (current_direction)
{
case Game.direction.down:
MoveInDirection(0, 1, map);
current_direction = Game.direction.none;
break;
case Game.direction.left:
if (rectangle.X > 0)
MoveInDirection(-1, 0, map);
current_direction = Game.direction.none;
break;
case Game.direction.right:
MoveInDirection(1, 0, map);
current_direction = Game.direction.none;
break;
case Game.direction.up:
if (rectangle.Y > 0)
MoveInDirection(0, -1, map);
current_direction = Game.direction.none;
break;
default:
MoveInDirection(0, 0, map);
current_direction = Game.direction.none;
break;
}
}
示例12: Update
/// <summary>
/// Aktualizacja stanu dynamitu
/// </summary>
/// <param name="gametime">czas gry</param>
/// <param name="map">mapa obiektów</param>
public override void Update(GameTime gametime, Map.Map map)
{
if (is_fired)
{
Map.MapObject obj;
this.OnDestroy(map);
obj = map.getObject(x - 1, y-1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x - 1, y+1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x - 1, y );
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x , y-1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x , y+1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x + 1, y);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x + 1, y-1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x + 1, y + 1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType() == typeof(Characters.Enemy))
(obj as Characters.Enemy).Die(map);
}
}
示例13: 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;
}
示例14: Update
/// <summary>
/// Aktualizacja stanu dynamitu
/// </summary>
/// <param name="gametime">czas gry</param>
/// <param name="map">mapa obiektów</param>
public override void Update(GameTime gametime, Map.Map map)
{
if (is_fired)
{
Map.MapObject obj;
this.OnDestroy(map);
obj = map.getObject(x - 1, y-1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x - 1, y+1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x - 1, y );
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x , y-1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x , y+1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x + 1, y);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x + 1, y-1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
obj = map.getObject(x + 1, y + 1);
if (obj is Zniszczalny) (obj as Zniszczalny).OnDestroy(map);
else if (obj.GetType().IsSubclassOf(typeof(Characters.Enemy)))
(obj as Characters.Enemy).Die(map);
if (!map.player.AudioSettings.IsMuted)
{
SoundEffect.MasterVolume = (float)map.player.AudioSettings.SoundVolume;
fired_soundEffect.Play();
}
}
}
示例15: Update
public override void Update(GameTime gametime, Map.Map map)
{
if (!is_immortal)
{
//sprawdzenie czy styka sie z wrogiem
if (map.getObject(x, y).GetType() == typeof(Characters.Enemy) || map.getObject(x, y) is Skazony)
{ is_alive = false; return; }
/* if (map.getObject(x + 1, y).GetType() == typeof(Characters.Enemy) || map.getObject(x + 1, y) is Skazony)
{ is_alive = false; return; }
if (map.getObject(x, y - 1).GetType() == typeof(Characters.Enemy) || map.getObject(x, y - 1) is Skazony)
{ is_alive = false; return; }
if (map.getObject(x, y + 1).GetType() == typeof(Characters.Enemy) || map.getObject(x, y + 1) is Skazony)
{ is_alive = false; return; }
//lub skazonym polem po skosie
if (map.getObject(x - 1, y - 1) is Skazony)
{ is_alive = false; return; }
if (map.getObject(x + 1, y - 1) is Skazony)
{ is_alive = false; return; }
if (map.getObject(x - 1, y + 1) is Skazony)
{ is_alive = false; return; }
if (map.getObject(x + 1, y + 1) is Skazony)
{ is_alive = false; return; }*/
}
if (gametime.TotalGameTime.Milliseconds % 20 == 0)
{
switch (current_direction)
{
case Game.direction.down:
// if (rectangle.Y + velocity < max_height - rectangle.Height)
MoveInDirection(0, 1, map);
current_direction = Game.direction.none;
break;
case Game.direction.left:
if (rectangle.X > 0)
MoveInDirection(-1, 0, map);
current_direction = Game.direction.none;
break;
case Game.direction.right:
// if (rectangle.X + velocity < max_width - rectangle.Width)
MoveInDirection(1, 0, map);
current_direction = Game.direction.none;
break;
case Game.direction.up:
if (rectangle.Y > 0)
MoveInDirection(0, -1, map);
current_direction = Game.direction.none;
break;
default:
MoveInDirection(0, 0, map);
current_direction = Game.direction.none;
break;
}
}
}