设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1531|回复: 0
打印 上一主题 下一主题

[已经过期] 角色仓库怎么添加装备显示?(分辨率为640x480)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
107 小时
注册时间
2012-8-20
帖子
54
跳转到指定楼层
1
发表于 2015-8-8 15:29:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
  1. #—————————————————————————————————————
  2. # ●APACK ver 1.6 date.2015.3.21 by.Lyaci
  3. #  ·角色存储(仓库)
  4. #  ·PMSYS更名为LYA_RASPM PMCC更名为该脚本名APACK
  5. #  ·使用:
  6. #    -创建仓库并打开界面(默认已创建ID为APACK_MAXLABEL的仓库)
  7. #    $game_party.scene_apack(仓库ID,该仓库名称,仓库容量)
  8. #    -进一步使用请查询Game_Party定义
  9. #—————————————————————————————————————
  10. module LYA_RASPM
  11.   #————————————————————————————————————————
  12.   #●仓库类设置
  13.   #————————————————————————————————————————
  14.   APACK_ALL = 50                  #仓库的容量(默认)
  15.   APACK_MAX = 15                  #队伍最多人数(必须设置)
  16.   APACK_MIN = 1                   #队伍最少人数(nil为不设)
  17.   APACK_DEF = nil                 #队伍固定这个数(nil为不设)
  18.   APACK_NOPM = [5,6,8]            #不能存放的角色(默认)
  19.   APACK_MAXLABEL = 0              #默认窗口ID,队伍满员后传送到的仓库ID
  20.   #————————————————————————————————————————
  21.   #●窗口类设置
  22.   #————————————————————————————————————————
  23.   APACKWIN_FACE = true            #是否绘制头像特写
  24.   APACKWIN_CR_NAME = Color.new(255,255,255,255) #普通名字描绘色
  25.   APACKWIN_CR_SNAME = Color.new(255,50,50,255)  #禁止存/取名字描绘色
  26.   APACKWIN_CR_XN = Color.new(255,255,255,128)   #默认前景色
  27.   APACKWIN_CR_BACK = Color.new(180,230,255,88)  #默认背景色
  28.   APACKWIN_CR_LBACK = Color.new(255,200,28,88) #收藏背景色
  29. end
  30. #————————————————————————————————————————
  31. # ●Game_Party 数据主体
  32. #————————————————————————————————————————
  33. class Game_Party < Game_Unit
  34.   include LYA_RASPM
  35.   attr_accessor :apack                           #储存体
  36.   attr_reader :apack_vol                         #存储体容量
  37.   attr_reader :apack_label                       #存储体标签
  38.   attr_reader :apack_max, :apack_min, :apack_def #限定变量
  39.   attr_reader :apack_ap_name                     #存储体名称
  40.   #———————————————————————————————————————
  41.   #初始化仓库
  42.   #———————————————————————————————————————
  43.   alias :apack_initialize :initialize
  44.   def initialize
  45.     apack_initialize
  46.     @apack = {}
  47.     @apack_vol = {}
  48.     @apack_max = APACK_MAX
  49.     @apack_min = APACK_MIN
  50.     @apack_def = APACK_DEF
  51.     @apack_label = APACK_MAXLABEL
  52.     @apack_ap_name = ""
  53.     open_apack @apack_label
  54.   end
  55.   #———————————————————————————————————————
  56.   #打开仓库数据及界面
  57.   #———————————————————————————————————————
  58.   def scene_apack(label, ap_name = "普通仓库", vol = APACK_ALL)
  59.     open_apack(label, ap_name, vol)
  60.     SceneManager.call(Scene_APACK)
  61.   end
  62.   #———————————————————————————————————————
  63.   #设定存储体标签(设定准备要打开的仓库ID)
  64.   #———————————————————————————————————————
  65.   def apack_label=(label)
  66.     @apack_label = label
  67.     @apack[label] ||= Array.new(APACK_ALL)
  68.   end
  69.   #———————————————————————————————————————
  70.   #打开仓库数据
  71.   #———————————————————————————————————————
  72.   def open_apack(label, ap_name = "普通仓库", vol = APACK_ALL)
  73.     @apack_ap_name = ap_name
  74.     @apack_label = label
  75.     apack_all_set(label, vol)
  76.   end
  77.   #———————————————————————————————————————
  78.   #取得目前打开仓库的容量
  79.   #———————————————————————————————————————
  80.   def apack_vol
  81.     @apack_vol[@apack_label]
  82.   end
  83.   #———————————————————————————————————————
  84.   #角色入队
  85.   #———————————————————————————————————————
  86.   def add_actor(actor_id)
  87.     unless @actors.include?(actor_id)
  88.       if @actors.size < apack_max
  89.         name = $game_actors[actor_id].name
  90.         $game_message.add("角色【#{name}】加入队伍!")
  91.         @actors.push(actor_id) ; apack_ove(actor_id)
  92.       else
  93.         index = @apack[APACK_MAXLABEL].index(nil)
  94.         name = $game_actors[actor_id].name
  95.         if index
  96.           @apack[APACK_MAXLABEL][index] = actor_id
  97.           $game_message.add("角色【#{name}】已存入仓库!")
  98.         else
  99.           $game_message.add("仓库已满!角色【#{name}】未能存放!")
  100.         end
  101.       end
  102.     end
  103.     $game_player.refresh
  104.     $game_map.need_refresh = true
  105.   end
  106.   #———————————————————————————————————————
  107.   #角色离队
  108.   #———————————————————————————————————————
  109.   alias :apack_remove_actor :remove_actor
  110.   def remove_actor(actor_id)
  111.     apack_remove_actor(actor_id)
  112.     apack_ove(actor_id)
  113.   end
  114.   #———————————————————————————————————————
  115.   #存入、拿出角色(内部用)
  116.   #pi:队伍的项目ID ci:仓库的项目ID
  117.   #———————————————————————————————————————
  118.   def apack_pcts(pi,ci)
  119.     #取得目前仓库位置角色ID
  120.     cact = @apack[@apack_label][ci]
  121.     #放置新角色ID到该仓库位置
  122.     @apack[@apack_label][ci] = @actors[pi]
  123.     #该仓库位置有角色的情况下加入到队伍位置
  124.     #没有角色的话直接从队伍删除
  125.     cact ? @actors[pi] = cact : @actors.delete_at(pi)
  126.   end
  127.   #———————————————————————————————————————
  128.   #直接存入仓库
  129.   #———————————————————————————————————————
  130.   def apack_add(label, id)
  131.     #仓库是否有空位
  132.     index = @apack[label].index(nil)
  133.     if !@apack[label].include?(id) && index
  134.       #存入仓库
  135.       @apack[label][index] = id
  136.       #在队伍的话离队
  137.       @actors.delete(id)
  138.       #刷新队伍、及地图
  139.       $game_player.refresh
  140.       $game_map.need_refresh = true
  141.     end
  142.   end
  143.   #———————————————————————————————————————
  144.   #直接从仓库取出
  145.   #———————————————————————————————————————
  146.   def apack_get(id)
  147.     @apack.each {|key,val| break(add_actor(id)) if val.include?(id)}
  148.   end
  149.   #———————————————————————————————————————
  150.   #直接从仓库删除
  151.   #———————————————————————————————————————
  152.   def apack_ove(id)
  153.     @apack.each {|key,val| break(val[val.index(id)] = nil) if val.include?(id)}
  154.   end
  155.   #———————————————————————————————————————
  156.   #不能存放的角色(队伍仓库通用)
  157.   #———————————————————————————————————————
  158.   def apack_no(id=nil)
  159.     @apack_no ||= LYA_RASPM::APACK_NOPM
  160.     @apack_no << id if id && !@apack_no.include?(id);@apack_no
  161.   end
  162.   #———————————————————————————————————————
  163.   #解除不可存放的角色(队伍仓库通用)
  164.   #———————————————————————————————————————
  165.   def apack_ok(id)
  166.     @apack_no.delete(id)
  167.   end
  168.   #———————————————————————————————————————
  169.   #仓库的角色
  170.   #———————————————————————————————————————
  171.   def apack_actor
  172.     @apack[@apack_label].collect {|id| id ? $game_actors[id] : id }
  173.   end
  174.   #———————————————————————————————————————
  175.   #收藏的角色
  176.   #———————————————————————————————————————
  177.   def apack_like(id=nil)
  178.     @apack_like ||= []
  179.     @apack_like.include?(id) ? @apack_like.delete(id) : @apack_like.push(id) if id
  180.     @apack_like
  181.   end
  182.   #———————————————————————————————————————
  183.   #队伍的最大人数
  184.   #———————————————————————————————————————
  185.   def apack_max=(num)
  186.     @apack_max ||= LYA_RASPM::APACK_MAX
  187.     @apack_max = num if num ; @apack_max
  188.   end
  189.   #———————————————————————————————————————
  190.   #队伍的最少人数
  191.   #———————————————————————————————————————
  192.   def apack_min=(num)
  193.     @apack_min ||= LYA_RASPM::APACK_MIN
  194.     @apack_min = num if num ; @apack_min
  195.   end
  196.   #———————————————————————————————————————
  197.   #队伍的指定人数
  198.   #———————————————————————————————————————
  199.   def apack_def=(num)
  200.     @apack_def ||= LYA_RASPM::APACK_DEF
  201.     @apack_def = num if num ; @apack_def
  202.   end
  203.   #———————————————————————————————————————
  204.   #仓库的容量 del:false:限制容量 true:真实容量
  205.   #———————————————————————————————————————
  206.   def apack_all_set(label,num,del=false)
  207.     @apack[label] ||= Array.new
  208.     #获得当前、新的容量
  209.     @apack_vol[label] ||= @apack[label].size
  210.     now = @apack_vol[label]
  211.     new = @apack_vol[label] = num
  212.     c = new - now
  213.     #被扩大仓库情况
  214.     if now < new ; @apack[label] += Array.new(c)
  215.     #被缩小仓库情况(del为开启时)角色全部前移容量外的删除
  216.     elsif now > new && del
  217.     apack = @apack[label].compact
  218.     c = [new - apack.size, 0].max
  219.     @apack[label] = apack[0,new] + Array.new(c) ; end
  220.     num
  221.   end
  222.   #———————————————————————————————————————
  223.   #清空仓库(V1.1)
  224.   #———————————————————————————————————————
  225.   def apack_allove
  226.     @apack[@apack_label] = Array.new(@apack_vol[@apack_label]||0)
  227.   end
  228. end
  229. #————————————————————————————————————————
  230. # ●Window_APACK 窗口主体
  231. #————————————————————————————————————————
  232. class Window_APACK < Window_Selectable
  233.   C1 = Color.new(239, 32, 71, 255)
  234.   C2 = Color.new(214, 180, 160, 255)
  235.   #———————————————————————————————————————
  236.   #初始化对象
  237.   #———————————————————————————————————————
  238.   def initialize(x, y, w, h, l, type, viewport)
  239.     #列数及类型
  240.     @l = l ; @type = type
  241.     #使用父类
  242.     super(x, y, w, h)
  243.     #选项位置
  244.     self.index = -1
  245.     #显示端口
  246.     self.viewport = viewport
  247.     #预留空位(窗口)
  248.     self.padding_bottom = dnh
  249.     #生成动态行走图(z提高)
  250.     dviewport = Viewport.new(x+50,viewport.rect.y+hk,w,h-hk*2-2)
  251.     dviewport.z = 2000
  252.     @dych = Dynamic_Character.new(x, y, self.z, dviewport)
  253.     #记录隐蔽行走图的标准选项
  254.     @dychtfi = 0
  255.     #生成信息精灵
  256.     @info = Sprite.new(viewport)
  257.     #生成位图,宽、高继承预留空位
  258.     @info.bitmap = Bitmap.new(contents_width, h)
  259.     #信息坐标(边距同步)
  260.     @info.x = standard_padding
  261.     @info.y = standard_padding
  262.     #信息高于本窗口
  263.     @info.z = self.z
  264.     #生成成员信息精灵
  265.     @info_pc = Sprite.new(viewport)
  266.     @info_pc.bitmap = Bitmap.new(contents_width, h)
  267.     @info_pc.x = standard_padding ; @info_pc.y = standard_padding ; @info_pc.z = @info.z
  268.     #生成背景精灵
  269.     @back = Sprite.new(viewport)
  270.     #生成位图,宽、高继承本窗口绘制内容
  271.     @back.bitmap = Bitmap.new(contents_width, contents_height)
  272.     #背景坐标(边距同步)
  273.     @back.x , @back.y = x+standard_padding, y+standard_padding
  274.     #背景高于本窗口
  275.     @back.z = self.z
  276.     #更改字体大小
  277.     @back.bitmap.font.size = 18
  278.     #更改字体透明度
  279.     @back.bitmap.font.color.alpha = 86
  280.     #记录当前窗口选项
  281.     @sindex = 0
  282.     #绘制信息>内容
  283.     refresh
  284.     update_padding_bottom
  285.   end
  286.   #———————————————————————————————————————
  287.   #获取数据
  288.   #———————————————————————————————————————
  289.   def data
  290.     case @type ; when :L ; ldata ; when :R ; rdata ; end
  291.   end
  292.   #———————————————————————————————————————
  293.   #预留数据
  294.   #———————————————————————————————————————
  295.   def data2(data2=nil)
  296.     @data2 = data2 ? data2 : @data2 ; @data2
  297.   end
  298.   #———————————————————————————————————————
  299.   #基本数据
  300.   #———————————————————————————————————————
  301.   def ldata ; $game_party.members ; end
  302.   def rdata ; $game_party.apack_actor ; end
  303.   #———————————————————————————————————————
  304.   #获得、设置当前角色数据(V1.1)
  305.   #———————————————————————————————————————
  306.   def index_actor ; @index_actor ; end
  307.   def index_actor=(actor) ; @index_actor = actor ; end
  308.   #———————————————————————————————————————
  309.   #动态行走图选择项动态
  310.   #———————————————————————————————————————
  311.   def one=(tf) ; @dych.one=@dy_one=tf ; end
  312.   #———————————————————————————————————————
  313.   #动态行走图显示类型更改
  314.   #———————————————————————————————————————
  315.   def dy_type=(type) ; @dych.type=@dy_type=type ; end
  316.   #———————————————————————————————————————
  317.   #获取项目数
  318.   #———————————————————————————————————————
  319.   def item_max
  320.     case @type
  321.     when :L ; $game_party.apack_max
  322.     when :R ; $game_party.apack_vol ; end
  323.   end
  324.   #———————————————————————————————————————
  325.   #获取列数
  326.   #———————————————————————————————————————
  327.   def col_max ; @l ; end
  328.   #———————————————————————————————————————
  329.   #宽高间隔
  330.   #———————————————————————————————————————
  331.   def wk ; return 2 ; end
  332.   def hk ; return 8 ; end
  333.   #———————————————————————————————————————
  334.   #获取行高
  335.   #———————————————————————————————————————
  336.   def line_height ; return 24 ; end
  337.   #———————————————————————————————————————
  338.   #获取项目宽度、高度
  339.   #———————————————————————————————————————
  340.   def item_width ; return 196 ; end
  341.   def item_height ; return line_height ; end
  342.   #———————————————————————————————————————
  343.   #获取标准边距
  344.   #———————————————————————————————————————
  345.   def standard_padding ; return 12 ; end
  346.   #———————————————————————————————————————
  347.   #下端空白内容高度
  348.   #———————————————————————————————————————
  349.   def dnh ; return 0 ; end
  350.   #———————————————————————————————————————
  351.   #计算窗口内容的高度
  352.   #———————————————————————————————————————
  353.   def contents_height
  354.     ch = [super - super % item_height, all_row_max * (item_height + hk)].max
  355.     case @type
  356.     when :L ; return ch + (item_height + hk)
  357.     when :R ; return ch ; end
  358.   end
  359.   #--------------------------------------------------------------------------
  360.   # ● 获取一页內显示的行数
  361.   #--------------------------------------------------------------------------
  362.   def page_row_max
  363.     (height - padding - padding_bottom) / (item_height + hk) + 1
  364.   end
  365.   #--------------------------------------------------------------------------
  366.   # ● 更新下端边距
  367.   #--------------------------------------------------------------------------
  368.   def update_padding_bottom
  369.     self.padding_bottom = hk
  370.   end
  371.   #———————————————————————————————————————
  372.   # ● 获取队伍、仓库全部行数
  373.   #———————————————————————————————————————
  374.   def all_row_max
  375.     case @type
  376.     when :L ; all_item_max = $game_party.apack_max
  377.     when :R ; all_item_max = rdata.size ; end
  378.     [(all_item_max + col_max - 1) / col_max, 1].max
  379.   end
  380.   #———————————————————————————————————————
  381.   #获取顶行位置
  382.   #———————————————————————————————————————
  383.   def top_row
  384.     oy / (item_height + hk)
  385.   end
  386.   #———————————————————————————————————————
  387.   #设置顶行位置
  388.   #———————————————————————————————————————
  389.   def top_row=(row)
  390.     #窗口原点坐标更新
  391.     row = 0 if row < 0
  392.     row = row_max - 1 if row > row_max - 1
  393.     self.oy = row * (item_height + hk)
  394.     #必要精灵原点更新
  395.     sproxoy
  396.   end
  397.   #———————————————————————————————————————
  398.   #更新必要精灵原点(背景、行走图)
  399.   #———————————————————————————————————————
  400.   def sproxoy
  401.     @dych.oy = @back.oy = self.oy
  402.   end
  403.   #———————————————————————————————————————
  404.   #获取项目的绘制矩形
  405.   #———————————————————————————————————————
  406.   def item_rect(index)
  407.     rect = Rect.new
  408.     rect.width = item_width
  409.     rect.height = item_height
  410.     rect.x = index % col_max * (item_width + wk) + 320+95
  411.     rect.y = index / col_max * (item_height + hk)
  412.     rect
  413.   end
  414.   #———————————————————————————————————————
  415.   #更新光标
  416.   #———————————————————————————————————————
  417.   def update_cursor
  418.     super
  419.     #更新动态行走图光标
  420.     @dych.index = self.index if @dy_one && @dych
  421.     #更新选中对象的能力值信息
  422.     if @index != @old_index
  423.       @old_index = @index
  424.       info_pc(data[@index]) if self.active
  425.     end
  426.   end
  427.   #———————————————————————————————————————
  428.   #绘制内容
  429.   #———————————————————————————————————————
  430.   def refresh
  431.     #清除全体
  432.     contents.clear
  433.     @dych.clear
  434.     @back.bitmap.clear
  435.     #开始绘制
  436.     item_max.times {|index|
  437.     draw_item(index)}
  438.     #更新内容
  439.     data_refresh
  440.     info
  441.     info_pc(data.compact[0])
  442.   end
  443.   #———————————————————————————————————————
  444.   #更新内容
  445.   #———————————————————————————————————————
  446.   def data_refresh
  447.     #必要精灵原点更新
  448.     sproxoy
  449.   end
  450.   #———————————————————————————————————————
  451.   #更新背景
  452.   #———————————————————————————————————————
  453.   def back_refresh
  454.     #清除背景
  455.     @back.bitmap.clear
  456.     #开始绘制
  457.     item_max.times {|index|
  458.     #项目数据
  459.     actor = data[index]
  460.     #项目矩形
  461.     rect = item_rect(index)
  462.     #项目坐标
  463.     x = rect.x ; y = rect.y
  464.     #描绘背景
  465.     back(x, y, index, actor)}
  466.   end
  467.   #———————————————————————————————————————
  468.   #绘制项目(替换时更新)
  469.   #———————————————————————————————————————
  470.   def draw_item(index)
  471.     #项目数据
  472.     actor = data[index]
  473.     #项目矩形
  474.     rect = item_rect(index)
  475.     #项目坐标
  476.     x = rect.x ; y = rect.y
  477.     #描绘背景
  478.     back(x, y, index, actor)
  479.     #角色不存在则返回
  480.     return unless actor
  481.     #行走图
  482.     @dych.draw_character(x+15, y+30, actor, index)
  483.     #描绘基本色
  484.     contents.font.color = LYA_RASPM::APACKWIN_CR_NAME
  485.     #名字背景
  486.     lh = (line_height) * 0
  487.     c = LYA_RASPM::APACKWIN_CR_XN
  488.     contents.back_w(x,y+lh,item_width,line_height,0.25,c)
  489.     #是否可存取角色
  490.     apack_no = $game_party.apack_no.include?(actor.id)
  491.     contents.font.color = LYA_RASPM::APACKWIN_CR_SNAME  if apack_no
  492.     #头像
  493.     draw_face(actor, rect.x + 51, rect.y + 1) if LYA_RASPM::APACKWIN_FACE
  494.     #名字
  495.     contents.draw_text(x+20, y+lh, item_width, line_height, actor.name, 1)
  496.   end
  497.   #———————————————————————————————————————
  498.   #绘制角色肖像图
  499.   #———————————————————————————————————————
  500.   def draw_face(actor, x, y)
  501.     #图像名 没有的话返回
  502.     face_name = actor.face_name
  503.     #没有图像
  504.     return unless face_name
  505.     #索引种类
  506.     face_index = actor.face_index
  507.     #传送位图
  508.     bitmap = Cache.face(face_name)
  509.     zx = face_index % 4 * 96
  510.     zy = face_index / 4 * 96
  511.     cw = ch = 94
  512.     rect = Rect.new(zx, zy+28, 96-2, line_height-1)
  513.     contents.blt(x+40, y, bitmap, rect, 164)
  514.     bitmap.dispose
  515.   end
  516.   #———————————————————————————————————————
  517.   #绘制背景
  518.   #———————————————————————————————————————
  519.   def back(x, y, index, actor)
  520.     #存在角色的情况下
  521.     if actor
  522.       actor_like = $game_party.apack_like.include?(actor.id)
  523.       #不显示头像或有收藏的情况下(选择默认、收藏背景)
  524.       if actor_like
  525.         #收藏背景颜色
  526.         c = LYA_RASPM::APACKWIN_CR_LBACK
  527.       else
  528.         #默认背景颜色
  529.         c = LYA_RASPM::APACKWIN_CR_BACK
  530.       end
  531.     else
  532.       #默认背景颜色
  533.       c = LYA_RASPM::APACKWIN_CR_BACK
  534.     end
  535.     #描绘背景
  536.     @back.bitmap.back_h(x,y,item_width-1,item_height-1,0.5,c)
  537.     #描绘编号
  538.     @back.bitmap.draw_text(x+2, y+2, 20, item_height, index+1,1)
  539.   end
  540.   #———————————————————————————————————————
  541.   #绘制收藏背景(更新用)
  542.   #———————————————————————————————————————
  543.   def back_like(index)
  544.     #项目数据
  545.     actor = data[index]
  546.     #项目矩形
  547.     rect = item_rect(index)
  548.     #项目坐标
  549.     x = rect.x + 1 ; y = rect.y + 1
  550.     #消除背景
  551.     @back.bitmap.clear_rect(rect)
  552.     #描绘背景
  553.     back(x, y, index, actor)
  554.   end
  555.   #———————————————————————————————————————
  556.   #绘制行走图
  557.   #———————————————————————————————————————
  558.   def draw_character(character_name, character_index, x, y)
  559.     return unless character_name
  560.     bitmap = Cache.character(character_name)
  561.     sign = character_name[/^[\!\$]./]
  562.     if sign && sign.include?(')
  563.       cw = bitmap.width / 3
  564.       ch = bitmap.height / 4
  565.     else
  566.       cw = bitmap.width / 12
  567.       ch = bitmap.height / 8
  568.     end
  569.     n = character_index
  570.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  571.     @info_pc.bitmap.blt(x +10- cw / 2, y - ch, bitmap, src_rect)
  572.   end
  573.   #———————————————————————————————————————
  574.   #绘制信息标题
  575.   #———————————————————————————————————————
  576.   def info
  577.     #清除旧信息
  578.     @info.bitmap.clear
  579.     actor = data.compact[0]
  580.     @info.bitmap.font.size = 20
  581.     return info_top unless actor
  582.     type = @type.eql? :L
  583.     nc = type ? " 队伍" : " 仓库"
  584.     nu = type ? "#{data.compact.size}" : "#{data.compact.size}/#{item_max}"
  585.     txt2 = nc+"人数:"+nu
  586.     @info.bitmap.draw_text(0,0,320,line_height,txt2)
  587.     @info.bitmap.font.size = 18
  588.     @info.bitmap.back_w(0,82,320,1,0.2,Color.new(255,255,255,128))
  589.   end
  590.   def info_top
  591.     return if @type.eql? :L
  592.     txt = $game_party.apack_ap_name + " 仓库人数:#{data.compact.size}/#{item_max}"
  593.     @info.bitmap.draw_text(0,0,320,line_height,txt)
  594.   end
  595.   #———————————————————————————————————————
  596.   #绘制选中成员信息(更新用)
  597.   #———————————————————————————————————————
  598.   def info_pc(actor)
  599.     @info_pc.bitmap.clear
  600.     return unless actor
  601.     draw_parameters(actor,38, 65)
  602.   end
  603.   def draw_parameters(actor,x, y)
  604.     @info_pc.bitmap.font.size = 18
  605.     #描绘名字职业等级
  606.    # text = "#{actor.name} #{actor.class.name} Lv:#{actor.level}"
  607.    # @info_pc.bitmap.draw_text(x-20, y -36, 286, 24, text,1)
  608.     #描绘Hp Mp
  609.     c1 = Color.new(239, 32, 71, 255)
  610.     c2 = Color.new(214, 180, 160, 255)
  611.     draw_cr(x-10,y-30,c1,c2,actor.hp,actor.mhp,txt='Hp',width=100,height=5)
  612.     c1 = Color.new(58, 112, 128, 255)
  613.     c2 = Color.new(118, 244, 254, 255)
  614.     draw_cr(x-10,y,c1,c2,actor.mp,actor.mmp,txt='Mp',width=100,height=5)
  615.     #绘制能力值背景
  616.     @info_pc.bitmap.font.size = 21
  617.     @info_pc.bitmap.back_w(x-30,y+30,145,120,0.2,Color.new(255,255,-255,64))
  618.     6.times {|i|
  619.     #能力值的显示位置
  620.      y2 = i
  621.     # x2 = i/3*130 ; y2 = i%3
  622.     #描绘能力值
  623.     change_color(system_color)
  624.     @info_pc.bitmap.font.color = system_color
  625.     @info_pc.bitmap.draw_text(x-10, y + 20 * y2, 86, line_height+55, Vocab::param(i+2))
  626.     @info_pc.bitmap.font.color = normal_color
  627.     @info_pc.bitmap.draw_text(x+60, y + 20 * y2, 86, line_height+55, actor.param(i+2))}
  628.     end
  629.   #———————————————————————————————————————
  630.   #绘制HP MP
  631.   #———————————————————————————————————————
  632.   def draw_cr(x,y,c1,c2,current,max,txt='',width=100,height=5)
  633.     #背景颜色
  634.     back_color = Color.new(0,0,0,255)
  635.     #边框色颜色
  636.     bk_color = Color.new(255,255,255,255)
  637.     #倒影颜色
  638.     dy_color = Color.new(0,0,0,128)
  639.     #倒影偏移
  640.     dx = 2;dy = 4
  641.     #斜率
  642.     xl = 5
  643.     #数值是否显示
  644.     num = true
  645.     #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
  646.     num_align = 1
  647.     #计算比率
  648.     bl = current.to_f / max
  649.     #计算实际宽
  650.     w = (width*bl).round
  651.     #计算锯齿
  652.     px = [1,(xl/height.to_f).round].max
  653.     #实际斜率
  654.     oxl = px*height
  655.     #描绘值槽
  656.     x2 = 0;height.times {|i|
  657.     @info_pc.bitmap.fill_rect(x+oxl-x2+dx/px, y+i+dy, width, 1, dy_color)
  658.     px.times {|n| x2 += 1}}
  659.     x2 = 0;height.times {|i|
  660.     @info_pc.bitmap.fill_rect(x+oxl-x2, y+i, width, 1, back_color)
  661.     px.times {|n| x2 += 1}}
  662.     x2 = 0;height.times {|i|
  663.     @info_pc.bitmap.gradient_fill_rect(x+oxl-x2, y+i, w, 1, c1,c2)
  664.     px.times {|n| x2 += 1}}
  665.     x2 = 0
  666.     @info_pc.bitmap.fill_rect(x+oxl, y-1, width+1, 1, bk_color)
  667.     @info_pc.bitmap.fill_rect(x, y+height, width+1, 1, bk_color)
  668.     height.times {|i|;px.times {|n|
  669.     @info_pc.bitmap.fill_rect(x+oxl-x2-1, y+i, 1, 1, bk_color)
  670.     @info_pc.bitmap.fill_rect(x+oxl-x2+width, y+i, 1, 1, bk_color);x2 += 1}}
  671.     #描绘文字
  672.     @info_pc.bitmap.font.size = 16
  673.     txt_w = @info_pc.bitmap.text_size(txt).width + 2
  674.     @info_pc.bitmap.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
  675.     @info_pc.bitmap.draw_text(x+oxl/2,y+height/2-12, width, 24,
  676.     current.to_s+'/'+max.to_s,num_align) if num
  677.   end
  678.   #———————————————————————————————————————
  679.   #绘制战力
  680.   #———————————————————————————————————————
  681. # def draw_cr2(x,y,c1,c2,current,max,txt='',width=100,height=5,bitmap)
  682.     #背景颜色
  683.   #  back_color = Color.new(0,0,0,64)
  684.     #数值是否显示
  685.   #  num = true
  686.     #显示数值的对齐方式 0:向左对齐 1:向中间对齐 2:向右边对齐
  687.    # num_align = 1
  688.     #计算比率
  689.    # bl = current.to_f / max
  690.     #计算实际宽
  691.    # w = [(width*bl).round, width].min
  692.   # bitmap.fill_rect(x, y, width, height, back_color)
  693.   #  bitmap.gradient_fill_rect(x, y, w, height, c1,c2)
  694.     #描绘文字
  695.    # bitmap.font.size = 16
  696.    # txt_w = @info_pc.bitmap.text_size(txt).width + 2
  697.    # bitmap.draw_text(x-txt_w,y+height/2-12, width, 24, txt)
  698.    # bitmap.draw_text(x,y+height/2-12, width, 24,
  699.    # current.to_s+'/'+max.to_s,num_align) if num
  700. # end
  701.   #———————————————————————————————————————
  702.   #重定义激活方法
  703.   #———————————————————————————————————————
  704.   def actives=(tf)
  705.     #是否关闭未激活窗口的动态行走图
  706.     @dych.type = tf ? @dy_type : nil
  707.     #记录和使用该窗口位置
  708.     if tf ; self.index = @sindex
  709.     else ; @sindex = [self.index,0].max ; end
  710.     #窗口是否激活
  711.     self.active = tf
  712.   end
  713.   #———————————————————————————————————————
  714.   #获取总能力值(基础)
  715.   #———————————————————————————————————————
  716. # def param_base(actor)
  717. #   all_param_base = 0
  718.   #  8.times {|i| f = i > 1 ? 1 : LYA_RASPM::APACKWIN_PBHPMP
  719.   #  all_param_base += actor.param_base(i) / f }
  720.   #  all_param_base
  721. # end
  722.   #———————————————————————————————————————
  723.   #位图剪切排序法
  724.   #———————————————————————————————————————
  725.   def new_bit_rect
  726.     #获得新的数据
  727.     new_d = data
  728.     #获得旧的数据
  729.     now_d = data2
  730.     #获得当前位图
  731.     bit = contents
  732.     #以旧的数据长度循环
  733.     new_d.each_index {|index|
  734.     #当前循环项对应的新数据
  735.     new_d_i = new_d[index]
  736.     #查找新的数据在旧的数据里的位置(旧项目、继承矩形用)
  737.     new_now_index = now_d.index(new_d_i)
  738.     #新旧位置相同时不重绘,进入下个循环项
  739.     next unless new_now_index && index != new_now_index
  740.     #新位置的矩形
  741.     new_rect = item_rect(index)
  742.     #旧位置的矩形
  743.     now_rect = item_rect(new_now_index)
  744.     #清除新项目上的矩形
  745.     contents.clear_rect(new_rect)
  746.     #绘制旧项目上的矩形
  747.     contents.blt(new_rect.x, new_rect.y ,bit,now_rect)
  748.     #清除旧项目上的矩形
  749.     contents.clear_rect(now_rect)}
  750.   end
  751.   #———————————————————————————————————————
  752.   #消除项目
  753.   #———————————————————————————————————————
  754.   def clear_item(index)
  755.     #要消除的项目矩形
  756.     rect = item_rect(index)
  757.     #本窗口消除
  758.     contents.clear_rect(rect)
  759.     #背景消除
  760.     @back.bitmap.clear_rect(rect)
  761.     #队伍窗口的情况查看是否要排序
  762.     if @type == :L
  763.       #项目数量没有变化时不执行排序
  764.       return if data.size == data2.size
  765.       #释放行走图精灵(队伍)
  766.       @dych.dispose_index(index)
  767.       #显示隐蔽的行走图
  768.       @dych.visible(@dychtfi-1, true)
  769.       #行走图排序开始
  770.       @dych.new_spr_xy
  771.       #位图排序开始
  772.       new_bit_rect
  773.       #背景排序开始
  774.       back_refresh
  775.     elsif @type == :R
  776.       #预留数据不存在的情况下
  777.       return unless data2[index]
  778.       #释放行走图精灵(仓库)
  779.       @dych.dispose_index(index,true)
  780.     end
  781.   end
  782.   #———————————————————————————————————————
  783.   #重绘项目
  784.   #———————————————————————————————————————
  785.   def redraw_item(index)
  786.     #消除项目
  787.     clear_item(index)
  788.     #绘制项目
  789.     draw_item(index)
  790.   end
  791.   #———————————————————————————————————————
  792.   #排序绘制
  793.   #———————————————————————————————————————
  794.   def new_refresh
  795.     true_index = @type.eql?(:L) ? [@index, data2.size].min : @index
  796.     #更新信息
  797.     info; info_pc(data[@index])
  798.     #重绘项目
  799.     redraw_item(true_index)
  800.     #更新内容
  801.     data_refresh
  802.   end
  803.   #———————————————————————————————————————
  804.   #按下确定键时的处理
  805.   #———————————————————————————————————————
  806.   def a_c
  807. #~     refresh    #常规绘制(*预留)
  808.     new_refresh #排序绘制
  809.   end
  810.   #———————————————————————————————————————
  811.   #按下CTRL键时的处理
  812.   #———————————————————————————————————————
  813.   def a_ctrl
  814.     #获取当前选项
  815.     index = self.index
  816.     #对应角色数据
  817.     actor = data[index]
  818.     #角色不存在则反回
  819.     return unless actor
  820.     #收藏、取消收藏角色
  821.     $game_party.apack_like(actor.id)
  822.     #更新收藏背景
  823.     back_like(index)
  824.   end
  825.   #———————————————————————————————————————
  826.   #全部刷新
  827.   #———————————————————————————————————————
  828.   def update
  829.     super
  830.     @dych.update
  831.   end
  832.   #———————————————————————————————————————
  833.   #全部释放
  834.   #———————————————————————————————————————
  835.   def dispose
  836.     super
  837.     @dych.dispose
  838.     @info.bitmap.dispose ; @info.dispose
  839.     @info_pc.bitmap.dispose ; @info_pc.dispose
  840.     @back.bitmap.dispose ; @back.dispose
  841.   end
  842. end
  843. #————————————————————————————————————————
  844. # ●Scene_APACK By.Clov
  845. #  *仓库界面
  846. #  *Ver:1.0 Date:2013.9.14
  847. #  *使用:SceneManager.call(Scene_APACK)
  848. #  -ENTER:    确认/返回
  849. #  -ESC:      返回
  850. #  -L/R:      换页
  851. #  -CTRL:     添加收藏/取消收藏
  852. #————————————————————————————————————————
  853. class Scene_APACK
  854.   #———————————————————————————————————————
  855.   #数据内容
  856.   #———————————————————————————————————————
  857.   def data
  858.     w = Graphics.width
  859.     h = Graphics.height / 2
  860.     #生成端口
  861.     @viewport = Viewport.new
  862.     @viewport.z = 2001
  863.     @viewport1 = Viewport.new(0,0,w,h)
  864.     @viewport1.z = 200
  865.     @viewport2 = Viewport.new(0,h,w,h)
  866.     @viewport2.z = 200
  867.     #生成队伍窗口
  868.     @apack_window_l = Window_APACK.new(0,0,w,h,1,:L,@viewport1)
  869.     @apack_window_l.one = false
  870.     @apack_window_l.dy_type = :W
  871.     @apack_window_l.actives = !false
  872.     #生成仓库窗口
  873.     @apack_window_r = Window_APACK.new(0,0,w,h,1,:R,@viewport2)
  874.     @apack_window_r.one = true
  875.     @apack_window_r.dy_type = :W
  876.     @apack_window_r.actives = false
  877.     #生成结束窗口
  878.     @apack_window_end = Window_Base.new(22,160,500,96)
  879.     @apack_window_end.viewport = @viewport
  880.     @apack_window_end.z = @apack_window_r.z + 1
  881.     @apack_window_end.visible = false
  882.     #生成背景
  883.     create_background
  884.     #仓库确认计数(循环替换状态计数,操作流畅度提高用)
  885.     @ok2 = 0
  886.   end
  887.   #———————————————————————————————————————
  888.   #主循环
  889.   #———————————————————————————————————————
  890.   def main
  891.     #准备数据
  892.     data
  893.     #执行过渡
  894.     Graphics.transition
  895.     #进行更新
  896.     update until SceneManager.scene != self
  897.     #准备过渡
  898.     Graphics.freeze
  899.     #释放全部
  900.     dispose
  901.   end
  902.   #———————————————————————————————————————
  903.   #主更新
  904.   #———————————————————————————————————————
  905.   def update
  906.     #画面、输入更新
  907.     Graphics.update
  908.     Input.update
  909.     #按键更新
  910.     updata_c
  911.     updata_b
  912.     updata_ctrl
  913.     #窗口更新
  914.     @apack_window_l.update
  915.     @apack_window_r.update
  916.     @apack_window_end.update
  917.   end
  918.   #———————————————————————————————————————
  919.   #结束窗口的描绘
  920.   #———————————————————————————————————————
  921.   def end_txt(txt)
  922.     @apack_window_end.contents.clear
  923.     @apack_window_end.contents.draw_text(0,4,500,24,txt,1)
  924.     @apack_window_end.contents.draw_text(0,36,500,24,"[ESC] [ENTER]",1)
  925.   end
  926.   #———————————————————————————————————————
  927.   #是否可以退出仓库
  928.   #———————————————————————————————————————
  929.   def end_ok?
  930.     apack_max = $game_party.apack_max
  931.     apack_min = $game_party.apack_min
  932.     apack_def = $game_party.apack_def
  933.     return true if apack_min.to_i > apack_max || apack_def.to_i > apack_max
  934.     pas = $game_party.members.compact.size
  935.     minb = apack_min <=> pas #-1 ok 0
  936.     defb = apack_def <=> pas # 0 ok 0
  937.     tf = true
  938.     tf = false if minb == 1
  939.     tf = false if defb && defb != 0
  940.     tf = true if defb && defb == 0
  941.     unless tf
  942.       Sound.play_buzzer
  943.       if defb ; txt = "队伍人数必须等于#{apack_def}名"
  944.       else ;
  945.       apack_min = apack_min ? "最少#{apack_min}名" : ""
  946.       txt = "队伍人数必须#{apack_min}" ; end
  947.       end_txt(txt+"(目前#{pas}名)")
  948.     end ; tf
  949.   end
  950.   #———————————————————————————————————————
  951.   #是否可以替换角色
  952.   #———————————————————————————————————————
  953.   def pcts_ok?(t,i)
  954.     #获得禁止角色
  955.     apack_no = $game_party.apack_no
  956.     case t
  957.     when :L ; id = $game_party.members[i].id if $game_party.members[i]
  958.     when :R ; id = $game_party.apack_actor[i].id if $game_party.apack_actor[i] ; end
  959.     tf = !apack_no.include?(id)
  960.     #禁止的情况下演奏声效并返回禁止/不禁止状态
  961.     Sound.play_buzzer unless tf ; tf
  962.   end
  963.   #———————————————————————————————————————
  964.   #生成背景 VA
  965.   #———————————————————————————————————————
  966.   def create_background
  967.     @background_sprite = Sprite.new
  968.     @background_sprite.bitmap = SceneManager.background_bitmap
  969.     @background_sprite.color.set(16, 16, 16, 128)
  970.   end
  971.   #———————————————————————————————————————
  972.   #替换队伍、仓库成员
  973.   #———————————————————————————————————————
  974.   def pcts
  975.     #演奏声效
  976.     Sound.play_reflection
  977.     #队伍、仓库当前选择项
  978.     members = $game_party.members
  979.     pi = [@apack_window_l.index, members.size].min
  980.     ci = @apack_window_r.index
  981.     #预留数据
  982.     @apack_window_l.data2(members)
  983.     @apack_window_r.data2($game_party.apack_actor)
  984.     #更换成员执行
  985.     $game_party.apack_pcts(pi,ci)
  986.     #更新绘制
  987.     @apack_window_l.a_c
  988.     @apack_window_r.a_c
  989.   end
  990.   #———————————————————————————————————————
  991.   #进入队伍窗口
  992.   #———————————————————————————————————————
  993.   def pwin
  994.     @apack_window_r.actives = false
  995.     @apack_window_l.actives = true
  996.     @apack_window_end.visible = false
  997.   end
  998.   #———————————————————————————————————————
  999.   #进入仓库窗口
  1000.   #———————————————————————————————————————
  1001.   def cwin
  1002.     @apack_window_r.actives = true
  1003.     @apack_window_l.actives = false
  1004.     @apack_window_end.visible = false
  1005.   end
  1006.   #———————————————————————————————————————
  1007.   #进入结束窗口
  1008.   #———————————————————————————————————————
  1009.   def ewin
  1010.     @apack_window_r.actives = false
  1011.     @apack_window_l.actives = false
  1012.     @apack_window_end.visible = true
  1013.   end
  1014.   #———————————————————————————————————————
  1015.   #按下确定键
  1016.   #———————————————————————————————————————
  1017.   def updata_c
  1018.     #按下确定键的情况下
  1019.     if Input.trigger?(:C)
  1020.       #结束窗口的情况下
  1021.      if @apack_window_end.visible
  1022.        #返回队伍窗口
  1023.        pwin ; return
  1024.      end
  1025.       #队伍窗口的情况下
  1026.      if @apack_window_l.active && pcts_ok?(:L, @apack_window_l.index)
  1027.        case @ok2
  1028.        #替换成员、仓库确认计数1(进入循环替换状态)
  1029.        when 2 ; pcts ; @ok2 = 1 ; cwin
  1030.        #进入仓库窗口
  1031.        when 0 ; cwin ; end
  1032.      #仓库窗口的情况下
  1033.      elsif @apack_window_r.active && pcts_ok?(:R, @apack_window_r.index)
  1034.        #仓库确认计数+1
  1035.        @ok2 += 1
  1036.        case @ok2
  1037.        #替换成员(转入循环替换状态前)
  1038.        when 1 ; pcts
  1039.        #进入队伍窗口
  1040.        when 2 ; pwin ; end
  1041.      end
  1042.    end
  1043.   end
  1044.   #———————————————————————————————————————
  1045.   #按下返回键
  1046.   #———————————————————————————————————————
  1047.   def updata_b
  1048.     #按下返回键的情况下
  1049.    if Input.trigger?(:B)
  1050.      #结束窗口的情况下
  1051.      if @apack_window_end.visible
  1052.        #返回队伍窗口
  1053.        pwin ; return
  1054.      end
  1055.      #队伍窗口的情况下
  1056.      if @apack_window_l.active
  1057.        #不可以退出仓库的情况下
  1058.        unless end_ok?
  1059.          #进入结束窗口
  1060.          ewin ; return
  1061.        end
  1062.        case @ok2
  1063.        #循环替换状态的话返回仓库窗口
  1064.        when 2 ; @ok2 = 1; cwin ; return ; end
  1065.        #返回上个界面
  1066.        SceneManager.return
  1067.      #仓库窗口的情况下
  1068.      elsif @apack_window_r.active
  1069.        #仓库确认计数重置
  1070.        @ok2 = 0
  1071.        #返回队伍窗口
  1072.        pwin
  1073.      end
  1074.     end
  1075.   end
  1076.   #———————————————————————————————————————
  1077.   #按下CTRL键
  1078.   #———————————————————————————————————————
  1079.   def updata_ctrl
  1080.     #按下返回键的情况下
  1081.    if Input.trigger?(:CTRL)
  1082.      #队伍窗口的情况下
  1083.      if @apack_window_l.active
  1084.        @apack_window_l.a_ctrl
  1085.      #仓库窗口的情况下
  1086.      elsif @apack_window_r.active
  1087.        @apack_window_r.a_ctrl
  1088.      end
  1089.     end
  1090.   end
  1091.   #———————————————————————————————————————
  1092.   #全部释放
  1093.   #———————————————————————————————————————
  1094.   def dispose
  1095.     #端口释放
  1096.     @viewport.dispose
  1097.     @viewport1.dispose
  1098.     @viewport2.dispose
  1099.     #窗口释放
  1100.     @apack_window_l.dispose
  1101.     @apack_window_r.dispose
  1102.     @apack_window_end.dispose
  1103.     #背景释放
  1104.     @background_sprite.dispose
  1105.   end
  1106. end
  1107. #————————————————————————————————————————
  1108. # ●Dynamic_Character By.Clov
  1109. #   *多类型动态行走图
  1110. #   *Ver:1.0 Date:2013.9.7
  1111. #   *使用:Dynamic_Character.new
  1112. #   *必须:update dispose
  1113. #   -draw_character(x, y, actor, index)主描绘
  1114. #   -@type                  动态类型 :W行走动态 :H转向动态 :WH行走转并行动态
  1115. #   -@one                   是否独立选择角色动态
  1116. #   -@speed                 每个动作的更新周期
  1117. #   -@wa                    行走动作表
  1118. #   -@ha                    转向动作表
  1119. #   *实例方法:
  1120. #   -self.one=true/false    更改选择/全部动态
  1121. #   -self.type=:W/:H/:WH    更改动态类型
  1122. #   -self.index=index       选择动态必须传递值
  1123. #   -self.new_spr_xy        执行排序 可乱序
  1124. #   -self.clear             建立新位图必要
  1125. #————————————————————————————————————————
  1126. class Dynamic_Character
  1127.   #———————————————————————————————————————
  1128.   #初始化数据
  1129.   #———————————————————————————————————————
  1130.   def initialize(x, y, z, viewport)
  1131.     #基本坐标
  1132.     @x = x ; @y = y ; @z = z
  1133.     #显示端口
  1134.     @viewport = viewport
  1135.     #生成精灵
  1136.     @sprs = []
  1137.     #实际精灵
  1138.     @sprs_true = []
  1139.     #记录矩形坐标
  1140.     @xa = [] ; @ya = []
  1141.     #记录精灵坐标
  1142.     @sx = [] ; @sy = []
  1143.     #是否使用动态行走图
  1144.     @type = :W
  1145.     #是否选中角色才动态
  1146.     @one = true
  1147.     #当前选项
  1148.     @index = 0
  1149.     #初始显示坐标
  1150.     #cx:0>右脚 1>并脚 2>左脚
  1151.     #cy:0>正面 1>左面 2>右面 3>背面
  1152.     @cx = 1 ; @cy = 0
  1153.     #行走图坐标数据(动作数据,循环以下动作显示)
  1154.     @wa = [0,1,1,2] ; @ha = [0,1,3,2]
  1155.     #动作更新速度(帧)
  1156.     @speed = 25
  1157.     #速度计时器
  1158.     @dcs = 0
  1159.     #数据计时器
  1160.     @dcx = 0
  1161.     @dcy = 0
  1162.   end
  1163.   #———————————————————————————————————————
  1164.   #绘制行走图
  1165.   #———————————————————————————————————————
  1166.   def draw_character(x, y, actor, index)
  1167.     #实际坐标
  1168.     x = x + @x ; y = y + @y
  1169.     #图像名 没有的话返回
  1170.     character_name = actor.character_name
  1171.     #没有图像
  1172.     return unless character_name
  1173.     #生成独立精灵
  1174.     @sprs[index] ||= Sprite.new(@viewport)
  1175.     #取得位图
  1176.     bitmap = bit("Graphics/Characters/"+character_name)
  1177.     @sprs[index].bitmap = bitmap
  1178.     #标准行走图宽高
  1179.     sign = character_name[/^[\!\$]./]
  1180.     if sign && sign.include?(')
  1181.       cw = bitmap.width / 3
  1182.       ch = bitmap.height / 4
  1183.     else
  1184.       cw = bitmap.width / 12
  1185.       ch = bitmap.height / 8
  1186.     end
  1187.     #索引角色种类
  1188.     n = actor.character_index
  1189.     #角色种类x,y @wi:显示第几横 @hi:显示第几列
  1190.     zx = (n%4*3)*cw
  1191.     zy = (n/4*4)*ch
  1192.     #更新精灵坐标
  1193.     @sprs[index].x = @sx[index] = x - cw / 2
  1194.     @sprs[index].y = @sy[index] = y - ch
  1195.     @sprs[index].z = @z
  1196.     #记录矩形坐标
  1197.     @xa[index] = zx ; @ya[index] = zy
  1198.     #显示坐标
  1199.     zx = zx+@cx*cw ; zy = zy+@cy*ch
  1200.     #位图矩形
  1201.     src_rect = Rect.new(zx, zy, cw, ch)
  1202.     @sprs[index].src_rect = src_rect
  1203.     #实际存在的精灵
  1204.     @sprs_true = @sprs.compact
  1205.   end
  1206.   #———————————————————————————————————————
  1207.   #位图资源
  1208.   #———————————————————————————————————————
  1209.   def bit(f)
  1210.     @bit ||= {}
  1211.     unless @bit[f] && !@bit[f].disposed?
  1212.     @bit[f] = Bitmap.new(f) ; end ; @bit[f]
  1213.   end
  1214.   #———————————————————————————————————————
  1215.   #选中角色动态开关设置
  1216.   #———————————————————————————————————————
  1217.   def one=(tf)
  1218.     @one = tf
  1219.   end
  1220.   #———————————————————————————————————————
  1221.   #选项更新(选中角色动态必须传递选项位置)
  1222.   #———————————————————————————————————————
  1223.   def index=(index)
  1224.     #指定的动态角色项
  1225.     @index = index
  1226.     #姿势矫正
  1227.     mrc
  1228.   end
  1229.   #———————————————————————————————————————
  1230.   #姿势矫正
  1231.   #———————————————————————————————————————
  1232.   def mrc(cx=1, cy=0)
  1233.     #更改显示坐标
  1234.     @cx = cx ; @cy = cy
  1235.     #更新位图
  1236.     update_src
  1237.   end
  1238.   #———————————————————————————————————————
  1239.   #更改显示类型
  1240.   #———————————————————————————————————————
  1241.   def type=(t, cx=1, cy=0)
  1242.     #更改显示类型
  1243.     @type = t
  1244.     #静态类型的话强制更新到设定坐标
  1245.     mrc(cx, cy) unless @type
  1246.   end
  1247.   #———————————————————————————————————————
  1248.   #精灵是否可见
  1249.   #———————————————————————————————————————
  1250.   def visible(index, tf)
  1251.     #获取精灵
  1252.     spr = @sprs[index]
  1253.     #没有精灵
  1254.     return unless spr
  1255.     spr.visible = tf
  1256.   end
  1257.   #———————————————————————————————————————
  1258.   #精灵继位排序法
  1259.   #———————————————————————————————————————
  1260.   def new_spr_xy
  1261.     @sprs_true.each_index {|i|
  1262.     #获取精灵
  1263.     spr = @sprs_true[i]
  1264.     #开始排位
  1265.     spr.x = @sx[i]
  1266.     spr.y = @sy[i]}
  1267.   end
  1268.   #———————————————————————————————————————
  1269.   #精灵原点坐标(列数情况(t>开头列 h>项目高 oy>ox)
  1270.   #———————————————————————————————————————
  1271.   def oy=(y)
  1272.     @sprs_true.each {|spr| spr.oy = y}
  1273.   end
  1274.   def ox=(x)
  1275.     @sprs_true.each {|spr| spr.ox = x}
  1276.   end
  1277.   def oy2(top, h)
  1278.     @sprs_true.each {|spr| spr.oy = top*h}
  1279.   end
  1280.   def ox2(top, w)
  1281.     @sprs_true.each {|spr| spr.ox = top*w}
  1282.   end
  1283.   #———————————————————————————————————————
  1284.   #主更新
  1285.   #———————————————————————————————————————
  1286.   def update
  1287.     #数据更新
  1288.     update_data
  1289.     #精灵更新(*预留)
  1290.     #@sprs_true.each {|spr| spr.update}
  1291.   end
  1292.   #———————————————————————————————————————
  1293.   #更新位图矩形(全体)
  1294.   #———————————————————————————————————————
  1295.   def update_src
  1296.     @sprs.each_index {|i|
  1297.     #获取精灵
  1298.     spr = @sprs[i]
  1299.     #没有精灵
  1300.     next unless spr
  1301.     #获取矩形
  1302.     src = spr.src_rect
  1303.     #更新矩形x,y
  1304.     spr.src_rect.x = @xa[i]+src.width*@cx
  1305.     spr.src_rect.y = @ya[i]+src.height*@cy }
  1306.   end
  1307.   #———————————————————————————————————————
  1308.   #更新位图矩形(指定)
  1309.   #———————————————————————————————————————
  1310.   def update_src2(i)
  1311.     #获取精灵
  1312.     spr = @sprs[i]
  1313.     #没有精灵
  1314.     return unless spr
  1315.     #获取矩形
  1316.     src = spr.src_rect
  1317.     #更新矩形x,y
  1318.     spr.src_rect.x = @xa[i]+src.width*@cx
  1319.     spr.src_rect.y = @ya[i]+src.height*@cy
  1320.   end
  1321.   #———————————————————————————————————————
  1322.   #计时器及显示坐标更新
  1323.   #———————————————————————————————————————
  1324.   def update_data
  1325.     if @type
  1326.       @dcs += 1
  1327.       if @dcs == @speed
  1328.         case @type
  1329.         when :W
  1330.           @dcx += 1
  1331.           @dcx = @dcx < @wa.size ? @dcx : 0
  1332.           @cx = @wa[@dcx]
  1333.         when :H
  1334.           @dcy += 1
  1335.           @dcy = @dcy < @ha.size ? @dcy : 0
  1336.           @cy = @ha[@dcy]
  1337.         when :WH
  1338.           @dcx += 1 ; @dcy += 1
  1339.           @dcx = @dcx < @wa.size ? @dcx : 0
  1340.           @dcy = @dcy < @ha.size ? @dcy : 0
  1341.           @cx = @wa[@dcx] ; @cy = @ha[@dcy]
  1342.         end
  1343.         @one ? update_src2(@index) : update_src
  1344.         @dcs = 0
  1345.       end
  1346.     end
  1347.   end
  1348.   #———————————————————————————————————————
  1349.   #指定释放
  1350.   #———————————————————————————————————————
  1351.   def dispose_index(index,index_nil=false)
  1352.     #获取精灵
  1353.     spr = @sprs[index]
  1354.     #没有精灵
  1355.     return unless spr
  1356.     #释放精灵
  1357.     spr.dispose
  1358.     #是否占位(占位处理)
  1359.     if index_nil ; @sprs[index] = nil
  1360.     @sprs_true = @sprs.compact ; return ; end
  1361.     #删除精灵数据
  1362.     @sprs.delete_at(index)
  1363.     @xa.delete_at(index)
  1364.     @ya.delete_at(index)
  1365.     #实际存在的精灵
  1366.     @sprs_true = @sprs.compact
  1367.   end
  1368.   #———————————————————————————————————————
  1369.   #清除位图
  1370.   #———————————————————————————————————————
  1371.   def clear
  1372.     @sprs_true.each {|spr| spr.bitmap.dispose}
  1373.   end
  1374.   #———————————————————————————————————————
  1375.   #全部释放
  1376.   #———————————————————————————————————————
  1377.   def dispose
  1378.     @viewport.dispose if @viewport
  1379.     @sprs_true.each {|spr| spr.bitmap.dispose ; spr.dispose}
  1380.   end
  1381. end
  1382. #————————————————————————————————————————
  1383. # ●位图的追加绘制方法 By.Clov
  1384. #  *渐透明描绘以及RGSS1用gradient_fill_rect
  1385. #————————————————————————————————————————
  1386. class Bitmap
  1387.   #———————————————————————————————————————
  1388.   # ● 渐透明描绘(宽)
  1389.   #———————————————————————————————————————
  1390.   def back_w(x,y,w,h,bl=0.3,c=Color.new(0,200,230,128))
  1391.     r = c.red ; g = c.green ; b = c.blue ; o = c.alpha
  1392.     l = (w*bl).round
  1393.     all = [l,w-l*2,l]
  1394.     all.each_index {|i| ; w2 = all[i]
  1395.     case i
  1396.     when 0 ; x2 = 0 ; o1 = 0 ; o2 = o
  1397.     when 1 ; x2 = all[0] ; o1 = o2 = o
  1398.     when 2 ; x2 = all[0] + all[1] ; o1 = o ; o2 = 0 ; end
  1399.     c1 = Color.new(r,g,b,o1) ; c2 = Color.new(r,g,b,o2)
  1400.     gradient_fill_rect(x+x2, y, w2, h, c1, c2) if w2 > 0 }
  1401.   end
  1402.   #———————————————————————————————————————
  1403.   # ● 渐透明描绘(高)
  1404.   #———————————————————————————————————————
  1405.   def back_h(x,y,w,h,bl=0.3,c=Color.new(0,200,230,128))
  1406.     r = c.red ; g = c.green ; b = c.blue ; o = c.alpha
  1407.     l = (h*bl).round
  1408.     all = [l,h-l*2,l]
  1409.     all.each_index {|i| ; h2 = all[i]
  1410.     case i
  1411.     when 0 ; y2 = 0 ; o1 = 0 ; o2 = o
  1412.     when 1 ; y2 = all[0] ; o1 = o2 = o
  1413.     when 2 ; y2 = all[0] + all[1] ; o1 = o ; o2 = 0 ; end
  1414.     c1 = Color.new(r,g,b,o1) ; c2 = Color.new(r,g,b,o2)
  1415.     gradient_fill_rect(x, y+y2, w, h2, c1, c2, true) if h2 > 0 }
  1416.   end
  1417. end
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-7 12:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表