rpg物品存放.docx
《rpg物品存放.docx》由会员分享,可在线阅读,更多相关《rpg物品存放.docx(43页珍藏版)》请在冰豆网上搜索。
rpg物品存放
#==============================================================================
#■Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
classGame_System
attr_accessor:
goods
aliasvaule_shop_66RPG_initializeinitialize
definitialize
vaule_shop_66RPG_initialize
@goods=[]
###########################################################################
#初期的时候的商店物品,编号顺序:
种类,ID,可卖数量
@goods[1]=[[-1,-1,-1]]
###########################################################################
end
defshop_change(shop,kind,id,delnumber)
dl=delnumber
fordtin$game_system.goods[shop]
if(dt[0]==kind)and(dt[1]==id)
dt[2]-=dl
dt[2]=[dt[2],99].min
ifdt[2]==0
$game_system.goods[shop].delete(dt)
end
return
end
end
$game_system.goods[shop].push([kind,id,-delnumber])
end
end
classScene_Shop_Vb
definitialize(shop_number)
#当前商店编号
@shop_now=shop_number
end
#--------------------------------------------------------------------------
#●主处理
#--------------------------------------------------------------------------
defmain
#生成帮助窗口
@help_window=Window_Help_Vb.new
#生成指令窗口
@command_window=Window_ShopCommand_Vb.new
#生成金钱窗口
@gold_window=Window_Gold_Vb.new
@gold_window.x=480
@gold_window.y=64
#生成游戏时间窗口
@playtime_window=Window_PlayTime_Vb.new
@playtime_window.x=380
@playtime_window.y=0
#生成时间窗口
@dummy_window=Window_Base.new(0,128,640,352)
#生成购买窗口
@buy_window=Window_ShopBuy_Vb.new($game_system.goods[@shop_now])
@buy_window.active=false
@buy_window.visible=false
@buy_window.help_window=@help_window
#生成卖出窗口
@sell_window=Window_ShopSell_Vb.new
@sell_window.active=false
@sell_window.visible=false
@sell_window.help_window=@help_window
#生成数量输入窗口
@number_window=Window_ShopNumber_Vb.new
@number_window.active=false
@number_window.visible=false
#生成状态窗口
@status_window=Window_ShopStatus_Vb.new
@status_window.visible=true
#执行过渡
Graphics.transition
#主循环
loopdo
#刷新游戏画面
Graphics.update
#刷新输入信息
Input.update
#刷新画面
update
#如果画面切换的话就中断循环
if$scene!
=self
break
end
end
#准备过渡
Graphics.freeze
#释放窗口
@help_window.dispose
@command_window.dispose
@playtime_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
#●刷新画面
#--------------------------------------------------------------------------
defupdate
#刷新窗口
@help_window.update
@command_window.update
@playtime_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
#指令窗口激活的情况下:
调用update_command
if@command_window.active
update_command
return
end
#购买窗口激活的情况下:
调用update_buy
if@buy_window.active
update_buy
return
end
#卖出窗口激活的情况下:
调用update_sell
if@sell_window.active
update_sell
return
end
#个数输入窗口激活的情况下:
调用update_number
if@number_window.active
update_number
return
end
end
#--------------------------------------------------------------------------
#●刷新画面(指令窗口激活的情况下)
#--------------------------------------------------------------------------
defupdate_command
#按下B键的情况下
ifInput.trigger?
(Input:
:
B)
#演奏取消SE
$game_system.se_play($data_system.cancel_se)
#切换到地图画面
$scene=Scene_Map.new
return
end
#按下C键的情况下
ifInput.trigger?
(Input:
:
C)
#命令窗口光标位置分支
case@command_window.index
when1#购买
#演奏确定SE
$game_system.se_play($data_system.decision_se)
#窗口状态转向购买模式
@command_window.active=false
@dummy_window.visible=false
@buy_window.active=true
@buy_window.visible=true
@buy_window.refresh
@status_window.visible=true
when0#卖出
#演奏确定SE
$game_system.se_play($data_system.decision_se)
#窗口状态转向卖出模式
@command_window.active=false
@dummy_window.visible=false
@sell_window.active=true
@sell_window.visible=true
@sell_window.refresh
@status_window.visible=true
when2#取消
#演奏确定SE
$game_system.se_play($data_system.decision_se)
#切换到地图画面
$scene=Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
#●刷新画面(购买窗口激活的情况下)
#--------------------------------------------------------------------------
defupdate_buy
#设置状态窗口的物品
@status_window.item=@buy_window.item
#按下B键的情况下
ifInput.trigger?
(Input:
:
B)
#演奏取消SE
$game_system.se_play($data_system.cancel_se)
#窗口状态转向初期模式
@command_window.active=true
@dummy_window.visible=true
@buy_window.active=false
@buy_window.visible=false
@status_window.visible=true
@status_window.item=nil
#删除帮助文本
@help_window.set_text("")
return
end
#按下C键的情况下
ifInput.trigger?
(Input:
:
C)
#获取物品
@item=@buy_window.item
#物品无效的情况下、或者价格在所持金以上的情况下
if@item==nil#or@item.price>$game_party.gold
#演奏冻结SE
$game_system.se_play($data_system.buzzer_se)
return
end
#获取物品所持数
case@item
whenRPG:
:
Item
number=$game_party.item_number(@item.id)
whenRPG:
:
Weapon
number=$game_party.weapon_number(@item.id)
whenRPG:
:
Armor
number=$game_party.armor_number(@item.id)
end
#如果已经拥有了99个情况下
ifnumber==99
#演奏冻结SE
$game_system.se_play($data_system.buzzer_se)
return
end
#演奏确定SE
$game_system.se_play($data_system.decision_se)
#计算可以最多购买的数量
max=@item.price==0?
99:
$game_party.gold/@item.price
max=[[max,99-number].min,@buy_window.item_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
#--------------------------------------------------------------------------
#●画面更新(卖出窗口激活的情况下)
#--------------------------------------------------------------------------
defupdate_sell
#按下B键的情况下
ifInput.trigger?
(Input:
:
B)
#演奏取消SE
$game_system.se_play($data_system.cancel_se)
#窗口状态转向初期模式
@command_window.active=true
@dummy_window.visible=true
@sell_window.active=false
@sell_window.visible=false
@status_window.visible=true
@status_window.item=nil
#删除帮助文本
@help_window.set_text("")
return
end
#按下C键的情况下
ifInput.trigger?
(Input:
:
C)
#获取物品
@item=@sell_window.item
#物品无效的情况下、或者价格为0(不能卖出)的情况下
if@item==nil#or@item.price==0
#演奏冻结SE
$game_system.se_play($data_system.buzzer_se)
return
end
#如果金钱为0G情况下
if$game_party.gold==0
#演奏冻结SE
$game_system.se_play($data_system.buzzer_se)
$game_temp.message_text="老大,没有钱不要来存东西好不好?
"
#切换到地图画面
$scene=Scene_Map.new
return
end
#演奏确定SE
$game_system.se_play($data_system.decision_se)
#获取物品的所持数
case@item
whenRPG:
:
Item
number=$game_party.item_number(@item.id)
whenRPG:
:
Weapon
number=$game_party.weapon_number(@item.id)
whenRPG:
:
Armor
number=$game_party.armor_number(@item.id)
end
#最大卖出个数=物品的所持数
max=number
#窗口状态转向个数输入模式
@sell_window.active=false
@sell_window.visible=false
@number_window.set(@item,max,@item.price/2)
@number_window.active=true
@number_window.visible=true
@status_window.visible=true
end
end
#--------------------------------------------------------------------------
#●刷新画面(个数输入窗口激活的情况下)
#--------------------------------------------------------------------------
defupdate_number
#按下B键的情况下
ifInput.trigger?
(Input:
:
B)
#演奏取消SE
$game_system.se_play($data_system.cancel_se)
#设置个数输入窗口为不活动·非可视状态
@number_window.active=false
@number_window.visible=false
#命令窗口光标位置分支
case@command_window.index
when1#购买
#窗口状态转向购买模式
@buy_window.active=true
@buy_window.visible=true
when0#卖出
#窗口状态转向卖出模式
@sell_window.active=true
@sell_window.visible=true
end
return
end
#按下C键的情况下
ifInput.trigger?
(Input:
:
C)
#演奏商店SE
$game_system.se_play($data_system.shop_se)
#设置个数输入窗口为不活动·非可视状态
@number_window.active=false
@number_window.visible=false
#命令窗口光标位置分支
case@command_window.index
when1#购买
#购买处理
temp=0
case@item
whenRPG:
:
Item
$game_party.gain_item(@item.id,@number_window.number)
whenRPG:
:
Weapon
$game_party.gain_weapon(@item.id,@number_window.number)
temp=1
whenRPG:
:
Armor
$game_party.gain_armor(@item.id,@number_window.number)
temp=2
end
goods_del(temp,@item.id,@number_window.number)
#刷新各窗口
@buy_window=Window_ShopBuy_Vb.new($game_system.goods[@shop_now])
@buy_window.help_window=@help_window
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
#窗口状态转向购买模式
@buy_window.active=true
@buy_window.visible=true
when0#卖出
#卖出处理
$game_party.lose_gold(@number_window.number)
temp=0
case@item
whenRPG:
:
Item
$game_party.lose_item(@item.id,@number_window.number)
whenRPG:
:
Weapon
$game_party.lose_weapon(@item.id,@number_window.number)
temp=1
whenRPG:
:
Armor
$game_party.lose_armor(@item.id,@number_window.number)
temp=2
end
#刷新各窗口
goods_del(temp,@item.id,-@number_window.number)
@buy_window=Window_ShopBuy_Vb.new($game_system.goods[@shop_now])
@buy_window.active=false
@buy_window.visible=false
@buy_window.help_window=@help_window
@gol