• R/O
  • SSH
  • HTTPS

simyukkuri: 提交


Commit MetaInfo

修订版2 (tree)
时间2012-08-23 00:34:27
作者mimisuke

Log Message

First release

更改概述

差异

--- tags/1.3/Yukkuri.java (nonexistent)
+++ tags/1.3/Yukkuri.java (revision 2)
@@ -0,0 +1,197 @@
1+import java.util.*;
2+
3+public class Yukkuri {
4+ public static ArrayList bodyList = new ArrayList();
5+ public static ArrayList foodList = new ArrayList();
6+ public static ArrayList shitList = new ArrayList();
7+
8+ private Random rnd = new Random();
9+
10+ private int distance(int x, int y) {
11+ return x*x + y*y;
12+ }
13+
14+ private boolean checkPartner(Body b) {
15+ if (b.isDead() || b.isSleeping()) {
16+ return false;
17+ }
18+ boolean ret = false;
19+ Body found = null;
20+ int minDistance = Box.maxX * Box.maxY;
21+ // find nearest neighborhood
22+ for (int i = 0; i < bodyList.size(); i++) {
23+ Body partner = (Body)bodyList.get(i);
24+ if (partner == b) {
25+ continue;
26+ }
27+ if (partner.isDead() || (b.isExciting() && !partner.isAdult())) {
28+ continue;
29+ }
30+ int dist, dx, dy;
31+ dx = b.getX() - partner.getX();
32+ dy = b.getY() - partner.getY();
33+ dist = distance(dx, dy);
34+ if (minDistance > dist) {
35+ found = partner;
36+ minDistance = dist;
37+ }
38+ }
39+ if (found != null) {
40+ if (minDistance <= distance(b.getStep(), b.getStep())) {
41+ if (b.isExciting()) {
42+ b.doSukkiri(found);
43+ }
44+ else if (!found.isAccessory()) {
45+ b.showHateYukkuri();
46+ found.strikeByNeedle();
47+ }
48+ else if (rnd.nextInt(20) == 0) {
49+ b.doSurisuri(found);
50+ }
51+ }
52+ else {
53+ if (b.isExciting()) {
54+ b.moveToSukkiri(found.getX(), found.getY());
55+ ret = true;
56+ }
57+ else if (!found.isAccessory() && rnd.nextInt(10) == 0) {
58+ b.showHateYukkuri();
59+ b.moveTo(found.getX(), found.getY());
60+ }
61+ else if (!b.isAdult() && found.isAdult()) {
62+ b.moveTo(found.getX(), found.getY());
63+ }
64+ }
65+ }
66+ return ret;
67+ }
68+
69+ private boolean checkFood(Body b) {
70+ boolean ret = false;
71+ if (b.isSleeping() || b.isDead() || !b.isHungry()) {
72+ return false;
73+ }
74+ Food found = null;
75+ int minDistance = Box.maxX * Box.maxY;
76+ for (int i = 0; i < foodList.size(); i++) {
77+ Food f = (Food)foodList.get(i);
78+ if (f.isEmpty()) {
79+ continue;
80+ }
81+ int distance, dx, dy;
82+ dx = b.getX() - f.getX();
83+ dy = b.getY() - f.getY();
84+ distance = distance(dx, dy);
85+ if (minDistance > distance) {
86+ found = f;
87+ minDistance = distance;
88+ }
89+ }
90+ if (found != null) {
91+ if (minDistance <= distance(b.getStep(), b.getStep())) {
92+ b.eatFood(b.getEatAmount());
93+ found.eatFood(b.getEatAmount());
94+ } else {
95+ // go to nearest food
96+ b.moveToFood(found.getX(), found.getY());
97+ ret = true;
98+ }
99+ }
100+ else {
101+ b.showNoFood();
102+ }
103+ return ret;
104+ }
105+
106+ private boolean checkShit(Body b) {
107+ boolean ret = false;
108+ Shit found = null;
109+ int minDistance = Box.maxX * Box.maxY;
110+ for (int i = 0; i < shitList.size(); i++) {
111+ Shit s = (Shit)shitList.get(i);
112+ int distance, dx, dy;
113+ dx = b.getX() - s.getX();
114+ dy = b.getY() - s.getY();
115+ distance = distance(dx, dy);
116+ if (minDistance > distance) {
117+ found = s;
118+ minDistance = distance;
119+ }
120+ }
121+ if (found != null) {
122+ if (minDistance <= distance(b.getStep(), b.getStep())) {
123+ if (!b.isSleeping() && !b.isExciting()) {
124+ b.showHateShit();
125+ }
126+ }
127+ }
128+ return ret;
129+ }
130+
131+ public void addBody(int x, int y, int type, int age) {
132+ bodyList.add(new Body(x, y, type, age));
133+ }
134+
135+ public void addFood(int x, int y, int type) {
136+ foodList.add(new Food(x, y, type));
137+ }
138+
139+ public void addYukkuriFood(int x, int y) {
140+ addFood(x, y, Food.YUKKURIFOOD);
141+ }
142+
143+ public void addCake(int x, int y) {
144+ addFood(x, y, Food.CAKE);
145+ }
146+
147+ public void addShit(int x, int y, int ageState) {
148+ shitList.add(new Shit(x, y, ageState));
149+ }
150+
151+ public void run() {
152+ int ret = 0;
153+ // Update food state.
154+ for (int i=0; i < foodList.size(); i++) {
155+ Food f = (Food)foodList.get(i);
156+ ret = f.clockTick();
157+ if (ret == Food.REMOVED) {
158+ foodList.remove(i);
159+ }
160+ }
161+ // Update shit state.
162+ for (int i=0; i < shitList.size(); i++) {
163+ Shit s = (Shit)shitList.get(i);
164+ ret = s.clockTick();
165+ if (ret == Shit.REMOVED) {
166+ shitList.remove(i);
167+ }
168+ }
169+ // update body state
170+ for (int i=0; i < bodyList.size(); i++) {
171+ Body b = (Body)bodyList.get(i);
172+ ret = b.clockTick();
173+ switch (ret) {
174+ case Body.DEAD:
175+ continue;
176+ case Body.BIRTHBABY:
177+ addBody(b.getX(), b.getY(), b.getBabyType(), 0);
178+ break;
179+ case Body.DOSHIT:
180+ addShit(b.getX(), b.getY(), b.getAgeState());
181+ break;
182+ case Body.REMOVED:
183+ bodyList.remove(i);
184+ continue;
185+ default:
186+ break;
187+ }
188+
189+ // check Sukkiri
190+ if (!checkPartner(b)) {
191+ // check Food
192+ checkFood(b);
193+ checkShit(b);
194+ }
195+ }
196+ }
197+}
\ No newline at end of file
--- tags/1.3/Food.java (nonexistent)
+++ tags/1.3/Food.java (revision 2)
@@ -0,0 +1,50 @@
1+public class Food extends Obj {
2+ public static final int YUKKURIFOOD = 1;
3+ public static final int CAKE = 2;
4+
5+ private int foodType;
6+ private int amount;
7+
8+ public Food(int initX, int initY, int initType) {
9+ objType = FOOD;
10+ x = initX;
11+ y = initY;
12+ z = 0;
13+ foodType = initType;
14+ switch (initType) {
15+ case YUKKURIFOOD:
16+ amount = 60*60*2;
17+ break;
18+ case CAKE:
19+ amount = 60*60;
20+ break;
21+ default:
22+ amount = 60*60;
23+ }
24+ removed = false;
25+ }
26+
27+ public boolean isEmpty() {
28+ if (amount == 0) {
29+ return true;
30+ }
31+ return false;
32+ }
33+
34+ public void eatFood(int eatAmount) {
35+ if (isEmpty()) {
36+ return;
37+ }
38+ amount -= eatAmount;
39+ if (amount < 0) {
40+ amount = 0;
41+ }
42+ }
43+
44+ public int clockTick() {
45+ if (removed == false) {
46+ return DONOTHING;
47+ }
48+ return REMOVED;
49+ }
50+}
\ No newline at end of file
--- tags/1.3/Shit.java (nonexistent)
+++ tags/1.3/Shit.java (revision 2)
@@ -0,0 +1,22 @@
1+public class Shit extends Obj {
2+ private int ageState;
3+
4+ public Shit (int initX, int initY, int initAgeState) {
5+ objType = SHIT;
6+ x = initX;
7+ y = initY;
8+ ageState = initAgeState;
9+ removed = false;
10+ }
11+
12+ public int getAgeState() {
13+ return ageState;
14+ }
15+
16+ public int clockTick() {
17+ if (removed == false) {
18+ return DONOTHING;
19+ }
20+ return REMOVED;
21+ }
22+}
\ No newline at end of file
--- tags/1.3/Box.java (nonexistent)
+++ tags/1.3/Box.java (revision 2)
@@ -0,0 +1,5 @@
1+public class Box {
2+ public static final int maxX = 300;
3+ public static final int maxY = 300;
4+ public static final int maxZ = 100;
5+}
--- tags/1.3/Obj.java (nonexistent)
+++ tags/1.3/Obj.java (revision 2)
@@ -0,0 +1,45 @@
1+public class Obj {
2+ // Object type
3+ public static final int YUKKURI = 1;
4+ public static final int SHIT = 2;
5+ public static final int FOOD = 3;
6+
7+ // Object event
8+ public static final int BIRTHBABY = 1;
9+ public static final int DOSHIT = 2;
10+ public static final int DEAD = 3;
11+ public static final int REMOVED = 4;
12+ public static final int DONOTHING = 5;
13+
14+ // basic attributes
15+ protected int x, y, z; //location
16+ protected int objType; //YUKKURI, SHIT, FOOD
17+ protected boolean removed = false;
18+
19+ public int getX() {
20+ return x;
21+ }
22+
23+ public int getY() {
24+ return y;
25+ }
26+
27+ public int getZ() {
28+ return z;
29+ }
30+
31+ public int getObjType() {
32+ return objType;
33+ }
34+
35+ public void remove() {
36+ removed = true;
37+ }
38+
39+ public int clockTick() {
40+ if (removed == true) {
41+ return REMOVED;
42+ }
43+ return DONOTHING;
44+ }
45+}
\ No newline at end of file
--- tags/1.3/SimYukkuri.java (nonexistent)
+++ tags/1.3/SimYukkuri.java (revision 2)
@@ -0,0 +1,363 @@
1+import java.awt.*;
2+import java.awt.event.*;
3+import javax.swing.*;
4+import javax.swing.border.*;
5+import java.io.*;
6+import javax.imageio.*;
7+import java.util.ArrayList;
8+import java.util.Collections;
9+import java.util.Comparator;
10+import java.util.List;
11+
12+public class SimYukkuri extends JFrame {
13+ JPanel rootPane = new JPanel();
14+ JPanel buttonPane = new JPanel();
15+ JComboBox s1;
16+ static myPane mypane = new myPane();
17+ static Thread mythread;
18+
19+ public SimYukkuri() {
20+ super("‚µ‚Þ‚ä‚Á‚­‚è");
21+ // setup button pane
22+ buttonPane.setLayout(new GridLayout(20, 1));
23+ buttonPane.setBorder(new LineBorder(Color.gray, 2));
24+ JLabel title = new JLabel("‚µ‚Þ‚ä‚Á‚­‚è Ver1.3@");
25+ buttonPane.add(title);
26+ JLabel l1 = new JLabel("“¹‹ï");
27+ buttonPane.add(l1);
28+ String[] list1 = {"j", "ƒnƒ“ƒ}[", "ƒoƒCƒu", "ƒWƒ…[ƒX", "‚¦‚³", "ƒzƒEƒL", "‚¨‚©‚´‚è"};
29+ s1 = new JComboBox(list1);
30+ buttonPane.add(s1);
31+ // setup my pane
32+ mypane.addMouseListener(new myListener());
33+ // setup root pane
34+ rootPane.setLayout(new BorderLayout());
35+ rootPane.add("Center", mypane);
36+ rootPane.add("East", buttonPane);
37+ // setup my frame
38+ setSize(1024, 600);
39+ setDefaultCloseOperation(EXIT_ON_CLOSE);
40+ setLocation(new Point(100, 100));
41+ setContentPane(rootPane);
42+ setResizable(false);
43+ setVisible(true);
44+ }
45+
46+ public static void main(String[] args) {
47+ SimYukkuri myyukkuri = new SimYukkuri();
48+ mypane.isRunning = true;
49+ mythread = new Thread(mypane);
50+ mythread.start();
51+ }
52+
53+ public class myListener extends MouseAdapter {
54+ public void mouseClicked(MouseEvent e){
55+ Point p = e.getPoint();
56+ Dimension size = mypane.getSize();
57+ int w = size.width, h = size.height;
58+ boolean hit = false;
59+ for (int i = 0; i < Yukkuri.shitList.size() && s1.getSelectedIndex() == 5; i++) {//ƒzƒEƒL
60+ Shit s = (Shit)Yukkuri.shitList.get(i);
61+ int ageState = s.getAgeState();
62+ int dia[] = {10, 20, 30};
63+ int offsetX = (myPane.maxSize - dia[ageState])/2;
64+ int offsetY = (myPane.maxSize - dia[ageState]);
65+ int dx = (int)p.getX() - (Translate.transX(s.getX(), s.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX);
66+ int dy = (int)p.getY() - (Translate.transY(s.getX(), s.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY);
67+ if (dx >= 0 && dx <= dia[ageState] && dy >= 0 && dy <= dia[ageState]) {
68+ s.remove();
69+ hit = true;
70+ }
71+ }
72+ for (int i = 0; i < Yukkuri.foodList.size() && s1.getSelectedIndex() == 5; i++) {//ƒzƒEƒL
73+ Food f = (Food)Yukkuri.foodList.get(i);
74+ int offsetX = (myPane.maxSize - myPane.foodSize)/2;
75+ int offsetY = (myPane.maxSize - myPane.foodSize/2);
76+ int dx = (int)p.getX() - (Translate.transX(f.getX(), f.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX);
77+ int dy = (int)p.getY() - (Translate.transY(f.getX(), f.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY);
78+ if (dx >= 0 && dx <= myPane.foodSize && dy >= 0 && dy <= myPane.foodSize/2) {
79+ f.remove();
80+ hit = true;
81+ }
82+ }
83+ for (int i = 0; i < Yukkuri.bodyList.size(); i++) {
84+ Body b = (Body)Yukkuri.bodyList.get(i);
85+ int ageState = b.getAgeState();
86+ int dia[] = {myPane.maxSize/4, myPane.maxSize/2, myPane.maxSize};
87+ int offsetX = (myPane.maxSize - dia[ageState])/2;
88+ int offsetY = (myPane.maxSize - dia[ageState]);
89+ int dx = (int)p.getX() - (Translate.transX(b.getX(), b.getY(), Box.maxX, Box.maxY)*(w-myPane.maxSize)/Box.maxX + offsetX);
90+ int dy = (int)p.getY() - (Translate.transY(b.getX(), b.getY(), Box.maxX, Box.maxY)*(h-myPane.maxSize)/Box.maxY + offsetY);
91+ if (dx >= 0 && dx <= dia[ageState] && dy >= 0 && dy <= dia[ageState]) {
92+ switch (s1.getSelectedIndex()) {
93+ case 0:
94+ //j
95+ b.strikeByNeedle();
96+ break;
97+ case 1:
98+ //ƒnƒ“ƒ}[
99+ b.strikeByHammer();
100+ break;
101+ case 2:
102+ //ƒoƒCƒu
103+ b.forceSukkiri();
104+ break;
105+ case 3:
106+ //ƒWƒ…[ƒX
107+ b.giveJuice();
108+ break;
109+ case 4:
110+ //‚¦‚³
111+ break;
112+ case 5:
113+ //ƒzƒEƒL
114+ if (b.isDead()) {
115+ b.remove();
116+ }
117+ break;
118+ case 6:
119+ //‚¨‚©‚´‚è
120+ if (b.isAccessory()) {
121+ b.takeAccessory();
122+ }
123+ else {
124+ b.giveAccessory();
125+ }
126+ break;
127+ default:
128+ System.out.println("invalid tool");
129+ }
130+ hit = true;
131+ }
132+ }
133+ if (!hit && s1.getSelectedIndex() == 4) { // 4:‚¦‚³
134+ int offsetX = (myPane.maxSize - mypane.foodSize)/2;
135+ int offsetY = (myPane.maxSize - myPane.foodSize/2);
136+ int X = ((int)p.getX() - offsetX)*Box.maxX/(w-myPane.maxSize);
137+ int Y = ((int)p.getY() - offsetY)*Box.maxY/(h-myPane.maxSize);
138+ int x = Translate.invX(X, Y, Box.maxX, Box.maxY);
139+ int y = Translate.invY(X, Y, Box.maxX, Box.maxY);
140+ if (x >= 0 && x <= Box.maxX && y >= 0 && y <= Box.maxY) {
141+ //‚ä‚Á‚­‚èƒt[ƒh
142+ mypane.yukkuri.addYukkuriFood(x, y);
143+ }
144+ }
145+ }
146+ }
147+}
148+
149+class myPane extends JPanel implements Runnable {
150+ public boolean isRunning = false;
151+ public Yukkuri yukkuri = new Yukkuri();
152+ public static final int maxSize = 128; // max size of icons
153+ public static final int foodSize = 64; // size of food
154+ private Image[][] bodyImage = new Image[3][15];
155+ private Image[] foodImage = new Image[2];
156+ private Image shitImage;
157+ private Image shadowImage;
158+ private Image backGroundImage;
159+ private List <Obj>list4sort = new ArrayList<Obj>();
160+ private int jump[] = {0, 8, 12, 14, 15, 14, 12, 8, 0};
161+
162+ public void run() {
163+ //load images
164+ try {
165+ ClassLoader loader = this.getClass().getClassLoader();
166+ bodyImage[1][0] = ImageIO.read(loader.getResourceAsStream("images/marisa1.png"));
167+ bodyImage[1][1] = ImageIO.read(loader.getResourceAsStream("images/marisa2.png"));
168+ bodyImage[1][2] = ImageIO.read(loader.getResourceAsStream("images/marisa3.png"));
169+ bodyImage[1][3] = ImageIO.read(loader.getResourceAsStream("images/marisa4.png"));
170+ bodyImage[1][4] = ImageIO.read(loader.getResourceAsStream("images/marisa5.png"));
171+ bodyImage[1][5] = ImageIO.read(loader.getResourceAsStream("images/marisa6.png"));
172+ bodyImage[1][6] = ImageIO.read(loader.getResourceAsStream("images/marisa7.png"));
173+ bodyImage[1][7] = ImageIO.read(loader.getResourceAsStream("images/marisa8.png"));
174+ bodyImage[1][8] = ImageIO.read(loader.getResourceAsStream("images/marisa9.png"));
175+ bodyImage[1][9] = ImageIO.read(loader.getResourceAsStream("images/marisa10.png"));
176+ bodyImage[1][10] = ImageIO.read(loader.getResourceAsStream("images/marisa11.png"));
177+ bodyImage[1][11] = ImageIO.read(loader.getResourceAsStream("images/marisa2-1.png"));
178+ bodyImage[1][12] = ImageIO.read(loader.getResourceAsStream("images/marisa2-2.png"));
179+ bodyImage[1][13] = ImageIO.read(loader.getResourceAsStream("images/marisa1-2.png"));
180+ bodyImage[1][14] = ImageIO.read(loader.getResourceAsStream("images/marisa3-2.png"));
181+ bodyImage[2][0] = ImageIO.read(loader.getResourceAsStream("images/reimu1.png"));
182+ bodyImage[2][1] = ImageIO.read(loader.getResourceAsStream("images/reimu2.png"));
183+ bodyImage[2][2] = ImageIO.read(loader.getResourceAsStream("images/reimu3.png"));
184+ bodyImage[2][3] = ImageIO.read(loader.getResourceAsStream("images/reimu4.png"));
185+ bodyImage[2][4] = ImageIO.read(loader.getResourceAsStream("images/reimu5.png"));
186+ bodyImage[2][5] = ImageIO.read(loader.getResourceAsStream("images/reimu6.png"));
187+ bodyImage[2][6] = ImageIO.read(loader.getResourceAsStream("images/reimu7.png"));
188+ bodyImage[2][7] = ImageIO.read(loader.getResourceAsStream("images/reimu8.png"));
189+ bodyImage[2][8] = ImageIO.read(loader.getResourceAsStream("images/reimu9.png"));
190+ bodyImage[2][9] = ImageIO.read(loader.getResourceAsStream("images/reimu10.png"));
191+ bodyImage[2][10] = ImageIO.read(loader.getResourceAsStream("images/reimu11.png"));
192+ bodyImage[2][11] = ImageIO.read(loader.getResourceAsStream("images/reimu2-1.png"));
193+ bodyImage[2][12] = ImageIO.read(loader.getResourceAsStream("images/reimu2-2.png"));
194+ bodyImage[2][13] = ImageIO.read(loader.getResourceAsStream("images/reimu1-2.png"));
195+ bodyImage[2][14] = ImageIO.read(loader.getResourceAsStream("images/reimu3-2.png"));
196+ foodImage[0] = ImageIO.read(loader.getResourceAsStream("images/gohan1.png"));
197+ foodImage[1] = ImageIO.read(loader.getResourceAsStream("images/gohan2.png"));
198+ shitImage = ImageIO.read(loader.getResourceAsStream("images/unun.png"));
199+ shadowImage = ImageIO.read(loader.getResourceAsStream("images/shadow.png"));
200+ backGroundImage = ImageIO.read(loader.getResourceAsStream("images/back.jpg"));
201+ } catch (IOException e1) {System.out.println("File I/O error");}
202+ // make initial bodies
203+ yukkuri.addBody(10, 20, Body.MARISA, Body.ADULT);
204+ yukkuri.addBody(120, 20, Body.REIMU, Body.ADULT);
205+ // run animation
206+ while (isRunning) {
207+ yukkuri.run();
208+ repaint();
209+ try {
210+ Thread.sleep(100);
211+ } catch (InterruptedException e2) {e2.printStackTrace();}
212+ }
213+ }
214+
215+ public void paint(Graphics g) {
216+ list4sort.clear();
217+ list4sort.addAll(Yukkuri.bodyList);
218+ list4sort.addAll(Yukkuri.foodList);
219+ list4sort.addAll(Yukkuri.shitList);
220+ Collections.sort(list4sort, new objComparator());
221+ Dimension size = getSize();
222+ int w = size.width, h = size.height;
223+ g.drawImage(backGroundImage, 0, 0, w, h, this);
224+ for (Obj o : list4sort) {
225+ switch (o.objType) {
226+ case Obj.YUKKURI: {
227+ Body b = (Body)o;
228+ int ageState = b.getAgeState();
229+ int dia[] = {maxSize/4, maxSize/2, maxSize};
230+ int offsetX = (maxSize - dia[ageState])/2;
231+ int offsetY = (maxSize - dia[ageState]);
232+ int drX = Translate.transX(b.getX(), b.getY(), Box.maxX, Box.maxY)*(w-maxSize)/Box.maxX + offsetX;
233+ int drY = Translate.transY(b.getX(), b.getY(), Box.maxX, Box.maxY)*(h-maxSize)/Box.maxY + offsetY;
234+ int jumpLevel[] = {4, 2, 1};
235+ // draw face
236+ g.drawImage(shadowImage, drX, drY, dia[ageState], dia[ageState], this);
237+ if (!b.isAccessory()) {
238+ if (b.isDead()) {
239+ g.drawImage(bodyImage[b.getBodyType()][10], drX, drY, dia[ageState], dia[ageState], this);
240+ }
241+ else if (b.isDamaged()) {
242+ g.drawImage(bodyImage[b.getBodyType()][9], drX, drY, dia[ageState], dia[ageState], this);
243+ }
244+ else {
245+ drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState];
246+ g.drawImage(bodyImage[b.getBodyType()][8],drX, drY, dia[ageState], dia[ageState], this);
247+ }
248+ }
249+ else if (b.isStrike()) {
250+ g.drawImage(bodyImage[b.getBodyType()][7],drX, drY, dia[ageState], dia[ageState], this);
251+ }
252+ else if (b.isShitting() || b.isBirth()) {
253+ g.drawImage(bodyImage[b.getBodyType()][1], drX, drY, dia[ageState], dia[ageState], this);
254+ }
255+ else if (b.isFurifuri()) {
256+ if (b.getAge() % 8 <= 3) {
257+ g.drawImage(bodyImage[b.getBodyType()][11], drX, drY, dia[ageState], dia[ageState], this);
258+ }
259+ else if (b.getAge() % 8 <= 7) {
260+ g.drawImage(bodyImage[b.getBodyType()][12], drX, drY, dia[ageState], dia[ageState], this);
261+ }
262+ }
263+ else if (b.isExciting()) {
264+ drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState];
265+ g.drawImage(bodyImage[b.getBodyType()][2], drX, drY, dia[ageState], dia[ageState], this);
266+ }
267+ else if (b.isSleeping()) {
268+ g.drawImage(bodyImage[b.getBodyType()][3], drX, drY, dia[ageState], dia[ageState], this);
269+ }
270+ else if (b.isPeroPero() || b.isEating()) {
271+ g.drawImage(bodyImage[b.getBodyType()][13], drX, drY, dia[ageState], dia[ageState], this);
272+ }
273+ else if (b.isSukkiri()) {
274+ g.drawImage(bodyImage[b.getBodyType()][14], drX, drY, dia[ageState], dia[ageState], this);
275+ }
276+ else if (b.isDead()) {
277+ g.drawImage(bodyImage[b.getBodyType()][4], drX, drY, dia[ageState], dia[ageState], this);
278+ }
279+ else if (b.isDamaged()) {
280+ g.drawImage(bodyImage[b.getBodyType()][5], drX, drY, dia[ageState], dia[ageState], this);
281+ }
282+ else if (b.isUngry()) {
283+ drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState];
284+ g.drawImage(bodyImage[b.getBodyType()][6], drX, drY, dia[ageState], dia[ageState], this);
285+ }
286+ else {
287+ drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState];
288+ g.drawImage(bodyImage[b.getBodyType()][0], drX, drY, dia[ageState], dia[ageState], this);
289+ }
290+ // draw script
291+ if (b.getMessage() != null) {
292+ g.setColor(Color.white);
293+ g.fillRoundRect(drX+14, drY-14, b.getMessage().length()*13+4, 16, 8, 8);
294+ g.setColor(Color.black);
295+ g.drawRoundRect(drX+14, drY-14, b.getMessage().length()*13+4, 16, 8, 8);
296+ g.drawString(b.getMessage(), drX+14+2, drY);
297+ }
298+ }
299+ break;
300+ case Obj.FOOD: {
301+ Food f = (Food)o;
302+ int offsetX = (maxSize - foodSize)/2;
303+ int offsetY = (maxSize - foodSize/2);
304+ int drX = Translate.transX(f.getX(), f.getY(), Box.maxX, Box.maxY)*(w-maxSize)/Box.maxX + offsetX;
305+ int drY = Translate.transY(f.getX(), f.getY(), Box.maxX, Box.maxY)*(h-maxSize)/Box.maxY + offsetY;
306+ if (f.isEmpty()) {
307+ g.drawImage(foodImage[0], drX, drY, foodSize, foodSize/2, this);
308+ }
309+ else {
310+ g.drawImage(foodImage[1], drX, drY, foodSize, foodSize/2, this);
311+ }
312+ }
313+ break;
314+ case Obj.SHIT: {
315+ Shit s = (Shit)o;
316+ int ageState = s.getAgeState();
317+ int dia[] = {10, 20, 30};
318+ int offsetX = (maxSize - dia[ageState])/2;
319+ int offsetY = (maxSize - dia[ageState]);
320+ int drX = Translate.transX(s.getX(), s.getY(), Box.maxX, Box.maxY)*(w-maxSize)/Box.maxX + offsetX;
321+ int drY = Translate.transY(s.getX(), s.getY(), Box.maxX, Box.maxY)*(h-maxSize)/Box.maxY + offsetY;
322+ g.drawImage(shitImage, drX, drY, dia[ageState], dia[ageState], this);
323+ }
324+ break;
325+ }
326+ }
327+ }
328+}
329+
330+class objComparator implements Comparator {
331+ public int compare(Object arg0, Object arg1) {
332+ Obj o1 = (Obj)arg0;
333+ Obj o2 = (Obj)arg1;
334+ if (o1.getY() > o2.getY()) {
335+ return 1;
336+ } else if (o1.getY() < o2.getY()) {
337+ return -1;
338+ } else {
339+ return 0;
340+ }
341+ }
342+}
343+
344+class Translate {
345+ static final private double m = 1.0 / 8.0;
346+ static final private double n = 7.0 / 8.0;
347+
348+ static public int transX(int x, int y, int X, int Y) {
349+ return (int)(((n-m)*Y*x - m*X*y + m*X*Y)/((n-m-1)*y + Y));
350+ }
351+
352+ static public int transY(int x, int y, int X, int Y) {
353+ return (int)(((n-m)*Y*y)/((n-m-1)*y + Y));
354+ }
355+
356+ static public int invX(int x, int y, int X, int Y) {
357+ return (int)((Y*x + m*X*y - m*X*Y)/((n-m)*Y - (n-m-1)*y));
358+ }
359+
360+ static public int invY(int x, int y, int X, int Y) {
361+ return (int)(Y*y/((n-m)*Y - (n-m-1)*y));
362+ }
363+}
\ No newline at end of file
--- tags/1.3/Body.java (nonexistent)
+++ tags/1.3/Body.java (revision 2)
@@ -0,0 +1,1137 @@
1+import java.util.Random;
2+
3+public class Body extends Obj {
4+ // public variables
5+ public static final int MARISA = 1;
6+ public static final int REIMU = 2;
7+ public static final int EATAMOUNT[] = {100*4, 100*6, 100*8};
8+ public static final int BABY = 0;
9+ public static final int CHILD = 1;
10+ public static final int ADULT = 2;
11+
12+ // private variables
13+ private static final int HUNGRYLIMIT[] = {100*24, 100*24*3, 100*24*7};
14+ private static final int SHITLIMIT[] = {100*8, 100*12, 100*24};
15+ private static final int DAMAGELIMIT[] = {100*24, 100*24*3, 100*24*7};
16+ private static final int BABYLIMIT = 100*24*2;
17+ private static final int CHILDLIMIT = 100*24*7;
18+ private static final int LIFELIMIT = 100*24*365*5;
19+ private static final int HUNGRYNOT = 0;
20+ private static final int HUNGRYMUCH = 1;
21+ private static final int DAMAGENOT = 0;
22+ private static final int DAMAGEMUCH = 1;
23+ private static final int STEP[] = {1, 2, 4};
24+ private static final int RELAXPERIOD = 100*1;
25+ private static final int EXCITEPERIOD = 100*3;
26+ private static final int PREGPERIOD = 100*24;
27+ private static final int SLEEPPERIOD = 100*3;
28+ private static final int ACTIVEPERIOD = 100*6;
29+ private static final int NEEDLE = 100;
30+ private static final int HAMMER = 100*24;
31+ private static final int TICK = 1;
32+ private static final int HOLDMESSAGE = 15;
33+ private static final int STAYLIMIT = 15;
34+
35+ private long age; //counter indicating age
36+ private int ageState; //BABY, CHILD, ADULT
37+ private String messageBuf;
38+ private int yukkuriType;
39+ private int dextX = -1, destY = -1; //destination
40+ private int damage = 0; //counter indicating damage
41+ private int damageState = DAMAGENOT;
42+ private int hungry = 0; //counter indicating how hungry
43+ private int hungryState = HUNGRYNOT;
44+ private int shit = 0;
45+ private int noDamagePeriod = 0;
46+ private int noHungryPeriod = 0;
47+ private boolean hasAccessory = true; //true if having accessory
48+ private boolean hasBaby = false; //having baby or not
49+ private int babyType;
50+ private int pregnant = 0;
51+ private boolean dead = false; // dead of alive
52+ private boolean excitement = false; //
53+ private int excite = 0;
54+ private boolean relax = false;
55+ private boolean sleeping = false;
56+ private int sleep = 0;
57+ private long wakeUpTime;
58+ private Random rnd = new Random();
59+ private int countX = 0, countY = 0; // how many steps to same direction
60+ private int dirX = 0, dirY = 0; // direction to move on
61+ private int messageCount = 0;
62+ private boolean staying = false;
63+ private int staycount = 0;
64+ private int stayTime = STAYLIMIT;
65+ private boolean toFood = false;
66+ private boolean toSukkiri = false;
67+ private boolean shitting = false;
68+ private boolean birth = false;
69+ private boolean ungry = false;
70+ private boolean furifuri = false;
71+ private boolean strike = false;
72+ private boolean eating = false;
73+ private boolean peropero = false;
74+ private boolean sukkiri = false;
75+
76+ // private methods
77+ private int checkAageState() {
78+ int state;
79+ if (age < BABYLIMIT) {
80+ state = BABY;
81+ } else if (age < CHILDLIMIT) {
82+ state = CHILD;
83+ } else {
84+ state = ADULT;
85+ }
86+ return state;
87+ }
88+
89+ private int checkHungryState() {
90+ int state;
91+ if (hungry < HUNGRYLIMIT[ageState]/4) {
92+ state = HUNGRYNOT;
93+ } else {
94+ state = HUNGRYMUCH;
95+ }
96+ return state;
97+ }
98+
99+ private int checkDamageState() {
100+ int state;
101+ if (damage < DAMAGELIMIT[ageState]/2) {
102+ state = DAMAGENOT;
103+ } else {
104+ state = DAMAGEMUCH;
105+ }
106+ return state;
107+ }
108+
109+ private void checkHungry() {
110+ if (excitement == true || hasBaby == true) {
111+ hungry += TICK*2;
112+ } else {
113+ hungry += TICK;
114+ }
115+ if (hungry > HUNGRYLIMIT[ageState]) {
116+ dead = true;
117+ }
118+ if (hungryState == HUNGRYNOT && checkHungryState() == HUNGRYNOT) {
119+ noHungryPeriod += TICK;
120+ } else {
121+ noHungryPeriod = 0;
122+ }
123+ hungryState = checkHungryState();
124+ }
125+
126+ private void checkDamage() {
127+ if (hungryState == HUNGRYNOT) {
128+ damage -= TICK;
129+ }
130+ if (damage < 0) {
131+ damage = 0;
132+ } else if (damage > DAMAGELIMIT[ageState]) {
133+ dead = true;
134+ }
135+ if (damageState == DAMAGENOT && checkDamageState() == DAMAGENOT) {
136+ noDamagePeriod += TICK;
137+ } else {
138+ noDamagePeriod = 0;
139+ }
140+ damageState = checkDamageState();
141+ }
142+
143+ private boolean checkShit() {
144+ boolean cantMove = false;
145+ if (hungryState == HUNGRYNOT) {
146+ shit += TICK*2;
147+ } else {
148+ shit += TICK;
149+ }
150+ if (shit > SHITLIMIT[ageState] - TICK*100) {
151+ cantMove = true;
152+ shitting = true;
153+ showShit();
154+ }
155+ if (shit > SHITLIMIT[ageState]) {
156+ shitting = false;
157+ shit = 0;
158+ showShit2();
159+ }
160+ return cantMove;
161+ }
162+
163+ private boolean checkPregnant() {
164+ boolean cantMove = false;
165+ if (hasBaby) {
166+ pregnant += TICK;
167+ if (pregnant > PREGPERIOD - TICK*100) {
168+ cantMove = true;
169+ birth = true;
170+ showBreed();
171+ }
172+ if (pregnant > PREGPERIOD) {
173+ // Keep babyType for generating baby.
174+ pregnant = 0;
175+ birth = false;
176+ hasBaby = false;
177+ showBreed2();
178+ }
179+ }
180+ return cantMove;
181+ }
182+
183+ private boolean checkSleep() {
184+ if (wakeUpTime + ACTIVEPERIOD < age && excitement == false && relax == true) {
185+ toFood = false;
186+ sleeping = true;
187+ ungry = false;
188+ sleep += TICK;
189+ if (sleep > SLEEPPERIOD) {
190+ showWakeup();
191+ wakeup();
192+ }
193+ } else {
194+ sleep = 0;
195+ sleeping = false;
196+ }
197+ return sleeping;
198+ }
199+
200+ private void wakeup() {
201+ sleep = 0;
202+ sleeping = false;
203+ wakeUpTime = age;
204+ }
205+
206+ private void checkExciteAndRelax() {
207+ if (noHungryPeriod > RELAXPERIOD && noDamagePeriod > RELAXPERIOD && !sleeping && hasAccessory) {
208+ if (excitement == false && relax == false) {
209+ int r = rnd.nextInt(24);
210+ if (ageState == ADULT && hasBaby == false && r == 0) {
211+ excitement = true;
212+ relax = false;
213+ showExcite();
214+ }
215+ else {
216+ excitement = false;
217+ relax = true;
218+ ungry = false;
219+ showRelax();
220+ }
221+ } else {
222+ excite += TICK;
223+ if (excite > EXCITEPERIOD) {
224+ excite = 0;
225+ excitement = false;
226+ relax = false;
227+ }
228+ }
229+ }
230+ if (hungryState != HUNGRYNOT || damageState != DAMAGENOT || !hasAccessory) {
231+ relax = false;
232+ wakeup();
233+ }
234+ }
235+
236+ private void checkMessage() {
237+ if (--messageCount <= 0) {
238+ messageCount = 0;
239+ messageBuf = null;
240+ furifuri = false;
241+ strike = false;
242+ eating = false;
243+ peropero = false;
244+ sukkiri = false;
245+ }
246+ if (dead) {
247+ String messages[] = {"‚à‚Á‚¿‚å‚ä‚Á‚­‚¿‚µ‚¿‚á‚©‚Á‚½AAA", "‚à‚Á‚¿‚å‚ä‚Á‚­‚¿‚µ‚¿‚á‚©‚Á‚½AAA", "‚à‚Á‚Æ‚ä‚Á‚­‚肵‚½‚©‚Á‚½AAA"};
248+ setMessage(messages[ageState]);
249+ } else if (messageBuf == null) {
250+ if (toFood) {
251+ showWantFood();
252+ }
253+ else if (toSukkiri) {
254+ showExcite();
255+ }
256+ else if (sleeping) {
257+ if (rnd.nextInt(10) == 0) {
258+ showSleep();
259+ }
260+ }
261+ else if (!hasAccessory) {
262+ showNoAccessory();
263+ }
264+ else if (isHungry()) {
265+ if (rnd.nextInt(15) == 0) {
266+ showHungry();
267+ }
268+ }
269+ }
270+ }
271+
272+ private void stay() {
273+ staying = true;
274+ stayTime = STAYLIMIT;
275+ }
276+
277+ private void stay(int time) {
278+ staying = true;
279+ stayTime = time;
280+ }
281+
282+ private void moveBody() {
283+ int sameDest = 30 * STEP[ageState];
284+ int step;
285+ if (hasBaby || hungryState == HUNGRYMUCH || damageState == DAMAGEMUCH) {
286+ step = STEP[ageState]/2;
287+ } else {
288+ step = STEP[ageState];
289+ }
290+ if (step == 0) {
291+ step = 1;
292+ }
293+ int freq = STEP[ADULT]/step;
294+ if (age % freq != 0) {
295+ return;
296+ }
297+ step = 1;
298+ // calculate x axis
299+ if (dextX >= 0) {
300+ if (dextX - x > step) {
301+ x += step;
302+ } else if (x - dextX > step) {
303+ x -= step;
304+ } else {
305+ dextX = -1;
306+ }
307+ } else {
308+ if (countX++ == 0) {
309+ int r = rnd.nextInt(2);
310+ switch (dirX) {
311+ case 0: {
312+ if (r == 0) {
313+ dirX = 1;
314+ } else {
315+ dirX = -1;
316+ }
317+ break;
318+ }
319+ case 1: {
320+ if (r == 0) {
321+ dirX = 0;
322+ }
323+ break;
324+ }
325+ case -1: {
326+ if (r == 0) {
327+ dirX = 0;
328+ }
329+ break;
330+ }
331+ default:
332+ break;
333+ }
334+ } else {
335+ if (countX++ >= sameDest) {
336+ countX = 0;
337+ }
338+ }
339+ x += dirX * step;
340+ }
341+ if (x < 0) {
342+ x = 0;
343+ dirX *= -1;
344+ } else if (x > Box.maxX) {
345+ x = Box.maxX;
346+ dirX *= -1;
347+ }
348+ // calculate y axis
349+ if (destY >= 0) {
350+ if (destY - y > step) {
351+ y += step;
352+ } else if (y - destY > step) {
353+ y -= step;
354+ } else {
355+ destY = -1;
356+ }
357+ } else {
358+ if (countY++ == 0) {
359+ int r = rnd.nextInt(2);
360+ switch (dirY) {
361+ case 0: {
362+ if (r == 0) {
363+ dirY = 1;
364+ } else {
365+ dirY = -1;
366+ }
367+ break;
368+ }
369+ case 1: {
370+ if (r == 0) {
371+ dirY = 0;
372+ }
373+ break;
374+ }
375+ case -1: {
376+ if (r == 0) {
377+ dirY = 0;
378+ }
379+ break;
380+ }
381+ default:
382+ break;
383+ }
384+ } else {
385+ if (countY++ >= sameDest) {
386+ countY = 0;
387+ }
388+ }
389+ y += dirY * step;
390+ }
391+ if (y < 0) {
392+ y = 0;
393+ dirY *= -1;
394+ } else if (y > Box.maxY) {
395+ y = Box.maxY;
396+ dirY *= -1;
397+ }
398+ }
399+
400+ private void setMessage(String message) {
401+ if (staying == true && messageBuf != null) {
402+ return;
403+ }
404+ messageCount = HOLDMESSAGE;
405+ messageBuf = message;
406+ }
407+ private void setMessage(String message, int count) {
408+ if (staying == true && messageBuf != null) {
409+ return;
410+ }
411+ messageCount = count;
412+ messageBuf = message;
413+ }
414+
415+ private void showWantFood() {
416+ switch (yukkuriType) {
417+ case MARISA: {
418+ String messages[] = {"‚²‚Í‚ñ‚µ‚á‚ñ‚Ì‚É‚¨‚¢‚ª‚µ‚ã‚è‚ã‚Ì‚¶‚¥", "‚²‚Í‚ñ‚µ‚á‚ñ‚Ì‚É‚¨‚¢‚ª‚·‚é‚Ì‚¶‚¥", "‚²‚Í‚ñ‚³‚ñ‚Ì‚É‚¨‚¢‚ª‚·‚é‚Ì‚º"};
419+ setMessage(messages[ageState]);
420+ }
421+ break;
422+ case REIMU: {
423+ String messages[] = {"‚²‚Í‚ñ‚µ‚á‚ñ‚Ì‚É‚¨‚¢‚ª‚·‚è‚ã‚æ", "‚²‚Í‚ñ‚µ‚á‚ñ‚Ì‚É‚¨‚¢‚ª‚·‚è‚ã‚æ", "‚²‚Í‚ñ‚³‚ñ‚Ì‚É‚¨‚¢‚ª‚·‚é‚æ"};
424+ setMessage(messages[ageState]);
425+ }
426+ break;
427+ default:
428+ System.out.println("Uknown type");
429+ break;
430+ }
431+ }
432+
433+ public void showNoFood() {
434+ if (toFood == false) {
435+ return;
436+ }
437+ toFood = false;
438+ switch (yukkuriType) {
439+ case MARISA: {
440+ String messages[][] = {{"‚²‚Í‚ñ‚µ‚á‚ñ‚É‚á‚¢‚æI", "‚²‚Í‚ñ‚µ‚á‚ñ‚É‚á‚¢‚ɂ傶‚¥H‚΂«‚á‚Ȃ́H‚µ‚É‚ã‚́H", "‚²‚Í‚ñ‚³‚ñ‚È‚¢‚Ì‚ºH‚΂©‚Ȃ́H‚µ‚ʂ́H"},
441+ {"‚²‚Í‚ñ‚µ‚á‚ñ‚©‚¦‚¿‚āAAA", "‚²‚Í‚ñ‚µ‚á‚ñ‚©‚¦‚¿‚āAAA", "‚²‚Í‚ñ‚³‚ñ‚ª‚¦‚À‚Å‚®‚¾‚´‚¢‚¡AAA"}};
442+ setMessage(messages[damageState][ageState]);
443+ }
444+ break;
445+ case REIMU: {
446+ String messages[][] = {{"‚²‚Í‚ñ‚µ‚á‚ñ‚É‚á‚¢‚æI", "‚²‚Í‚ñ‚µ‚á‚ñ‚É‚á‚¢‚æH‚΂«‚á‚Ȃ́H‚µ‚É‚ã‚́H", "‚²‚Í‚ñ‚³‚ñ‚È‚¢‚æH‚΂©‚Ȃ́H‚µ‚ʂ́H"},
447+ {"‚²‚Í‚ñ‚µ‚á‚ñ‚©‚¦‚¿‚āAAA", "‚²‚Í‚ñ‚µ‚á‚ñ‚©‚¦‚¿‚āAAA", "‚²‚Í‚ñ‚³‚ñ‚ª‚¦‚À‚Å‚®‚¾‚´‚¢‚¡AAA"}};
448+ setMessage(messages[damageState][ageState]);
449+ }
450+ break;
451+ default:
452+ System.out.println("Uknown type");
453+ break;
454+ }
455+ stay();
456+ }
457+
458+ private void showExcite() {
459+ if (excitement) {
460+ switch(yukkuriType) {
461+ case MARISA: {
462+ setMessage("‚·‚Á‚¬‚肶‚¾‚¢‚Ì‚º`I");
463+ }
464+ break;
465+ case REIMU: {
466+ setMessage("‚·‚Á‚¬‚肶‚¾‚¢‚́`I");
467+ }
468+ break;
469+ }
470+ }
471+ }
472+
473+ private void showRelax() {
474+ switch (yukkuriType) {
475+ case MARISA: {
476+ if (rnd.nextInt(2) == 0) {
477+ String messages[] = {"‚Ӂ[‚è‚Ӂ[‚è", "‚Ü‚è‚¿‚á‚Í‚³‚¢‚Á‚«‚傤‚ɂ傶‚¥I", "‚܂肳‚Í‚³‚¢‚Á‚«‚傤‚È‚Ì‚ºI"};
478+ furifuri = true;
479+ setMessage(messages[ageState], 30);
480+ stay(30);
481+ }
482+ else {
483+ String messages[] = {"‚ä‚Á‚«‚ã‚肵‚Ä‚¢‚Á‚¿‚¥‚ˁI", "‚ä‚Á‚«‚ã‚肵‚Ä‚¢‚Á‚¿‚¥‚ˁI", "‚ä‚Á‚­‚肵‚Ä‚¢‚Á‚ĂˁI"};
484+ setMessage(messages[ageState]);
485+ stay();
486+ }
487+ }
488+ break;
489+ case REIMU: {
490+ if (rnd.nextInt(2) == 0) {
491+ String messages[] = {"‚Ӂ[‚è‚Ӂ[‚è", "‚ê‚¢‚Ý‚ã‚©‚í‚¢‚«‚ã‚Ä‚²‚Ý‚¥‚ñ‚ˁI", "‚ê‚¢‚Þ‚Ì‚ ‚É‚á‚é‚Å‚µ‚±‚Á‚Ä‚à‚¢‚¢‚æI"};
492+ furifuri = true;
493+ setMessage(messages[ageState], 30);
494+ stay(30);
495+ }
496+ else {
497+ String messages[] = {"‚ä‚Á‚«‚ã‚肵‚Ä‚¢‚Á‚¿‚¥‚ˁI", "‚ä‚Á‚«‚ã‚肵‚Ä‚¢‚Á‚¿‚¥‚ˁI", "‚ä‚Á‚­‚肵‚Ä‚¢‚Á‚ĂˁI"};
498+ setMessage(messages[ageState]);
499+ stay();
500+ }
501+ }
502+ break;
503+ default:
504+ System.out.println("Uknown type");
505+ break;
506+ }
507+ }
508+
509+ private void showWakeup() {
510+ String messages[] = {"‚ä‚Á‚«‚ã‚肵‚Ä‚¢‚Á‚¿‚¥‚ˁI", "‚ä‚Á‚«‚ã‚肵‚Ä‚¢‚Á‚¿‚¥‚ˁI", "‚ä‚Á‚­‚肵‚Ä‚¢‚Á‚ĂˁI"};
511+ setMessage(messages[ageState]);
512+ stay();
513+ }
514+
515+ private void showSleep() {
516+ if (sleep != 0) {
517+ setMessage("‚·[‚â‚·[‚â");
518+ }
519+ }
520+
521+ private void showScream() {
522+ staying = false;
523+ strike = true;
524+ switch (yukkuriType) {
525+ case MARISA: {
526+ String messages[][] = {{"‚ä‚ñ‚â[I", "‚¢‚¿‚á‚¢I‚Õ‚«‚ã[‚·‚é‚Ì‚¶‚¥I", "‚â‚ß‚é‚ñ‚¾‚ºI‚Õ‚­[‚¾‚ºI"},
527+ {"‚â‚ß‚¿‚¥‚É‚¥‚â‚ß‚¿‚¥‚É‚¥AAA", "‚²‚ß‚ñ‚É‚á‚¿‚á‚¢‚â‚ß‚¿‚¥‚ˁAAA", "‚¨‚Ë‚ª‚¢‚¶‚΂¸A‚â‚ß‚Å‚®‚¾‚´‚¢AAA"}};
528+ setMessage(messages[damageState][ageState]);
529+ }
530+ break;
531+ case REIMU: {
532+ String messages[][] = {{"‚ä‚ñ‚â[I", "‚¢‚¿‚á‚¢I‚Õ‚«‚ã[‚¶‚á‚æI", "‚¢‚½‚¢I‚Õ‚­[‚¾‚æI"},
533+ {"‚â‚ß‚¿‚¥‚É‚¥‚â‚ß‚¿‚¥‚É‚¥", "‚²‚ß‚ñ‚È‚¿‚á‚¢‚â‚ß‚¿‚¥‚É‚¥AAA", "‚Ç‚Ú‚¶‚Å‚Å‚¢‚Ô‚É‚±‚ñ‚È‚²‚Ç‚¸‚é‚Ì‚§AAA"}};
534+ setMessage(messages[damageState][ageState]);
535+ }
536+ break;
537+ default:
538+ System.out.println("Uknown type");
539+ break;
540+ }
541+ stay();
542+ }
543+
544+ private void showDieing() {
545+ staying = false;
546+ switch (yukkuriType) {
547+ case MARISA: {
548+ String messages[] = {"‚ä‚ׂÁI", "‚Õ‚«‚ã‚ÁI", "‚Ô‚Ú‚ÁI"};
549+ setMessage(messages[ageState]);
550+ }
551+ break;
552+ case REIMU: {
553+ String messages[] = {"‚ä‚ׂÁI", "‚Õ‚«‚ã‚ÁI", "‚°‚Ú‚ÁI"};
554+ setMessage(messages[ageState]);
555+ }
556+ break;
557+ default:
558+ System.out.println("Uknown type");
559+ break;
560+ }
561+ stay();
562+ }
563+
564+ private void showEating() {
565+ eating = true;
566+ switch (yukkuriType) {
567+ case MARISA: {
568+ String messages[][] = {{"‚ށ`‚¿‚á‚ށ`‚¿‚áA‚¿‚ ‚í‚¿‚¥[", "‚ށ[‚¿‚á‚ށ[‚¿‚áA‚¿‚ ‚í‚¿‚¥[", "‚ށ[‚µ‚á‚ށ[‚µ‚áA‚µ‚ ‚킹["},
569+ {"‚Þ‚Á‚¿‚á‚Þ‚Á‚¿‚áAAA", "‚Þ‚¿‚á‚Þ‚¿‚áA‚Í‚Ó‚Í‚Ó", "‚Þ‚Á‚µ‚á‚Þ‚Á‚µ‚áA‚ß‚Á‚¿‚Ⴄ‚ß‚¥"}};
570+ setMessage(messages[hungryState][ageState]);
571+ }
572+ break;
573+ case REIMU: {
574+ String messages[][] = {{"‚ށ`‚¿‚á‚ށ`‚¿‚áA‚¿‚ ‚í‚¿‚¥[", "‚ށ[‚¿‚á‚ށ[‚¿‚áA‚¿‚ ‚í‚¿‚¥[", "‚ށ[‚µ‚á‚ށ[‚µ‚áA‚µ‚ ‚킹["},
575+ {"‚Þ‚Á‚¿‚á‚Þ‚Á‚¿‚áAAA", "‚Þ‚¿‚á‚Þ‚¿‚áA‚Í‚Ó‚Í‚Ó", "‚Þ‚Á‚µ‚á‚Þ‚Á‚µ‚áA‚¤‚ß‚¥"}};
576+ setMessage(messages[hungryState][ageState]);
577+ }
578+ break;
579+ default:
580+ System.out.println("Uknown type");
581+ break;
582+ }
583+ stay();
584+ }
585+
586+ private void showFull() {
587+ switch (yukkuriType) {
588+ case MARISA: {
589+ String messages[] = {"‚¨‚É‚á‚©‚¢‚Á‚Ï‚¢AAA", "‚¨‚É‚á‚©‚¢‚Á‚Ï‚¢AAA", "‚à‚¤‚½‚ׂç‚ê‚È‚¢‚Ì‚ºAAA"};
590+ setMessage(messages[ageState]);
591+ }
592+ break;
593+ case REIMU: {
594+ String messages[] = {"‚¨‚É‚á‚©‚¢‚Á‚Ï‚¢AAA", "‚¨‚É‚á‚©‚¢‚Á‚Ï‚¢AAA", "‚à‚¤‚½‚ׂç‚ê‚È‚¢‚́AAA"};
595+ setMessage(messages[ageState]);
596+ }
597+ break;
598+ default:
599+ System.out.println("Uknown type");
600+ break;
601+ }
602+ stay();
603+ }
604+
605+ private void showHealing() {
606+ switch (yukkuriType) {
607+ case MARISA: {
608+ String messages[][] = {{"‚ ‚Ý‚á‚ ‚Ý‚áI", "‚ä‚Á‚«‚ã‚¿‚µ‚¿‚á‚Ì‚¶‚¥I", "‚ä‚Á‚­‚肵‚½‚Ì‚ºI"},
609+ {"‚ ‚Ý‚á‚ ‚Ý‚á", "‚ä‚Á‚«‚ã‚¿‚µ‚¿‚á‚æ", "‚ä‚Á‚­‚肵‚½‚Ì‚º"}};
610+ setMessage(messages[damageState][ageState]);
611+ }
612+ break;
613+ case REIMU: {
614+ String messages[][] = {{"‚ ‚Ý‚ã‚ ‚Ý‚áI", "‚ä‚Á‚«‚ã‚¿‚µ‚¿‚á‚æI", "‚ä‚Á‚­‚肵‚½‚æI"},
615+ {"‚ ‚Ý‚á‚ ‚Ý‚á", "‚ä‚Á‚«‚ã‚¿‚µ‚¿‚á‚æ", "‚ä‚Á‚­‚肵‚½‚æ"}};
616+ setMessage(messages[damageState][ageState]);
617+ }
618+ break;
619+ default:
620+ System.out.println("Uknown type");
621+ break;
622+ }
623+ stay();
624+ }
625+
626+ private void showSukkiri() {
627+ String messages[] = {"‚¿‚ã‚Á‚«‚¿I", "‚¿‚ã‚Á‚«‚èI", "‚·‚Á‚«‚èI"};
628+ setMessage(messages[ageState], 30);
629+ sukkiri = true;
630+ stay(30);
631+ }
632+
633+ private void showBirth() {
634+ setMessage("‚ä‚Á‚­‚¿‚¿‚Ä‚¢‚Á‚¿‚¥‚ˁI", 30);
635+ stay(30);
636+ }
637+
638+ private void showShit() {
639+ switch (yukkuriType) {
640+ case MARISA: {
641+ String messages[] = {"‚¤‚ñ‚¤‚ñ‚À‚¥‚è‚ãI", "‚Ü‚è‚¿‚á‚Ì‚·[‚Ò‚á[‚¤‚ñ‚¤‚ñ‚¿‚á‚¢‚Ý‚ã‚ɂ傶‚¥I", "‚܂肳‚Ì‚·[‚ρ[‚¤‚ñ‚¤‚ñ‚½‚¢‚Þ‚Ì‚ºI"};
642+ setMessage(messages[ageState]);
643+ }
644+ break;
645+ case REIMU: {
646+ String messages[] = {"‚¤‚ñ‚¤‚ñ‚À‚¥‚è‚ãI", "‚è‚¥‚¢‚Ý‚ã‚Ì‚·[‚Ò‚á[‚¤‚ñ‚¤‚ñ‚¿‚á‚¢‚Ý‚ã‚Í‚À‚Ý‚á‚è‚ã‚É‚åI", "‚ê‚¢‚Þ‚Ì‚·[‚ρ[‚¤‚ñ‚¤‚ñ‚½‚¢‚Þ‚Í‚¶‚Ü‚é‚æI"};
647+ setMessage(messages[ageState]);
648+ }
649+ break;
650+ default:
651+ System.out.println("Uknown type");
652+ break;
653+ }
654+ }
655+
656+ private void showShit2() {
657+ String messages[] = {"‚·‚Á‚«‚¿I", "‚·‚Á‚«‚¿[I", "‚·‚Á‚«‚è[I"};
658+ setMessage(messages[ageState]);
659+ furifuri = true;
660+ stay();
661+ }
662+
663+ private void showSurisuri() {
664+ String messages[] = {"‚¿‚ã‚è‚¿‚ã‚è", "‚¿‚ã[‚è‚¿‚ã[‚è", "‚·[‚è‚·[‚è"};
665+ setMessage(messages[ageState]);
666+ stay();
667+ }
668+
669+ private void showPeroPero() {
670+ peropero = true;
671+ String messages[] = {"‚Ø‚è‚å‚Ø‚è‚å", "‚؁[‚è‚å‚؁[‚è‚å", "‚؁[‚ë‚؁[‚ë"};
672+ setMessage(messages[ageState]);
673+ stay();
674+ }
675+
676+ private void showBreed() {
677+ setMessage("‚¤A‚¤‚΂ê‚éAAA");
678+ }
679+
680+ private void showBreed2() {
681+ messageBuf = null;
682+ setMessage("‚ä‚Á‚­‚肵‚Ä‚¢‚Á‚ĂˁI");
683+ furifuri = true;
684+ stay();
685+ }
686+
687+ public void showHateShit() {
688+ String messages[][] = {{"‚­‚¿‚á‚¢I", "‚¤‚ñ‚¤‚ñ‚­‚¿‚á‚¢I‚µ‚ガ‚ã‚É‚©‚½‚¶‚ã‚«‚¥‚è‚åI", "‚¤‚ñ‚¤‚ñ‚©‚½‚¯‚ĂˁI‚·‚®‚Å‚¢‚¢‚æI"},
689+ {"‚­‚¿‚á‚¢AAA", "‚­‚¿‚á‚¢‚æA‚ä‚Á‚«‚ã‚è‚Å‚«‚É‚á‚¢AAA", "‚­‚³‚¢‚æA‚ä‚Á‚­‚è‚Å‚«‚È‚¢‚æAAA"}};
690+ setMessage(messages[damageState][ageState]);
691+ }
692+
693+ private void showHungry() {
694+ switch (yukkuriType) {
695+ case MARISA: {
696+ String messages[][] = {{"‚ ‚Ý‚á‚ ‚Ý‚á‚¿‚傤‚¶‚á‚¢I", "‚²‚Í‚ñ‚µ‚á‚ñ‚܂肵‚á‚É‚à‚Á‚Ä‚«‚ã‚é‚Ì‚¶‚¥I", "‚²‚Í‚ñ‚³‚ñ‚܂肳‚ɂ悱‚·‚Ì‚ºI‚½‚­‚³‚ñ‚Å‚¢‚¢‚æI"},
697+ {"‚²‚Í‚ñ‚µ‚á‚ñ‚Ç‚«‚åH", "‚¨‚É‚á‚«‚á‚Ö‚Á‚¿‚á‚Ì‚¶‚¥AAA", "‚΂肴‚É‚²‚Í‚ñ‚®‚¾‚´‚¢‚¡"}};
698+ setMessage(messages[damageState][ageState]);
699+ }
700+ break;
701+ case REIMU: {
702+ String messages[][] = {{"‚ ‚Ý‚á‚ ‚Ý‚á‚¿‚傤‚¶‚á‚¢I", "‚²‚Í‚ñ‚µ‚á‚ñ‚ð‚ê‚¢‚Ý‚ã‚É‚à‚Á‚Ä‚«‚¿‚¥‚ˁI", "‚²‚Í‚ñ‚³‚ñ‚ð‚ê‚¢‚Þ‚É‚¿‚傤‚¾‚¢‚ˁI‚½‚­‚³‚ñ‚Å‚¢‚¢‚æI"},
703+ {"‚²‚Í‚ñ‚µ‚á‚ñ‚Ç‚«‚åH", "‚¨‚É‚á‚«‚á‚Ö‚Á‚¿‚á‚æAAA", "‚Å‚¢‚Ô‚É‚²‚Í‚ñ‚®‚¾‚´‚¢‚¡"}};
704+ setMessage(messages[damageState][ageState]);
705+ }
706+ break;
707+ default:
708+ System.out.println("Uknown type");
709+ break;
710+ }
711+ stay();
712+ }
713+
714+ private void showNoAccessory() {
715+ switch (yukkuriType) {
716+ case MARISA: {
717+ String messages[] = {"‚ä‚¥[‚ñI‚¨‚Ú‚¤‚µ‚µ‚á‚ñ‚Ç‚«‚åH", "‚ä‚¥[‚ñI‚Ü‚è‚¿‚á‚Ì‚«‚á‚í‚¢‚¢‚¨‚т傤‚µ‚µ‚á‚ñ‚Ç‚«‚å‚É‚á‚Ì‚¶‚¥H", "‚܂肳‚Ì‚¨‚Ú‚¤‚µ‚³‚ñ‚Ç‚±‚È‚Ì‚ºH"};
718+ setMessage(messages[ageState]);
719+ }
720+ break;
721+ case REIMU: {
722+ String messages[] = {"‚ä‚¥[‚ñI‚¨‚«‚Ⴖ‚á‚肵‚á‚ñ‚Ç‚«‚åH", "‚ä‚¥[‚ñI‚è‚¥‚¢‚Ý‚ã‚Ì‚«‚á‚í‚¢‚¢‚¨‚«‚Ⴖ‚á‚肵‚á‚ñ‚Ç‚±H", "‚ê‚¢‚Þ‚Ì‚¨‚©‚´‚肳‚ñ‚Ç‚±H"};
723+ setMessage(messages[ageState]);
724+ }
725+ break;
726+ default:
727+ System.out.println("Uknown type");
728+ break;
729+ }
730+ }
731+
732+ public void showHateYukkuri() {
733+ switch (yukkuriType) {
734+ case MARISA: {
735+ String messages[] = {"‚ä‚Á‚­‚¿‚Å‚«‚É‚á‚¢‚ä‚Á‚­‚¿‚ª‚¢‚è‚ã‚æ", "‚ä‚Á‚­‚¿‚Å‚«‚É‚á‚¢‚ä‚Á‚­‚¿‚ª‚¢‚è‚ã‚Ì‚¶‚¥", "‚ä‚Á‚­‚è‚Å‚«‚È‚¢‚ä‚Á‚­‚肪‚¢‚é‚Ì‚ºI‚¹‚¢‚Á‚³‚¢‚·‚é‚Ì‚ºI"};
736+ setMessage(messages[ageState]);
737+ }
738+ break;
739+ case REIMU: {
740+ String messages[] = {"‚ä‚Á‚­‚¿‚Å‚«‚É‚á‚¢‚ä‚Á‚­‚¿‚ª‚¢‚è‚ã‚æ", "‚ä‚Á‚­‚¿‚Å‚«‚É‚á‚¢‚ä‚Á‚­‚¿‚ª‚¢‚è‚ã‚æ", "‚ä‚Á‚­‚è‚Å‚«‚È‚¢‚ä‚Á‚­‚肪‚¢‚é‚æI‚¹‚¢‚Á‚³‚¢‚·‚é‚æI"};
741+ setMessage(messages[ageState]);
742+ }
743+ break;
744+ default:
745+ System.out.println("Uknown type");
746+ break;
747+ }
748+ }
749+
750+ // public methods
751+ public Body(int initX, int initY, int initType, int initAgeState) {
752+ objType = YUKKURI;
753+ x = initX;
754+ y = initY;
755+ z = 0;
756+ yukkuriType = initType;
757+ switch (initAgeState) {
758+ case BABY:
759+ age = 0;
760+ showBirth();
761+ break;
762+ case CHILD:
763+ age = BABYLIMIT;
764+ break;
765+ case ADULT:
766+ default:
767+ age = CHILDLIMIT;
768+ break;
769+ }
770+ age += rnd.nextInt(100);
771+ ageState = checkAageState();
772+ shit = rnd.nextInt(SHITLIMIT[ageState]);
773+ wakeUpTime = age;
774+ removed = false;
775+ }
776+
777+ public int getBodyType() {
778+ return yukkuriType;
779+ }
780+
781+ public int getBabyType() {
782+ return babyType;
783+ }
784+
785+ public int getAgeState() {
786+ return ageState;
787+ }
788+
789+ public long getAge() {
790+ return age;
791+ }
792+
793+ public int getEatAmount() {
794+ return EATAMOUNT[ageState];
795+ }
796+
797+ public int getStep() {
798+ return STEP[ageState];
799+ }
800+
801+ public String getMessage() {
802+ return messageBuf;
803+ }
804+
805+ public boolean isDead() {
806+ return dead;
807+ }
808+
809+ public boolean isAdult() {
810+ if (ageState == ADULT) {
811+ return true;
812+ }
813+ else {
814+ return false;
815+ }
816+ }
817+
818+ public boolean isSleeping() {
819+ if (dead) {
820+ return false;
821+ }
822+ return sleeping;
823+ }
824+
825+ public boolean isHungry() {
826+ if (dead) {
827+ return false;
828+ }
829+ if (hungry >= HUNGRYLIMIT[ageState]/8) {
830+ return true;
831+ }
832+ return false;
833+ }
834+
835+ public boolean isShitting() {
836+ if (dead) {
837+ return false;
838+ }
839+ return(shitting);
840+ }
841+
842+ public boolean isExciting() {
843+ if (dead) {
844+ return false;
845+ }
846+ return(excitement);
847+ }
848+
849+ public boolean isUngry() {
850+ if (dead) {
851+ return false;
852+ }
853+ return (ungry);
854+ }
855+
856+ public boolean isFurifuri() {
857+ if (dead) {
858+ return false;
859+ }
860+ return (furifuri);
861+ }
862+
863+ public boolean isStrike() {
864+ if (dead) {
865+ return false;
866+ }
867+ return strike;
868+ }
869+
870+ public boolean isDamaged() {
871+ if (checkDamageState() == DAMAGEMUCH) {
872+ return true;
873+ }
874+ return false;
875+ }
876+
877+ public boolean isBirth() {
878+ if (dead) {
879+ return false;
880+ }
881+ if (birth) {
882+ return true;
883+ }
884+ return false;
885+ }
886+
887+ public boolean isAccessory() {
888+ return hasAccessory;
889+ }
890+
891+ public boolean isEating() {
892+ if (dead) {
893+ return false;
894+ }
895+ return eating;
896+ }
897+
898+ public boolean isPeroPero() {
899+ if (dead) {
900+ return false;
901+ }
902+ return peropero;
903+ }
904+
905+ public boolean isSukkiri() {
906+ if (dead) {
907+ return false;
908+ }
909+ return sukkiri;
910+ }
911+
912+ public void doSukkiri(Body partner) {
913+ if (dead) {
914+ return;
915+ }
916+ toSukkiri = false;
917+ // show message
918+ showSukkiri();
919+ partner.showSukkiri();
920+ // change state
921+ excitement = false;
922+ relax = false;
923+ ungry = false;
924+ noHungryPeriod = 0;
925+ hungry += 100*12;
926+ hungryState = checkHungryState();
927+ //change partner state
928+ partner.hasBaby = true;
929+ if (yukkuriType == partner.yukkuriType) {
930+ partner.babyType = yukkuriType;
931+ } else if (rnd.nextInt(2) == 0) {
932+ partner.babyType = yukkuriType;
933+ } else {
934+ partner.babyType = partner.yukkuriType;
935+ }
936+ partner.excitement = false;
937+ partner.relax = false;
938+ partner.ungry = false;
939+ partner.noHungryPeriod = 0;
940+ partner.hungry += 100*24;
941+ partner.hungryState = partner.checkHungryState();
942+ }
943+
944+ public void forceSukkiri() {
945+ if (dead || !hasAccessory) {
946+ return;
947+ }
948+ if (hasBaby == false) {
949+ excitement = true;
950+ showExcite();
951+ }
952+ stay();
953+ }
954+
955+ public void doSurisuri(Body partner) {
956+ if (dead) {
957+ return;
958+ }
959+ if (ageState == ADULT && partner.ageState != ADULT) {
960+ showPeroPero();
961+ }
962+ else {
963+ showSurisuri();
964+ }
965+ ungry = false;
966+ partner.ungry = false;
967+ //partner.stay();
968+ }
969+
970+ public void moveTo(int toX, int toY) {
971+ if (dead) {
972+ return;
973+ }
974+ dextX = toX;
975+ destY = toY;
976+ }
977+
978+ public void moveToFood(int toX, int toY) {
979+ toFood = true;
980+ toSukkiri = false;
981+ moveTo(toX, toY);
982+ }
983+
984+ public void moveToSukkiri(int toX, int toY) {
985+ toSukkiri = true;
986+ toFood = false;
987+ moveTo(toX, toY);
988+ }
989+
990+ public void eatFood(int amount) {
991+ if (dead) {
992+ return;
993+ }
994+ toFood = false;
995+ if (!isHungry()) {
996+ showFull();
997+ return;
998+ }
999+ hungry -= amount;
1000+ if (hungry < 0) {
1001+ hungry = 0;
1002+ }
1003+ showEating();
1004+ hungryState = checkHungryState();
1005+ ungry = false;
1006+ }
1007+
1008+ public void strike(int amount) {
1009+ if (dead) {
1010+ return;
1011+ }
1012+ damage += amount;
1013+ showScream();
1014+ damageState = checkDamageState();
1015+ if (damageState == DAMAGENOT && hasAccessory) {
1016+ ungry = true;
1017+ }
1018+ else {
1019+ ungry = false;
1020+ }
1021+ wakeup();
1022+ }
1023+
1024+ public void strikeByNeedle() {
1025+ strike(NEEDLE);
1026+ }
1027+
1028+ public void strikeByHammer() {
1029+ if (dead) {
1030+ return;
1031+ }
1032+ strike(HAMMER);
1033+ if (damage > DAMAGELIMIT[ageState]) {
1034+ showDieing();
1035+ }
1036+ }
1037+
1038+ public void takeAccessory() {
1039+ hasAccessory = false;
1040+ }
1041+
1042+ public void giveAccessory() {
1043+ hasAccessory = true;
1044+ }
1045+
1046+ public void giveJuice(){
1047+ if (dead) {
1048+ return;
1049+ }
1050+ damage -= 100*100;
1051+ if (damage < 0) {
1052+ damage = 0;
1053+ }
1054+ showHealing();
1055+ damageState = checkDamageState();
1056+ ungry = false;
1057+ }
1058+
1059+ // calling every tick
1060+ public int clockTick() {
1061+ int retval = DONOTHING;
1062+
1063+ // if removed, remove body
1064+ if (removed) {
1065+ return REMOVED;
1066+ }
1067+
1068+ // if dead, do nothing.
1069+ if (dead) {
1070+ checkMessage();
1071+ return DEAD;
1072+ }
1073+
1074+ // check age
1075+ age += TICK;
1076+ if (age > LIFELIMIT) {
1077+ dead = true;
1078+ }
1079+ ageState = checkAageState();
1080+
1081+ // check hungry
1082+ checkHungry();
1083+
1084+ // check damage
1085+ checkDamage();
1086+
1087+ // check events
1088+ boolean dontMove = false;
1089+
1090+ // check shit
1091+ int oldShit = shit;
1092+ if (checkShit()) {
1093+ dontMove = true;
1094+ }
1095+ if (oldShit != 0 && shit == 0) {
1096+ retval = DOSHIT;
1097+ }
1098+
1099+ // check pregnant
1100+ boolean oldHasBaby = hasBaby;
1101+ if (checkPregnant()) {
1102+ dontMove = true;
1103+ }
1104+ if (oldHasBaby == true && hasBaby == false) {
1105+ retval = BIRTHBABY;
1106+ }
1107+
1108+ // check sleep
1109+ if (checkSleep()) {
1110+ dontMove = true;
1111+ }
1112+
1113+ // check relax and excitement
1114+ checkExciteAndRelax();
1115+
1116+ if (staying) {
1117+ staycount += TICK;
1118+ if (staycount > stayTime) {
1119+ staycount = 0;
1120+ staying = false;
1121+ } else {
1122+ dontMove = true;
1123+ }
1124+ }
1125+
1126+ // move to destination
1127+ // if there is no destination, walking randomly.
1128+ if (dontMove == false) {
1129+ moveBody();
1130+ }
1131+
1132+ //
1133+ checkMessage();
1134+
1135+ return retval;
1136+ }
1137+}
Show on old repository browser