赞 | 451 |
VIP | 56 |
好人卡 | 75 |
积分 | 424 |
经验 | 124650 |
最后登录 | 2024-11-27 |
在线时间 | 7603 小时 |
Lv5.捕梦者 (管理员) 老黄鸡
- 梦石
- 0
- 星屑
- 42436
- 在线时间
- 7603 小时
- 注册时间
- 2009-7-6
- 帖子
- 13506
|
本帖最后由 fux2 于 2011-9-1 15:20 编辑
修正问题:
1.判断忽略空值问题
2.优化判断方法,提高效率
3.可以在存档中保存和读取.(之前的档案会失效)
- class Scene_Shop < Scene_Base
- def update_buy_selection
- @status_window.item = @buy_window.item
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @command_window.active = true
- @dummy_window.visible = true
- @buy_window.active = false
- @buy_window.visible = false
- @status_window.visible = false
- @status_window.item = nil
- @help_window.set_text("")
- return
- end
- if Input.trigger?(Input::C)
- @item = @buy_window.item
- number = $game_party.item_number(@item)
- if @item == nil or @item.price > $game_party.gold or number == 99
- Sound.play_buzzer
- else
- Sound.play_decision
- if $buy_rec[$game_map.map_id]
- if $buy_rec[$game_map.map_id][$curevent]
- $buy_rec[$game_map.map_id][$curevent] << [@item.type,@item.id]
- else
- $buy_rec[$game_map.map_id][$curevent] = [[@item.type,@item.id]]
- end
- else
- $buy_rec[$game_map.map_id] = {$curevent=>[[@item.type,@item.id]]}
- end
- max = @item.price == 0 ? 99 : $game_party.gold / @item.price
- max = [max, 99 - number].min
- @buy_window.active = false
- @buy_window.visible = false
- @number_window.set(@item, max, @item.price)
- @number_window.active = true
- @number_window.visible = true
- end
- end
- end
- end
- class Game_Player < Game_Character
- def check_event_trigger_there(triggers)
- return false if $game_map.interpreter.running?
- result = false
- front_x = $game_map.x_with_direction(@x, @direction)
- front_y = $game_map.y_with_direction(@y, @direction)
- for event in $game_map.events_xy(front_x, front_y)
- if triggers.include?(event.trigger) and event.priority_type == 1
- event.start
- $curevent = event.event.id
- result = true
- end
- end
- if result == false and $game_map.counter?(front_x, front_y)
- front_x = $game_map.x_with_direction(front_x, @direction)
- front_y = $game_map.y_with_direction(front_y, @direction)
- for event in $game_map.events_xy(front_x, front_y)
- if triggers.include?(event.trigger) and event.priority_type == 1
- event.start
- result = true
- end
- end
- end
- return result
- end
- end
- class Window_ShopBuy < Window_Selectable
- def refresh
- @data = []
- @shop_goods.each{|goods_item|
- case goods_item[0]
- when 0
- item = $data_items[goods_item[1]]
- when 1
- item = $data_weapons[goods_item[1]]
- when 2
- item = $data_armors[goods_item[1]]
- end
- next if $buy_rec[$game_map.map_id] && $buy_rec[$game_map.map_id][$curevent] && $buy_rec[$game_map.map_id][$curevent].include?([item.type,item.id])
- if item != nil
- @data.push(item)
- end
- }
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- class Scene_Title < Scene_Base
- alias:cng:command_new_game
- define_method(:command_new_game){$buy_rec = {};cng}
- end
- class Scene_File < Scene_Base
- alias:wsd:write_save_data
- def write_save_data(file)
- wsd(file)
- Marshal.dump($buy_rec,file)
- end
- alias:rsd:read_save_data
- def read_save_data(file)
- rsd(file)
- $buy_rec = Marshal.load(file)
- end
- end
复制代码 [acfun]http://ftp.66rpg.com/user/fux2/myzone.html[/acfun] |
|