• R/O
  • SSH
  • HTTPS

simyukkuri: 提交


Commit MetaInfo

修订版260 (tree)
时间2015-09-09 12:06:21
作者mimisuke

Log Message

Showing the price when productchute gets product.

更改概述

差异

--- branches/test/ObjEX.java (revision 259)
+++ branches/test/ObjEX.java (revision 260)
@@ -40,6 +40,10 @@
4040 public Direction getDirection() {
4141 return direction;
4242 }
43+
44+ public String getMessage() {
45+ return null;
46+ }
4347
4448 public boolean isTargetObj(Obj o) {
4549 return false;
--- branches/test/ProductChute.java (revision 259)
+++ branches/test/ProductChute.java (revision 260)
@@ -28,6 +28,10 @@
2828 private static int value = 5000;
2929 private static int cost = 10;
3030
31+ private final static int HOLDMESSAGE = 10;
32+ private static String messageBuf = null;
33+ private int messageCount = 0;
34+
3135 public static void loadImages(ClassLoader loader, String path) throws IOException {
3236 images[0] = ImageIO.read(loader.getResourceAsStream(path + "productchute.png"));
3337 images[0] = images[0].getScaledInstance(size * 9 / 8, size * 3 / 4, Image.SCALE_AREA_AVERAGING);
@@ -55,8 +59,33 @@
5559 }
5660 return false;
5761 }
62+
63+ private void setMessage(String message) {
64+ setMessage(message, HOLDMESSAGE);
65+ }
5866
67+ private void setMessage(String message, int count) {
68+ messageCount = count;
69+ messageBuf = message;
70+ }
71+
5972 @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
6089 public boolean checkHitObj(Obj o) {
6190 int objX = o.getX();
6291 int objY = o.getY();
@@ -81,6 +110,7 @@
81110 public void objHitProcess(Obj o) {
82111 if ((o.objType == Type.YUKKURI) || (o.objType == Type.FOOD)) {
83112 Cash.addCash(o.getPrice(Price.SELLING));
113+ setMessage(InitLoader.getStatus(8) + o.getPrice(Price.SELLING));
84114 }
85115 Cash.delCash(getCost());
86116 o.remove();
--- branches/test/SimYukkuri.java (revision 259)
+++ branches/test/SimYukkuri.java (revision 260)
@@ -1174,7 +1174,20 @@
11741174 translation.concatenate(new AffineTransform(1, 0, skew, 1, 0, 0)); // get skew by X position
11751175 translation.concatenate(new AffineTransform(1, 0, 0, scale, 0, 0)); // get scale by Y position
11761176 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+ }
11781191 }
11791192 for (Obj o: Terrarium.toiletList) {
11801193 Toilet t = (Toilet)o;
Show on old repository browser