Newer
Older
CactusServer / src / main / java / fight3D / FightCanvas3D.java
y-ota on 10 May 2018 5 KB 初うp
  1. package fight3D;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.GraphicsConfiguration;
  6.  
  7. import framework.RWT.RWTCanvas3D;
  8. import framework.RWT.RWTLabel;
  9.  
  10.  
  11. public class FightCanvas3D extends RWTCanvas3D implements FightListener{
  12. Game game;
  13. double distance;
  14. RWTLabel player[] = new RWTLabel[6];
  15. float showY = 0.8f;
  16. float showX[];
  17. static final double POINT_SPACE = 0.075;
  18. double Point_distance = 0;
  19.  
  20. RWTLabel TP[] = new RWTLabel[6];
  21. static final float TP_showY = 0.85f;
  22. float TP_showX[];
  23. RWTLabel HP[] = new RWTLabel[6];
  24. static final float HP_showY = 0.9f;
  25. float HP_showX[];
  26. RWTLabel GP[] = new RWTLabel[6];
  27. static final float GP_showY = 0.95f;
  28. float GP_showX[];
  29. int playerNum;
  30.  
  31. RWTLabel TIMER_Minute = new RWTLabel();
  32. RWTLabel kolon = new RWTLabel();
  33. RWTLabel TIMER_Second = new RWTLabel();
  34. public void update(Fight f){
  35. //各種ポイントの表示
  36. for(int i = 0; i < f.getPlayerList().size(); i++){
  37. TP_showX = new float[playerNum];
  38. HP_showX = new float[playerNum];
  39. String T_P = Integer.toString(f.getPlayerList().get(i).getTp());
  40. String H_P = Integer.toString(f.getPlayerList().get(i).getHp());
  41. String G_P = Integer.toString(f.getPlayerList().get(i).getGp());
  42. TP[i].setString("TP : " + T_P);
  43. HP[i].setString("HP : " + H_P);
  44. GP[i].setString("GP : " + G_P);
  45. TP_showX[i] = (float) ((POINT_SPACE - 0.05) + Point_distance * i);
  46. HP_showX[i] = (float) ((POINT_SPACE - 0.05) + Point_distance * i);
  47. GP_showX[i] = (float) ((POINT_SPACE - 0.05) + Point_distance * i);
  48. TP[i].setRelativePosition((float)(TP_showX[i] + POINT_SPACE),TP_showY, RWTLabel.DRAW_RIGHT);
  49. HP[i].setRelativePosition((float)(HP_showX[i] + POINT_SPACE),HP_showY, RWTLabel.DRAW_RIGHT);
  50. GP[i].setRelativePosition((float)(HP_showX[i] + POINT_SPACE),GP_showY, RWTLabel.DRAW_RIGHT);
  51. }
  52. //タイマー表示
  53. String.valueOf(f.getRemnantMinute());
  54. String.valueOf(f.getRemnantSecond());
  55.  
  56. String TIMER_M = Integer.toString(f.getRemnantMinute());
  57. String TIMER_S = Integer.toString(f.getRemnantSecond());
  58. if(TIMER_S.length() == 1){
  59. TIMER_S = "0" + TIMER_S;
  60. }
  61. TIMER_Minute.setString(TIMER_M);
  62. kolon.setString(":");
  63. TIMER_Second.setString(TIMER_S);
  64. if(f.checkEnd() == true){
  65. game.setRank(f.getRank());
  66. game.setTp(f.getTp());
  67. game.setDefeated(f.getDefeated());
  68. game.setDefeat(f.getDefeat());
  69. game.goNextGameState();
  70. }
  71. }
  72. ////////////////////////////////////////////////////////////////////////////////////
  73. public FightCanvas3D(GraphicsConfiguration gc, Game g, int playerNum) {
  74. super(gc);
  75. init(g, playerNum);
  76. }
  77.  
  78. public FightCanvas3D(Game g, int playerNum) {
  79. init(g, playerNum);
  80. }
  81. public void init(Game g, int playerNum) {
  82. game = g;
  83. this.playerNum = playerNum;
  84. //プレイヤー
  85.  
  86. double space = 0.075;
  87. distance = (1.0 - space * 2) / (double)playerNum;
  88.  
  89. showX = new float[playerNum];
  90. for(int i = 0; i < playerNum; i++){
  91. player[i] = new RWTLabel();
  92. String name = Integer.toString(i+1);
  93. name = name + "P";
  94. player[i].setString(name);
  95. player[i].setColor(Color.GREEN);
  96. showX[i] = (float) (distance * i);
  97. player[i].setRelativePosition((float)(showX[i] + space),showY);
  98. Font p = new Font("",Font.PLAIN,20);
  99. player[i].setFont(p);
  100. addWidget(player[i]);
  101. }
  102. //トータルポイント
  103. double Point_space = 0.075;
  104. Point_distance = (1.0 - Point_space * 2) / (double)playerNum;
  105.  
  106. TP_showX = new float[playerNum];
  107. for(int i = 0; i < playerNum; i++){
  108. TP[i] = new RWTLabel();
  109. String name = "TP:";
  110. TP[i].setString(name);
  111. TP[i].setColor(Color.RED);
  112. TP_showX[i] = (float) ((Point_space - 0.06) + Point_distance * i);
  113. TP[i].setRelativePosition((float)(TP_showX[i] + Point_space),TP_showY, RWTLabel.DRAW_LEFT);
  114. Font tp = new Font("",Font.PLAIN,10);
  115. TP[i].setFont(tp);
  116. addWidget(TP[i]);
  117. }
  118. //ヒットポイント
  119.  
  120. HP_showX = new float[playerNum];
  121. for(int i = 0; i < playerNum; i++){
  122. HP[i] = new RWTLabel();
  123. String name = "HP:";
  124. HP[i].setString(name);
  125. HP[i].setColor(Color.BLUE);
  126. HP_showX[i] = (float) ((Point_space - 0.06)+ Point_distance * i);
  127. HP[i].setRelativePosition((float)(HP_showX[i] + Point_space),HP_showY, RWTLabel.DRAW_LEFT);
  128. Font hp = new Font("",Font.PLAIN,10);
  129. HP[i].setFont(hp);
  130. addWidget(HP[i]);
  131. }
  132. //ガードポイント
  133. GP_showX = new float[playerNum];
  134. for(int i = 0; i < playerNum; i++){
  135. GP[i] = new RWTLabel();
  136. String name = "GP:";
  137. GP[i].setString(name);
  138. GP[i].setColor(Color.YELLOW);
  139. GP_showX[i] = (float) ((Point_space - 0.06) + Point_distance * i);
  140. GP[i].setRelativePosition((float)(GP_showX[i] + Point_space),GP_showY, RWTLabel.DRAW_LEFT);
  141. Font gp = new Font("",Font.PLAIN,10);
  142. GP[i].setFont(gp);
  143. addWidget(GP[i]);
  144. }
  145.  
  146. TIMER_Minute.setColor(Color.WHITE);
  147. kolon.setColor(Color.WHITE);
  148. TIMER_Second.setColor(Color.WHITE);
  149. TIMER_Minute.setRelativePosition(0.8f, 0.1f);
  150. kolon.setRelativePosition(0.86f, 0.1f);
  151. TIMER_Second.setRelativePosition(0.9f, 0.1f);
  152. Font t1 = new Font("",Font.PLAIN,40);
  153. Font k = new Font("",Font.PLAIN,40);
  154. Font t2 = new Font("",Font.PLAIN,40);
  155. TIMER_Minute.setFont(t1);
  156. kolon.setFont(k);
  157. TIMER_Second.setFont(t2);
  158. addWidget(TIMER_Minute);
  159. addWidget(kolon);
  160. addWidget(TIMER_Second);
  161. Point_distance = (1.0 - POINT_SPACE * 2) / (double)playerNum;
  162. }
  163.  
  164.  
  165. }