From b3045d38e79a68e776bd9fcf56801d2c18b181b1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 10 Feb 2016 16:34:00 +0000 Subject: [PATCH] Add colour selection for multiple block types. --- .../game/arcade/game/games/draw/Draw.java | 118 +++++++++--------- .../game/games/draw/kits/KitArtist.java | 4 +- 2 files changed, 62 insertions(+), 60 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index b66ce1ff1..9a140789c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -68,6 +68,7 @@ public class Draw extends SoloGame //Brush private byte _brushColor = 15; + private Material _brushMaterial = Material.WOOL; private Location _brushPrevious = null; private boolean _lockDrawer = true; @@ -215,8 +216,11 @@ public class Draw extends SoloGame @Override public void ParseData() { - for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("LIME").get(0), WorldData.GetDataLocs("LIME").get(1), false)) - _canvas.add(b); + for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false)) + { + if (b.getType() != Material.AIR) + _canvas.add(b); + } _drawerLocation = WorldData.GetDataLocs("RED").get(0); _textLocation = WorldData.GetDataLocs("YELLOW").get(0); @@ -229,10 +233,6 @@ public class Draw extends SoloGame return; Reset(); - - for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false)) - if (b.getType().equals(Material.WOOL) && b.getData() == DyeColor.WHITE.getWoolData()) - b.setType(Material.AIR); } @EventHandler @@ -373,11 +373,12 @@ public class Draw extends SoloGame drawer.setFlying(true); drawer.setFlySpeed(0.4f); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte) 0, 1, "Pencil")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, "Paint Brush")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte) 0, 1, "Line Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Spray Can")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Spray Can")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_HOE, (byte)0, 1, "Paint Bucket")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_HOE, (byte)0, 1, "Clear Canvas")); @@ -564,7 +565,7 @@ public class Draw extends SoloGame for (Tool tool : _tools) tool.update(); } - + @EventHandler public void Paint(UpdateEvent event) { @@ -578,23 +579,24 @@ public class Draw extends SoloGame { if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) continue; - + if (!player.isBlocking()) { _brushPrevious = null; continue; } - + Block block = player.getTargetBlock((HashSet) null, 200); - if (block == null || !_canvas.contains(block)) + if (block == null || !_canvas.contains(block)) continue; - if (block.getData() == _brushColor) + if (block.getData() == _brushColor && block.getType() == _brushMaterial) continue; - + //Color + block.setType(_brushMaterial); block.setData(_brushColor); - + //Thick Brush if (UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) { @@ -602,40 +604,27 @@ public class Draw extends SoloGame { if (!_canvas.contains(other)) continue; - + + block.setType(_brushMaterial); other.setData(_brushColor); } } - //Spray Can - if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) - { - for (Block other : UtilBlock.getSurrounding(block, false)) - { - if (!_canvas.contains(other)) - continue; - - if (Math.random() > 0.75) - continue; - - other.setData(_brushColor); - } - } - //Join Dots if (_brushPrevious != null) - { + { while (UtilMath.offset(_brushPrevious, block.getLocation().add(0.5, 0.5, 0.5)) > 0.5) - { + { _brushPrevious.add(UtilAlg.getTrajectory(_brushPrevious, block.getLocation().add(0.5, 0.5, 0.5)).multiply(0.5)); Block fixBlock = _brushPrevious.getBlock(); - + if (!_canvas.contains(fixBlock)) continue; - + + fixBlock.setType(_brushMaterial); fixBlock.setData(_brushColor); - + //Thick Brush if (UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) { @@ -643,33 +632,19 @@ public class Draw extends SoloGame { if (!_canvas.contains(other)) continue; - - other.setData(_brushColor); - } - } - - //Spray Can - if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) - { - for (Block other : UtilBlock.getSurrounding(fixBlock, false)) - { - if (!_canvas.contains(other)) - continue; - - if (Math.random() > 0.75) - continue; + other.setType(_brushMaterial); other.setData(_brushColor); } } } } - + for (Player other : UtilServer.getPlayers()) other.playSound(other.getLocation(), Sound.FIZZ, 0.2f, 2f); - + _lockDrawer = false; - + _brushPrevious = block.getLocation().add(0.5, 0.5, 0.5); } } @@ -697,6 +672,7 @@ public class Draw extends SoloGame //Restore _brushColor = color; + _brushMaterial = Material.WOOL; _lockDrawer = false; for (Player other : UtilServer.getPlayers()) @@ -723,29 +699,34 @@ public class Draw extends SoloGame //Fill byte color = block.getData(); + Material material = block.getType(); - if (color == _brushColor) + if (color == _brushColor && material == _brushMaterial) return; - FillRecurse(block, color); + FillRecurse(block, color, material); for (Player other : UtilServer.getPlayers()) other.playSound(other.getLocation(), Sound.SPLASH, 0.4f, 1.5f); } - public void FillRecurse(Block block, byte color) + public void FillRecurse(Block block, byte color, Material material) { + if (block.getType() != material) + return; + if (block.getData() != color) return; if (!_canvas.contains(block)) return; + block.setType(_brushMaterial); block.setData(_brushColor); for (Block other : UtilBlock.getSurrounding(block, false)) { - FillRecurse(other, color); + FillRecurse(other, color, material); } } @@ -761,10 +742,15 @@ public class Draw extends SoloGame return; Block block = player.getTargetBlock((HashSet) null, 200); - if (block == null || block.getType() != Material.WOOL || _canvas.contains(block)) + + List possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), + WorldData.GetDataLocs("GREEN").get(1)); + + if (block == null || !possibleBlocks.contains(block)) return; _brushColor = block.getData(); + _brushMaterial = block.getType(); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f); } @@ -779,6 +765,7 @@ public class Draw extends SoloGame } _brushColor = 15; + _brushMaterial = Material.WOOL; if (_textBlocks != null) { @@ -961,8 +948,23 @@ public class Draw extends SoloGame return _brushColor; } + public Material getBrushMaterial() + { + return _brushMaterial; + } + public void setLock(boolean b) { _lockDrawer = b; } + + @EventHandler + public void sprayCan(UpdateEvent e) + { + if (!IsLive()) + return; + + //if (e.getType() != UpdateType.TICK) + //todo spray can BOW PULL BACK + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java index 36776e64c..ad2eb8a45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java @@ -21,13 +21,13 @@ public class KitArtist extends Kit super(manager, "Artist", KitAvailability.Free, new String[] { - "Show off your drawing skills!" + "The world is but a canvas to our imagination." }, new Perk[] { }, - EntityType.ZOMBIE, new ItemStack(Material.STONE_SWORD)); + EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); } @Override