Bug fix.
@@ -87,7 +87,7 @@ | ||
87 | 87 | int foodAmount = 1; |
88 | 88 | if (o.objType == Obj.Type.YUKKURI) { |
89 | 89 | Body b = (Body)o; |
90 | - if (b.isCrashed() == true || b.isBaby() == true) { | |
90 | + if (b.isCrashed() || b.isBaby()) { | |
91 | 91 | if (shitCount != 0) { |
92 | 92 | foodType = Food.type.BITTER; |
93 | 93 | shitCount = 0; |
@@ -176,7 +176,7 @@ | ||
176 | 176 | } |
177 | 177 | |
178 | 178 | for (int i = 0; i < foodAmount; i++) { |
179 | - SimYukkuri.mypane.terrarium.addFood(x + 52, y, foodType); | |
179 | + SimYukkuri.mypane.terrarium.addFood(x + 52 + rnd.nextInt(10), y + rnd.nextInt(10), foodType); | |
180 | 180 | } |
181 | 181 | Cash.delCash(getCost()); |
182 | 182 | return; |
@@ -731,28 +731,33 @@ | ||
731 | 731 | return new Body(type, x, y, z, age, p1, p2); |
732 | 732 | } |
733 | 733 | |
734 | - public void addBody(int x, int y, int z, int type, Body.AgeState age, Body p1, Body p2) { | |
734 | + public void buyBody(int x, int y, int z, int type, Body.AgeState age, Body p1, Body p2) { | |
735 | 735 | Body b = makeBody(x, y, z, type, age, p1, p2); |
736 | 736 | Cash.delCash(b.getPrice(Obj.Price.BUYING)); |
737 | 737 | bodyList.add(b); |
738 | 738 | } |
739 | 739 | |
740 | - public void addBody(Body b) { | |
740 | + public void buyBody(Body b) { | |
741 | 741 | Cash.delCash(b.getPrice(Obj.Price.BUYING)); |
742 | 742 | bodyList.add(b); |
743 | 743 | } |
744 | 744 | |
745 | - public void addFood(int x, int y, Food.type type) { | |
745 | + public void buyFood(int x, int y, Food.type type) { | |
746 | 746 | Food f = new Food(x, y, type); |
747 | 747 | Cash.delCash(f.getPrice(Obj.Price.BUYING)); |
748 | 748 | foodList.add(f); |
749 | 749 | } |
750 | + | |
751 | + public void addFood(int x, int y, Food.type type) { | |
752 | + Food f = new Food(x, y, type); | |
753 | + foodList.add(f); | |
754 | + } | |
750 | 755 | |
751 | 756 | public void addShit(int x, int y, int z, Body.AgeState ageState) { |
752 | 757 | shitList.add(new Shit(x, y, z, ageState)); |
753 | 758 | } |
754 | 759 | |
755 | - public void addToy(int x, int y) { | |
760 | + public void buyToy(int x, int y) { | |
756 | 761 | Toy t = new Toy(x, y); |
757 | 762 | Cash.delCash(t.getPrice(Obj.Price.BUYING)); |
758 | 763 | toyList.add(t); |
@@ -764,7 +769,7 @@ | ||
764 | 769 | shitList.add(s); |
765 | 770 | } |
766 | 771 | |
767 | - public void addToilet(int x, int y) { | |
772 | + public void buyToilet(int x, int y) { | |
768 | 773 | Toilet t = new Toilet(x, y); |
769 | 774 | Cash.delCash(t.getPrice(Obj.Price.BUYING)); |
770 | 775 | toiletList.add(t); |
@@ -771,7 +776,7 @@ | ||
771 | 776 | |
772 | 777 | } |
773 | 778 | |
774 | - public void addObjEX( int addObjEX, int x, int y, ObjEX.Direction dir) { | |
779 | + public void buyObjEx( int addObjEX, int x, int y, ObjEX.Direction dir) { | |
775 | 780 | ObjEX o; |
776 | 781 | switch(addObjEX){ |
777 | 782 | case SimYukkuri.BELTCONVEYOR: |
@@ -54,7 +54,7 @@ | ||
54 | 54 | JPanel rootPane = new JPanel(); |
55 | 55 | JPanel buttonPane = new JPanel(); |
56 | 56 | JComboBox<String> s1, s2, s3; |
57 | - static JLabel l1, l2, l3, l4, l5, l6, l7, l8; | |
57 | + static JLabel l1, l2, l3, l4, l5, l6, l7, l8, l9, l10; | |
58 | 58 | |
59 | 59 | JButton saveButton, loadButton, addYukkuriButton, languageButton, pauseButton, showLogButton, nextPageLogButton, clearLogButton; |
60 | 60 |
@@ -84,6 +84,8 @@ | ||
84 | 84 | l6 = new JLabel(" "); |
85 | 85 | l7 = new JLabel(" "); |
86 | 86 | l8 = new JLabel(" "); |
87 | + l9 = new JLabel(" "); | |
88 | + l10 = new JLabel(" "); | |
87 | 89 | saveButton = new JButton(); |
88 | 90 | loadButton = new JButton(); |
89 | 91 | addYukkuriButton = new JButton(); |
@@ -127,6 +129,8 @@ | ||
127 | 129 | buttonPane.add(l6); |
128 | 130 | buttonPane.add(l7); |
129 | 131 | buttonPane.add(l8); |
132 | + buttonPane.add(l9); | |
133 | + buttonPane.add(l10); | |
130 | 134 | |
131 | 135 | // setup my pane |
132 | 136 | MyMouseListener mml = new MyMouseListener(); |
@@ -159,7 +163,8 @@ | ||
159 | 163 | |
160 | 164 | try { |
161 | 165 | InitLoader.loadSystemInitFile(loader); |
162 | - } catch (NullPointerException e) { | |
166 | + } | |
167 | + catch (NullPointerException e) { | |
163 | 168 | e.printStackTrace(); |
164 | 169 | JOptionPane.showMessageDialog(SimYukkuri.this, "Init file format for system is invalid", SimYukkuri.TITLE, JOptionPane.ERROR_MESSAGE); |
165 | 170 | System.exit(1); |
@@ -167,31 +172,31 @@ | ||
167 | 172 | |
168 | 173 | // title and version |
169 | 174 | title.setText(InitLoader.getTitle() + " " + InitLoader.getVersion() + " "); |
170 | - | |
175 | + | |
171 | 176 | // initialize foundage |
172 | 177 | Cash.initFoundage(InitLoader.getFoundage()); |
173 | - | |
174 | - //pulldown menu1 | |
178 | + | |
179 | + // pulldown menu1 | |
175 | 180 | int numOfMenu = InitLoader.getNumOfMenu(0); |
176 | 181 | String[] menu = new String[numOfMenu]; |
177 | - for (int i=0; i<numOfMenu; i++) { | |
182 | + for (int i = 0; i < numOfMenu; i++) { | |
178 | 183 | menu[i] = InitLoader.getMenu(0, i); |
179 | 184 | } |
180 | 185 | s1.setModel(new DefaultComboBoxModel<String>(menu)); |
181 | 186 | int selectedIndex = s1.getSelectedIndex(); |
182 | - if(selectedIndex > -1) | |
187 | + if (selectedIndex > -1) | |
183 | 188 | s1.setSelectedIndex(selectedIndex); |
184 | - | |
185 | - //pulldown menu2 | |
189 | + | |
190 | + // pulldown menu2 | |
186 | 191 | numOfMenu = InitLoader.getNumOfMenu(1); |
187 | 192 | menu = new String[numOfMenu]; |
188 | - for (int i=0; i<numOfMenu; i++) { | |
193 | + for (int i = 0; i < numOfMenu; i++) { | |
189 | 194 | menu[i] = InitLoader.getMenu(1, i); |
190 | 195 | } |
191 | 196 | s3.setModel(new DefaultComboBoxModel<String>(menu)); |
192 | 197 | s3.setSelectedIndex(selectedGameSpeed); |
193 | - | |
194 | - //buttons | |
198 | + | |
199 | + // buttons | |
195 | 200 | addYukkuriButton.setText(InitLoader.getButton(0)); |
196 | 201 | saveButton.setText(InitLoader.getButton(1)); |
197 | 202 | loadButton.setText(InitLoader.getButton(2)); |
@@ -198,16 +203,18 @@ | ||
198 | 203 | showLogButton.setText(InitLoader.getButton(3)); |
199 | 204 | nextPageLogButton.setText(InitLoader.getButton(4)); |
200 | 205 | clearLogButton.setText(InitLoader.getButton(5)); |
201 | - | |
202 | - //status | |
206 | + | |
207 | + // status | |
203 | 208 | l2.setText(InitLoader.getStatus(0)); |
204 | - l3.setText(" "+InitLoader.getStatus(1)+": " + "-" + "%"); | |
205 | - l4.setText(" "+InitLoader.getStatus(2)+": " + "-" + "%"); | |
206 | - l5.setText(" "+InitLoader.getStatus(3)+": " + "-" + "%"); | |
207 | - l6.setText(" "+InitLoader.getStatus(4)+": " + "-" + "%"); | |
208 | - l7.setText(" "+InitLoader.getStatus(5)+": " + "-"); | |
209 | - l8.setText(" "+InitLoader.getStatus(6)+": " + "-"); | |
210 | - | |
209 | + l3.setText(" " + InitLoader.getStatus(1) + ": " + "-" + "%"); | |
210 | + l4.setText(" " + InitLoader.getStatus(2) + ": " + "-" + "%"); | |
211 | + l5.setText(" " + InitLoader.getStatus(3) + ": " + "-" + "%"); | |
212 | + l6.setText(" " + InitLoader.getStatus(4) + ": " + "-" + "%"); | |
213 | + l7.setText(" " + InitLoader.getStatus(5) + ": " + "-"); | |
214 | + l8.setText(" " + InitLoader.getStatus(6) + ": " + "-"); | |
215 | + l9.setText(InitLoader.getStatus(7)); | |
216 | + l10.setText(" " + InitLoader.getStatus(8) + Integer.toString(Cash.getCash())); | |
217 | + | |
211 | 218 | showSubMenu(); |
212 | 219 | } |
213 | 220 |
@@ -630,7 +637,7 @@ | ||
630 | 637 | foodType = Food.type.FUNGICIDE; |
631 | 638 | break; |
632 | 639 | } |
633 | - mypane.terrarium.addFood(x, y, foodType); | |
640 | + mypane.terrarium.buyFood(x, y, foodType); | |
634 | 641 | } |
635 | 642 | } |
636 | 643 | break; |
@@ -638,7 +645,7 @@ | ||
638 | 645 | int x = Translate.invX(e.getX(), e.getY(), Toilet.getSizeS(), w, h); |
639 | 646 | int y = Translate.invY(e.getX(), e.getY(), Toilet.getSizeS() * 2 / 3, w, h); |
640 | 647 | if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) { |
641 | - mypane.terrarium.addToilet(x, y); | |
648 | + mypane.terrarium.buyToilet(x, y); | |
642 | 649 | } |
643 | 650 | } |
644 | 651 | break; |
@@ -646,7 +653,7 @@ | ||
646 | 653 | int x = Translate.invX(e.getX(), e.getY(), Toy.getSizeS(), w, h); |
647 | 654 | int y = Translate.invY(e.getX(), e.getY(), Toy.getSizeS(), w, h); |
648 | 655 | if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) { |
649 | - mypane.terrarium.addToy(x, y); | |
656 | + mypane.terrarium.buyToy(x, y); | |
650 | 657 | } |
651 | 658 | } |
652 | 659 | break; |
@@ -671,7 +678,7 @@ | ||
671 | 678 | dir = ObjEX.Direction.LEFT; |
672 | 679 | break; |
673 | 680 | } |
674 | - mypane.terrarium.addObjEX(BELTCONVEYOR,x, y, dir); | |
681 | + mypane.terrarium.buyObjEx(BELTCONVEYOR,x, y, dir); | |
675 | 682 | } |
676 | 683 | } |
677 | 684 | break; |
@@ -696,7 +703,7 @@ | ||
696 | 703 | dir = ObjEX.Direction.LEFT; |
697 | 704 | break; |
698 | 705 | } |
699 | - mypane.terrarium.addObjEX(BREEDINGPOOL, x, y, dir); | |
706 | + mypane.terrarium.buyObjEx(BREEDINGPOOL, x, y, dir); | |
700 | 707 | } |
701 | 708 | } |
702 | 709 | break; |
@@ -705,7 +712,7 @@ | ||
705 | 712 | int x = Translate.invX(e.getX(), e.getY(), GarbageChute.getSizeS(), w, h); |
706 | 713 | int y = Translate.invY(e.getX(), e.getY(), GarbageChute.getSizeS() / 2, w, h); |
707 | 714 | if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) { |
708 | - mypane.terrarium.addObjEX(GARBAGECHUTE, x, y, ObjEX.Direction.BACK); | |
715 | + mypane.terrarium.buyObjEx(GARBAGECHUTE, x, y, ObjEX.Direction.BACK); | |
709 | 716 | } |
710 | 717 | } |
711 | 718 | break; |
@@ -714,7 +721,7 @@ | ||
714 | 721 | int x = Translate.invX(e.getX(), e.getY(), MachinePress.getSizeS(), w, h); |
715 | 722 | int y = Translate.invY(e.getX(), e.getY(), MachinePress.getSizeS() / 2, w, h); |
716 | 723 | if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) { |
717 | - mypane.terrarium.addObjEX(MACHINEPRESS, x, y, ObjEX.Direction.BACK); | |
724 | + mypane.terrarium.buyObjEx(MACHINEPRESS, x, y, ObjEX.Direction.BACK); | |
718 | 725 | } |
719 | 726 | } |
720 | 727 | break; |
@@ -723,7 +730,7 @@ | ||
723 | 730 | int x = Translate.invX(e.getX(), e.getY(), FoodMaker.getSizeS(), w, h); |
724 | 731 | int y = Translate.invY(e.getX(), e.getY(), FoodMaker.getSizeS() / 2, w, h); |
725 | 732 | if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) { |
726 | - mypane.terrarium.addObjEX(FOODMAKER, x, y, ObjEX.Direction.BACK); | |
733 | + mypane.terrarium.buyObjEx(FOODMAKER, x, y, ObjEX.Direction.BACK); | |
727 | 734 | } |
728 | 735 | } |
729 | 736 | break; |
@@ -748,7 +755,7 @@ | ||
748 | 755 | dir = ObjEX.Direction.BACK; |
749 | 756 | break; |
750 | 757 | } |
751 | - mypane.terrarium.addObjEX(ORANGEPOOL, x, y, dir); | |
758 | + mypane.terrarium.buyObjEx(ORANGEPOOL, x, y, dir); | |
752 | 759 | } |
753 | 760 | } |
754 | 761 | break; |
@@ -757,7 +764,7 @@ | ||
757 | 764 | int x = Translate.invX(e.getX(), e.getY(), ProductChute.getSizeS(), w, h); |
758 | 765 | int y = Translate.invY(e.getX(), e.getY(), ProductChute.getSizeS() / 2, w, h); |
759 | 766 | if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) { |
760 | - mypane.terrarium.addObjEX(PRODUCTCHUTE, x, y, ObjEX.Direction.BACK); | |
767 | + mypane.terrarium.buyObjEx(PRODUCTCHUTE, x, y, ObjEX.Direction.BACK); | |
761 | 768 | } |
762 | 769 | } |
763 | 770 | break; |
@@ -1060,6 +1067,7 @@ | ||
1060 | 1067 | speed = gameSpeed[SimYukkuri.selectedGameSpeed]; |
1061 | 1068 | } |
1062 | 1069 | SimYukkuri.l3.setText(" " + InitLoader.getStatus(1) + ": " + stress + "%"); |
1070 | + SimYukkuri.l10.setText(" " + InitLoader.getStatus(8) + Integer.toString(Cash.getCash())); | |
1063 | 1071 | if (speed != PAUSE) { |
1064 | 1072 | synchronized (SimYukkuri.lock) { |
1065 | 1073 | terrarium.run(); |
@@ -1150,7 +1158,7 @@ | ||
1150 | 1158 | } |
1151 | 1159 | for (Body b: bodies) { |
1152 | 1160 | synchronized(SimYukkuri.lock) { |
1153 | - terrarium.addBody(b); | |
1161 | + terrarium.buyBody(b); | |
1154 | 1162 | } |
1155 | 1163 | } |
1156 | 1164 | } |
@@ -30,4 +30,7 @@ | ||
30 | 30 | cash -= value; |
31 | 31 | } |
32 | 32 | |
33 | + public static int getCash() { | |
34 | + return cash; | |
35 | + } | |
33 | 36 | } |
\ No newline at end of file |