赞 | 153 |
VIP | 10 |
好人卡 | 39 |
积分 | 93 |
经验 | 146191 |
最后登录 | 2024-5-6 |
在线时间 | 2504 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9280
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 帖子
- 15389
|
- #==============================================================================
- # ■ Scene_SellShop
- #------------------------------------------------------------------------------
- # 处理商店画面的类。使用方法:$scene=Scene_SellShop.new。
- # 这种商店称作“典当行”,只能卖不能买。
- #==============================================================================
- class Scene_SellShop
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 生成帮助窗口
- $itembankflag = 0
- @help_window = Window_Help.new
- # 生成指令窗口
- @command_window = Window_SSShopCommand.new
- # 生成金钱窗口
- @gold_window = Window_Gold.new
- @gold_window.x = 800#480
- @gold_window.y = 192#64
- # 生成时间窗口
- @dummy_window = Window_Base.new(0, 128, 800, 480)#0,128,640,352
- # 生成卖出窗口
- @sell_window = Window_ShopSell.new
- @sell_window.active = false
- @sell_window.visible = false
- @sell_window.help_window = @help_window
- # 生成数量输入窗口
- @number_window = Window_ShopNumber.new
- @number_window.active = false
- @number_window.visible = false
- # 生成状态窗口
- @status_window = Window_ShopStatus.new
- @status_window.visible = false
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @command_window.dispose
- @gold_window.dispose
- @dummy_window.dispose
-
- @sell_window.dispose
- @number_window.dispose
- @status_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @command_window.update
- @gold_window.update
- @dummy_window.update
-
- @sell_window.update
- @number_window.update
- @status_window.update
- # 指令窗口激活的情况下: 调用 update_command
- if @command_window.active
- update_command
- return
- end
-
- # 卖出窗口激活的情况下: 调用 update_sell
- if @sell_window.active
- update_sell
- return
- end
- # 个数输入窗口激活的情况下: 调用 update_number
- if @number_window.active
- update_number
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (指令窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_command
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 卖出
- # 演奏确定 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
- when 1 # 取消
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- return
- end
- end
-
- #--------------------------------------------------------------------------
- # ● 画面更新 (卖出窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_sell
- # 按下 B 键的情况下
- if Input.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.item = nil
- # 删除帮助文本
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 获取物品
- @item = @sell_window.item
- # 设置状态窗口的物品
- @status_window.item = @item
- # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
- if @item == nil or @item.price == 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取物品的所持数
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- when RPG::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
- #--------------------------------------------------------------------------
- # ● 刷新画面 (个数输入窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_number
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 设置个数输入窗口为不活动·非可视状态
- @number_window.active = false
- @number_window.visible = false
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 卖出
- # 窗口状态转向卖出模式
- @sell_window.active = true
- @sell_window.visible = true
- @status_window.visible = false
- end
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏商店 SE
- $game_system.se_play($data_system.shop_se)
- # 设置个数输入窗口为不活动·非可视状态
- @number_window.active = false
- @number_window.visible = false
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 卖出
- # 卖出处理
- $game_party.gain_gold(@number_window.number * (@item.price / 2))
- case @item
- when RPG::Item
- $game_party.lose_item(@item.id, @number_window.number)
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, @number_window.number)
- when RPG::Armor
- $game_party.lose_armor(@item.id, @number_window.number)
- end
- # 刷新各窗口
- @gold_window.refresh
- @sell_window.refresh
- @status_window.refresh
- # 窗口状态转向卖出模式
- @sell_window.active = true
- @sell_window.visible = true
- @status_window.visible = false
- end
- return
- end
- end
- end
- #==============================================================================
- # ■ Window_ShopCommand
- #------------------------------------------------------------------------------
- # 商店画面、选择要做的事的窗口
- #==============================================================================
- class Window_SSShopCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 800, 64)#0,64,480,64选项窗口大小
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = 2
- @column_max = 2
- @commands = [" 出售", " 算了"]
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘卖出选项位置
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 64 + index * 400
- self.contents.draw_text(x, 0, 192, 32, @commands[index])#0,128,32
- end
- end
复制代码 插入后打开先是有2歌项目,卖出、取消
点了卖出之后,里面现实的菜单高度变小了,但是却没有改的地方···而且里面卖品也是走样,还是一排2歌怎样改成4歌
‘‘──chd114于2012-6-16 10:39补充以下内容:
[@]hcm[/@]
’’
‘‘──chd114于2012-6-16 10:41补充以下内容:
忘记补充了,这个是和一下几个脚本在一起的- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- # 欢迎访问www.66RPG.com
- # 梦想世界,在你手中
- #==============================================================================
- #
- # Sample master list for crafting script (物品分类增强版)
- # written by Deke
- # 增强:叶子
- # 增强版编写日期:12-30-2005
- #============================================================================================
- # 简介:
- # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
- # 物品方法。
- # ------
- # 增强版补充说明:
- # 在这个增强版中,可以对成品进行手动分类。
- # 成品增加了一个分类属性。
- # 这个分类纯粹是按自己的意愿,没有规定第几类必须是什么。
- # 召唤特定分类的界面,就只会看到特定分类的成品。
- #
- # 例如:
- # 使用脚本$scene = Scene_Craft.new(1),
- # 出来的界面就只会显示成品分类为1的东西
- # 同样道理,使用脚本$scene = Scene_Craft.new(2),
- # 出来的界面就只会显示成品分类为2的东西
- #
- # 如果使用脚本$scene = Scene_Craft.new或$scene = Scene_Craft.new(0)来召唤界面
- # 就可以看到所有成品。
- #
- # 注意:不要弄混淆“成品种类”和“成品分类”
- # 成品种类是指成品是普通物品(0),防具(1)或武器(2)
- # 成品分类是指此物品的自定义分类
- #
- #
- # 使用方法:
- # 1、召唤界面:使用脚本$scene = Scene_Craft.new(分类的数字)
- # 例如:使用脚本$scene = Scene_Craft.new(1),出来分类1的界面
- #
- # 2、学习合成:$game_party.learn_recipe(合成项目)
- #
- # 2.1、其实这个脚本可以使同一成品有不同配方
- #
- # 就这样说可能解释得不清楚,先来解释一下脚本学习配方的原理:
- # $game_party.learn_recipe(合成项目)的处理过程并不是直接学习这个配方,
- # 而是在配方库中找到和合成项目成品相同的配方。
- #
- # 如果配方库中有两个配方成品相同的话,配方版本就变得重要。
- # $game_party.learn_recipe(合成项目,配方版本)
- # 配方版本为1的话,学到的配方就是@recipe_list[xx]中与合成项目成品相同且数字最小的配方
- # 配方版本为2的话,学到的配方就是数字第二小的配方
- # 在上面这个脚本语句中,不填配方版本的话就默认为1
- #
- # 2.2、忘记配方:$game_party.forget_recipe(合成项目)
- # 2.21、同样道理,这个语句也可以写配方版本
- # $game_party.forget_recipe(合成项目,配方版本)
- # 配方版本定义见2.1
- #
- # 2.3、配方版本不能乱填!例如游戏中某一个配方的成品是唯一的,与所有其它配方的成品都不相同
- # 那么学习的时候就不用填配方版本。
- # 如果这时在配方版本填了2的话,就有可能学不到或者忘不了(-_-||)
- #
- #
- # 3、合成定义:
- # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
- # 直接写在这里就可以,另一种是在学习之前现场定义。
- #
- # 4、举例
- # 4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
- # 注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
- #
- # 4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,
- # 脚本:
- # 材料 = [$game_variables[1],$game_variables[2]] #——材料编号是变量1、2的编号
- # 材料种类 = [0,0] #——材料是物品
- # 材料数量 = [$game_variables[3],$game_variables[4]] #——需要材料数量是变量3、4的编号
- # 成品 = $game_variables[5] #——获得结果编号是5
- # 成品种类 = 1 #——成品是防具类
- # 成品分类 = 1 #——这一项不写的话默认为0
- # $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类,成品分类))
- # 上面这条语句的成品分类这一项不写也行,这样它就默认为0了。
- # (也就是此物品没有分类,不会在分类菜单中出现)
- # 省略成品分类的脚本语句可以像下面这样写:
- # $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类))
- #
- #===========================================================================================
- $VAR_NUMBER = 136
- class Game_Temp
- attr_reader :recipe_list
- alias crafting_temp_initialize initialize
- def initialize
- crafting_temp_initialize
- @recipe_list=[]
- get_recipe_list
- end
-
- def get_recipe_list
- 材料 = [1] # 需要材料的数据库编号
- 材料种类 = [0] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [2] # 需要材料的数量
- 成品 = 2 # 获得物品编号
- 获得数 = 1
- 成品种类 = 0 # 获得物品种类,0是普通物品,1是防具,2是武器
- 成品分类 = 0 # 获得成品分类
- @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
-
- 材料 = [1,2] # 需要材料的数据库编号
- 材料种类 = [0,0] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [2,1] # 需要材料的数量
- 成品 = 3 # 获得物品编号
- 获得数 = 2
- 成品种类 = 0 # 获得物品种类,0是普通物品,1是防具,2是武器
- 成品分类 = 0 # 获得成品分类
- @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
-
- 材料 = [1] # 需要材料的数据库编号
- 材料种类 = [2] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [2] # 需要材料的数量
- 成品 = 4 # 获得物品编号
- 获得数 = 1
- 成品种类 = 2 # 获得物品种类,0是普通物品,1是防具,2是武器
- 成品分类 = 0 # 获得成品分类
- @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
-
- 材料 = [1,2] # 需要材料的数据库编号
- 材料种类 = [2,2] # 需要材料的种类,0是普通物品,1是防具,2是武器
- 材料数量 = [2,2] # 需要材料的数量
- 成品 = 4 # 获得物品编号
- 获得数 = 3
- 成品种类 = 2 # 获得物品种类,0是普通物品,1是防具,2是武器
- 成品分类 = 0 # 获得成品分类
- @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,获得数,成品种类,成品分类)
-
- end # of get_recipe_list method
- end # of updates to Game_Temp Class
- #================================
- # CRAFTING PROGRAM
- #----------------------------------------------------------------
- #-written by Deke
- #-yes_no window code created by Phsylomortis
- #----------------------------------------------------------------
- #================================
- #updates to Game_Party class
- =begin
- 负重系统v0.1
- 作者:秀秀
-
- 功能:物品 武器 防具都多了重量属性
-
- 增加了背包负重 超过负重最大值 则不能获得
-
- 使用方法:在(物品,武器,防具)数据库中设置名称
-
- 方式为:名称+n+重量
-
- 比如 铜剑n1.5 表示铜剑重量为1.5
- 回复剂n0.5 表示回复剂重量为0.5
-
- 设置背包重量:默认为变量1,一定要在游戏开始设置好
- 搜索 VAR_NUMBER 可以改变存放背包负重的变量
- 当然也可以随时改变这个数值
- 获取背包最大负重:
- $game_variables[VAR_NUMBER]
- 获取背包当前负重:
- $gane_party.weight
- 获取物品重量:
- $data_items[id].weight
- 获取武器重量:
- $data_weapons[id].weight
- 获取防具重量:
- $data_armors[id].weight
- =end
- module RPG
- class Item
- def name
- return @name.split(/,/)[0] # w 代表重量
- end
- def weight
- return @name.split(/,/)[1].to_i # w 代表重量
- end
- end
- class Weapon
- def name
- return @name.split(/,/)[0] # w 代表重量
- end
- def weight
- return @name.split(/,/)[1].to_i # w 代表重量
- end
- end
-
- class Armor
- def name
- return @name.split(/,/)[0] # w 代表重量
- end
- def weight
- return @name.split(/,/)[1].to_i # w 代表重量
- end
- end
- end
- class Game_Party
-
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :weight
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- alias wt_initialize initialize
- def initialize
- wt_initialize
- @weight = 0
- end
-
-
- #--------------------------------------------------------------------------
- # ● 增加物品 (减少)
- # item_id : 物品 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_item(item_id, n)
- # 更新 hash 的个数数据
- if item_id > 0
-
- temp = @weight + $data_items[item_id].weight * n
-
- return if (n < 0 and @items[item_id] == nil)
-
- if temp > max_weight
- return
- end
- if temp < 0
- a = @weight
- for i in 1..n.abs
- a -= $data_items[item_id].weight
- if a < 0
- return
- else
- # 数量-1
- @items[item_id] = [[item_number(item_id) - i, 0].max, 99].min
- # 负重-1
- @weight -= $data_items[item_id].weight
- # p @weight
- end
- end
- # p @weight
- return
- end
-
- if @items[item_id] != nil
- b = @items[item_id] - n.abs
- if b < 0 and n < 0
- c = @items[item_id]
- @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
- @weight -= $data_items[item_id].weight * c
- # p @weight
- return
- end
- end
-
- @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
- @weight = temp
- # p @weight
- end
- end
- #--------------------------------------------------------------------------
- # ● 增加武器 (减少)
- # weapon_id : 武器 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_weapon(weapon_id, n)
- # 更新 hash 的个数数据
- if weapon_id > 0
- temp = @weight + $data_weapons[weapon_id].weight * n
-
- return if (n < 0 and @weapons[weapon_id] == nil)
-
- if temp > max_weight
- return
- end
- if temp < 0
- a = @weight
- for i in 1..n.abs
- a -= $data_weapons[weapon_id].weight
- if a < 0
- return
- else
- # 数量-1
- @weapons[weapon_id] = [[weapon_number(weapon_id) - i, 0].max, 99].min
- # 负重-1
- @weight -= $data_weapons[weapon_id].weight
- # p @weight
- end
- end
- # p @weight
- return
- end
-
- if @weapons[weapon_id] != nil
- b = @weapons[weapon_id] - n.abs
- if b < 0 and n < 0
- c = @weapons[weapon_id]
- @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
- @weight -= $data_weapons[weapon_id].weight * c
- # p @weight
- return
- end
- end
-
- @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
- @weight = temp
- # p @weight
- end
- end
- #--------------------------------------------------------------------------
- # ● 增加防具 (减少)
- # armor_id : 防具 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_armor(armor_id, n)
- # 更新 hash 的个数数据
- if armor_id > 0
- temp = @weight + $data_armors[armor_id].weight * n
-
- return if (n < 0 and @armors[armor_id] == nil)
-
- if temp > max_weight
- return
- end
- if temp < 0
- a = @weight
- for i in 1..n.abs
- a -= $data_armors[armor_id].weight
- if a < 0
- return
- else
- # 数量-1
- @armors[armor_id] = [[armor_number(armor_id) - i, 0].max, 99].min
- # 负重-1
- @weight -= $data_armors[armor_id].weight
- # p @weight
- end
- end
- # p @weight
- return
- end
-
- if @armors[armor_id] != nil
- b = @armors[armor_id] - n.abs
- if b < 0 and n < 0
- c = @armors[armor_id]
- @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
- @weight -= $data_armors[armor_id].weight * c
- # p @weight
- return
- end
- end
-
- @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
- @weight = temp
- # p @weight
- end
- end
- def max_weight
- return $game_variables[$VAR_NUMBER]
- end
- def check_weight
-
- end
- end
- #================================================================================
- #==============================================================================
- # ■ Scene_Item
- #------------------------------------------------------------------------------
- # 处理物品画面的类。
- #==============================================================================
- class Scene_Item
- alias ori_main main
- def main
- @weight_window = Window_Weight.new
- @weight_window.x = 0
- @weight_window.y = 544
- @weight_window.z = 9999
- ori_main
- @weight_window.dispose
- end
- alias ori_update update
- # def update
- # case @item_window.item
- # when RPG::Item
- # @weight_window.refresh($data_items[@item_window.item.id].weight)
- # when RPG::Weapon
- # @weight_window.refresh($data_weapons[@item_window.item.id].weight)
- # when RPG::Armor
- # @weight_window.refresh($data_armors[@item_window.item.id].weight)
- # end
- # ori_update
- #end
- end
- class Window_Item < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 800, 480)#0,64,640,592
- @column_max = 2
- refresh
- self.index = 0
- # 战斗中的情况下将窗口移至中央并将其半透明化
- if $game_temp.in_battle
- self.y = 64
- self.height = 256
- self.back_opacity = 160
- end
- end
- end
-
- class Window_Weight < Window_Base
- def initialize
- super(0,0,800,64)#0,0,640,64
- self.opacity = 128
- self.contents = Bitmap.new(width-32,height-32)
- refresh(nil)
- end
- def refresh(weight)
- self.contents.clear
- if weight != nil
- self.contents.draw_text(0,0,256,32,"物品重量:#{weight}")
- end
- self.contents.draw_text(256,0,320,32,"背包重量:"+$game_party.weight.to_s + "/" + $game_variables[$VAR_NUMBER].to_s , 0)
- end
- end
- class Game_Party
-
- attr_accessor :recipes
-
- alias crafting_party_initialize initialize
-
- def initialize
- crafting_party_initialize
- @recipes=[]
- end
-
- #----------------------------------------------------------------------
- def know?(recipe, version = 1)
- unless recipe.is_a?(Game_Recipe)
- recipe = get_recipe_from_master_list(recipe, version)
- end
- return $game_party.recipes.include?(recipe)
- end
-
- #----------------------------------------------------------------------
- def learn_recipe(recipe , version = 1)
- unless recipe.is_a?(Game_Recipe)
- recipe = get_recipe_from_master_list(recipe, version)
- end
- if recipe.is_a?(Game_Recipe)
- unless know?(recipe)
- @recipes.push(recipe)
- end
- end
- end
-
- #----------------------------------------------------------------------
- def forget_recipe(recipe , version = 1)
- if !recipe.is_a?(Game_Recipe)
- recipe = get_recipe_from_master_list(recipe, version)
- end
- if recipe.is_a?(Game_Recipe)
- for i in [email protected]
- if recipe == @recipes[i]
- index = i
- break
- end
- end
- if index != nil
- @recipes.delete(@recipes[index])
- end
- end
- end
-
- #----------------------------------------------------------------------
- def get_recipe_from_master_list(item, version)
- index = nil
- for i in 0...$game_temp.recipe_list.size
- #print $game_temp.recipe_list.size
- if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
- version -= 1
- if version == 0
- index = i
- break
- end
- end
- end
- if index.is_a?(Integer)
- return ($game_temp.recipe_list[index])
- else
- return false
- end
- end
-
- end # of Game_Party updates
- #================================
- class Game_Recipe
- attr_reader :ingredients
- attr_reader :quantities
- attr_reader :result
- attr_reader :result_num
- attr_reader :result_type
- attr_reader :ingredient_types
- attr_reader :craft_type #物品分类
-
- #----------------------------------------------------------------------
- def initialize( ingredients, ingredient_types, quantities, result, result_num,result_type, craft_type=0)
- @ingredients = ingredients
- @ingredient_types = ingredient_types
- @quantities = quantities
- @result = result
- @result_num = result_num
- $rrresultnum = result_num
- @result_type = result_type
- @craft_type = craft_type
- end
-
- #----------------------------------------------------------------------
- def name
- case @result_type
- when 0
- name = $data_items[@result].name
- when 1
- name = $data_armors[@result].name
- when 2
- name = $data_weapons[@result].name
- end
- return name
- end
- #----------------------------------------------------------------------
- def have
- have_all = true
- for i in [email protected]
- case @ingredient_types[i]
- when 0
- if $game_party.item_number(@ingredients[i]) < @quantities[i]
- have_all=false
- end
- when 1
- if $game_party.armor_number(@ingredients[i]) < @quantities[i]
- have_all=false
- end
- when 2
- if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
- have_all=false
- end
- end
- end
- return have_all
- end
- #----------------------------------------------------------------------
- def decrement
- for i in [email protected]
- case @ingredient_types[i]
- when 0
- $game_party.lose_item(@ingredients[i], @quantities[i])
- when 1
- $game_party.lose_armor(@ingredients[i], @quantities[i])
- when 2
- $game_party.lose_weapon(@ingredients[i], @quantities[i])
- end
- end
- end
- #----------------------------------------------------------------------
- def make
- if have
- decrement
- case @result_type
- when 0
- $game_party.gain_item(@result, @result_num)
- when 1
- $game_party.gain_armor(@result, @result_num)
- when 2
- $game_party.gain_weapon(@result, @result_num)
- end
- end
- end
-
- #----------------------------------------------------------------------
- def == (recipe)
- if recipe.is_a?(Game_Recipe)
- equal = true
- if recipe.ingredients != self.ingredients
- equal = false
- end
- if recipe.ingredient_types != self.ingredient_types
- equal = false
- end
- if recipe.quantities != self.quantities
- equal = false
- end
- if recipe.result != self.result
- equal=false
- end
- if recipe.result_type != self.result_type
- equal = false
- end
- else
- equal = false
- end
- return equal
- end
-
- end # of Game_Recipe class
- #===================================
- class Window_Craft < Window_Selectable
- attr_reader :data #声明数据
- #--------------------------------------------------------------------------
- def initialize(craft_type=0)
- @craft_type = craft_type
- super(0, 64, 240, 544)#0,64,240,416
- @column_max = 1
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- def recipe
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for i in 0...$game_party.recipes.size
- #@craft_type为0时就显示全部物品
- #不为0时就显示对应物品
- @data.push($game_party.recipes[i])
- #if @craft_type == 0
- # @data.push($game_party.recipes[i])
- #elsif $game_party.recipes[i].craft_type == @craft_type
- # @data.push($game_party.recipes[i])
- #end
- end
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- self.contents.font.name = "黑体" # = "黑体"
- self.contents.font.size = 18 # = 18
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- def draw_item(index)
- recipe = @data[index]
- self.contents.font.color = recipe.have ? normal_color : disabled_color
- x = 16
- y = index * 32
- self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
- end
- #--------------------------------------------------------------------------
- def update_help
- current_recipe = recipe
- if current_recipe.is_a?(Game_Recipe)
- case current_recipe.result_type
- when 0
- description = $data_items[current_recipe.result].description
- when 1
- description = $data_armors[current_recipe.result].description
- when 2
- description = $data_weapons[current_recipe.result].description
- end
- else
- description = ""
- end
- @help_window.set_text(description)
- @help_window.update
- end
-
- end # of Window_Craft
- #=======================================
- class Window_CraftResult < Window_Base
- #--------------------------------------------------------------------------
- def initialize
- super(240, 64, 560, 184)#240,64,400,184
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
- self.contents.font.size = 18 # = 20
- @result = nil
- @type = nil
- end
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- case @type
- when 0
- item = $data_items[@result]
- if item.recover_hp_rate > item.recover_hp
- hp_string = "HP回复率:"
- hp_stat = item.recover_hp_rate
- else
- hp_string = "HP回复量:"
- hp_stat = item.recover_hp
- end
- if item.recover_sp_rate > item.recover_sp
- sp_string = "SP回复率:"
- sp_stat = item.recover_sp_rate
- else
- sp_string = "SP回复量:"
- sp_stat = item.recover_sp
- end
- @strings = [hp_string, sp_string, "物理防御:" , "魔法防御:", "命中率:", "分散度:"]
- @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
- $rrresultnum]
- ssstats=$game_party.item_number(@result)
- @bitmap = RPG::Cache.icon(item.icon_name)
- when 1
- item = $data_armors[@result]
- @strings = ["物理防御:", "魔法防御:", "回避修正:", "力量增加:", "灵巧增加:",
- "速度增加:", "魔力增加:"]
- @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
- item.agi_plus, item.int_plus, $rrresultnum]
- ssstats=$game_party.armor_number(@result)
- @bitmap = RPG::Cache.icon(item.icon_name)
- when 2
- item = $data_weapons[@result]
- @strings =["攻击力:", "物理防御:", "魔法防御:", "力量增加:", "灵巧增加:",
- "速度增加:", "魔力增加:"]
- @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
- item.agi_plus, item.int_plus, $rrresultnum]
- ssstats=$game_party.weapon_number(@result)
- @bitmap = RPG::Cache.icon(item.icon_name)
- end
- for i in [email protected]
- x = i%2 * 184
- y = i /2 *28 +32
- self.contents.font.color = normal_color
- self.contents.draw_text(x,y,100, 28,@strings[i])
- self.contents.font.color = system_color
- self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
- end
- self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 32, 32), 255)
- self.contents.font.color= normal_color
- self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
- self.contents.font.color = system_color
- count = ssstats.to_s
- self.contents.draw_text(294, 0, 45, 28, count)
- end
-
- #----------------------------------------------------------------------
- def set_result(result , type)
- @result = result
- @type = type
- refresh
- end
- end #of Window_CraftResult
- #=======================================
- class Window_CraftIngredients < Window_Base
- #--------------------------------------------------------------------------
- def initialize
- super(240, 248, 560, 472)#240,248,400,232
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
- self.contents.font.size = 18 # = 20
- @ingredients = []
- @types = []
- @quantities = []
- @item = nil
- @count = 0
- end
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in [email protected]
- case @types[i]
- when 0
- @item = $data_items[@ingredients[i]]
- @count = $game_party.item_number(@ingredients[i])
- when 1
- @item = $data_armors[@ingredients[i]]
- @count = $game_party.armor_number(@ingredients[i])
- when 2
- @item = $data_weapons[@ingredients[i]]
- @count = $game_party.weapon_number(@ingredients[i])
- end
- y = i *26
- self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 32, 32), 255)
- self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
- self.contents.draw_text(30, y, 280, 28, @item.name)
- self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
- self.contents.font.color = system_color
- self.contents.draw_text(245, y, 45, 28, @count.to_s )
- end
- end
-
- #--------------------------------------------------------------------------
- def set_ingredients(ingredients , types, quantities)
- @ingredients = ingredients
- @types = types
- @quantities = quantities
- refresh
- end
- end # of Window_CraftIngredients
- #======================================
- class Scene_Craft
- #--------------------------------------------------------------------------
- # @craft_type:物品种类,0就是全部
- def initialize(craft_type=0,craft_index=0)
- @craft_index=craft_index
- @craft_type = craft_type
- end
-
- #--------------------------------------------------------------------------
- def main
- @craft_window = Window_Craft.new(@craft_type)
- @craft_window.index=@craft_index
- @confirm_window = Window_Base.new(120, 188, 400, 64)#120,188,400,64
- @confirm_window.contents = Bitmap.new(368, 32)
- @confirm_window.contents.font.name = "黑体"
- @confirm_window.contents.font.size = 20
- @help_window = Window_Help.new
- @craft_window.help_window = @help_window
- @result_window=Window_CraftResult.new
- @ingredients_window=Window_CraftIngredients.new
- @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
- @confirm_window.visible = false
- @confirm_window.z = 1500
- @yes_no_window.visible = false
- @yes_no_window.active = false
- @yes_no_window.index = 1
- @yes_no_window.x = 270
- @yes_no_window.y = 252
- @yes_no_window.z = 1500
- @label_window = Window_Base.new(450,200,285,52)#450,200,190,52
- @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
- @label_window.contents.font.size=20
- @label_window.contents.font.color = @label_window.normal_color
- @label_window.contents.font.name = "黑体"
- @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, " 现有 需要")
- Graphics.transition
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- Graphics.freeze
- @help_window.dispose
- @craft_window.dispose
- @result_window.dispose
- @ingredients_window.dispose
- @confirm_window.dispose
- @yes_no_window.dispose
- @label_window.dispose
- end
- #--------------------------------------------------------------------------
- def update
- @craft_window.update
- @ingredients_window.update
- if @craft_window.data.size > 0 #本类窗口物品大于0的话
- @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
- @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
- @craft_window.recipe.ingredient_types,
- @craft_window.recipe.quantities)
- end
- if @craft_window.active
- update_craft
- return
- end
- if @yes_no_window.active
- confirm_update
- return
- end
- end
- #--------------------------------------------------------------------------
- def update_craft
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Menu.new(0)
- return
- end
- if Input.trigger?(Input::C) and $game_party.recipes.size != 0
- @recipe = @craft_window.recipe
- if @recipe != nil
- if @recipe.have
- @yes_no_window.active = true
- @craft_window.active = false
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- end
- end
- #--------------------------------------------------------------------------
- def confirm_update
- @craft_index = @craft_window.index
- @confirm_window.visible = true
- @confirm_window.z = 1500
- @yes_no_window.visible = true
- @yes_no_window.active = true
- @yes_no_window.z = 1500
- @yes_no_window.update
- string = "合成 " + @recipe.name + "?"
- cw = @confirm_window.contents.text_size(string).width
- center = @confirm_window.contents.width/2 - cw /2
- unless @drawn
- @confirm_window.contents.draw_text(center, 0, cw, 30, string)
- @drawn = true
- end
- if Input.trigger?(Input::C)
- if @yes_no_window.index == 0
- $game_system.se_play($data_system.decision_se)
- @recipe.make
- $game_system.se_play($data_system.save_se)
- $scene=Scene_Craft.new(@craft_index)
- else
- $game_system.se_play($data_system.cancel_se)
- $scene=Scene_Craft.new(@craft_index)
- end
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene=Scene_Craft.new(@craft_index)
- end
- end
- end # of Scene_Craft
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- # 欢迎访问www.66RPG.com
- # 梦想世界,在你手中
- #==============================================================================
复制代码- #==============================================================================
- # 本脚本来自www.66rpg.com,转载和使用请保留此信息
- # 脚本名:真实商店,脚本作者:柳柳
- #==============================================================================
- #
- # 功能:
- #
- # 买进卖出的物品在商店有所体现,卖出后会在商店可买物品中出现,物品有数量限制
- # 商店可进货出货————总之就是模拟真实商店。
- #
- # 这个脚本和原装商店并不冲突,两个商店可以并存。
- #
- # 使用方法:
- #
- # 1、在下面被井号框起来的中间部分,设置初期物品。格式如下:
- # @goods[商店编号] = [ [种类,ID,可卖数量] , [种类,ID,可卖数量]......]
- # 其中种类,0为道具,1为武器,2为防具;ID是数据库编号
- #
- # 2、调用:$scene = Scene_Shop_Va.new(商店编号)
- # 比如你可以直接测试$scene = Scene_Shop_Va.new(1),已经设置好了。
- #
- # 3、商店出货:$game_system.shop_change(商店编号,种类,ID,数量)
- # 如果是进货,把数量设置为负数即可
- #
- class WWWindow_ShopCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 800, 64)#0,64,48,64
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = 3
- @column_max = 3
- @commands = [" 买进", " 卖出", " 算了"]
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 4 + index * 265
- self.contents.draw_text(x, 0, 128, 32, @commands[index])
- end
- end
- class W2Window_ShopCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 640, 192)#0,64,480,64
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = 3
- @column_max = 3
- @commands = ["取出物品", "存入物品", "算了"]
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 4 + index * 265
- self.contents.draw_text(x, 0, 128, 32, @commands[index])
- end
- end
- class Game_System
- attr_accessor :goods
- alias vaule_shop_66RPG_initialize initialize
- def initialize
- vaule_shop_66RPG_initialize
- @goods = []
- ###########################################################################
- # 初期的时候的商店物品,编号顺序:种类,ID,可卖数量
- @goods[0] = [[-1,-1,-1]]
- @goods[1] = [[0,1,30],[0,2,30],[2,1,10],[1,2,10],[1,3,10]]
- ###########################################################################
- end
- def shop_change(shop,kind,id,delnumber)
- dl = delnumber
- for dt in $game_system.goods[shop]
- if (dt[0]==kind) and (dt[1]==id)
- dt[2] -= dl
- dt[2] = [dt[2],99].min
- if dt[2] == 0
- $game_system.goods[shop].delete(dt)
- end
- return
- end
- end
- $game_system.goods[shop].push([kind,id,-delnumber])
- end
- end
- class Scene_Shop_Va
- def initialize(shop_number)
- # 当前商店编号
- @shop_now = shop_number
- # 0号商店为物品仓库
- $itembankflag = @shop_now > 0 ? 0 : 1
- end
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 生成帮助窗口
- @help_window = Window_Help.new
- # 生成指令窗口
- if $itembankflag == 0 #是不是物品仓库?
- @command_window = WWWindow_ShopCommand.new
- else
- @command_window = W2Window_ShopCommand.new
- end
- # 生成金钱窗口
- @gold_window = Window_Gold.new
- @gold_window.x = 800
- @gold_window.y = 64
- # 生成时间窗口
- @dummy_window = Window_Base.new(0, 128, 800, 592)#0,128,640,352
- # 生成购买窗口
- @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
- @buy_window.active = false
- @buy_window.visible = false
- @buy_window.help_window = @help_window
- # 生成卖出窗口
- @sell_window = Window_ShopSell.new
- @sell_window.active = false
- @sell_window.visible = false
- @sell_window.help_window = @help_window
- # 生成数量输入窗口
- @number_window = Window_ShopNumber.new
- @number_window.active = false
- @number_window.visible = false
- # 生成状态窗口
- @status_window = Window_ShopStatus.new
- @status_window.visible = false
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @command_window.dispose
- @gold_window.dispose
- @dummy_window.dispose
- @buy_window.dispose
- @sell_window.dispose
- @number_window.dispose
- @status_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @command_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
- #--------------------------------------------------------------------------
- # ● 刷新画面 (指令窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_command
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 购买
- # 演奏确定 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
- when 1 # 卖出
- # 演奏确定 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
- when 2 # 取消
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (购买窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_buy
- # 设置状态窗口的物品
- @status_window.item = @buy_window.item
- # 按下 B 键的情况下
- if Input.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 = false
- @status_window.item = nil
- # 删除帮助文本
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 获取物品
- @item = @buy_window.item
-
- # 如果是物品仓库就不对金钱做出处理=============================================
- ppprice = $itembankflag == 0 ? @item.price : 0
- # 物品无效的情况下、或者价格在所持金以上的情况下
- if @item == nil or ppprice > $game_party.gold
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 获取物品所持数
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- when RPG::Armor
- number = $game_party.armor_number(@item.id)
- end
- # 如果已经拥有了 99 个情况下
- if number == 99
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 计算可以最多购买的数量
- max = ppprice == 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, ppprice)
- @number_window.active = true
- @number_window.visible = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 画面更新 (卖出窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_sell
- # 按下 B 键的情况下
- if Input.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.item = nil
- # 删除帮助文本
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 获取物品
- @item = @sell_window.item
- # 设置状态窗口的物品
- @status_window.item = @item
- # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
- if @item == nil or @item.price == 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取物品的所持数
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- when RPG::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)
- @number_window.active = true
- @number_window.visible = true
- @status_window.visible = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (个数输入窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_number
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 设置个数输入窗口为不活动·非可视状态
- @number_window.active = false
- @number_window.visible = false
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 购买
- # 窗口状态转向购买模式
- @buy_window.active = true
- @buy_window.visible = true
- when 1 # 卖出
- # 窗口状态转向卖出模式
- @sell_window.active = true
- @sell_window.visible = true
- @status_window.visible = false
- end
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏商店 SE
- $game_system.se_play($data_system.shop_se)
- # 设置个数输入窗口为不活动·非可视状态
- @number_window.active = false
- @number_window.visible = false
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 购买
- # 购买处理
- temp = 0
- if $超重不能买 > 0
- @number_window.active = true
- @number_window.visible = true
- return
- end
- # 如果是物品仓库就不对金钱做出处理=============================================
- if $itembankflag == 0
- $game_party.lose_gold(@number_window.number * @item.price)
- end
- # =============================================================================
-
- case @item
- when RPG::Item
- $game_party.gain_item(@item.id, @number_window.number)
- when RPG::Weapon
- $game_party.gain_weapon(@item.id, @number_window.number)
- temp = 1
- when RPG::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_Va.new($game_system.goods[@shop_now])
- @gold_window.refresh
- @buy_window.refresh
- @status_window.refresh
- # 窗口状态转向购买模式
- @buy_window.active = true
- @buy_window.visible = true
- when 1 # 卖出
- # 卖出处理
-
- # 如果是物品仓库就不对金钱做出处理=============================================
- if $itembankflag == 0
- $game_party.gain_gold(@number_window.number * @item.price)
- end
- # =============================================================================
-
- temp = 0
- case @item
- when RPG::Item
- $game_party.lose_item(@item.id, @number_window.number)
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, @number_window.number)
- temp = 1
- when RPG::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_Va.new($game_system.goods[@shop_now])
- @buy_window.active = false
- @buy_window.visible = false
- @buy_window.help_window = @help_window
- @gold_window.refresh
- @sell_window.refresh
- @status_window.refresh
- # 窗口状态转向卖出模式
- @sell_window.active = true
- @sell_window.visible = true
- @status_window.visible = false
- end
- return
- end
- end
- # 删除可出售商品内容
- def goods_del(kind,id,delnumber)
- dl = delnumber
- for dt in $game_system.goods[@shop_now]
- if (dt[0]==kind) and (dt[1]==id)
- dt[2] -= dl
- dt[2] = [dt[2],99].min
- if dt[2] == 0
- $game_system.goods[@shop_now].delete(dt)
- end
- return
- end
- end
- $game_system.goods[@shop_now].push([kind,id,-delnumber])
- end
- end
- #==============================================================================
- # ■ Window_ShopBuy_Va
- #------------------------------------------------------------------------------
- # 商店画面、浏览显示可以购买的商品的窗口。
- #==============================================================================
- class Window_ShopBuy_Va < Window_Selectable
- attr_accessor :shop_goods
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # shop_goods : 商品
- #--------------------------------------------------------------------------
- def initialize(shop_goods)
- super(0, 128, 528, 592)#0,128,368,352
- @shop_goods = shop_goods
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item_number
- return @data_number[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- @data_number = []
- for goods_item in @shop_goods
- 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
- if (item != nil) and (goods_item[2] != 0)
- @data.push(item)
- @data_number.push(goods_item[2])
- else
- @data.delete(item)
- end
- end
- # 如果项目数不是 0 就生成位图、描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘羡慕
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- # 获取物品所持数
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
- # 除此之外的情况设置为无效文字色
- if item.price <= $game_party.gold and number < 99
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 88, 32, "剩 ", 2)
- self.contents.draw_text(x + 240, y, 88, 32, @data_number[index].to_s, 2)
- if $itembankflag == 0
- self.contents.draw_text(x + 180, y, 88, 32, item.price.to_s, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
复制代码- #==============================================================================
- # ■ Scene_Shop
- #------------------------------------------------------------------------------
- # 处理商店画面的类。改变了原先的商店模式,只能买不能卖。
- #==============================================================================
- class Scene_Shop
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 生成帮助窗口
- $超重不能买=0
- $itembankflag = 0
- @help_window = Window_Help.new
- # 生成指令窗口
- @command_window = Window_ShopCommand.new
- # 生成金钱窗口
- @gold_window = Window_Gold.new
- @gold_window.x = 800
- @gold_window.y = 64
- # 生成时间窗口
- @dummy_window = Window_Base.new(0, 128, 800, 480)#0,128,640,352
- # 生成购买窗口
- @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
- @buy_window.active = false
- @buy_window.visible = false
- @buy_window.help_window = @help_window
- # 生成卖出窗口
- @sell_window = Window_ShopSell.new
- @sell_window.active = false
- @sell_window.visible = false
- @sell_window.help_window = @help_window
- # 生成数量输入窗口
- @number_window = Window_ShopNumber.new
- @number_window.active = false
- @number_window.visible = false
- # 生成状态窗口
- @status_window = Window_ShopStatus.new
- @status_window.visible = false
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @command_window.dispose
- @gold_window.dispose
- @dummy_window.dispose
- @buy_window.dispose
- @sell_window.dispose
- @number_window.dispose
- @status_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @command_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
- $player_buying=1
- update_buy
- return
- else
- $player_buying=0
- end
- # 卖出窗口激活的情况下: 调用 update_sell
- if @sell_window.active
- update_sell
- return
- end
- # 个数输入窗口激活的情况下: 调用 update_number
- if @number_window.active
- update_number
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (指令窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_command
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 购买
- # 演奏确定 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
- when 2 # 卖出
- # 演奏确定 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
- when 1 # 取消
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (购买窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_buy
- # 设置状态窗口的物品
- @status_window.item = @buy_window.item
- # 按下 B 键的情况下
- if Input.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 = false
- @status_window.item = nil
- # 删除帮助文本
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况下
- if Input.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
- when RPG::Item
- number = $game_party.item_number(@item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- when RPG::Armor
- number = $game_party.armor_number(@item.id)
- end
- # 如果已经拥有了 99 个情况下
- if number == 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.active = false
- @buy_window.visible = false
- @number_window.set(@item, max, @item.price)
- @number_window.active = true
- @number_window.visible = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 画面更新 (卖出窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_sell
- # 按下 B 键的情况下
- if Input.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.item = nil
- # 删除帮助文本
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 获取物品
- @item = @sell_window.item
- # 设置状态窗口的物品
- @status_window.item = @item
- # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
- if @item == nil or @item.price == 0
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取物品的所持数
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- when RPG::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
- #--------------------------------------------------------------------------
- # ● 刷新画面 (个数输入窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_number
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 设置个数输入窗口为不活动·非可视状态
- @number_window.active = false
- @number_window.visible = false
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 购买
- # 窗口状态转向购买模式
- @buy_window.active = true
- @buy_window.visible = true
- when 1 # 卖出
- # 窗口状态转向卖出模式
- @sell_window.active = true
- @sell_window.visible = true
- @status_window.visible = false
- end
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏商店 SE
- $game_system.se_play($data_system.shop_se)
- # 设置个数输入窗口为不活动·非可视状态
- @number_window.active = false
- @number_window.visible = false
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 购买
- # 购买处理
- if $超重不能买 > 0
- @number_window.active = true
- @number_window.visible = true
- return
- end
- $game_party.lose_gold(@number_window.number * @item.price)
- case @item
- when RPG::Item
- $game_party.gain_item(@item.id, @number_window.number)
- when RPG::Weapon
- $game_party.gain_weapon(@item.id, @number_window.number)
- when RPG::Armor
- $game_party.gain_armor(@item.id, @number_window.number)
- end
- # 刷新各窗口
- @gold_window.refresh
- @buy_window.refresh
- @status_window.refresh
- # 窗口状态转向购买模式
- @buy_window.active = true
- @buy_window.visible = true
- when 1 # 卖出
- # 卖出处理
- $game_party.gain_gold(@number_window.number * (@item.price / 2))
- case @item
- when RPG::Item
- $game_party.lose_item(@item.id, @number_window.number)
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, @number_window.number)
- when RPG::Armor
- $game_party.lose_armor(@item.id, @number_window.number)
- end
- # 刷新各窗口
- @gold_window.refresh
- @sell_window.refresh
- @status_window.refresh
- # 窗口状态转向卖出模式
- @sell_window.active = true
- @sell_window.visible = true
- @status_window.visible = false
- end
- return
- end
- end
- end
- #==============================================================================
- # ■ Window_ShopBuy
- #------------------------------------------------------------------------------
- # 商店画面、浏览显示可以购买的商品的窗口。
- #==============================================================================
- class Window_ShopBuy < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # shop_goods : 商品
- #--------------------------------------------------------------------------
- def initialize(shop_goods)
- super(0, 128, 712, 480)#0,128,552,352
- @shop_goods = shop_goods
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for goods_item in @shop_goods
- 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
- if item != nil
- @data.push(item)
- end
- end
- # 如果项目数不是 0 就生成位图、描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘羡慕
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- # 获取物品所持数
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
- # 除此之外的情况设置为无效文字色
-
- if (item.price <= $game_party.gold and number < 99) or $itembankflag==1
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
- #==============================================================================
- # ■ Window_ShopNumber
- #------------------------------------------------------------------------------
- # 商店画面、输入买卖数量的窗口。
- #==============================================================================
- class Window_ShopNumber < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 128, 528, 480)#0,128,368,352
- self.contents = Bitmap.new(width - 32, height - 32)
- @item = nil
- @max = 1
- @price = 0
- @number = 1
- end
- #--------------------------------------------------------------------------
- # ● 设置物品、最大个数、价格
- #--------------------------------------------------------------------------
- def set(item, max, price)
- @item = item
- @max = max
- @price = price
- @number = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 被输入的件数设置
- #--------------------------------------------------------------------------
- def number
- return @number
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_item_name(@item, 4, 96)
- case @item
- when RPG::Item
- wwwt=@number * $data_items[@item.id].weight
- when RPG::Weapon
- wwwt=@number * $data_weapons[@item.id].weight
- when RPG::Armor
- wwwt=@number * $data_armors[@item.id].weight
- end
- if wwwt>($game_variables[136]-$game_party.weight)
- self.contents.font.color = normal_color
- $超重不能买 = 1
- else
- self.contents.font.color = normal_color
- $超重不能买 = 0
- end
- self.contents.draw_text(4, 192, 336, 32, "总重", 2)#4,192,224,32
- self.contents.draw_text(240, 192, 256, 32, wwwt.to_s, 2)#240,192,96,32
- self.contents.draw_text(272, 96, 192, 32, "×")#272,96,32,32
- self.contents.draw_text(308, 96, 184, 32, @number.to_s, 2)#308,96,24,32
- self.cursor_rect.set(464, 96, 192, 32)#304,96,32,32
- # 描绘合计价格和货币单位
- domination = $data_system.words.gold
- cx = contents.text_size(domination).width
- total_price = @price * @number
- #self.contents.font.color = normal_color
- if $itembankflag != 1
- self.contents.draw_text(4, 160, 328-cx-2, 32, total_price.to_s, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(332-cx, 160, cx, 32, domination, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if self.active
- # 光标右 (+1)
- if Input.repeat?(Input::RIGHT) and @number < @max
- $game_system.se_play($data_system.cursor_se)
- @number += 1
- refresh
- end
- # 光标左 (-1)
- if Input.repeat?(Input::LEFT) and @number > 1
- $game_system.se_play($data_system.cursor_se)
- @number -= 1
- refresh
- end
- # 光标上 (+10)
- if Input.repeat?(Input::UP) and @number < @max
- $game_system.se_play($data_system.cursor_se)
- @number = [@number + 10, @max].min
- refresh
- end
- # 光标下 (-10)
- if Input.repeat?(Input::DOWN) and @number > 1
- $game_system.se_play($data_system.cursor_se)
- @number = [@number - 10, 1].max
- refresh
- end
- case @item
- when RPG::Item
- $wwwt=@number * $data_items[@item.id].weight
- when RPG::Weapon
- $wwwt=@number * $data_weapons[@item.id].weight
- when RPG::Armor
- $wwwt=@number * $data_armors[@item.id].weight
- end
- end
- end
- end
- #==============================================================================
- # ■ Window_ShopStatus
- #------------------------------------------------------------------------------
- # 商店画面、显示物品所持数与角色装备的窗口。
- #==============================================================================
- class Window_ShopStatus < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(528, 128, 432, 480)#368,128,272,352
- self.contents = Bitmap.new(width - 32, height - 32)
- @item = nil
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- if @item == nil
- return
- end
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- when RPG::Armor
- number = $game_party.armor_number(@item.id)
- end
- self.contents.font.color = system_color
- self.contents.draw_text(4, 0, 360, 32, "所持数")#4,0,200,32
- self.contents.draw_text(4, 288, 384, 32, "剩余负载能力")#4,288,224,32
- self.contents.font.color = normal_color
-
- self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
- self.contents.draw_text(140, 288, 96, 32, ($game_variables[136]-$game_party.weight).to_s, 2)
- if @item.is_a?(RPG::Item)#140,288,96,32
- return
- end
- # 添加装备品信息
- for i in 0...$game_party.actors.size
- # 获取角色
- actor = $game_party.actors[i]
- # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
- if actor.equippable?(@item)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- # 描绘角色名字
- self.contents.draw_text(4, 64 + 64 * i, 280, 32, actor.name)#120,32
- # 获取当前的装备品
- if @item.is_a?(RPG::Weapon)
- item1 = $data_weapons[actor.weapon_id]
- elsif @item.kind == 0
- item1 = $data_armors[actor.armor1_id]
- elsif @item.kind == 1
- item1 = $data_armors[actor.armor2_id]
- elsif @item.kind == 2
- item1 = $data_armors[actor.armor3_id]
- else
- item1 = $data_armors[actor.armor4_id]
- end
- # 可以装备的情况
- if actor.equippable?(@item)
- # 武器的情况
- if @item.is_a?(RPG::Weapon)
- atk1 = item1 != nil ? item1.atk : 0
- atk2 = @item != nil ? @item.atk : 0
- change = atk2 - atk1
- end
- # 防具的情况
- if @item.is_a?(RPG::Armor)
- pdef1 = item1 != nil ? item1.pdef : 0
- mdef1 = item1 != nil ? item1.mdef : 0
- pdef2 = @item != nil ? @item.pdef : 0
- mdef2 = @item != nil ? @item.mdef : 0
- change = pdef2 - pdef1 + mdef2 - mdef1
- end
- # 描绘能力值变化
- self.contents.draw_text(124, 64 + 64 * i, 112, 32,
- sprintf("%+d", change), 2)
- end
- # 描绘物品
- if item1 != nil
- x = 4
- y = 64 + 64 * i + 32
- bitmap = RPG::Cache.icon(item1.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item1.name)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置物品
- # item : 新的物品
- #--------------------------------------------------------------------------
- def item=(item)
- if @item != item
- @item = item
- refresh
- end
- end
- end
- #==============================================================================
- # ■ Window_ShopCommand(购物中心窗口,只能买不能卖)
- #------------------------------------------------------------------------------
- # 商店画面、选择要做的事的窗口
- #==============================================================================
- class Window_ShopCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 640, 192)#0,64,480,64
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = 2
- @column_max = 2
- @commands = ["购物", "取消"]
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 64 + index * 400
- self.contents.draw_text(x, 0, 288, 32, @commands[index])#0,128,32
- end
- end
复制代码 这些要放在一起才有用···我的屏幕分辨率为800*608···注意是800*608不是800*600···
’’ |
|