/// <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; }