Advertisement
Bounen

Untitled

May 11th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.37 KB | None | 0 0
  1. public class Bounens_Slots extends MappApp {
  2. ////////////////////////////////////////////
  3. // App name (must be unique key)
  4. // アプリ名:ユニークな必要があります
  5. final static String appName = "bounenslots";
  6.  
  7. static int amount=50;
  8. static String massege;
  9. static Player clickplayer;
  10.  
  11. static int hit;//0=未当選 1=当選
  12. static int slot_mode;
  13. static int slot_seconds;
  14. static int hit_number;
  15.  
  16. //設定に使われる項目
  17. static String slot_name;
  18. static int hit_chance;
  19. static int use_coin;
  20. static int hit_coin;
  21. static String picture[] = new String[3];
  22. static int rool_time[] = new int[3];
  23. static int slot_picture_amount;
  24. static String slot_images[] = new String[30];
  25. static String slot_back;
  26.  
  27. static class MappData{
  28. int data;
  29. // Add your data here / マップごとに保存するデータはここに追加
  30.  
  31.  
  32. }
  33. /*
  34. static HashMap<Integer,YourMappApp.MappData> hashMap = new HashMap<Integer,YourMappApp.MappData>();
  35.  
  36. // ユーザーデーター読み込み
  37. static MappData loadData(int mapId) {
  38. MappData data = hashMap.get(mapId);
  39. if(data == null){
  40. data = new MappData();
  41. }
  42. return data;
  43. }
  44. // ユーザーデータ保存
  45. static MappData saveData(int mapId,MappData data){
  46. return hashMap.put(mapId,data);
  47. }*/
  48.  
  49. static public void register() {
  50.  
  51.  
  52. /////////////////////////////////////////////////
  53. // Button (nearby map) clicked event
  54. // ボタン押された時の処理
  55. DynamicMapRenderer.registerButtonEvent(appName, (String key, int mapId, Player player) -> {
  56. if (slot_mode==0) {
  57. slots_data slotsData_class = new slots_data();
  58. slotsData_class.slots_datas(0);
  59.  
  60. slot_mode = 1;
  61. clickplayer = player;
  62. ///////
  63. //処理
  64. player.sendMessage("§b§l[Bounen'§f§lsSlot]§aスロットを回しました!");
  65.  
  66. amount = amount - use_coin;
  67. ///////
  68. //確率
  69. Random rand = new Random();
  70. int randomNumber = rand.nextInt(10000);
  71. if(randomNumber<=hit_chance){
  72. hit=1;
  73. hit_number = rand.nextInt(slot_picture_amount);
  74. }
  75.  
  76.  
  77. }else{
  78. player.sendMessage("§b§l[Bounen'§f§lsSlot]§cこのスロットは回されています!");
  79. }
  80. return true;
  81. });
  82. //////////////////////////////////////////////////
  83. // DisplayTouch Event
  84. DynamicMapRenderer.registerDisplayTouchEvent(appName, (String key, int mapId, Player player, int x, int y) -> {
  85.  
  86. //////////////////////////////////////////////
  87. // Get Graphics context for drawing
  88. // 描画用コンテキスト取得
  89. Graphics2D gr = DynamicMapRenderer.getGraphics(mapId);
  90. if (gr == null) {
  91. return false;
  92. }
  93.  
  94. gr.setColor(Color.RED);
  95. gr.drawLine(x, y, x, y);
  96.  
  97. // true -> updateView:描画更新
  98. return true;
  99. });
  100.  
  101. /////////////////////////////////////////////////
  102. // rendering logic 描画ロジックをここに書く
  103. DynamicMapRenderer.register(appName, 3, (String key, int mapId, Graphics2D g) -> {
  104. /*
  105.  
  106. スロット ボタンを押した時の処理
  107.  
  108. */
  109. if (slot_mode == 1) {
  110. slot_seconds = slot_seconds + 1;
  111.  
  112. //////////
  113. //終了 処理
  114. if (slot_seconds >= rool_time[2]-2) {
  115. slot_mode = 2;
  116. slot_seconds = 0;
  117. hit = 0;
  118. //当たり
  119. if(picture[0].equalsIgnoreCase(picture[1])&&picture[1].equalsIgnoreCase(picture[2])){
  120. Bukkit.broadcastMessage("§b§l[Bounen'§f§lsSlot]§e§lおめでとうございます! コイン"+hit_coin+"枚獲得!");
  121. amount=amount+hit_coin;
  122. World w = clickplayer.getWorld();
  123. w.playSound(clickplayer.getLocation(), Sound.ENCHANT_THORNS_HIT, 3, 1);
  124. return true;
  125. }else{//ハズレ
  126. Bukkit.broadcastMessage("§b§l[Bounen'§f§lsSlot]§b§lハズレ");
  127. }
  128. }
  129.  
  130. /*
  131. スロット 回転処理
  132. */
  133. if (slot_seconds % 1 == 0) {
  134.  
  135. //////
  136. //描画
  137. if (slot_seconds <= rool_time[0]) { Bounens_Slots.slot_picture(0); }
  138. if (slot_seconds <= rool_time[1]) { Bounens_Slots.slot_picture(1); }
  139. if (slot_seconds <= rool_time[2]) { Bounens_Slots.slot_picture(2); }
  140.  
  141. ///////
  142. //Sounds
  143. World w = clickplayer.getWorld();
  144. w.playSound(clickplayer.getLocation(), Sound.BLOCK_DISPENSER_FAIL, 3, 1);
  145. }
  146. }
  147. //////
  148. //背景
  149. if(slot_mode==1 || slot_mode==2){
  150. DynamicMapRenderer.drawImage(g,slot_back+"",0,0,128,128);
  151.  
  152. g.setColor(Color.DARK_GRAY);
  153. g.fillRect(13, 24, 103, 49);//52
  154. g.setColor(Color.GRAY);
  155. g.fillRect(13, 26, 103, 45);//50
  156. g.setColor(Color.LIGHT_GRAY);
  157. g.fillRect(13, 29, 103, 39);//48
  158. g.setColor(Color.WHITE);
  159. g.fillRect(13, 32, 103, 33);//46
  160. g.setFont(new Font("SansSerif", Font.BOLD, 16));
  161. g.setColor(Color.WHITE);
  162. g.drawString("所持コイン: "+amount, 1, 124);
  163. g.drawString("所持コイン: "+amount, 1, 125);
  164. g.drawString("所持コイン: "+amount, 1, 123);
  165. g.drawString("所持コイン: "+amount, 0, 125);
  166. g.drawString("所持コイン: "+amount, 0, 123);
  167. g.drawString("所持コイン: "+amount, -1, 123);
  168. g.drawString("所持コイン: "+amount, -1, 124);
  169. g.drawString("所持コイン: "+amount, -1, 125);
  170.  
  171. g.setColor(Color.YELLOW);
  172. g.drawString("所持コイン: "+amount, 0, 124);
  173.  
  174. g.setColor(Color.BLACK);
  175. g.setFont(new Font("SansSerif", Font.BOLD, 10));
  176. g.drawString("["+slot_name+"]", 0, 85);
  177. g.drawString("1 play: "+use_coin+"枚", 0, 98);
  178. g.drawString("当たり: "+hit_coin+"枚", 0, 111);
  179.  
  180. g.setColor(Color.BLACK);
  181. g.setFont(new Font("SansSerif", Font.BOLD, 32));
  182. DynamicMapRenderer.drawImage(g,picture[0]+"",14,32,32,32);
  183. DynamicMapRenderer.drawImage(g,picture[1]+"",48,32,32,32);
  184. DynamicMapRenderer.drawImage(g,picture[2]+"",82,32,32,32);
  185. if(slot_mode==2){
  186. slot_mode=0;
  187. }
  188. return true;
  189. }else{
  190. return false;
  191. }
  192. });
  193. }
  194. /*
  195. スロット 絵柄
  196. */
  197.  
  198. static public void slot_picture(int in_amount){
  199. Random rand = new Random();
  200. int randomNumber = rand.nextInt(slot_picture_amount);
  201.  
  202. picture[in_amount]=slot_images[randomNumber];
  203. if(hit==1 && (slot_seconds==rool_time[0] || slot_seconds==rool_time[1] || slot_seconds>=rool_time[2]-3)){
  204.  
  205. if (slot_seconds == rool_time[0]) {
  206. picture[0] = new String("" + slot_images[hit_number]).toString();
  207. }
  208. if (slot_seconds == rool_time[1]) {
  209. picture[1] = new String("" + slot_images[hit_number]).toString();
  210. }
  211. if (slot_seconds >= rool_time[2]-3) {
  212. picture[2] = new String("" + slot_images[hit_number]).toString();
  213. }
  214.  
  215. }
  216. }
  217.  
  218. }
  219. class slots_data{
  220. public void slots_datas(int slots_number){
  221. switch (slots_number){
  222. case 0:
  223. Bounens_Slots.slot_name="βスロット";
  224. Bounens_Slots.slot_back="bounenslot_fairy";
  225. Bounens_Slots.hit_chance=5000;// <hit_chans>/10000の確率で当たる
  226.  
  227. Bounens_Slots.slot_picture_amount=4;//使う絵柄の枚数
  228. Bounens_Slots.slot_images[0]="bounenslot_fairy";//0から1としてカウントしてね
  229. Bounens_Slots.slot_images[1]="bounenslot_bread";
  230. Bounens_Slots.slot_images[2]="bounenslot_man10";
  231. Bounens_Slots.slot_images[3]="bounenslot_mochi";
  232.  
  233. Bounens_Slots.use_coin=1;//回す時に使う枚数
  234. Bounens_Slots.hit_coin=2;//当たりの枚数
  235.  
  236. Bounens_Slots.rool_time[0]=30;//ロールが回る時間 左
  237. Bounens_Slots.rool_time[1]=60;//ロールが回る時間 中
  238. Bounens_Slots.rool_time[2]=90;//ロールが回る時間 右
  239. }
  240.  
  241. }
  242. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement