Showing the price when productchute gets product.
@@ -40,6 +40,10 @@ | ||
40 | 40 | public Direction getDirection() { |
41 | 41 | return direction; |
42 | 42 | } |
43 | + | |
44 | + public String getMessage() { | |
45 | + return null; | |
46 | + } | |
43 | 47 | |
44 | 48 | public boolean isTargetObj(Obj o) { |
45 | 49 | return false; |
@@ -28,6 +28,10 @@ | ||
28 | 28 | private static int value = 5000; |
29 | 29 | private static int cost = 10; |
30 | 30 | |
31 | + private final static int HOLDMESSAGE = 10; | |
32 | + private static String messageBuf = null; | |
33 | + private int messageCount = 0; | |
34 | + | |
31 | 35 | public static void loadImages(ClassLoader loader, String path) throws IOException { |
32 | 36 | images[0] = ImageIO.read(loader.getResourceAsStream(path + "productchute.png")); |
33 | 37 | images[0] = images[0].getScaledInstance(size * 9 / 8, size * 3 / 4, Image.SCALE_AREA_AVERAGING); |
@@ -55,8 +59,33 @@ | ||
55 | 59 | } |
56 | 60 | return false; |
57 | 61 | } |
62 | + | |
63 | + private void setMessage(String message) { | |
64 | + setMessage(message, HOLDMESSAGE); | |
65 | + } | |
58 | 66 | |
67 | + private void setMessage(String message, int count) { | |
68 | + messageCount = count; | |
69 | + messageBuf = message; | |
70 | + } | |
71 | + | |
59 | 72 | @Override |
73 | + public String getMessage() { | |
74 | + return messageBuf; | |
75 | + } | |
76 | + | |
77 | + @Override | |
78 | + public void upDate() { | |
79 | + if (messageCount > 0) { | |
80 | + messageCount--; | |
81 | + } | |
82 | + else { | |
83 | + messageCount = 0; | |
84 | + messageBuf = null; | |
85 | + } | |
86 | + } | |
87 | + | |
88 | + @Override | |
60 | 89 | public boolean checkHitObj(Obj o) { |
61 | 90 | int objX = o.getX(); |
62 | 91 | int objY = o.getY(); |
@@ -81,6 +110,7 @@ | ||
81 | 110 | public void objHitProcess(Obj o) { |
82 | 111 | if ((o.objType == Type.YUKKURI) || (o.objType == Type.FOOD)) { |
83 | 112 | Cash.addCash(o.getPrice(Price.SELLING)); |
113 | + setMessage(InitLoader.getStatus(8) + o.getPrice(Price.SELLING)); | |
84 | 114 | } |
85 | 115 | Cash.delCash(getCost()); |
86 | 116 | o.remove(); |
@@ -1174,7 +1174,20 @@ | ||
1174 | 1174 | translation.concatenate(new AffineTransform(1, 0, skew, 1, 0, 0)); // get skew by X position |
1175 | 1175 | translation.concatenate(new AffineTransform(1, 0, 0, scale, 0, 0)); // get scale by Y position |
1176 | 1176 | g2d.drawImage(oex.getImage(), translation, this); // Affine transform seems to be adapted to reverse order of concatenation. |
1177 | - // g.drawImage(oex.getImage(), drX, drY, this); | |
1177 | + // draw script | |
1178 | + String message = oex.getMessage(); | |
1179 | + if (message != null) { | |
1180 | + final int FONTWIDTH = 12; | |
1181 | + final int NUMOFCHAR = 12; | |
1182 | + g.setFont(new Font(Font.MONOSPACED, Font.PLAIN, FONTWIDTH)); | |
1183 | + int width = Math.min(message.length(), NUMOFCHAR) * FONTWIDTH; | |
1184 | + int hight = drawStringMultiLine(g, message, 0, 0, width, false); | |
1185 | + g.setColor(new Color(255, 255, 255, 200)); // transparent white. | |
1186 | + g.fillRoundRect(drX + 14, drY - hight - 4, width + 8, hight + 8, 8, 8); | |
1187 | + g.setColor(new Color(0, 0, 0, 255)); // no transparent black. | |
1188 | + g.drawRoundRect(drX + 14, drY - hight - 4, width + 8, hight + 8, 8, 8); | |
1189 | + drawStringMultiLine(g, message, drX + 18, drY - hight, width, true); | |
1190 | + } | |
1178 | 1191 | } |
1179 | 1192 | for (Obj o: Terrarium.toiletList) { |
1180 | 1193 | Toilet t = (Toilet)o; |