Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. public class PixelDrawer implements PixelShader{
  2. @Override
  3. public List<MapPixel> getPixels(Player player, int centerX, int centerY, MapView.Scale scale) {
  4. Location center = null;
  5. Color regionColor = Color.BLACK;
  6. int width = 16;
  7. int height = 16;
  8.  
  9. List< MapPixel > pixels = new ArrayList<>();
  10. //noinspection ConstantConditions
  11. center.setY( player.getLocation().getY() );
  12. if ( center.getWorld() != player.getWorld() ) {
  13. return pixels;
  14. }
  15. MapCursorLocation location = MapUtil.findRelCursorPosition( center, centerX, centerY, scale );
  16. int pixelX = ( location.getX() + 128 ) / 2;
  17. int pixelY = ( location.getY() + 128 ) / 2;
  18.  
  19. for ( int x = 0; x < width / MapUtil.getScaleSize( scale ); x++ ) {
  20. for ( int y = 0; y < height / MapUtil.getScaleSize( scale ); y++ ) {
  21. int px = pixelX + x;
  22. int py = pixelY + y;
  23. SimpleChunkLocation sc = new SimpleChunkLocation(center.getChunk());
  24. Land land = GameManagement.getLandManager().getOrLoadLand(sc);
  25. if(land.getOwner()==null)continue;
  26. else{
  27. Kingdom k = GameManagement.getKingdomManager().getOrLoadKingdom(land.getOwner());
  28. KingdomPlayer kp = GameManagement.getPlayerManager().getSession(player);
  29. if(k.isMember(kp))regionColor=Color.CYAN;
  30. if(k.isAllyMember(kp))regionColor=Color.GREEN;
  31. if(k.isTruceWith(kp.getKingdom()))regionColor=Color.GRAY;
  32. }
  33. if ( px < 128 && py < 128 && px > -1 && py > -1 ) {
  34. pixels.add( new MapPixel( pixelX + x, pixelY + y, regionColor ) );
  35. }
  36. }
  37. }
  38. return pixels;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement