Newer
Older
CactusServer / src / main / java / fight3D / Character.java
y-ota on 10 May 2018 6 KB 初うp
  1. package fight3D;
  2. import framework.animation.Animation3D;
  3. import framework.audio.Sound3D;
  4. import framework.gameMain.Mode;
  5. import framework.gameMain.ModeOnGround;
  6. import framework.gameMain.ActorModel;
  7. import framework.physics.Velocity3D;
  8.  
  9.  
  10.  
  11. public class Character extends ActorModel {
  12.  
  13. private String name, comment;
  14. private String attackingPartName = null;
  15. private String upperAttackingPartName = null;
  16. private String jumpAttackingPartName = null;
  17. private long attackTimeLag = 0;
  18. private long upperAttackTimeLag = 0;
  19. private long jumpAttackTimeLag = 0;
  20. private WeaponModel weaponModel, upperWeaponModel, jumpWeaponModel;
  21. private Velocity3D weaponSpeed = new Velocity3D(4.0, 0.0, 0.0);
  22. private Velocity3D upperWeaponSpeed = new Velocity3D(4.0, 0.0, 0.0);
  23. private Velocity3D jumpWeaponSpeed = new Velocity3D(4.0, 0.0, 0.0);
  24. private double runSpeed = 5.0, jumpPower = 10.0;
  25. private int p, jf, d, s;
  26.  
  27. private static Animation3D defaultAnimation = new Animation3D();
  28. public Animation3D rightMoveAnimation = defaultAnimation;
  29. public Animation3D leftMoveAnimation = defaultAnimation;
  30. public Animation3D jumpAnimation = defaultAnimation;
  31. public Animation3D damagedAnimation = defaultAnimation;
  32. public Animation3D attackAnimation = defaultAnimation;
  33. public Animation3D upperAttackAnimation = defaultAnimation;
  34. public Animation3D jumpAttackAnimation = defaultAnimation;
  35. public Sound3D jumpSound = null;
  36. public Sound3D attackSound = null;
  37. public Sound3D upperAttackSound = null;
  38. public Sound3D jumpAttackSound = null;
  39. public Sound3D damagedSound = null;
  40. public Character(String fileName) {
  41. super(fileName);
  42. }
  43.  
  44. /**
  45. * アニメーションを返す
  46. * @param m プレイヤーのモード
  47. * @param s プレイヤーの状態
  48. * @return アニメーション
  49. */
  50. public Animation3D getAnimation(Mode m, State s) {
  51. if(m instanceof ModeOnGround) {
  52. //左右に動くアニメーションは地上にいるときのみ
  53. if(s instanceof StateLeftMove) {
  54. return new Animation3D(leftMoveAnimation);
  55. }
  56. else if(s instanceof StateRightMove) {
  57. return new Animation3D(rightMoveAnimation);
  58. }
  59. }
  60. if(s instanceof StateJump) {
  61. return new Animation3D(jumpAnimation);
  62. }
  63. else if(s instanceof StateAttack){
  64. return new Animation3D(attackAnimation);
  65. }
  66. else if(s instanceof StateUpperAttack){
  67. return new Animation3D(upperAttackAnimation);
  68. }
  69. else if(s instanceof StateJumpAttack){
  70. return new Animation3D(jumpAttackAnimation);
  71. }
  72. else if(s instanceof StateDamaged){
  73. return new Animation3D(damagedAnimation);
  74. }
  75. return new Animation3D(defaultAnimation);
  76. }
  77. /**
  78. * 効果音を返す
  79. * @param m プレイヤーのモード
  80. * @param s プレイヤーの状態
  81. * @return 効果音
  82. */
  83. public Sound3D getSoundEffect(Mode m, State s) {
  84. if(s instanceof StateJump) {
  85. return jumpSound;
  86. }
  87. else if(s instanceof StateAttack){
  88. return attackSound;
  89. }
  90. else if(s instanceof StateUpperAttack){
  91. return upperAttackSound;
  92. }
  93. else if(s instanceof StateJumpAttack){
  94. return jumpAttackSound;
  95. }
  96. else if(s instanceof StateDamaged){
  97. return damagedSound;
  98. }
  99. return null;
  100. }
  101. // public Attackable getAttackable(Player p){
  102. // Attackable a = new AttackingPart(attackingPartName , p);
  103. // return a;
  104. // }
  105.  
  106. public void setName(String n) {
  107. name = n;
  108. }
  109. public String getName() {
  110. return name;
  111. }
  112. public void setComment(String comment) {
  113. this.comment = comment;
  114. }
  115. public String getComment() {
  116. return comment;
  117. }
  118. // 攻撃する部分の名前(通常攻撃、上向きの攻撃、下向きの攻撃)
  119. public void setAttackingPartName(String apn) {
  120. attackingPartName = apn;
  121. }
  122. public String getAttackingPartName() {
  123. return attackingPartName;
  124. }
  125. public void setUpperAttackingPartName(String s) {
  126. upperAttackingPartName = s;
  127. }
  128.  
  129. public String getUpperAttackingPartName() {
  130. return upperAttackingPartName;
  131. }
  132. public void setJumpAttackingPartName(String s) {
  133. jumpAttackingPartName = s;
  134. }
  135.  
  136. public String getJumpAttackingPartName() {
  137. return jumpAttackingPartName;
  138. }
  139.  
  140. // 武器モデル(通常攻撃、上向きの攻撃、下向きの攻撃)
  141. public void setWeaponModel(WeaponModel w) {
  142. weaponModel = w;
  143. }
  144. public WeaponModel getWeaponModel() {
  145. return weaponModel;
  146. }
  147. public void setUpperWeaponModel(WeaponModel w) {
  148. upperWeaponModel = w;
  149. }
  150.  
  151. public WeaponModel getUpperWeaponModel() {
  152. return upperWeaponModel;
  153. }
  154.  
  155. public void setJumpWeaponModel(WeaponModel w) {
  156. jumpWeaponModel = w;
  157. }
  158.  
  159. public WeaponModel getJumpWeaponModel() {
  160. return jumpWeaponModel;
  161. }
  162. //飛び道具の速さ(通常攻撃、上向きの攻撃、下向きの攻撃)
  163. public void setWeaponSpeed(double x, double y, double z) {
  164. this.weaponSpeed = new Velocity3D(x, y, z);
  165. }
  166.  
  167. public Velocity3D getWeaponSpeed() {
  168. return weaponSpeed;
  169. }
  170.  
  171. public void setUpperWeaponSpeed(double x, double y, double z) {
  172. upperWeaponSpeed = new Velocity3D(x, y, z);
  173. }
  174.  
  175. public Velocity3D getUpperWeaponSpeed() {
  176. return upperWeaponSpeed;
  177. }
  178.  
  179. public void setJumpWeaponSpeed(double x, double y, double z) {
  180. jumpWeaponSpeed = new Velocity3D(x, y, z);
  181. }
  182. public Velocity3D getJumpWeaponSpeed() {
  183. return jumpWeaponSpeed;
  184. }
  185. //移動の速さ
  186. public void setRunSpeed(double rs) {
  187. this.runSpeed = rs;
  188. }
  189.  
  190. public double getRunSpeed() {
  191. return runSpeed;
  192. }
  193.  
  194. //攻撃力
  195. public void setPower(int p) {
  196. this.p = p;
  197. }
  198.  
  199. public int getPower() {
  200. return p;
  201. }
  202.  
  203. //ジャンプ力
  204. public void setJumpPower(double e) {
  205. this.jumpPower = e;
  206. }
  207.  
  208. public double getJumpPower() {
  209. return jumpPower;
  210. }
  211.  
  212. //ジャンプ回数
  213. public void setJumpFrequency(int jf) {
  214. this.jf = jf;
  215. }
  216.  
  217. public int getJumpFrequency() {
  218. return jf;
  219. }
  220.  
  221. //防御力
  222. public void setDefense(int d) {
  223. this.d = d;
  224. }
  225.  
  226. public int getDefense() {
  227. return d;
  228. }
  229. public void setSize(int s) {
  230. this.s = s;
  231. }
  232.  
  233. public int getSize() {
  234. return s;
  235. }
  236. //WeaponとAttackingPartとどちらを持っているかを聞くメソッド
  237. public boolean hasAttackingPart(){
  238. if(getAttackingPartName() != null)
  239. return true;
  240. else return false;
  241. }
  242.  
  243. public boolean hasUpperAttackingPart(){
  244. if(getUpperAttackingPartName() != null)
  245. return true;
  246. else return false;
  247. }
  248.  
  249. public boolean hasJumpAttackingPart(){
  250. if(getJumpAttackingPartName() != null)
  251. return true;
  252. else return false;
  253. }
  254.  
  255. public void setAttackTimeLag(long attackTimeLag) {
  256. this.attackTimeLag = attackTimeLag;
  257. }
  258.  
  259. public long getAttackTimeLag() {
  260. return attackTimeLag;
  261. }
  262.  
  263. public void setUpperAttackTimeLag(long upperAttackTimeLag) {
  264. this.upperAttackTimeLag = upperAttackTimeLag;
  265. }
  266.  
  267. public long getUpperAttackTimeLag() {
  268. return upperAttackTimeLag;
  269. }
  270.  
  271. public void setJumpAttackTimeLag(long jumpAttackTimeLag) {
  272. this.jumpAttackTimeLag = jumpAttackTimeLag;
  273. }
  274.  
  275. public long getJumpAttackTimeLag() {
  276. return jumpAttackTimeLag;
  277. }
  278.  
  279. }