無人機動兵器ダンジョン探索ゲーム JAVAベース
プレイヤー以外の機体も階段降りて新しい階に移動出来るようにしてみた
| @@ -167,7 +167,7 @@ | ||
| 167 | 167 | } |
| 168 | 168 | floor.add(dungeon); |
| 169 | 169 | if (usebone == false) { |
| 170 | - plot_init_enemy(); | |
| 170 | + plot_init_enemy(current_floor); | |
| 171 | 171 | } |
| 172 | 172 | pcOke = pc; |
| 173 | 173 | viewBaseOke = pcOke; |
| @@ -414,6 +414,39 @@ | ||
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
| 417 | + * 新しいフロアを生成 | |
| 418 | + * | |
| 419 | + * @return 階数 | |
| 420 | + */ | |
| 421 | + public int generate_floor() { | |
| 422 | + int new_floor = floor.size(); | |
| 423 | + DungeonFloor dungeon; | |
| 424 | + boolean usebone; | |
| 425 | + dungeon = load_bone_file(); | |
| 426 | + if (dungeon == null) { | |
| 427 | + dungeon = new DungeonFloor(new_floor); | |
| 428 | + usebone = false; | |
| 429 | + } else { | |
| 430 | + usebone = true; | |
| 431 | + } | |
| 432 | + floor.add(dungeon); | |
| 433 | + if (usebone == false) { | |
| 434 | + plot_init_enemy(new_floor); | |
| 435 | + } | |
| 436 | + if (higefloor == new_floor) { | |
| 437 | + //plot hige | |
| 438 | + do { | |
| 439 | + higex = (int) (Math.random() * (DungeonFloor.FLOOR_X - 2)) | |
| 440 | + + 1; | |
| 441 | + higey = (int) (Math.random() * (DungeonFloor.FLOOR_Y - 2)) | |
| 442 | + + 1; | |
| 443 | + } while (dungeon.iswall(higex, higey) == true); | |
| 444 | + dungeon.clear_downstairs(); | |
| 445 | + } | |
| 446 | + return new_floor; | |
| 447 | + } | |
| 448 | + | |
| 449 | + /** | |
| 417 | 450 | * 階数を一つ降りる |
| 418 | 451 | * |
| 419 | 452 | * @return 移動後の階数 |
| @@ -422,31 +455,9 @@ | ||
| 422 | 455 | DungeonFloor dungeon; |
| 423 | 456 | current_floor++; |
| 424 | 457 | if (current_floor >= floor.size()) { |
| 425 | - boolean usebone; | |
| 426 | - dungeon = load_bone_file(); | |
| 427 | - if (dungeon == null) { | |
| 428 | - dungeon = new DungeonFloor(current_floor); | |
| 429 | - usebone = false; | |
| 430 | - } else { | |
| 431 | - usebone = true; | |
| 432 | - } | |
| 433 | - floor.add(dungeon); | |
| 434 | - if (usebone == false) { | |
| 435 | - plot_init_enemy(); | |
| 436 | - } | |
| 437 | - if (higefloor == current_floor) { | |
| 438 | - //plot hige | |
| 439 | - do { | |
| 440 | - higex = (int) (Math.random() * (DungeonFloor.FLOOR_X - 2)) | |
| 441 | - + 1; | |
| 442 | - higey = (int) (Math.random() * (DungeonFloor.FLOOR_Y - 2)) | |
| 443 | - + 1; | |
| 444 | - } while (dungeon.iswall(higex, higey) == true); | |
| 445 | - dungeon.clear_downstairs(); | |
| 446 | - } | |
| 447 | - } else { | |
| 448 | - dungeon = (DungeonFloor) floor.get(current_floor); | |
| 458 | + current_floor = generate_floor(); | |
| 449 | 459 | } |
| 460 | + dungeon = (DungeonFloor) floor.get(current_floor); | |
| 450 | 461 | pcOke.set_x(dungeon.get_up_stairsx()); |
| 451 | 462 | pcOke.set_y(dungeon.get_up_stairsy()); |
| 452 | 463 | pcOke.set_floor(current_floor); |
| @@ -995,7 +1006,7 @@ | ||
| 995 | 1006 | if (turn_count == 1800) { |
| 996 | 1007 | turn_count = 0; |
| 997 | 1008 | if (CarnageHack.dice100() > 70) { |
| 998 | - plot_init_enemy(); | |
| 1009 | + plot_init_enemy(current_floor); | |
| 999 | 1010 | } |
| 1000 | 1011 | } |
| 1001 | 1012 | if (pcOke.isdead() == true || pcOke.get_fuel() == 0) { |
| @@ -1027,11 +1038,12 @@ | ||
| 1027 | 1038 | * OKEデータを管理リストへ追加 |
| 1028 | 1039 | * |
| 1029 | 1040 | * @param p OKEデータ |
| 1041 | + * @param n 階数 | |
| 1030 | 1042 | */ |
| 1031 | - public void addOke(Oke p) { | |
| 1043 | + public void addOke(Oke p, int n) { | |
| 1032 | 1044 | int x; |
| 1033 | 1045 | int y; |
| 1034 | - DungeonFloor dungeon = (DungeonFloor) floor.get(current_floor); | |
| 1046 | + DungeonFloor dungeon = (DungeonFloor) floor.get(n); | |
| 1035 | 1047 | do { |
| 1036 | 1048 | x = (int) (Math.random() * (DungeonFloor.FLOOR_X - 2)) + 1; |
| 1037 | 1049 | y = (int) (Math.random() * (DungeonFloor.FLOOR_Y - 2)) + 1; |
| @@ -1038,21 +1050,23 @@ | ||
| 1038 | 1050 | } while (dungeon.iswall(x, y) == true); |
| 1039 | 1051 | p.set_x(x); |
| 1040 | 1052 | p.set_y(y); |
| 1041 | - p.set_floor(current_floor); | |
| 1053 | + p.set_floor(n); | |
| 1042 | 1054 | oke.add(p); |
| 1043 | 1055 | } |
| 1044 | 1056 | |
| 1045 | 1057 | /** |
| 1046 | 1058 | * 敵OKEを発生させる |
| 1059 | + * | |
| 1060 | + * @param n | |
| 1047 | 1061 | */ |
| 1048 | - public void makeNewOke() { | |
| 1062 | + public void makeNewOke(int n) { | |
| 1049 | 1063 | Oke p = new Oke(Oke.IFF_ENEMY, |
| 1050 | - (int) (Math.random() * (current_floor + 1) * 100) + (current_floor | |
| 1051 | - / 5 + 1) * 100, | |
| 1064 | + (int) (Math.random() * (n + 1) * 100) | |
| 1065 | + + (n / 5 + 1) * 100, | |
| 1052 | 1066 | CarnageHack.makeNewHard(), |
| 1053 | 1067 | CarnageHack.makeNewSoft(this), |
| 1054 | 1068 | null); |
| 1055 | - addOke(p); | |
| 1069 | + addOke(p, n); | |
| 1056 | 1070 | } |
| 1057 | 1071 | |
| 1058 | 1072 | /** |
| @@ -1092,11 +1106,12 @@ | ||
| 1092 | 1106 | /** |
| 1093 | 1107 | * 敵OKEの初期配備 |
| 1094 | 1108 | */ |
| 1095 | - private void plot_init_enemy() { | |
| 1096 | - int nmax = (int) (Math.random() * ((current_floor / 5) + 1) * 3) + 1; | |
| 1109 | + private void plot_init_enemy(int nfloor) { | |
| 1110 | + int nmax; | |
| 1097 | 1111 | int i; |
| 1112 | + nmax = (int) (Math.random() * ((nfloor / 5) + 1) * 3) + 1; | |
| 1098 | 1113 | for (i = 0; i < nmax; i++) { |
| 1099 | - makeNewOke(); | |
| 1114 | + makeNewOke(nfloor); | |
| 1100 | 1115 | } |
| 1101 | 1116 | } |
| 1102 | 1117 |
| @@ -605,10 +605,14 @@ | ||
| 605 | 605 | } else { |
| 606 | 606 | df = dungeon.get_floor(floor + 1); |
| 607 | 607 | if (df != null) { |
| 608 | - x = df.get_up_stairsx(); | |
| 609 | - y = df.get_up_stairsy(); | |
| 610 | 608 | floor++; |
| 609 | + } else { | |
| 610 | + //new floor | |
| 611 | + floor = dungeon.generate_floor(); | |
| 612 | + df = dungeon.get_floor(floor); | |
| 611 | 613 | } |
| 614 | + x = df.get_up_stairsx(); | |
| 615 | + y = df.get_up_stairsy(); | |
| 612 | 616 | } |
| 613 | 617 | action = ACTION_NONE; |
| 614 | 618 | status = STATUS_NORMAL; |