赞 | 2 |
VIP | 0 |
好人卡 | 0 |
积分 | 42 |
经验 | 13328 |
最后登录 | 2024-8-10 |
在线时间 | 258 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 4169
- 在线时间
- 258 小时
- 注册时间
- 2013-10-13
- 帖子
- 815
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
module Mercenaries
class Window_Help < ::Window_Base
def initialize
super(0, 0, 196, 256)
self.contents = Bitmap.new(width - 32, height - 32)
self.z += 10
end
def draw_actors(actor)
self.contents.clear
bitmap=RPG::Cache.battler(actor.battler_name, actor.battler_hue)
self.contents.blt(0,0,bitmap,bitmap.rect)
self.contents.draw_text(0,0,64,32,"价格:"+actor.price.to_s)
self.contents.draw_text(0,32,64,32,"姓名:"+actor.name.to_s)
self.contents.draw_text(0,64,64,32,"职业:"+actor.class_name.to_s)
self.contents.draw_text(0,96,64,32,"武器:#{$data_weapons[actor.weapon_id].name}")
self.contents.draw_text(0,128,64,32,"盔甲:#{$data_armors[actor.armor3_id].name}")
self.contents.draw_text(0,160,64,32,"攻击力:#{actor.atk}")
self.contents.draw_text(0,192,64,32,"防御力:#{actor.pdef}")
self.contents.draw_text(0,224,64,32,"魔御力:#{actor.mdef}")
end
end #帮助窗口
class Window_ShopCommand<::Window_Selectable
def initialize
super(80, 90 - 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
for i in [email protected]
x=i*160
self.contents.draw_text(x,0,128,32,@commands)
end
end
end#买卖指令窗口
class Window_Mercenaries<::Window_Selectable
attr_reader :mercenaries
attr_reader :column_max
def initialize(mercenaries)
super(80, 90, 480, 320)
@mercenaries = mercenaries
@column_max = 7
refresh
self.index = 0
end
def id
return @mercenaries[self.index]
end
def set_mercenaries(mercenaries)
@mercenaries=mercenaries
refresh
end
def refresh
@[email protected]
if @item_max>0
self.contents=Bitmap.new(width-32,row_max*80)
for i in 0...@item_max
draw_actor(i)
end
end
end
def draw_actor(index)
x=index%@column_max*64
y=index/@column_max*80
actor=$game_actors[@mercenaries[index]]
bitmap=RPG::Cache.character(actor.character_name, actor.character_hue)
rect=bitmap.rect
rect.width /=4
rect.height/=4
self.contents.blt(x,y,bitmap,rect)
self.contents.font.size=12
self.contents.draw_text(x,y+32,64,16,actor.name)
self.contents.font.size=9
self.contents.draw_text(x,y+48,64,16,"Lv"+sprintf("%03d",actor.level))
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
# 计算光标坐标
x = @index % @column_max * 64
y = @index / @column_max * 80 - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, 64, 80)
end
end#描绘雇佣与解雇窗口
class Scene_Mercenaries
def initialize(mercenaries)
@mercenaries = mercenaries
@windows = []
@temp = @mercenaries.dup
end
def main
main_start
Graphics.transition
main_loop
Graphics.freeze
main_end
end
def main_start
@window_shopcommand = Window_ShopCommand.new #最上面的窗口
@window_help = Window_Help.new #帮助窗口
@window_mercenaries = Window_Mercenaries.new(@mercenaries)#下面的窗口
@window_mercenaries.active = false
@window_mercenaries.index = -1
@window_gold = Window_Gold.new
@window_gold.x = 640 - @window_gold.width - 32 #右下角窗口
@window_gold.y = 480 - @window_gold.height - 32
@windows << @window_gold << @window_shopcommand << @window_mercenaries << @window_help
@window_help.visible = false
@spriteset = Spriteset_Map.new
end
def main_loop
while $scene == self
rm_update
update_window
input_update
end
end
def main_end
@windows.each{ |window|window.dispose }
@spriteset.dispose
end
def rm_update
Graphics.update
Input.update
end
def update_window
@windows.each{ |window|window.update }
update_help
end
def update_help
if @window_mercenaries.active=true
@window_help.visible=true
wx=@window_mercenaries.index%@window_mercenaries.column_max*64
wy=@window_mercenaries.index/@window_mercenaries.column_max*80
@window_help.x=wx+@window_mercenaries.x+64
@window_help.y=wy+@window_mercenaries.y+80
if @window_help.x+@window_help.width>640
@window_help.x=640-@window_help.width
end
if @window_help.y+@window_help.height>480
@window_help.y=480-@window_help.height
end
@window_help.draw_actors($game_actors[@window_mercenaries.id])
else
@window_help.visible=false
end
end
def input_update
if Input.trigger?(Input::B)
@window_shopcommand.active=true
@window_mercenaries.active=false
@window_mercenaries.index=-1
return
end
if Input.trigger?(Input::C)
if @window_shopcommand.active
case @window_shopcommand.index
when 0 #准备雇佣窗口
#出现2-9号角色的窗口
p @window_mercenaries.id
@window_mercenaries.set_mercenaries(@temp)
@type=0
@window_shopcommand.active=false
@window_mercenaries.active=true
@window_mercenaries.index = 0
return
when 1#准备解雇窗口
p @window_mercenaries.id
actors=[]
for actor in $game_party.actors
actors<<actor.id
end
# @mercenaries=[3,4,5,6,7,8,9],@window_mercenaries.id=9
@window_mercenaries.set_mercenaries(actors)
# @mercenaries=[1,2],@window_mercenaries.id=2
@type = 1
@window_shopcommand.active=false
@window_mercenaries.active=true
@window_mercenaries.index = 0
return
when 2
$scene=Scene_Map.new
return
end
end
# end #如果这里有end,角色迅速雇佣,是回车键
case @type
when 0 #雇佣2号角色的窗口
if $game_party.gold>=$game_actors[@window_mercenaries.id].price
if $game_party.actors.size<4
$game_party.lose_gold($game_actors[@window_mercenaries.id].price)
$game_party.add_actor(@window_mercenaries.id)
# @mercenaries=[2,3,4,5,6,7,8,9],@window_mercenaries.id=2
@window_mercenaries.mercenaries.delete(@window_mercenaries.id)
# @mercenaries=[3,4,5,6,7,8,9],@window_mercenaries.id=3
@window_mercenaries.refresh
if @window_mercenaries.index>@window_mercenaries.mercenaries.size-1
@window_mercenaries.index=@window_mercenaries.mercenaries.size-1
end
end
end
when 1 #解雇2号角色的窗口
if @window_mercenaries.id != 1
$game_party.gain_gold($game_actors[@window_mercenaries.id].price/2)
$game_party.remove_actor(@window_mercenaries.id)
# @mercenaries=[1,2],@window_mercenaries.id=2
@temp<<@window_mercenaries.id
@window_mercenaries.mercenaries.delete(@window_mercenaries.id)
# @mercenaries=[1],@window_mercenaries.id=nil
@window_mercenaries.refresh
if @window_mercenaries.index>@window_mercenaries.mercenaries.size-1
@window_mercenaries.index=@window_mercenaries.mercenaries.size-1
end
end
end# Input::C
@window_gold.refresh
end
end
end #雇佣场景类
end
class Game_Actor
def price
[email protected](/,/)[1].nil? ? 0 : @name.split(/,/)[1]
return price*self.level
end
def name
[email protected](/,/)[0]
end
end
在地图上建一事件,用脚本:
a=[2,3,4,5,6,7,8]
$scene=\
Mercenaries::\
Scene_Mercenaries.new(a)
请问:在P@window_mercenaries.id 的两个地方,为什么在雇佣转解雇 和 解雇转雇佣的时候,总是P出最大的值?
|
|