Merge from test branch.
@@ -129,6 +129,25 @@ | ||
129 | 129 | } |
130 | 130 | |
131 | 131 | @Override |
132 | + protected void showScare() { | |
133 | + if (sleeping) { | |
134 | + return; | |
135 | + } | |
136 | + switch (language) { | |
137 | + case JAPANESE: | |
138 | + String messagesJ[][] = {{"äñâ[I", "äÁèÅ«Éá¢[I", "Èñ¾©äÁèÅ«È¢æI"}, | |
139 | + {"âß¿¥É¥âß¿¥É¥", "²ßñÈ¿á¢âß¿¥É¥AAA", "ÇÚ¶ÅÅ¢ÔɱñȲǸȩ́AAA"}}; | |
140 | + setMessage(messagesJ[damageState][ageState]); | |
141 | + break; | |
142 | + case ENGLISH: | |
143 | + String messagesE[][] = {{"YUNYA-!!", "I can'ch chake id eajy!", "I feel to be not able to take it easy!"}, | |
144 | + {"Shdop id shdop id-", "Weimu ish showwy sho pwease shdop id...", "Why would you do thisss...."}}; | |
145 | + setMessage(messagesE[damageState][ageState]); | |
146 | + break; | |
147 | + } | |
148 | + } | |
149 | + | |
150 | + @Override | |
132 | 151 | protected void showDieing() { |
133 | 152 | messageBuf = null; |
134 | 153 | switch (language) { |
@@ -385,9 +404,23 @@ | ||
385 | 404 | break; |
386 | 405 | } |
387 | 406 | } |
407 | + | |
408 | + @Override | |
409 | + protected void showFlying() { | |
410 | + switch (language) { | |
411 | + case JAPANESE: | |
412 | + String messagesJ[] = {"¨¿åçðÆñÅèãÝ¿á¢I", "襢ÞͨµåçðÆÔÆè³ñI", "¨»çðÆñÅéݽ¢I"}; | |
413 | + setMessage(messagesJ[ageState]); | |
414 | + break; | |
415 | + case ENGLISH: | |
416 | + String messagesE[] = {"I feelu lyke flying!", "Ryeimu idu flying bird!", "I feel like flying!"}; | |
417 | + setMessage(messagesE[ageState]); | |
418 | + break; | |
419 | + } | |
420 | + } | |
388 | 421 | |
389 | 422 | // public methods |
390 | - public Reimu(int initX, int initY, int initAgeState, int language) { | |
391 | - super(initX, initY, Body.REIMU, initAgeState, language); | |
423 | + public Reimu(int initX, int initY, int initZ, int initAgeState, int language) { | |
424 | + super(initX, initY, initZ, Body.REIMU, initAgeState, language); | |
392 | 425 | } |
393 | 426 | } |
@@ -1,12 +1,16 @@ | ||
1 | 1 | import java.util.*; |
2 | 2 | |
3 | 3 | public class Yukkuri { |
4 | + private final static int ALARM_PERIOD = 300; // 30 seconds | |
5 | + | |
4 | 6 | public static ArrayList<Body> bodyList = new ArrayList<Body>(); |
5 | 7 | public static ArrayList<Food> foodList = new ArrayList<Food>(); |
6 | 8 | public static ArrayList<Shit> shitList = new ArrayList<Shit>(); |
7 | 9 | |
8 | - private Random rnd = new Random(); | |
9 | - private int language = Body.JAPANESE; | |
10 | + private static Random rnd = new Random(); | |
11 | + private static int language = Body.JAPANESE; | |
12 | + private static int alarmPeriod = 0; | |
13 | + private static boolean alarm = false; | |
10 | 14 | |
11 | 15 | private int distance(int x, int y) { |
12 | 16 | return x*x + y*y; |
@@ -24,9 +28,12 @@ | ||
24 | 28 | if (partner == b) { |
25 | 29 | continue; |
26 | 30 | } |
27 | - if (partner.isDead() || (b.isExciting() && !partner.isAdult())) { | |
31 | + if (partner.isDead() || (b.isExciting() && !partner.isAdult() || b.isScare())) { | |
28 | 32 | continue; |
29 | 33 | } |
34 | + if (b.getZ() != partner.getZ()) { | |
35 | + continue; | |
36 | + } | |
30 | 37 | int dist, dx, dy; |
31 | 38 | dx = b.getX() - partner.getX(); |
32 | 39 | dy = b.getY() - partner.getY(); |
@@ -77,6 +84,9 @@ | ||
77 | 84 | if (f.isEmpty()) { |
78 | 85 | continue; |
79 | 86 | } |
87 | + if (b.getZ() != f.getZ()) { | |
88 | + continue; | |
89 | + } | |
80 | 90 | int distance, dx, dy; |
81 | 91 | dx = b.getX() - f.getX(); |
82 | 92 | dy = b.getY() - f.getY(); |
@@ -107,6 +117,9 @@ | ||
107 | 117 | Shit found = null; |
108 | 118 | int minDistance = Box.maxX * Box.maxY; |
109 | 119 | for (Shit s:shitList) { |
120 | + if (b.getZ() != s.getZ()) { | |
121 | + continue; | |
122 | + } | |
110 | 123 | int distance, dx, dy; |
111 | 124 | dx = b.getX() - s.getX(); |
112 | 125 | dy = b.getY() - s.getY(); |
@@ -126,34 +139,34 @@ | ||
126 | 139 | return ret; |
127 | 140 | } |
128 | 141 | |
129 | - public void addBody(int x, int y, int type, int age, int language) { | |
142 | + synchronized public void addBody(int x, int y, int z, int type, int age, int language) { | |
130 | 143 | switch (type) { |
131 | 144 | case Body.MARISA: |
132 | - bodyList.add(new Marisa(x, y, age, language)); | |
145 | + bodyList.add(new Marisa(x, y, z, age, language)); | |
133 | 146 | break; |
134 | 147 | case Body.REIMU: |
135 | - bodyList.add(new Reimu(x, y, age, language)); | |
148 | + bodyList.add(new Reimu(x, y, z, age, language)); | |
136 | 149 | break; |
137 | 150 | } |
138 | 151 | } |
139 | 152 | |
140 | - public void addFood(int x, int y, int type) { | |
153 | + synchronized public void addFood(int x, int y, int type) { | |
141 | 154 | foodList.add(new Food(x, y, type)); |
142 | 155 | } |
143 | 156 | |
144 | - public void addYukkuriFood(int x, int y) { | |
157 | + synchronized public void addYukkuriFood(int x, int y) { | |
145 | 158 | addFood(x, y, Food.YUKKURIFOOD); |
146 | 159 | } |
147 | 160 | |
148 | - public void addCake(int x, int y) { | |
161 | + synchronized public void addCake(int x, int y) { | |
149 | 162 | addFood(x, y, Food.CAKE); |
150 | 163 | } |
151 | 164 | |
152 | - public void addShit(int x, int y, int ageState) { | |
153 | - shitList.add(new Shit(x, y, ageState)); | |
165 | + synchronized public void addShit(int x, int y, int z, int ageState) { | |
166 | + shitList.add(new Shit(x, y, z, ageState)); | |
154 | 167 | } |
155 | 168 | |
156 | - public void setLanguage(int lang) { | |
169 | + synchronized public void setLanguage(int lang) { | |
157 | 170 | switch (lang) { |
158 | 171 | case 0: |
159 | 172 | language = Body.JAPANESE; |
@@ -177,7 +190,23 @@ | ||
177 | 190 | return width; |
178 | 191 | } |
179 | 192 | |
180 | - public void run() { | |
193 | + synchronized public static void setAlarm() { | |
194 | + alarm = true; | |
195 | + alarmPeriod = ALARM_PERIOD; | |
196 | + } | |
197 | + | |
198 | + public static boolean getAlarm() { | |
199 | + return alarm; | |
200 | + } | |
201 | + | |
202 | + synchronized public void run() { | |
203 | + if (alarmPeriod >= 0) { | |
204 | + alarmPeriod--; | |
205 | + if (alarmPeriod <= 0) { | |
206 | + alarmPeriod = 0; | |
207 | + alarm = false; | |
208 | + } | |
209 | + } | |
181 | 210 | int ret = 0; |
182 | 211 | // Update food state. |
183 | 212 | for (int i=0; i < foodList.size(); i++) { |
@@ -204,10 +233,10 @@ | ||
204 | 233 | case Body.DEAD: |
205 | 234 | continue; |
206 | 235 | case Body.BIRTHBABY: |
207 | - addBody(b.getX(), b.getY(), b.getBabyType(), 0, language); | |
236 | + addBody(b.getX(), b.getY(), b.getZ(), b.getBabyType(), 0, language); | |
208 | 237 | break; |
209 | 238 | case Body.DOSHIT: |
210 | - addShit(b.getX(), b.getY(), b.getAgeState()); | |
239 | + addShit(b.getX(), b.getY(), b.getZ(), b.getAgeState()); | |
211 | 240 | break; |
212 | 241 | case Body.REMOVED: |
213 | 242 | bodyList.remove(i); |
@@ -43,6 +43,12 @@ | ||
43 | 43 | |
44 | 44 | public int clockTick() { |
45 | 45 | if (removed == false) { |
46 | + if (!grabbed && z > 0) { | |
47 | + z -= 2; | |
48 | + if (z <= 0) { | |
49 | + z = 0; | |
50 | + } | |
51 | + } | |
46 | 52 | return DONOTHING; |
47 | 53 | } |
48 | 54 | return REMOVED; |
@@ -1,11 +1,13 @@ | ||
1 | 1 | public class Shit extends Obj { |
2 | 2 | private static final int SHITLIMIT[] = {100*12, 100*24, 100*24*2}; |
3 | 3 | private int ageState; |
4 | + private int falldownDamage = 0; | |
4 | 5 | |
5 | - public Shit (int initX, int initY, int initAgeState) { | |
6 | + public Shit (int initX, int initY, int initZ, int initAgeState) { | |
6 | 7 | objType = SHIT; |
7 | 8 | x = initX; |
8 | 9 | y = initY; |
10 | + z = initZ; | |
9 | 11 | ageState = initAgeState; |
10 | 12 | removed = false; |
11 | 13 | } |
@@ -27,6 +29,17 @@ | ||
27 | 29 | if (age >= SHITLIMIT[ageState]) { |
28 | 30 | removed = true; |
29 | 31 | } |
32 | + if (!grabbed && z > 0) { | |
33 | + z -= 2; | |
34 | + falldownDamage += 2; | |
35 | + if (z <= 0) { | |
36 | + if (falldownDamage > 10) { | |
37 | + age += SHITLIMIT[ageState]/2; | |
38 | + } | |
39 | + z = 0; | |
40 | + falldownDamage = 0; | |
41 | + } | |
42 | + } | |
30 | 43 | return DONOTHING; |
31 | 44 | } |
32 | 45 | return REMOVED; |
@@ -18,6 +18,7 @@ | ||
18 | 18 | protected int x, y, z; //location |
19 | 19 | protected int objType; //YUKKURI, SHIT, FOOD |
20 | 20 | protected boolean removed = false; |
21 | + protected boolean grabbed = false; | |
21 | 22 | |
22 | 23 | public int getX() { |
23 | 24 | return x; |
@@ -31,6 +32,54 @@ | ||
31 | 32 | return z; |
32 | 33 | } |
33 | 34 | |
35 | + public void setX(int X) { | |
36 | + if (X < 0) { | |
37 | + x = 0; | |
38 | + } | |
39 | + else if (X > Box.maxX) { | |
40 | + x = Box.maxX; | |
41 | + } | |
42 | + else { | |
43 | + x = X; | |
44 | + } | |
45 | + } | |
46 | + | |
47 | + public void setY(int Y) { | |
48 | + if (Y < 0) { | |
49 | + y = 0; | |
50 | + } | |
51 | + else if(Y > Box.maxY) { | |
52 | + y = Box.maxY; | |
53 | + } | |
54 | + else { | |
55 | + y = Y; | |
56 | + } | |
57 | + } | |
58 | + | |
59 | + public void setZ(int Z) { | |
60 | + if (Z < 0) { | |
61 | + z = 0; | |
62 | + } | |
63 | + else if (Z > Box.maxZ) { | |
64 | + z = Box.maxZ; | |
65 | + } | |
66 | + else { | |
67 | + z = Z; | |
68 | + } | |
69 | + } | |
70 | + | |
71 | + public void grab() { | |
72 | + grabbed = true; | |
73 | + } | |
74 | + | |
75 | + public void release() { | |
76 | + grabbed = false; | |
77 | + } | |
78 | + | |
79 | + public boolean isGrabbed() { | |
80 | + return grabbed; | |
81 | + } | |
82 | + | |
34 | 83 | public int getObjType() { |
35 | 84 | return objType; |
36 | 85 | } |
@@ -128,6 +128,25 @@ | ||
128 | 128 | } |
129 | 129 | |
130 | 130 | @Override |
131 | + protected void showScare() { | |
132 | + if (sleeping) { | |
133 | + return; | |
134 | + } | |
135 | + switch (language) { | |
136 | + case JAPANESE: | |
137 | + String messagesJ[][] = {{"äñâ[I", "äÁ¿Å«Éá¢Ì¶¥[I", "âßéñ¾ºIÕ[¾ºI"}, | |
138 | + {"âß¿¥É¥âß¿¥É¥AAA", "²ßñÉá¿á¢âß¿¥ËAAA", "¨Ëª¢¶Î¸AâßÅ®¾´¢AAA"}}; | |
139 | + setMessage(messagesJ[damageState][ageState]); | |
140 | + break; | |
141 | + case ENGLISH: | |
142 | + String messagesE[][] = {{"YUNYA-!!", "I can'ch chake id eajy, je!", "Stop it, ze! Puff, ze!"}, | |
143 | + {"Shdop id, shdop id...", "Mawisha ish showwy sho pwease shdop id...", "Pwease, sdop id pwease..."}}; | |
144 | + setMessage(messagesE[damageState][ageState]); | |
145 | + break; | |
146 | + } | |
147 | + } | |
148 | + | |
149 | + @Override | |
131 | 150 | protected void showDieing() { |
132 | 151 | messageBuf = null; // show message immediately |
133 | 152 | switch (language) { |
@@ -385,9 +404,23 @@ | ||
385 | 404 | break; |
386 | 405 | } |
387 | 406 | } |
407 | + | |
408 | + @Override | |
409 | + protected void showFlying() { | |
410 | + switch (language) { | |
411 | + case JAPANESE: | |
412 | + String messagesJ[] = {"¨¿åçðÆñÅèãÝ¿á¢Ì¶¥I", "Üè¿áͨµåçð¹¢Óµ½Ì¶¥I", "Üè³Í¨»çð¹¢Óµ½ÌºI"}; | |
413 | + setMessage(messagesJ[ageState]); | |
414 | + break; | |
415 | + case ENGLISH: | |
416 | + String messagesE[] = {"I feel like flying!", "Maricha conquered shky, je!", "Maricha conquered the sky, ze!"}; | |
417 | + setMessage(messagesE[ageState]); | |
418 | + break; | |
419 | + } | |
420 | + } | |
388 | 421 | |
389 | 422 | // public methods |
390 | - public Marisa(int initX, int initY, int initAgeState, int language) { | |
391 | - super(initX, initY, Body.MARISA, initAgeState, language); | |
423 | + public Marisa(int initX, int initY, int initZ, int initAgeState, int language) { | |
424 | + super(initX, initY, initZ, Body.MARISA, initAgeState, language); | |
392 | 425 | } |
393 | 426 | } |
\ No newline at end of file |
@@ -15,7 +15,7 @@ | ||
15 | 15 | JComboBox s1, s2; |
16 | 16 | JLabel l1, l2; |
17 | 17 | static myPane mypane = new myPane(); |
18 | - static Thread mythread; | |
18 | + static Thread mythread; | |
19 | 19 | |
20 | 20 | public SimYukkuri() { |
21 | 21 | super("µÞäÁè"); |
@@ -22,11 +22,11 @@ | ||
22 | 22 | // setup button pane |
23 | 23 | buttonPane.setLayout(new GridLayout(20, 1)); |
24 | 24 | buttonPane.setBorder(new LineBorder(Color.gray, 2)); |
25 | - JLabel title = new JLabel("µÞäÁè Ver1.5@"); | |
25 | + JLabel title = new JLabel("µÞäÁè Ver1.6@"); | |
26 | 26 | buttonPane.add(title); |
27 | 27 | l1 = new JLabel("¹ï/Tools"); |
28 | 28 | buttonPane.add(l1); |
29 | - String[] list1 = {"j", "n}[", "oCu", "W [X", "¦³", "zEL", "¨©´è"}; | |
29 | + String[] list1 = {"j", "n}[", "oCu", "W [X", "¦³", "zEL", "¨©´è", "Ú®"}; | |
30 | 30 | s1 = new JComboBox(list1); |
31 | 31 | buttonPane.add(s1); |
32 | 32 | JLabel l2 = new JLabel("¾ê/Language"); |
@@ -36,7 +36,9 @@ | ||
36 | 36 | s2.addActionListener(this); |
37 | 37 | buttonPane.add(s2); |
38 | 38 | // setup my pane |
39 | - mypane.addMouseListener(new myListener()); | |
39 | + MyMouseListener ml = new MyMouseListener(); | |
40 | + mypane.addMouseListener(ml); | |
41 | + mypane.addMouseMotionListener(ml); | |
40 | 42 | // setup root pane |
41 | 43 | rootPane.setLayout(new BorderLayout()); |
42 | 44 | rootPane.add("Center", mypane); |
@@ -69,6 +71,7 @@ | ||
69 | 71 | s1.addItem("¦³"); |
70 | 72 | s1.addItem("zEL"); |
71 | 73 | s1.addItem("¨©´è"); |
74 | + s1.addItem("Ú®"); | |
72 | 75 | s2.removeAllItems(); |
73 | 76 | s2.addItem("ú{ê"); |
74 | 77 | s2.addItem("pê"); |
@@ -84,6 +87,7 @@ | ||
84 | 87 | s1.addItem("Food"); |
85 | 88 | s1.addItem("Sweep"); |
86 | 89 | s1.addItem("Accessory"); |
90 | + s1.addItem("Move"); | |
87 | 91 | s2.removeAllItems(); |
88 | 92 | s2.addItem("Japanese"); |
89 | 93 | s2.addItem("English"); |
@@ -92,9 +96,19 @@ | ||
92 | 96 | } |
93 | 97 | } |
94 | 98 | |
95 | - public class myListener extends MouseAdapter { | |
99 | + public class MyMouseListener extends MouseAdapter { | |
100 | + private Cursor cr = new Cursor(Cursor.HAND_CURSOR); | |
101 | + private Cursor defCr = new Cursor(Cursor.DEFAULT_CURSOR); | |
102 | + private Obj grabbedObj = null; | |
103 | + int startX = -1, startY = -1, startZ = -1; | |
104 | + int oX = 0, oY = 0, altitude = 0; | |
105 | + /* | |
106 | + BufferedImage bi = ImageIO.read(JSpreadUtilities.getUrl(resourcename)); | |
107 | + Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( | |
108 | + bi, new Point(x, y), cursorname); | |
109 | + */ | |
110 | + | |
96 | 111 | public void mouseClicked(MouseEvent e){ |
97 | - Point p = e.getPoint(); | |
98 | 112 | Dimension size = mypane.getSize(); |
99 | 113 | int w = size.width, h = size.height; |
100 | 114 | boolean hit = false; |
@@ -104,8 +118,8 @@ | ||
104 | 118 | int dia[] = {10, 20, 30}; |
105 | 119 | int offsetX = (myPane.maxSize - dia[ageState])/2; |
106 | 120 | int offsetY = (myPane.maxSize - dia[ageState]); |
107 | - int dx = (int)p.getX() - (Translate.transX(s.getX(), s.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
108 | - int dy = (int)p.getY() - (Translate.transY(s.getX(), s.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
121 | + int dx = e.getX() - (Translate.transX(s.getX(), s.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
122 | + int dy = e.getY() - (Translate.transY(s.getX(), s.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
109 | 123 | if (dx >= 0 && dx <= dia[ageState] && dy >= 0 && dy <= dia[ageState]) { |
110 | 124 | s.remove(); |
111 | 125 | hit = true; |
@@ -114,8 +128,8 @@ | ||
114 | 128 | for (Food f:Yukkuri.foodList) { |
115 | 129 | int offsetX = (myPane.maxSize - myPane.foodSize)/2; |
116 | 130 | int offsetY = (myPane.maxSize - myPane.foodSize/2); |
117 | - int dx = (int)p.getX() - (Translate.transX(f.getX(), f.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
118 | - int dy = (int)p.getY() - (Translate.transY(f.getX(), f.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
131 | + int dx = e.getX() - (Translate.transX(f.getX(), f.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
132 | + int dy = e.getY() - (Translate.transY(f.getX(), f.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
119 | 133 | if (dx >= 0 && dx <= myPane.foodSize && dy >= 0 && dy <= myPane.foodSize/2) { |
120 | 134 | f.remove(); |
121 | 135 | hit = true; |
@@ -127,17 +141,19 @@ | ||
127 | 141 | int dia[] = {myPane.maxSize/4, myPane.maxSize/2, myPane.maxSize}; |
128 | 142 | int offsetX = (myPane.maxSize - dia[ageState])/2; |
129 | 143 | int offsetY = (myPane.maxSize - dia[ageState]); |
130 | - int dx = (int)p.getX() - (Translate.transX(b.getX(), b.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
131 | - int dy = (int)p.getY() - (Translate.transY(b.getX(), b.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
144 | + int dx = e.getX() - (Translate.transX(b.getX(), b.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
145 | + int dy = e.getY() - (Translate.transY(b.getX(), b.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
132 | 146 | if (dx >= 0 && dx <= dia[ageState] && dy >= 0 && dy <= dia[ageState]) { |
133 | 147 | switch (s1.getSelectedIndex()) { |
134 | 148 | case 0: |
135 | 149 | //j |
136 | 150 | b.strikeByNeedle(); |
151 | + Yukkuri.setAlarm(); | |
137 | 152 | break; |
138 | 153 | case 1: |
139 | 154 | //n}[ |
140 | 155 | b.strikeByHammer(); |
156 | + Yukkuri.setAlarm(); | |
141 | 157 | break; |
142 | 158 | case 2: |
143 | 159 | //oCu |
@@ -172,10 +188,10 @@ | ||
172 | 188 | } |
173 | 189 | } |
174 | 190 | if (!hit && s1.getSelectedIndex() == 4) { //¦³ |
175 | - int offsetX = (myPane.maxSize - mypane.foodSize)/2; | |
191 | + int offsetX = (myPane.maxSize - myPane.foodSize)/2; | |
176 | 192 | int offsetY = (myPane.maxSize - myPane.foodSize/2); |
177 | - int X = ((int)p.getX() - offsetX)*Box.maxX/(w-myPane.maxSize); | |
178 | - int Y = ((int)p.getY() - offsetY)*Box.maxY/(h-myPane.maxSize); | |
193 | + int X = (e.getX() - offsetX)*Box.maxX/(w-myPane.maxSize); | |
194 | + int Y = (e.getY() - offsetY)*Box.maxY/(h-myPane.maxSize); | |
179 | 195 | int x = Translate.invX(X, Y, Box.maxX, Box.maxY); |
180 | 196 | int y = Translate.invY(X, Y, Box.maxX, Box.maxY); |
181 | 197 | if (x >= 0 && x <= Box.maxX && y >= 0 && y <= Box.maxY) { |
@@ -184,6 +200,181 @@ | ||
184 | 200 | } |
185 | 201 | } |
186 | 202 | } |
203 | + | |
204 | + public void mousePressed(MouseEvent e) { | |
205 | + if (s1.getSelectedIndex() != 7) { //Ú® | |
206 | + return; | |
207 | + } | |
208 | + if ((e.getModifiersEx() & e.BUTTON3_DOWN_MASK) != 0) { | |
209 | + startZ = e.getY() + altitude; | |
210 | + startY = e.getY(); | |
211 | + } | |
212 | + if (grabbedObj != null) { | |
213 | + return; | |
214 | + } | |
215 | + int maxY = -1; | |
216 | + Dimension size = mypane.getSize(); | |
217 | + int w = size.width, h = size.height; | |
218 | + for (Body b:Yukkuri.bodyList) { | |
219 | + int ageState = b.getAgeState(); | |
220 | + int dia[] = {myPane.maxSize/4, myPane.maxSize/2, myPane.maxSize}; | |
221 | + int offsetX = (myPane.maxSize - dia[ageState])/2; | |
222 | + int offsetY = (myPane.maxSize - dia[ageState]); | |
223 | + int dx = e.getX() - (Translate.transX(b.getX(), b.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
224 | + int dy = e.getY() - (Translate.transY(b.getX(), b.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
225 | + if (dx >= 0 && dx <= dia[ageState] && dy >= 0 && dy <= dia[ageState]) { | |
226 | + if (maxY < b.getY()) { | |
227 | + grabbedObj = b; | |
228 | + startX = e.getX(); | |
229 | + startY = e.getY(); | |
230 | + oX = dx; | |
231 | + oY = dy; | |
232 | + maxY = b.getY(); | |
233 | + } | |
234 | + } | |
235 | + } | |
236 | + for (Shit s:Yukkuri.shitList) { | |
237 | + int ageState = s.getAgeState(); | |
238 | + int dia[] = {10, 20, 30}; | |
239 | + int offsetX = (myPane.maxSize - dia[ageState])/2; | |
240 | + int offsetY = (myPane.maxSize - dia[ageState]); | |
241 | + int dx = e.getX() - (Translate.transX(s.getX(), s.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
242 | + int dy = e.getY() - (Translate.transY(s.getX(), s.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
243 | + if (dx >= 0 && dx <= dia[ageState] && dy >= 0 && dy <= dia[ageState]) { | |
244 | + if (maxY < s.getY()) { | |
245 | + grabbedObj = s; | |
246 | + startX = e.getX(); | |
247 | + startY = e.getY(); | |
248 | + oX = dx; | |
249 | + oY = dy; | |
250 | + maxY = s.getY(); | |
251 | + } | |
252 | + } | |
253 | + } | |
254 | + for (Food f:Yukkuri.foodList) { | |
255 | + int offsetX = (myPane.maxSize - myPane.foodSize)/2; | |
256 | + int offsetY = (myPane.maxSize - myPane.foodSize/2); | |
257 | + int dx = e.getX() - (Translate.transX(f.getX(), f.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX); | |
258 | + int dy = e.getY() - (Translate.transY(f.getX(), f.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY); | |
259 | + if (dx >= 0 && dx <= myPane.foodSize && dy >= 0 && dy <= myPane.foodSize/2) { | |
260 | + if (maxY < f.getY()) { | |
261 | + grabbedObj = f; | |
262 | + startX = e.getX(); | |
263 | + startY = e.getY(); | |
264 | + oX = dx; | |
265 | + oY = dy; | |
266 | + maxY = f.getY(); | |
267 | + } | |
268 | + } | |
269 | + } | |
270 | + if (grabbedObj != null) { | |
271 | + grabbedObj.grab(); | |
272 | + } | |
273 | + } | |
274 | + | |
275 | + public void mouseReleased(MouseEvent e) { | |
276 | + if ((e.getModifiersEx() & e.BUTTON1_DOWN_MASK) == 0) { | |
277 | + startZ = e.getY() + altitude; | |
278 | + startY = e.getY(); | |
279 | + } | |
280 | + if ((e.getModifiersEx() & (e.BUTTON1_DOWN_MASK|e.BUTTON3_DOWN_MASK)) != 0) { | |
281 | + return; | |
282 | + } | |
283 | + if (grabbedObj != null) { | |
284 | + grabbedObj.release(); | |
285 | + grabbedObj = null; | |
286 | + startX = -1; | |
287 | + startY = -1; | |
288 | + startZ = -1; | |
289 | + oX = 0; | |
290 | + oY = 0; | |
291 | + altitude = 0; | |
292 | + } | |
293 | + } | |
294 | + | |
295 | + public void mouseDragged(MouseEvent e) { | |
296 | + if (grabbedObj != null) { | |
297 | + int button = 1; | |
298 | + if ((e.getModifiersEx() & e.BUTTON3_DOWN_MASK) != 0) { | |
299 | + button = 2; | |
300 | + } | |
301 | + Dimension size = mypane.getSize(); | |
302 | + int w = size.width, h = size.height; | |
303 | + int offsetX = 0; | |
304 | + int offsetY = 0; | |
305 | + if (grabbedObj.objType == Obj.YUKKURI) { | |
306 | + int ageState = ((Body)grabbedObj).getAgeState(); | |
307 | + int dia[] = {myPane.maxSize/4, myPane.maxSize/2, myPane.maxSize}; | |
308 | + offsetX = (myPane.maxSize - dia[ageState])/2; | |
309 | + offsetY = (myPane.maxSize - dia[ageState]); | |
310 | + } | |
311 | + else if (grabbedObj.objType == Obj.SHIT) { | |
312 | + int ageState = ((Shit)grabbedObj).getAgeState(); | |
313 | + int dia[] = {10, 20, 30}; | |
314 | + offsetX = (myPane.maxSize - dia[ageState])/2; | |
315 | + offsetY = (myPane.maxSize - dia[ageState]); | |
316 | + } | |
317 | + else if (grabbedObj.objType == Obj.FOOD) { | |
318 | + offsetX = (myPane.maxSize - myPane.foodSize)/2; | |
319 | + offsetY = (myPane.maxSize - myPane.foodSize/2); | |
320 | + } | |
321 | + if (button == 2) { | |
322 | + int X = (e.getX() - oX - offsetX)*Box.maxX/(w-myPane.maxSize); | |
323 | + int Y = (startY - oY - offsetY)*Box.maxY/(h-myPane.maxSize); | |
324 | + int x = Translate.invX(X, Y, Box.maxX, Box.maxY); | |
325 | + int y = Translate.invY(X, Y, Box.maxX, Box.maxY); | |
326 | + grabbedObj.setX(x); | |
327 | + if (startZ - e.getY() > 0) { | |
328 | + altitude = startZ - e.getY(); | |
329 | + grabbedObj.setZ((startZ - e.getY())*Box.maxZ/h); | |
330 | + } | |
331 | + } | |
332 | + else { | |
333 | + int X = (e.getX() - oX - offsetX)*Box.maxX/(w-myPane.maxSize); | |
334 | + int Y = (e.getY() - oY - offsetY + altitude)*Box.maxY/(h-myPane.maxSize); | |
335 | + int x = Translate.invX(X, Y, Box.maxX, Box.maxY); | |
336 | + int y = Translate.invY(X, Y, Box.maxX, Box.maxY); | |
337 | + grabbedObj.setX(x); | |
338 | + grabbedObj.setY(y); | |
339 | + } | |
340 | + } | |
341 | + } | |
342 | + | |
343 | + public void mouseMoved(MouseEvent e) { | |
344 | + if (s1.getSelectedIndex() == 0 || s1.getSelectedIndex() == 1) { // j or n}[ | |
345 | + if (Yukkuri.getAlarm() == false) { | |
346 | + return; | |
347 | + } | |
348 | + Dimension size = mypane.getSize(); | |
349 | + int w = size.width, h = size.height; | |
350 | + for (Body b:Yukkuri.bodyList) { | |
351 | + int ageState = b.getAgeState(); | |
352 | + int dia[] = {myPane.maxSize/4, myPane.maxSize/2, myPane.maxSize}; | |
353 | + int offsetX = (myPane.maxSize - dia[ageState])/2; | |
354 | + int offsetY = (myPane.maxSize - dia[ageState]); | |
355 | + int X = (e.getX() - offsetX)*Box.maxX/(w-myPane.maxSize); | |
356 | + int Y = (e.getY() - offsetY)*Box.maxY/(h-myPane.maxSize); | |
357 | + int x = Translate.invX(X, Y, Box.maxX, Box.maxY); | |
358 | + int y = Translate.invY(X, Y, Box.maxX, Box.maxY); | |
359 | + if (b.isAdult()) { | |
360 | + b.setAngry(); | |
361 | + b.lookTo(x, y); | |
362 | + } | |
363 | + else { | |
364 | + b.runAway(x, y); | |
365 | + } | |
366 | + b.showScare(); | |
367 | + } | |
368 | + } | |
369 | + } | |
370 | + | |
371 | + public void mouseEntered(MouseEvent e) { | |
372 | + setCursor(cr); | |
373 | + } | |
374 | + | |
375 | + public void mouseExited(MouseEvent e) { | |
376 | + setCursor(defCr); | |
377 | + } | |
187 | 378 | } |
188 | 379 | } |
189 | 380 |
@@ -195,7 +386,7 @@ | ||
195 | 386 | private Image[][][] bodyImage = new Image[3][15][2]; |
196 | 387 | private Image[] foodImage = new Image[2]; |
197 | 388 | private Image[] shitImage = new Image[2]; |
198 | - private Image shadowImage; | |
389 | + private Image shadowImage, foodShadow, shitShadow; | |
199 | 390 | private Image backGroundImage; |
200 | 391 | private List <Obj>list4sort = new ArrayList<Obj>(); |
201 | 392 | private int jump[] = {0, 8, 12, 14, 15, 14, 12, 8, 0}; |
@@ -269,11 +460,13 @@ | ||
269 | 460 | shitImage[0] = ImageIO.read(loader.getResourceAsStream("images/unun.png")); |
270 | 461 | shitImage[1] = ImageIO.read(loader.getResourceAsStream("images/unun2.png")); |
271 | 462 | shadowImage = ImageIO.read(loader.getResourceAsStream("images/shadow.png")); |
463 | + foodShadow = ImageIO.read(loader.getResourceAsStream("images/gohan-shadow.png")); | |
464 | + shitShadow = ImageIO.read(loader.getResourceAsStream("images/unun-shadow.png")); | |
272 | 465 | backGroundImage = ImageIO.read(loader.getResourceAsStream("images/back.jpg")); |
273 | 466 | } catch (IOException e1) {System.out.println("File I/O error");} |
274 | 467 | // make initial bodies |
275 | - yukkuri.addBody(10, 20, Body.MARISA, Body.ADULT, Body.JAPANESE); | |
276 | - yukkuri.addBody(120, 20, Body.REIMU, Body.ADULT, Body.JAPANESE); | |
468 | + yukkuri.addBody(10, 20, 0, Body.MARISA, Body.ADULT, Body.JAPANESE); | |
469 | + yukkuri.addBody(120, 20, 0, Body.REIMU, Body.ADULT, Body.JAPANESE); | |
277 | 470 | // run animation |
278 | 471 | while (isRunning) { |
279 | 472 | yukkuri.run(); |
@@ -306,6 +499,7 @@ | ||
306 | 499 | int jumpLevel[] = {4, 2, 1}; |
307 | 500 | // draw face |
308 | 501 | g.drawImage(shadowImage, drX, drY, dia[ageState], dia[ageState], this); |
502 | + drY -= b.getZ()*h/Box.maxZ; // considering z axis | |
309 | 503 | if (!b.isAccessory()) { |
310 | 504 | if (b.isDead()) { |
311 | 505 | g.drawImage(bodyImage[b.getBodyType()][10][b.getDirection()], drX, drY, dia[ageState], dia[ageState], this); |
@@ -314,7 +508,9 @@ | ||
314 | 508 | g.drawImage(bodyImage[b.getBodyType()][9][b.getDirection()], drX, drY, dia[ageState], dia[ageState], this); |
315 | 509 | } |
316 | 510 | else { |
317 | - drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState]; | |
511 | + if (!b.isGrabbed() && b.getZ() == 0) { | |
512 | + drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState]; | |
513 | + } | |
318 | 514 | g.drawImage(bodyImage[b.getBodyType()][8][b.getDirection()],drX, drY, dia[ageState], dia[ageState], this); |
319 | 515 | } |
320 | 516 | } |
@@ -333,7 +529,9 @@ | ||
333 | 529 | } |
334 | 530 | } |
335 | 531 | else if (b.isExciting()) { |
336 | - drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState]; | |
532 | + if (!b.isGrabbed() && b.getZ() == 0) { | |
533 | + drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState]; | |
534 | + } | |
337 | 535 | g.drawImage(bodyImage[b.getBodyType()][2][b.getDirection()], drX, drY, dia[ageState], dia[ageState], this); |
338 | 536 | } |
339 | 537 | else if (b.isSleeping()) { |
@@ -351,12 +549,19 @@ | ||
351 | 549 | else if (b.isDamaged()) { |
352 | 550 | g.drawImage(bodyImage[b.getBodyType()][5][b.getDirection()], drX, drY, dia[ageState], dia[ageState], this); |
353 | 551 | } |
354 | - else if (b.isUngry()) { | |
355 | - drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState]; | |
552 | + else if (b.isScare()) { | |
553 | + g.drawImage(bodyImage[b.getBodyType()][7][b.getDirection()],drX, drY, dia[ageState], dia[ageState], this); | |
554 | + } | |
555 | + else if (b.isAngry()) { | |
556 | + if (!b.isGrabbed() && b.getZ() == 0) { | |
557 | + drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState]; | |
558 | + } | |
356 | 559 | g.drawImage(bodyImage[b.getBodyType()][6][b.getDirection()], drX, drY, dia[ageState], dia[ageState], this); |
357 | 560 | } |
358 | 561 | else { |
359 | - drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState]; | |
562 | + if (!b.isGrabbed() && b.getZ() == 0) { | |
563 | + drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState]; | |
564 | + } | |
360 | 565 | g.drawImage(bodyImage[b.getBodyType()][0][b.getDirection()], drX, drY, dia[ageState], dia[ageState], this); |
361 | 566 | } |
362 | 567 | // draw script |
@@ -375,6 +580,8 @@ | ||
375 | 580 | int offsetY = (maxSize - foodSize/2); |
376 | 581 | int drX = Translate.transX(f.getX(), f.getY(), Box.maxX, Box.maxY)*(w-maxSize)/Box.maxX + offsetX; |
377 | 582 | int drY = Translate.transY(f.getX(), f.getY(), Box.maxX, Box.maxY)*(h-maxSize)/Box.maxY + offsetY; |
583 | + g.drawImage(foodShadow, drX, drY, foodSize, foodSize/2, this); | |
584 | + drY -= f.getZ()*h/Box.maxZ; // considering z axis | |
378 | 585 | if (f.isEmpty()) { |
379 | 586 | g.drawImage(foodImage[0], drX, drY, foodSize, foodSize/2, this); |
380 | 587 | } |
@@ -391,6 +598,8 @@ | ||
391 | 598 | int offsetY = (maxSize - dia[ageState]); |
392 | 599 | int drX = Translate.transX(s.getX(), s.getY(), Box.maxX, Box.maxY)*(w-maxSize)/Box.maxX + offsetX; |
393 | 600 | int drY = Translate.transY(s.getX(), s.getY(), Box.maxX, Box.maxY)*(h-maxSize)/Box.maxY + offsetY; |
601 | + g.drawImage(shitShadow, drX, drY, dia[ageState], dia[ageState], this); | |
602 | + drY -= s.getZ()*h/Box.maxZ; // considering z axis | |
394 | 603 | g.drawImage(shitImage[s.getShitState()], drX, drY, dia[ageState], dia[ageState], this); |
395 | 604 | } |
396 | 605 | break; |
@@ -15,8 +15,8 @@ | ||
15 | 15 | private static final int HUNGRYLIMIT[] = {100*24, 100*24*3, 100*24*7}; |
16 | 16 | private static final int SHITLIMIT[] = {100*8, 100*12, 100*24}; |
17 | 17 | private static final int DAMAGELIMIT[] = {100*24, 100*24*3, 100*24*7}; |
18 | - private static final int BABYLIMIT = 100*24*2; | |
19 | - private static final int CHILDLIMIT = 100*24*7; | |
18 | + private static final int BABYLIMIT = 100*24*7; | |
19 | + private static final int CHILDLIMIT = 100*24*21; | |
20 | 20 | private static final int LIFELIMIT = 100*24*365*5; |
21 | 21 | private static final int HUNGRYNOT = 0; |
22 | 22 | private static final int HUNGRYMUCH = 1; |
@@ -29,7 +29,7 @@ | ||
29 | 29 | private static final int SLEEPPERIOD = 100*3; |
30 | 30 | private static final int ACTIVEPERIOD = 100*6; |
31 | 31 | private static final int NEEDLE = 100; |
32 | - private static final int HAMMER = 100*24; | |
32 | + private static final int HAMMER = 100*24*2; | |
33 | 33 | private static final int HOLDMESSAGE = 15; |
34 | 34 | private static final int STAYLIMIT = 15; |
35 | 35 |
@@ -71,13 +71,15 @@ | ||
71 | 71 | protected boolean toSukkiri = false; |
72 | 72 | protected boolean shitting = false; |
73 | 73 | protected boolean birth = false; |
74 | - protected boolean ungry = false; | |
74 | + protected boolean angry = false; | |
75 | 75 | protected boolean furifuri = false; |
76 | 76 | protected boolean strike = false; |
77 | 77 | protected boolean eating = false; |
78 | 78 | protected boolean peropero = false; |
79 | 79 | protected boolean sukkiri = false; |
80 | + protected boolean scare = false; | |
80 | 81 | protected int language = JAPANESE; |
82 | + protected int falldownDamage = 0; | |
81 | 83 | |
82 | 84 | // private methods |
83 | 85 | private int checkAageState() { |
@@ -119,7 +121,7 @@ | ||
119 | 121 | hungry += TICK; |
120 | 122 | } |
121 | 123 | if (hungry > HUNGRYLIMIT[ageState]) { |
122 | - dead = true; | |
124 | + hungry = HUNGRYLIMIT[ageState]; | |
123 | 125 | } |
124 | 126 | if (hungryState == HUNGRYNOT && checkHungryState() == HUNGRYNOT) { |
125 | 127 | noHungryPeriod += TICK; |
@@ -133,6 +135,9 @@ | ||
133 | 135 | if (hungryState == HUNGRYNOT) { |
134 | 136 | damage -= TICK; |
135 | 137 | } |
138 | + else if (hungry >= HUNGRYLIMIT[ageState]) { | |
139 | + damage += TICK*2; | |
140 | + } | |
136 | 141 | if (damage < 0) { |
137 | 142 | damage = 0; |
138 | 143 | } else if (damage > DAMAGELIMIT[ageState]) { |
@@ -187,10 +192,10 @@ | ||
187 | 192 | } |
188 | 193 | |
189 | 194 | private boolean checkSleep() { |
190 | - if (wakeUpTime + ACTIVEPERIOD < age && excitement == false && relax == true) { | |
195 | + if (wakeUpTime + ACTIVEPERIOD < age && !excitement && relax && !scare) { | |
191 | 196 | toFood = false; |
192 | 197 | sleeping = true; |
193 | - ungry = false; | |
198 | + angry = false; | |
194 | 199 | sleep += TICK; |
195 | 200 | if (sleep > SLEEPPERIOD) { |
196 | 201 | showWakeup(); |
@@ -221,7 +226,8 @@ | ||
221 | 226 | else { |
222 | 227 | excitement = false; |
223 | 228 | relax = true; |
224 | - ungry = false; | |
229 | + angry = false; | |
230 | + scare = false; | |
225 | 231 | showRelax(); |
226 | 232 | } |
227 | 233 | } else { |
@@ -271,6 +277,9 @@ | ||
271 | 277 | showHungry(); |
272 | 278 | } |
273 | 279 | } |
280 | + else if (getZ() != 0) { | |
281 | + showFlying(); | |
282 | + } | |
274 | 283 | } |
275 | 284 | } |
276 | 285 |
@@ -284,7 +293,27 @@ | ||
284 | 293 | stayTime = time; |
285 | 294 | } |
286 | 295 | |
287 | - private void moveBody() { | |
296 | + private void moveBody(boolean dontMove) { | |
297 | + if (grabbed) { | |
298 | + // if grabbed, cannot move. | |
299 | + falldownDamage = 0; | |
300 | + return; | |
301 | + } | |
302 | + if (z != 0) { | |
303 | + // if falling down, cannot move to xy axis | |
304 | + z -= 2; | |
305 | + falldownDamage += 2; | |
306 | + if (z <= 0) { | |
307 | + z = 0; | |
308 | + strike(falldownDamage*100*24*4/Box.maxZ); | |
309 | + } | |
310 | + return; | |
311 | + } | |
312 | + if (dontMove) { | |
313 | + return; | |
314 | + } | |
315 | + | |
316 | + // moving | |
288 | 317 | int sameDest = 30 * STEP[ageState]; |
289 | 318 | int step; |
290 | 319 | if (hasBaby || hungryState == HUNGRYMUCH || damageState == DAMAGEMUCH) { |
@@ -469,6 +498,10 @@ | ||
469 | 498 | System.out.println("Uknown type"); |
470 | 499 | stay(); |
471 | 500 | } |
501 | + | |
502 | + protected void showScare() { | |
503 | + System.out.println("Unknow type"); | |
504 | + } | |
472 | 505 | |
473 | 506 | protected void showDieing() { |
474 | 507 | staying = false; |
@@ -555,13 +588,17 @@ | ||
555 | 588 | public void showHateYukkuri() { |
556 | 589 | System.out.println("Uknown type"); |
557 | 590 | } |
591 | + | |
592 | + protected void showFlying() { | |
593 | + System.out.println("Uknown type"); | |
594 | + } | |
558 | 595 | |
559 | 596 | // public methods |
560 | - public Body(int initX, int initY, int initType, int initAgeState, int language) { | |
597 | + public Body(int initX, int initY, int initZ, int initType, int initAgeState, int language) { | |
561 | 598 | objType = YUKKURI; |
562 | 599 | x = initX; |
563 | 600 | y = initY; |
564 | - z = 0; | |
601 | + z = initZ; | |
565 | 602 | setLanguage(language); |
566 | 603 | yukkuriType = initType; |
567 | 604 | switch (initAgeState) { |
@@ -650,7 +687,7 @@ | ||
650 | 687 | if (dead) { |
651 | 688 | return false; |
652 | 689 | } |
653 | - return(shitting); | |
690 | + return shitting; | |
654 | 691 | } |
655 | 692 | |
656 | 693 | public boolean isExciting() { |
@@ -657,16 +694,23 @@ | ||
657 | 694 | if (dead) { |
658 | 695 | return false; |
659 | 696 | } |
660 | - return(excitement); | |
697 | + return excitement; | |
661 | 698 | } |
662 | 699 | |
663 | - public boolean isUngry() { | |
700 | + public boolean isAngry() { | |
664 | 701 | if (dead) { |
665 | 702 | return false; |
666 | 703 | } |
667 | - return (ungry); | |
704 | + return angry; | |
668 | 705 | } |
669 | 706 | |
707 | + public boolean isScare() { | |
708 | + if (dead) { | |
709 | + return false; | |
710 | + } | |
711 | + return scare; | |
712 | + } | |
713 | + | |
670 | 714 | public boolean isFurifuri() { |
671 | 715 | if (dead) { |
672 | 716 | return false; |
@@ -734,7 +778,7 @@ | ||
734 | 778 | // change state |
735 | 779 | excitement = false; |
736 | 780 | relax = false; |
737 | - ungry = false; | |
781 | + angry = false; | |
738 | 782 | noHungryPeriod = 0; |
739 | 783 | hungry += 100*12; |
740 | 784 | hungryState = checkHungryState(); |
@@ -749,7 +793,7 @@ | ||
749 | 793 | } |
750 | 794 | partner.excitement = false; |
751 | 795 | partner.relax = false; |
752 | - partner.ungry = false; | |
796 | + partner.angry = false; | |
753 | 797 | partner.noHungryPeriod = 0; |
754 | 798 | partner.hungry += 100*24; |
755 | 799 | partner.hungryState = partner.checkHungryState(); |
@@ -776,8 +820,10 @@ | ||
776 | 820 | else { |
777 | 821 | showSurisuri(); |
778 | 822 | } |
779 | - ungry = false; | |
780 | - partner.ungry = false; | |
823 | + angry = false; | |
824 | + partner.angry = false; | |
825 | + scare = false; | |
826 | + partner.scare = false; | |
781 | 827 | //partner.stay(); |
782 | 828 | } |
783 | 829 |
@@ -801,6 +847,19 @@ | ||
801 | 847 | moveTo(toX, toY); |
802 | 848 | } |
803 | 849 | |
850 | + public void lookTo(int toX, int toY) { | |
851 | + if (dead || sleeping) { | |
852 | + return; | |
853 | + } | |
854 | + if (toX > x) { | |
855 | + direction = RIGHT; | |
856 | + } | |
857 | + else if (toX < x) { | |
858 | + direction = LEFT; | |
859 | + } | |
860 | + stay(); | |
861 | + } | |
862 | + | |
804 | 863 | public void eatFood(int amount) { |
805 | 864 | if (dead) { |
806 | 865 | return; |
@@ -816,7 +875,7 @@ | ||
816 | 875 | } |
817 | 876 | showEating(); |
818 | 877 | hungryState = checkHungryState(); |
819 | - ungry = false; | |
878 | + angry = false; | |
820 | 879 | } |
821 | 880 | |
822 | 881 | public void strike(int amount) { |
@@ -826,12 +885,7 @@ | ||
826 | 885 | damage += amount; |
827 | 886 | showScream(); |
828 | 887 | damageState = checkDamageState(); |
829 | - if (damageState == DAMAGENOT && hasAccessory) { | |
830 | - ungry = true; | |
831 | - } | |
832 | - else { | |
833 | - ungry = false; | |
834 | - } | |
888 | + setAngry(); | |
835 | 889 | wakeup(); |
836 | 890 | } |
837 | 891 |
@@ -865,11 +919,49 @@ | ||
865 | 919 | if (damage < 0) { |
866 | 920 | damage = 0; |
867 | 921 | } |
922 | + hungry -= 100*100; | |
923 | + if (hungry < 0) { | |
924 | + hungry = 0; | |
925 | + } | |
868 | 926 | showHealing(); |
869 | 927 | damageState = checkDamageState(); |
870 | - ungry = false; | |
928 | + hungryState = checkHungryState(); | |
929 | + angry = false; | |
930 | + scare = false; | |
931 | + toFood = false; | |
871 | 932 | } |
872 | 933 | |
934 | + public void runAway(int fromX, int fromY) { | |
935 | + if (dead || sleeping || excitement || angry) { | |
936 | + return; | |
937 | + } | |
938 | + int toX, toY; | |
939 | + if (x > fromX) { | |
940 | + toX = Box.maxX; | |
941 | + } | |
942 | + else { | |
943 | + toX = 0; | |
944 | + } | |
945 | + if (y > fromY) { | |
946 | + toY = Box.maxY; | |
947 | + } | |
948 | + else { | |
949 | + toY = 0; | |
950 | + } | |
951 | + moveTo(toX, toY); | |
952 | + toFood = false; | |
953 | + scare = true; | |
954 | + } | |
955 | + | |
956 | + public void setAngry() { | |
957 | + if (damageState == DAMAGENOT && hasAccessory) { | |
958 | + angry = true; | |
959 | + } | |
960 | + else { | |
961 | + angry = false; | |
962 | + } | |
963 | + } | |
964 | + | |
873 | 965 | public void setLanguage(int lang) { |
874 | 966 | language = lang; |
875 | 967 | } |
@@ -940,12 +1032,10 @@ | ||
940 | 1032 | dontMove = true; |
941 | 1033 | } |
942 | 1034 | } |
943 | - | |
1035 | + | |
944 | 1036 | // move to destination |
945 | 1037 | // if there is no destination, walking randomly. |
946 | - if (dontMove == false) { | |
947 | - moveBody(); | |
948 | - } | |
1038 | + moveBody(dontMove); | |
949 | 1039 | |
950 | 1040 | // |
951 | 1041 | checkMessage(); |