Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Bounens_Slots extends MappApp {
- ////////////////////////////////////////////
- // App name (must be unique key)
- // アプリ名:ユニークな必要があります
- final static String appName = "bounenslots";
- static int amount=50;
- static String massege;
- static Player clickplayer;
- static int hit;//0=未当選 1=当選
- static int slot_mode;
- static int slot_seconds;
- static int hit_number;
- //設定に使われる項目
- static String slot_name;
- static int hit_chance;
- static int use_coin;
- static int hit_coin;
- static String picture[] = new String[3];
- static int rool_time[] = new int[3];
- static int slot_picture_amount;
- static String slot_images[] = new String[30];
- static String slot_back;
- static class MappData{
- int data;
- // Add your data here / マップごとに保存するデータはここに追加
- }
- /*
- static HashMap<Integer,YourMappApp.MappData> hashMap = new HashMap<Integer,YourMappApp.MappData>();
- // ユーザーデーター読み込み
- static MappData loadData(int mapId) {
- MappData data = hashMap.get(mapId);
- if(data == null){
- data = new MappData();
- }
- return data;
- }
- // ユーザーデータ保存
- static MappData saveData(int mapId,MappData data){
- return hashMap.put(mapId,data);
- }*/
- static public void register() {
- /////////////////////////////////////////////////
- // Button (nearby map) clicked event
- // ボタン押された時の処理
- DynamicMapRenderer.registerButtonEvent(appName, (String key, int mapId, Player player) -> {
- if (slot_mode==0) {
- slots_data slotsData_class = new slots_data();
- slotsData_class.slots_datas(0);
- slot_mode = 1;
- clickplayer = player;
- ///////
- //処理
- player.sendMessage("§b§l[Bounen'§f§lsSlot]§aスロットを回しました!");
- amount = amount - use_coin;
- ///////
- //確率
- Random rand = new Random();
- int randomNumber = rand.nextInt(10000);
- if(randomNumber<=hit_chance){
- hit=1;
- hit_number = rand.nextInt(slot_picture_amount);
- }
- }else{
- player.sendMessage("§b§l[Bounen'§f§lsSlot]§cこのスロットは回されています!");
- }
- return true;
- });
- //////////////////////////////////////////////////
- // DisplayTouch Event
- DynamicMapRenderer.registerDisplayTouchEvent(appName, (String key, int mapId, Player player, int x, int y) -> {
- //////////////////////////////////////////////
- // Get Graphics context for drawing
- // 描画用コンテキスト取得
- Graphics2D gr = DynamicMapRenderer.getGraphics(mapId);
- if (gr == null) {
- return false;
- }
- gr.setColor(Color.RED);
- gr.drawLine(x, y, x, y);
- // true -> updateView:描画更新
- return true;
- });
- /////////////////////////////////////////////////
- // rendering logic 描画ロジックをここに書く
- DynamicMapRenderer.register(appName, 3, (String key, int mapId, Graphics2D g) -> {
- /*
- スロット ボタンを押した時の処理
- */
- if (slot_mode == 1) {
- slot_seconds = slot_seconds + 1;
- //////////
- //終了 処理
- if (slot_seconds >= rool_time[2]-2) {
- slot_mode = 2;
- slot_seconds = 0;
- hit = 0;
- //当たり
- if(picture[0].equalsIgnoreCase(picture[1])&&picture[1].equalsIgnoreCase(picture[2])){
- Bukkit.broadcastMessage("§b§l[Bounen'§f§lsSlot]§e§lおめでとうございます! コイン"+hit_coin+"枚獲得!");
- amount=amount+hit_coin;
- World w = clickplayer.getWorld();
- w.playSound(clickplayer.getLocation(), Sound.ENCHANT_THORNS_HIT, 3, 1);
- return true;
- }else{//ハズレ
- Bukkit.broadcastMessage("§b§l[Bounen'§f§lsSlot]§b§lハズレ");
- }
- }
- /*
- スロット 回転処理
- */
- if (slot_seconds % 1 == 0) {
- //////
- //描画
- if (slot_seconds <= rool_time[0]) { Bounens_Slots.slot_picture(0); }
- if (slot_seconds <= rool_time[1]) { Bounens_Slots.slot_picture(1); }
- if (slot_seconds <= rool_time[2]) { Bounens_Slots.slot_picture(2); }
- ///////
- //Sounds
- World w = clickplayer.getWorld();
- w.playSound(clickplayer.getLocation(), Sound.BLOCK_DISPENSER_FAIL, 3, 1);
- }
- }
- //////
- //背景
- if(slot_mode==1 || slot_mode==2){
- DynamicMapRenderer.drawImage(g,slot_back+"",0,0,128,128);
- g.setColor(Color.DARK_GRAY);
- g.fillRect(13, 24, 103, 49);//52
- g.setColor(Color.GRAY);
- g.fillRect(13, 26, 103, 45);//50
- g.setColor(Color.LIGHT_GRAY);
- g.fillRect(13, 29, 103, 39);//48
- g.setColor(Color.WHITE);
- g.fillRect(13, 32, 103, 33);//46
- g.setFont(new Font("SansSerif", Font.BOLD, 16));
- g.setColor(Color.WHITE);
- g.drawString("所持コイン: "+amount, 1, 124);
- g.drawString("所持コイン: "+amount, 1, 125);
- g.drawString("所持コイン: "+amount, 1, 123);
- g.drawString("所持コイン: "+amount, 0, 125);
- g.drawString("所持コイン: "+amount, 0, 123);
- g.drawString("所持コイン: "+amount, -1, 123);
- g.drawString("所持コイン: "+amount, -1, 124);
- g.drawString("所持コイン: "+amount, -1, 125);
- g.setColor(Color.YELLOW);
- g.drawString("所持コイン: "+amount, 0, 124);
- g.setColor(Color.BLACK);
- g.setFont(new Font("SansSerif", Font.BOLD, 10));
- g.drawString("["+slot_name+"]", 0, 85);
- g.drawString("1 play: "+use_coin+"枚", 0, 98);
- g.drawString("当たり: "+hit_coin+"枚", 0, 111);
- g.setColor(Color.BLACK);
- g.setFont(new Font("SansSerif", Font.BOLD, 32));
- DynamicMapRenderer.drawImage(g,picture[0]+"",14,32,32,32);
- DynamicMapRenderer.drawImage(g,picture[1]+"",48,32,32,32);
- DynamicMapRenderer.drawImage(g,picture[2]+"",82,32,32,32);
- if(slot_mode==2){
- slot_mode=0;
- }
- return true;
- }else{
- return false;
- }
- });
- }
- /*
- スロット 絵柄
- */
- static public void slot_picture(int in_amount){
- Random rand = new Random();
- int randomNumber = rand.nextInt(slot_picture_amount);
- picture[in_amount]=slot_images[randomNumber];
- if(hit==1 && (slot_seconds==rool_time[0] || slot_seconds==rool_time[1] || slot_seconds>=rool_time[2]-3)){
- if (slot_seconds == rool_time[0]) {
- picture[0] = new String("" + slot_images[hit_number]).toString();
- }
- if (slot_seconds == rool_time[1]) {
- picture[1] = new String("" + slot_images[hit_number]).toString();
- }
- if (slot_seconds >= rool_time[2]-3) {
- picture[2] = new String("" + slot_images[hit_number]).toString();
- }
- }
- }
- }
- class slots_data{
- public void slots_datas(int slots_number){
- switch (slots_number){
- case 0:
- Bounens_Slots.slot_name="βスロット";
- Bounens_Slots.slot_back="bounenslot_fairy";
- Bounens_Slots.hit_chance=5000;// <hit_chans>/10000の確率で当たる
- Bounens_Slots.slot_picture_amount=4;//使う絵柄の枚数
- Bounens_Slots.slot_images[0]="bounenslot_fairy";//0から1としてカウントしてね
- Bounens_Slots.slot_images[1]="bounenslot_bread";
- Bounens_Slots.slot_images[2]="bounenslot_man10";
- Bounens_Slots.slot_images[3]="bounenslot_mochi";
- Bounens_Slots.use_coin=1;//回す時に使う枚数
- Bounens_Slots.hit_coin=2;//当たりの枚数
- Bounens_Slots.rool_time[0]=30;//ロールが回る時間 左
- Bounens_Slots.rool_time[1]=60;//ロールが回る時間 中
- Bounens_Slots.rool_time[2]=90;//ロールが回る時間 右
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement