#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
#==============================================================================
#——以下是一些自定义的内容
$mShop_use_1 = "LP" #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
$mShop_use_2 = "LP" #——这项是购买魔法特技的货币单位,如“点”、“¥”
$mShop_use_variable = 1 #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
$mShop_Window_Opacity = 200 #——这项是窗口透明度
#==============================================================================
# ■ Window_MGold
#------------------------------------------------------------------------------
# 显示LP的窗口。
#==============================================================================
class Window_MGold < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 544-32-standard_padding*2, 64)
self.contents = Bitmap.new(width - standard_padding*2, height - standard_padding*2)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
end
end
#==============================================================================
# ■ Scene_MShop
#------------------------------------------------------------------------------
# 处理特技商店画面的类。
#==============================================================================
class Scene_MShop < Scene_Base
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(id)
@id = id
create_main_viewport
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
if $mShop_use_variable == 0
$mShop_gold = $game_party.gold
else
$mShop_gold = $game_variables[$mShop_use_variable]
end
# 生成帮助窗口
@help_window = Window_Help.new
@help_window.opacity = $mShop_Window_Opacity
# 生成金钱窗口
@gold_window = Window_MGold.new
@gold_window.x = 0
@gold_window.y = 416 - 64
@gold_window.opacity = $mShop_Window_Opacity
# 生成购买窗口
@buy_window = Window_MShopBuy.new(@id)
@buy_window.active = true
@buy_window.visible = true
@buy_window.help_window = @help_window
@buy_window.opacity = $mShop_Window_Opacity
# 生成状态窗口
@status_window = Window_MShopStatus.new
@status_window.visible = true
@status_window.active = false
@status_window.opacity = $mShop_Window_Opacity
@status_window.skill = @buy_window.skill
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
if !SceneManager.scene_is? (Scene_MShop)
break
# 如果画面切换的话就中断循环
end
end
# 释放窗口
pre_terminate
terminate
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
#@mhelp_window.update
@gold_window.update
@buy_window.update
@status_window.update
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
@status_window.skill = @buy_window.skill
if Input.trigger?(Input::B)
Sound::play_cancel
# 返回
SceneManager.return
# 释放窗口
return
end
if Input.trigger?(Input::C)
[url=home.php?mod=space&uid=260100]@skill[/url] = @buy_window.skill
if @skill == nil or @skill.price > $mShop_gold
Sound::play_buzzer
return
end
Sound::play_ok
@buy_window.active = false
@status_window.index = 0
@status_window.active = true
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口激活的情况下)
#--------------------------------------------------------------------------
def update_status
if Input.trigger?(Input::B)
Sound::play_cancel
@status_window.active = false
@status_window.index = -1
@buy_window.active = true
end
if Input.trigger?(Input::C)
if $game_party.members[@status_window.index].skill_learn?(@skill)
Sound::play_buzzer
return
else
Sound::play_ok
if $mShop_use_variable == 0
$game_party.gain_gold([email]-@skill.price[/email])
$mShop_gold -= @skill.price
else
$game_variables[$mShop_use_variable] -= @skill.price
$mShop_gold -= @skill.price
end
$game_party.members[@status_window.index].learn_skill(@skill.id)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@status_window.active = false
@status_window.index = -1
@buy_window.active = true
end
end
end
end
#==============================================================================
# ■ Window_MShopBuy
#------------------------------------------------------------------------------
# 特技商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_MShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 修改行高为合适的值
#--------------------------------------------------------------------------
def line_height
return 32
end
#--------------------------------------------------------------------------
# ● 初始化对象
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize(id)
@id = id
super(0, 64, 544-32-standard_padding*2, 416-64-64)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
def item_max
if @id != nil
return @id.size
end
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for skill_id in @id
skill = $data_skills[skill_id]
if skill != nil
@data.push(skill)
end
end
if item_max > 0
self.contents = Bitmap.new(width - 32, item_max* 32)
for i in 0...item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
# 除此之外的情况设置为无效文字色
if skill.price <= $mShop_gold
self.contents.font.color = normal_color
else
self.contents.font.color = system_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 24, 24)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
draw_icon(skill.icon_index,x,y+4,self.contents.font.color == normal_color)
self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end
#==============================================================================
# ■ Window_MShopStatus
#------------------------------------------------------------------------------
# 特技商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_MShopStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 修改行高为合适的值
#--------------------------------------------------------------------------
def line_height
return 32
end
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(Graphics.width-standard_padding*2-32,64,standard_padding*2+32 , Graphics.height-64)
self.contents = Bitmap.new(width - 24, 32*$game_party.members.size+2*standard_padding>height - 32-64? 32*$game_party.members.size+2*standard_padding : height - 32-64)
self.contents.font.size = 32
@skill = nil
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.members.size
actor = $game_party.members[i]
if actor.class.skills.include?(@skill.id)
if !actor.skill_learn?(@skill)
draw_actor_graphic(actor,standard_padding+4,32*i+16+12+4)
else
draw_actor_graphic(actor,standard_padding+4,32*i+16+12+4,150)
end
else
next
end
end
end
def item_max
return $game_party.members.size
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def skill=(skill)
if @skill != skill
@skill = skill
refresh
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 32, 44, 44)
end
end
end
#==============================================================================
# ■ RPG原装定义
#==============================================================================
module RPG
class Skill
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def price
price = @description.split(/@/)[1]
return price != nil ? price.to_i : 0
end
end
class Class < BaseItem
def skills
@allskills = []
self.learnings.each do |skill|
@allskills.push(skill.skill_id)
end
return @allskills
end
end
end
#==============================================================================
# ■ 场景管理器定义
#==============================================================================
module SceneManager
#--------------------------------------------------------------------------
# ● 呼び出し
#--------------------------------------------------------------------------
def self.call(scene_class,para = nil)
@stack.push(@scene)
@scene = scene_class.new(para)
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 描绘角色行走图(只给定角色对象)
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y, alpha = 255)
draw_character(actor.character_name, actor.character_index, x, y,alpha)
end
#--------------------------------------------------------------------------
# ● 描绘行走图
#--------------------------------------------------------------------------
def draw_character(character_name, character_index, x, y,alpha = 255)
return unless character_name # 不给文件名神马的最讨厌了
bitmap = Cache.character(character_name) # 读取Cache里的行走图像
sign = character_name[/^[\!\$]./] # 如果文件名里带!和$的话有特殊含义哦
if sign && sign.include?('$') # 如果有$的话是大图
cw = bitmap.width / 3
ch = bitmap.height / 4
else # 不然是小图。有!表示非人物的行走图。宝箱之类的。
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index # 这都要偷懒啊……
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
contents.blt(x - cw / 2, y - ch, bitmap, src_rect,alpha) # Bitmap.blt方法
end
end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================