From 18 Jan, 2021 0:00 UTC: All services will be temporary unavailable for maintenance
  • R/O
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscaphegui翻訳comegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

無人機動兵器ダンジョン探索ゲーム JAVAベース


Commit MetaInfo

修订版26 (tree)
时间2015-06-25 18:11:13
作者manjihq

Log Message

ダンジョン探索中のステータス表示にソフトウェアチップパネル状態を追加

更改概述

差异

--- CarnageHack2/trunk/src/CarnageHack/CarnageHack.java (revision 25)
+++ CarnageHack2/trunk/src/CarnageHack/CarnageHack.java (revision 26)
@@ -24,7 +24,7 @@
2424 */
2525 public final class CarnageHack extends Panel implements ActionListener {
2626
27- public static final String version = "CarnageHack2 1.2.0 alpha";
27+ public static final String version = "CarnageHack2 V1.3.0 alpha";
2828 public static final ResourceBundle resource;
2929 public static CHArrayList main_weapon_list;
3030 public static CHArrayList sub_weapon_list;
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftTracePanel.java (nonexistent)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftTracePanel.java (revision 26)
@@ -0,0 +1,115 @@
1+package CarnageHack;
2+
3+import java.awt.Canvas;
4+import java.awt.Color;
5+import java.awt.Dimension;
6+import java.awt.Graphics;
7+import java.awt.Image;
8+
9+/**
10+ * ソフトウェアトレース表示パネル
11+ *
12+ * @author fukui
13+ */
14+public class OkeSoftTracePanel extends Canvas {
15+
16+ static final Color baseColor = new Color(0, 0, 0);
17+ static final Color greenChipColor = new Color(0, 127, 0);
18+ static final Color redChipColor = new Color(127, 0, 0);
19+ static final Color greenFocusChipColor = new Color(0, 255, 0);
20+ static final Color redFocusChipColor = new Color(255, 0, 0);
21+ static final Color normalCodeColor = new Color(0, 0, 127);
22+ static final Color condCodeColor = new Color(127, 0, 127);
23+ Oke.ChipTrace traceData[];
24+ OkeSoftData software;
25+
26+ /**
27+ * コンストラクタ
28+ *
29+ */
30+ OkeSoftTracePanel() {
31+ super();
32+ traceData = null;
33+ software = null;
34+ }
35+
36+ @Override
37+ public Dimension getPreferredSize() {
38+ return new Dimension(OkeSoftData.CHIPMAXX * 10 + 4,
39+ OkeSoftData.CHIPMAXY * 10 + 4);
40+ }
41+
42+ @Override
43+ public Dimension getMinimumSize() {
44+ return new Dimension(OkeSoftData.CHIPMAXX * 10 + 4,
45+ OkeSoftData.CHIPMAXY * 10 + 4);
46+ }
47+
48+ @Override
49+ public void update(Graphics g) {
50+ paint(g);
51+ }
52+
53+ @Override
54+ public void paint(Graphics g) {
55+ int x;
56+ int y;
57+ int nwidth = OkeSoftData.CHIPMAXX * 10 + 4;
58+ int nheight = OkeSoftData.CHIPMAXY * 10 + 4;
59+ Image offscreen = createImage(nwidth, nheight);
60+ Graphics offg = offscreen.getGraphics();
61+ offg.setColor(baseColor);
62+ offg.fillRect(0, 0, nwidth, nheight);
63+ offg.setColor(Color.YELLOW);
64+ for (y = 0; y < OkeSoftData.CHIPMAXY; y++) {
65+ for (x = 0; x < OkeSoftData.CHIPMAXX; x++) {
66+ offg.drawRect(x * 10 + 2, y * 10 + 2, 10, 10);
67+ }
68+ }
69+ if (software != null) {
70+ for (y = 0; y < OkeSoftData.CHIPMAXY; y++) {
71+ for (x = 0; x < OkeSoftData.CHIPMAXX; x++) {
72+ OkeSoftChip chip = software.get(x, y);
73+ if (chip.nullchip() == false) {
74+ offg.setColor(software.get(x, y).is_condchip()
75+ ? condCodeColor : normalCodeColor);
76+ offg.fillRect(x * 10 + 2 + 1, y * 10 + 2 + 1, 8, 8);
77+ }
78+ }
79+ }
80+ }
81+ if (traceData != null) {
82+ int i;
83+ int nmax = traceData.length - 1;
84+ for (i = 0; i < nmax; i++) {
85+ offg.setColor(traceData[i].get_branch()
86+ ? redChipColor : greenChipColor);
87+ offg.fillRect(traceData[i].get_position_x() * 10 + 2 + 1,
88+ traceData[i].get_position_y() * 10 + 2 + 1, 8, 8);
89+ }
90+ if (i > 0) {
91+ //最終チップだけフォーカス表示
92+ offg.setColor(traceData[i].get_branch()
93+ ? redFocusChipColor : greenFocusChipColor);
94+ offg.fillRect(traceData[i].get_position_x() * 10 + 2 + 1,
95+ traceData[i].get_position_y() * 10 + 2 + 1, 8, 8);
96+ }
97+ }
98+ g.drawImage(offscreen, 0, 0, this);
99+ }
100+
101+ /**
102+ * トレース対象のOKEを設定
103+ *
104+ * @param p トレース対象OKE
105+ */
106+ public void set_trace(Oke p) {
107+ if (p != null) {
108+ traceData = p.get_trace();
109+ software = p.get_software();
110+ } else {
111+ traceData = null;
112+ }
113+ repaint();
114+ }
115+}
--- CarnageHack2/trunk/src/CarnageHack/Oke.java (revision 25)
+++ CarnageHack2/trunk/src/CarnageHack/Oke.java (revision 26)
@@ -1,6 +1,7 @@
11 package CarnageHack;
22
33 import java.io.*;
4+import java.util.ArrayList;
45
56 /**
67 * OKEデータ
@@ -130,6 +131,96 @@
130131 int lastdamage;
131132 int destroycount;
132133
134+// <editor-fold defaultstate="collapsed" desc="ChipTrace class">
135+ public class ChipTrace implements Cloneable {
136+
137+ int chipx;
138+ int chipy;
139+ boolean bbranch; //trueの時赤矢印
140+
141+ ChipTrace() {
142+ chipx = -1;
143+ chipy = -1;
144+ bbranch = false;
145+ }
146+
147+ ChipTrace(int x, int y, boolean b) {
148+ chipx = x;
149+ chipy = y;
150+ bbranch = b;
151+ }
152+
153+ @Override
154+ public String toString() {
155+ StringBuilder retstr = new StringBuilder();
156+ retstr.append(chipx);
157+ retstr.append(',');
158+ retstr.append(chipy);
159+ retstr.append(',');
160+ retstr.append(bbranch ? "RED" : "GREEN");
161+ return retstr.toString();
162+ }
163+
164+ @Override
165+ protected Object clone() throws CloneNotSupportedException {
166+ ChipTrace s = (ChipTrace) super.clone();
167+ s.chipx = chipx;
168+ s.chipy = chipy;
169+ s.bbranch = bbranch;
170+ return s;
171+ }
172+
173+ /**
174+ * トレースチップ座標設定
175+ *
176+ * @param x チップX座標
177+ * @param y チップY座標
178+ */
179+ public void set_position(int x, int y) {
180+ chipx = x;
181+ chipy = y;
182+ }
183+
184+ /**
185+ * トレースチップ座標X取得
186+ *
187+ * @return 取得した座標
188+ */
189+ public int get_position_x() {
190+ return chipx;
191+ }
192+
193+ /**
194+ * トレースチップ座標Y取得
195+ *
196+ * @return 取得した座標
197+ */
198+ public int get_position_y() {
199+ return chipy;
200+ }
201+
202+ /**
203+ * 分岐状態設定
204+ *
205+ * @param b 分岐状態(trueの時赤矢印)
206+ */
207+ public void set_branch(boolean b) {
208+ bbranch = b;
209+ }
210+
211+ /**
212+ * 分岐状態取得
213+ *
214+ * @return 取得した分岐状態
215+ */
216+ public boolean get_branch() {
217+ return bbranch;
218+ }
219+ };
220+// </editor-fold>
221+
222+ ArrayList<ChipTrace> traceList;
223+
133224 /**
134225 * コンストラクタ
135226 *
@@ -165,6 +256,7 @@
165256 recalc_speed();
166257 backpack = new CHArrayList();
167258 fuel = hardware.get_fueltank().get_fuel();
259+ traceList = new ArrayList<ChipTrace>();
168260 }
169261
170262 /**
@@ -221,6 +313,7 @@
221313 speed_count = 0;
222314 tempture = 0;
223315 recalc_speed();
316+ traceList = new ArrayList<ChipTrace>();
224317 }
225318
226319 /**
@@ -255,10 +348,13 @@
255348 if (hp == 0 || software == null) {
256349 return;
257350 }
351+ traceList.clear();
258352 for (i = 0; i < nspeed; i++) {
259353 int narrow;
260354 OkeSoftChip chip = software.get(chipx, chipy);
355+ ChipTrace tr = new ChipTrace(chipx, chipy, false);
261356 if (chip == null || chip.nullchip() == true) {
357+ traceList.add(tr);
262358 if (chipx == 0 && chipy == 0) {
263359 //?? invalid software
264360 action = ACTION_SELFDESTRUCT;
@@ -272,10 +368,13 @@
272368 if (chip.exec(dungeon, this) == false) {
273369 //green arrow
274370 narrow = chip.get_green_arrow();
371+ tr.set_branch(false);
275372 } else {
276373 //red arrow
277374 narrow = chip.get_red_arrow();
375+ tr.set_branch(true);
278376 }
377+ traceList.add(tr);
279378 if (chipx == -1 && chipy == -1) {
280379 //change software
281380 chipx = 0;
@@ -1371,6 +1470,15 @@
13711470 }
13721471
13731472 /**
1473+ * 現在のソフトウェア番号
1474+ *
1475+ * @return ソフトウェア番号
1476+ */
1477+ public int get_current_software() {
1478+ return current_software;
1479+ }
1480+
1481+ /**
13741482 * 機体ステータスの処理パラメータ取得
13751483 *
13761484 * @return 現在の処理パラメータ
@@ -1397,6 +1505,17 @@
13971505 return chipy;
13981506 }
13991507
1508+ /**
1509+ * ソフトウェアトレースリストの取得
1510+ *
1511+ * @return 取得したトレース配列
1512+ */
1513+ public ChipTrace[] get_trace() {
1514+ ChipTrace dummy[] = new ChipTrace[1];
1515+ ChipTrace ret[] = traceList.toArray(dummy);
1516+ return ret;
1517+ }
1518+
14001519 }
14011520 //EOF
14021521
--- CarnageHack2/trunk/src/CarnageHack/OkeSoftChip.java (revision 25)
+++ CarnageHack2/trunk/src/CarnageHack/OkeSoftChip.java (revision 26)
@@ -88,6 +88,7 @@
8888 protected String param;
8989 OkeSoftExec code;
9090 OkeSoftPanel spanel;
91+ boolean bcondchip;
9192
9293 /**
9394 * コンストラクタ
@@ -98,6 +99,7 @@
9899 green_arrow = ARROW_NONE;
99100 red_arrow = ARROW_NONE;
100101 spanel = null;
102+ bcondchip = false;
101103 }
102104
103105 /**
@@ -111,6 +113,7 @@
111113
112114 /**
113115 * オブジェクト複製
116+ *
114117 * @return オブジェクトのコピー
115118 * @throws CloneNotSupportedException
116119 */
@@ -122,6 +125,7 @@
122125 wkchip.green_arrow = green_arrow;
123126 wkchip.red_arrow = red_arrow;
124127 wkchip.code = code;
128+ wkchip.bcondchip = bcondchip;
125129 return wkchip;
126130 }
127131
@@ -128,7 +132,7 @@
128132 /**
129133 * チップ内容が存在するかを確認
130134 *
131- * @return 内容が存在するときtrue
135+ * @return 内容が存在するとfalse
132136 */
133137 public boolean nullchip() {
134138 return (code == null);
@@ -141,101 +145,136 @@
141145 param = "";
142146 if (chipid.equals("NOP") == true) {
143147 code = softNop;
148+ bcondchip = false;
144149 } else if (chipid.equals("FORWARD") == true) {
145150 code = softMove;
146151 param = Integer.toString(OkeSoftMove.FORWARD);
152+ bcondchip = false;
147153 } else if (chipid.equals("BACKWARD") == true) {
148154 code = softMove;
149155 param = Integer.toString(OkeSoftMove.BACKWARD);
156+ bcondchip = false;
150157 } else if (chipid.equals("RIGHT") == true) {
151158 code = softMove;
152159 param = Integer.toString(OkeSoftMove.RIGHT);
160+ bcondchip = false;
153161 } else if (chipid.equals("LEFT") == true) {
154162 code = softMove;
155163 param = Integer.toString(OkeSoftMove.LEFT);
164+ bcondchip = false;
156165 } else if (chipid.equals("STOP") == true) {
157166 code = softMove;
158167 param = Integer.toString(OkeSoftMove.STOP);
168+ bcondchip = false;
159169 } else if (chipid.equals("TRIGHT") == true) {
160170 code = softTurn;
161171 param = Integer.toString(OkeSoftTurn.RIGHT);
172+ bcondchip = false;
162173 } else if (chipid.equals("TLEFT") == true) {
163174 code = softTurn;
164175 param = Integer.toString(OkeSoftTurn.LEFT);
176+ bcondchip = false;
165177 } else if (chipid.equals("JFORWARD") == true) {
166178 code = softJump;
167179 param = Integer.toString(OkeSoftJump.FORWARD);
180+ bcondchip = false;
168181 } else if (chipid.equals("JBACKWARD") == true) {
169182 code = softJump;
170183 param = Integer.toString(OkeSoftJump.BACKWARD);
184+ bcondchip = false;
171185 } else if (chipid.equals("JRIGHT") == true) {
172186 code = softJump;
173187 param = Integer.toString(OkeSoftJump.RIGHT);
188+ bcondchip = false;
174189 } else if (chipid.equals("JLEFT") == true) {
175190 code = softJump;
176191 param = Integer.toString(OkeSoftJump.LEFT);
192+ bcondchip = false;
177193 } else if (chipid.equals("SEARCHE") == true) {
178194 param = "0,90,20";
179195 code = softSearchE;
196+ bcondchip = true;
180197 } else if (chipid.equals("SEARCHW") == true) {
181198 param = "0,90,20";
182199 code = softSearchW;
200+ bcondchip = true;
183201 } else if (chipid.equals("SEARCHB") == true) {
184202 param = "0,90,20";
185203 code = softSearchB;
204+ bcondchip = true;
186205 } else if (chipid.equals("SEARCHP") == true) {
187206 param = "0,90,20";
188207 code = softSearchP;
208+ bcondchip = true;
189209 } else if (chipid.equals("SEARCHS") == true) {
190210 param = "0,90,20,UP";
191211 code = softSearchS;
212+ bcondchip = true;
192213 } else if (chipid.equals("MFIRE") == true) {
193214 param = "0,90,20";
194215 code = softFireMain;
216+ bcondchip = false;
195217 } else if (chipid.equals("SFIRE") == true) {
196218 param = "0,90,20,1";
197219 code = softFireSub;
220+ bcondchip = false;
198221 } else if (chipid.equals("OPTION") == true) {
199222 code = softOption;
223+ bcondchip = false;
200224 } else if (chipid.equals("FIGHT") == true) {
201225 code = softFight;
226+ bcondchip = false;
202227 } else if (chipid.equals("PRONE") == true) {
203228 code = softProne;
229+ bcondchip = false;
204230 } else if (chipid.equals("STAIRS") == true) {
205231 code = softStairs;
232+ bcondchip = false;
206233 } else if (chipid.equals("GET") == true) {
207234 code = softGet;
235+ bcondchip = false;
208236 } else if (chipid.equals("REMAIN") == true) {
209237 param = "MAIN WEAPON,>=,0";
210238 code = softRemain;
239+ bcondchip = true;
211240 } else if (chipid.equals("FUEL") == true) {
212241 param = ">=,0";
213242 code = softFuel;
214243 } else if (chipid.equals("HP") == true) {
244+ bcondchip = true;
215245 param = ">=,0";
216246 code = softHp;
247+ bcondchip = true;
217248 } else if (chipid.equals("HEAT") == true) {
218249 param = ">=,0";
219250 code = softHeat;
251+ bcondchip = true;
220252 } else if (chipid.equals("COUNTER") == true) {
221253 param = "A,=,0";
222254 code = softCounter;
255+ bcondchip = false;
223256 } else if (chipid.equals("COND") == true) {
224257 param = "A,==,0";
225258 code = softCond;
259+ bcondchip = true;
226260 } else if (chipid.equals("PARTSINFO") == true) {
227261 param = "0,==,MAIN WEAPON";
228262 code = softPartsInfo;
263+ bcondchip = true;
229264 } else if (chipid.equals("DROP") == true) {
230265 param = "0";
231266 code = softDropParts;
267+ bcondchip = false;
232268 } else if (chipid.equals("RANDOM") == true) {
233269 param = "1,6";
234270 code = softRandom;
271+ bcondchip = true;
235272 } else if (chipid.equals("CHANGE") == true) {
236273 code = softChange;
274+ bcondchip = false;
237275 } else {
238276 code = null;
277+ bcondchip = false;
239278 }
240279 }
241280
@@ -248,6 +287,7 @@
248287 green_arrow = ARROW_NONE;
249288 red_arrow = ARROW_NONE;
250289 code = null;
290+ bcondchip = false;
251291 }
252292
253293 /**
@@ -369,6 +409,15 @@
369409 }
370410
371411 /**
412+ * チップが条件チップかどうか?
413+ *
414+ * @return 条件チップの時にtrue
415+ */
416+ public boolean is_condchip() {
417+ return bcondchip;
418+ }
419+
420+ /**
372421 * ソフトウェア実行
373422 *
374423 * @param dungeon ダンジョンデータ
@@ -441,6 +490,7 @@
441490 code = null;
442491 green_arrow = ARROW_NONE;
443492 red_arrow = ARROW_NONE;
493+ bcondchip = false;
444494 } catch (NumberFormatException e) {
445495 chipid = "";
446496 param = "";
@@ -447,6 +497,7 @@
447497 code = null;
448498 green_arrow = ARROW_NONE;
449499 red_arrow = ARROW_NONE;
500+ bcondchip = false;
450501 }
451502 }
452503 }
--- CarnageHack2/trunk/src/CarnageHack/OkeStatusWindow.java (revision 25)
+++ CarnageHack2/trunk/src/CarnageHack/OkeStatusWindow.java (revision 26)
@@ -1,8 +1,9 @@
11 package CarnageHack;
22
33 import java.awt.Dialog;
4+import java.awt.GridBagConstraints;
5+import java.awt.GridBagLayout;
46 import java.awt.Label;
5-import java.awt.GridLayout;
67
78 /**
89 * OKEステータスウィンドウ
@@ -28,6 +29,7 @@
2829 Label counterD;
2930 Label counterE;
3031 Label counterF;
32+ OkeSoftTracePanel tracepanel;
3133 private static final long serialVersionUID = 32;
3234
3335 /**
@@ -37,8 +39,10 @@
3739 */
3840 OkeStatusWindow(Oke p) {
3941 super(CarnageHack.getFrame(), "Status", false);
42+ GridBagLayout glayout = new GridBagLayout();
43+ GridBagConstraints gconst = new GridBagConstraints();
4044 oke = p;
41- setLayout(new GridLayout(0, 1));
45+ setLayout(glayout);
4246 position = new Label();
4347 hp = new Label();
4448 fuel = new Label();
@@ -55,25 +59,54 @@
5559 counterD = new Label();
5660 counterE = new Label();
5761 counterF = new Label();
62+ tracepanel = new OkeSoftTracePanel();
63+ gconst.fill = GridBagConstraints.BOTH;
64+ gconst.gridwidth = 1;
65+ gconst.gridheight = 16;
66+ gconst.weightx = 1.0;
67+ gconst.weighty = 1.0;
68+ glayout.setConstraints(tracepanel, gconst);
69+ add(tracepanel);
70+ gconst.gridwidth = GridBagConstraints.REMAINDER;
71+ gconst.gridheight = 1;
72+ gconst.weightx = 0;
73+ gconst.weighty = 0;
74+ glayout.setConstraints(position, gconst);
5875 add(position);
76+ glayout.setConstraints(hp, gconst);
5977 add(hp);
78+ glayout.setConstraints(fuel, gconst);
6079 add(fuel);
80+ glayout.setConstraints(heat, gconst);
6181 add(heat);
82+ glayout.setConstraints(main_bullette, gconst);
6283 add(main_bullette);
84+ glayout.setConstraints(sub_bullette, gconst);
6385 add(sub_bullette);
86+ glayout.setConstraints(software, gconst);
6487 add(software);
88+ glayout.setConstraints(status, gconst);
6589 add(status);
90+ glayout.setConstraints(option, gconst);
6691 add(option);
92+ glayout.setConstraints(backpack, gconst);
6793 add(backpack);
94+ glayout.setConstraints(counterA, gconst);
6895 add(counterA);
96+ glayout.setConstraints(counterB, gconst);
6997 add(counterB);
98+ glayout.setConstraints(counterC, gconst);
7099 add(counterC);
100+ glayout.setConstraints(counterD, gconst);
71101 add(counterD);
102+ glayout.setConstraints(counterE, gconst);
72103 add(counterE);
104+ glayout.setConstraints(counterF, gconst);
73105 add(counterF);
74106 update();
107+ pack();
75108 setLocation(410, 0);
76- setSize(200, 300);
109+ setSize(getPreferredSize());
77110 setVisible(true);
78111 }
79112
@@ -143,7 +176,8 @@
143176 heat.setText("HEAT:" + oke.get_tempture());
144177 main_bullette.setText("MAIN:" + oke.get_bullette(0));
145178 sub_bullette.setText("SUB:" + oke.get_bullette(1));
146- software.setText("CHIP X:" + oke.get_chipx() + " Y:" + oke.get_chipy());
179+ software.setText("SOFTWARE:" + oke.get_current_software()
180+ + " CHIP X:" + oke.get_chipx() + " Y:" + oke.get_chipy());
147181 switch (oke.get_status()) {
148182 case Oke.STATUS_NORMAL:
149183 status_str = "NORMAL";
@@ -220,6 +254,7 @@
220254 counterD.setText("D = " + oke.get_counter("D"));
221255 counterE.setText("E = " + oke.get_counter("E"));
222256 counterF.setText("F = " + oke.get_counter("F"));
257+ tracepanel.set_trace(oke);
223258 }
224259
225260 /**
@@ -229,6 +264,6 @@
229264 */
230265 public void set_oke(Oke p) {
231266 oke = p;
232- repaint();
267+ invalidate();
233268 }
234269 }