赞 | 22 |
VIP | 917 |
好人卡 | 110 |
积分 | 218 |
经验 | 288474 |
最后登录 | 2022-10-15 |
在线时间 | 6925 小时 |
Lv5.捕梦者 (版主)
- 梦石
- 20
- 星屑
- 1840
- 在线时间
- 6925 小时
- 注册时间
- 2012-12-14
- 帖子
- 11485
|
- #==============================================================================
- # 动态显示的宝箱 v1.1 (old name: Chest Item Pop-Up)
- #------------------------------------------------------------------------------
- # 作者 : OriginalWij
- #------------------------------------------------------------------------------
- # 版本信息:
- #
- # v1.0
- # - 初版
- # v1.1
- # - 添加提示窗体
- #------------------------------------------------------------------------------
- # 注意: ① 得失物品/金钱之前,请先打开指定开关
- # ② 得失多个物品时,在多个物品之间插入一个wait(1),详见范例工程
- #------------------------------------------------------------------------------
- # 汉化版改动: ① 去掉开关自动还原功能
- # ② 按中文习惯显示描述信息
- # ③ 在描述信息中描绘图标
- # ④ 窗体屏幕居中显示
- # ⑤ 增加提示窗体自动关闭功能
- #==============================================================================
- # "金钱" 图标序号
- GOLD_ICON = 205
- # 激活动态显示的开关序号,默认为1号开关
- POPUP_SWITCH = 1
- # 得失物品的声音设定
- POPUP_SOUND = 'Chime2'
- POPUP_SOUND_VOLUME = 100
- POPUP_SOUND_PITCH = 150
-
- ## 提示窗体自动关闭的时间(以帧计算)
- WAIT_TIME = 100
- #==============================================================================
- # Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # Get X
- #--------------------------------------------------------------------------
- def get_x
- events = $game_map.events
- x_coord = events[@event_id]
- return x_coord.screen_x
- end
- #--------------------------------------------------------------------------
- # Get Y
- #--------------------------------------------------------------------------
- def get_y
- events = $game_map.events
- y_coord = events[@event_id]
- return y_coord.screen_y
- end
- #--------------------------------------------------------------------------
- # Change Gold
- #--------------------------------------------------------------------------
- def command_125
- value = operate_value(@params[0], @params[1], @params[2])
- $game_party.gain_gold(value)
- x_value = get_x
- y_value = get_y
- $scene = Chest_Popup.new(x_value, y_value, 0, value, 1) if $game_switches[POPUP_SWITCH]
- return true
- end
- #--------------------------------------------------------------------------
- # Change Items
- #--------------------------------------------------------------------------
- def command_126
- value = operate_value(@params[1], @params[2], @params[3])
- $game_party.gain_item($data_items[@params[0]], value)
- $game_map.need_refresh = true
- x_value = get_x
- y_value = get_y
- $scene = Chest_Popup.new(x_value, y_value, 1, value, @params[0]) if $game_switches[POPUP_SWITCH]
- return true
- end
- #--------------------------------------------------------------------------
- # Change Weapons
- #--------------------------------------------------------------------------
- def command_127
- value = operate_value(@params[1], @params[2], @params[3])
- $game_party.gain_item($data_weapons[@params[0]], value, @params[4])
- x_value = get_x
- y_value = get_y
- $scene = Chest_Popup.new(x_value, y_value, 2, value, @params[0]) if $game_switches[POPUP_SWITCH]
- return true
- end
- #--------------------------------------------------------------------------
- # Change Armor
- #--------------------------------------------------------------------------
- def command_128
- value = operate_value(@params[1], @params[2], @params[3])
- $game_party.gain_item($data_armors[@params[0]], value, @params[4])
- x_value = get_x
- y_value = get_y
- $scene = Chest_Popup.new(x_value, y_value, 3, value, @params[0]) if $game_switches[POPUP_SWITCH]
- return true
- end
- end
- #==============================================================================
- # Item Popup Window
- #==============================================================================
- class Item_Popup_Window < Window_Base
- #--------------------------------------------------------------------------
- # Initialize
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(0, 0, 544, 416)
- self.opacity = 0
- @x = x - 26
- @y = y - 56
- end
- #--------------------------------------------------------------------------
- # Pop-Up
- #--------------------------------------------------------------------------
- def pop_up(icon_index, x, y)
- self.contents.clear
- draw_icon(icon_index, x, y, true)
- end
- end
- #==============================================================================
- # Name window
- #==============================================================================
- class Name_Window < Window_Base
- #--------------------------------------------------------------------------
- # Initialize ## 去掉坐标传递,新增 icon_index
- #--------------------------------------------------------------------------
- def initialize(icon_index, desc, gold = false)
- ## 此位图缓存应该不需要重载
- width = Cache.system("Window").text_size(desc).width + 32
- width += 24 if gold
- ## 屏幕居中
- x = (Graphics.width - width)/2
- y = (Graphics.height - WLH-32)/2
-
- super(x, y, width, WLH + 32)
- self.opacity = 0
- if gold
-
- # self.contents.draw_text(0, 0, width-24, WLH, desc)
- # draw_icon(icon_index, width - 24-32, 0, true)
- else
- # draw_icon(icon_index, 56, 0, true)
- # self.contents.draw_text(0, 0, width, WLH, desc)
- end
- end
- end
- #==============================================================================
- # Scene_Base
- #==============================================================================
- class Scene_Base
- #--------------------------------------------------------------------------
- # Create Snapshot for Using as Background of Another Screen
- #--------------------------------------------------------------------------
- def snapshot_for_background
- $game_temp.background_bitmap.dispose
- $game_temp.background_bitmap = Graphics.snap_to_bitmap
- $game_temp.background_bitmap.blur if !$game_switches[POPUP_SWITCH]
- end
- end
- #==============================================================================
- # Chest_Popup
- #==============================================================================
- class Chest_Popup < Scene_Base
- #--------------------------------------------------------------------------
- # Initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, type, amount, index)
- @x = x
- @y = y
- @amount = amount
- [url=home.php?mod=space&uid=236945]@gold[/url] = false
- case type
- ## 改写成中文习惯
- when 0 # gold
- @icon_index = GOLD_ICON
- @desc = '金钱: ' + @amount.to_s
- @amount = 1
- @gold = true
- when 1 # items
- @icon_index = $data_items[index].icon_index
- ## 自定义文字时,请注意留空格,下同
- @desc = '物品: ' + $data_items[index].name + '×' + @amount.to_s
- when 2 # weapons
- @icon_index = $data_weapons[index].icon_index
- @desc = '武器: ' + $data_weapons[index].name + '×' + @amount.to_s
- when 3 # armors
- @icon_index = $data_armors[index].icon_index
- @desc = '防具: ' + $data_armors[index].name + '×' + @amount.to_s
- end
- end
- #--------------------------------------------------------------------------
- # Start
- #--------------------------------------------------------------------------
- def start
- create_background
- @popup_window = Item_Popup_Window.new(@x, @y)
- end
- #--------------------------------------------------------------------------
- # Terminate
- #--------------------------------------------------------------------------
- def terminate
- @popup_window.dispose
- @name_window.dispose
- @menuback_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # Return Scene
- #--------------------------------------------------------------------------
- def return_scene
- ##$game_switches[POPUP_SWITCH] = false ## 去掉还原限制
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # Update
- #--------------------------------------------------------------------------
- def update
- super
- @popup_window.update
- @menuback_sprite.update
- do_popup
- end
- #--------------------------------------------------------------------------
- # Update Basic
- #--------------------------------------------------------------------------
- def update_basic
- Graphics.update
- Input.update
- $game_map.update
- end
- #--------------------------------------------------------------------------
- # Wait
- #--------------------------------------------------------------------------
- def wait(duration)
- for i in 0...duration
- update_basic
- end
- end
- #--------------------------------------------------------------------------
- # Wait for "C"
- #--------------------------------------------------------------------------
- def wait_for_c
- ## 自动关闭的计数器
- @wait_count = WAIT_TIME
- loop do
- @wait_count -= 1
- update_basic
- ## 关闭判定
- break if Input.trigger?(Input::C) or @wait_count <= 0
- end
- end
- #--------------------------------------------------------------------------
- # Create Background
- #--------------------------------------------------------------------------
- def create_background
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = $game_temp.background_bitmap
- @menuback_sprite.update
- end
- #--------------------------------------------------------------------------
- # Show Name
- #--------------------------------------------------------------------------
- def show_name
- ## 去掉坐标传递,新增 icon_index
- @name_window = Name_Window.new(@icon_index, @desc, @gold)
- wait_for_c
- Sound.play_cancel
- end
- #--------------------------------------------------------------------------
- # Do Pop-Up
- #--------------------------------------------------------------------------
- def do_popup
- for i in 1..@amount
- Audio.se_play('Audio/SE/' + POPUP_SOUND, POPUP_SOUND_VOLUME, POPUP_SOUND_PITCH)
- for i in 0..4
- @popup_window.pop_up(@icon_index, @x - 26, @y - (i * 4) - 48)
- @popup_window.update
- wait(2)
- end
- wait(5) if i != @amount
- end
- wait(5)
- show_name
- return_scene
- end
- end
复制代码 我什么都没有干 |
评分
-
查看全部评分
|