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

Project1

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

[已经解决] 这个脚本怎么改才能显示钱数

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
57
在线时间
161 小时
注册时间
2011-2-2
帖子
469
跳转到指定楼层
1
发表于 2011-2-7 20:30:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  1. #==============================================================================
  2. # 分类物品的命令窗口
  3. #==============================================================================
  4. class Window_ItemCommand < Window_Selectable
  5. #———— 初始化 ————
  6.   def initialize
  7.     super(453, 190, 142, 192)
  8.     self.contents = Bitmap.new(width - 32, height - 32)
  9.     @item_max = 5
  10.     @commands = ["药物类", "武器类", "防具类", "装饰类", "特殊类"]
  11.     refresh
  12.     self.index = 0
  13.   end   
  14. #———— 刷新 ————
  15.   def refresh  
  16.     self.contents.clear
  17.     for i in 0...@item_max
  18.     draw_item(i, normal_color)
  19.     end
  20.   end
  21. #—— 描绘项目 ——| index:编号,color:颜色——————
  22.   def draw_item(index, color)
  23.     self.contents.font.color = color
  24.     y = index * 32
  25.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  26.   end
  27. #—— 帮助部分更新 ————
  28.   def update_help
  29.     @help_window.set_text(@commands[self.index])
  30.   end   
  31. end
  32. #==============================================================================
  33. # 物品清单窗口
  34. #==============================================================================
  35. class Window_ItemList < Window_Selectable
  36. #———— 初始化 ————
  37.   def initialize
  38.     super(30, 20, 378, 362)
  39. #   @column_max = 2
  40.     refresh
  41.     self.index = 0
  42.   end
  43. #—— 取得现在选择的物品 ——
  44.   def item
  45.     return @data[self.index]
  46.   end
  47. #—— 刷新 ———
  48.   def refresh
  49.     if self.contents != nil
  50.       self.contents.dispose
  51.       self.contents = nil
  52.     end
  53.     @data = []
  54.   end
  55. #—— 设置不同类别的物品 ———
  56.   def set_item(command)
  57.     refresh
  58.     #—— 根据现在的选项决定物品 ——
  59.     case command  
  60.     when 0            #药品类
  61.       for i in 1...$data_items.size
  62.         if ($data_items[i].type == "药物" and $game_party.item_number(i) > 0)
  63.           @data.push($data_items[i])
  64.         end
  65.       end
  66.     when 1            #武器类
  67.       for i in 1...$data_weapons.size
  68.         if $game_party.weapon_number(i) > 0
  69.           @data.push($data_weapons[i])
  70.         end
  71.       end
  72.     when 2            #防具类
  73.       for i in 1...$data_armors.size
  74.         if $data_armors[i].kind == 0 and $game_party.armor_number(i) > 0
  75.           @data.push($data_armors[i])
  76.         end
  77.       end
  78.       for i in 1...$data_armors.size
  79.         if $data_armors[i].kind == 1 and $game_party.armor_number(i) > 0
  80.           @data.push($data_armors[i])
  81.         end
  82.       end
  83.        for i in 1...$data_armors.size
  84.         if $data_armors[i].kind == 2 and $game_party.armor_number(i) > 0
  85.           @data.push($data_armors[i])
  86.         end
  87.       end
  88.     when 3            #装饰类
  89.       for i in 1...$data_armors.size
  90.         if $data_armors[i].kind == 3 and $game_party.armor_number(i) > 0
  91.           @data.push($data_armors[i])
  92.         end
  93.       end
  94.     when 4            #特殊类
  95.       for i in 1...$data_items.size
  96.         if ($data_items[i].type == "特殊" and $game_party.item_number(i) > 0)
  97.           @data.push($data_items[i])
  98.         end
  99.       end
  100.     end
  101.     @item_max = @data.size  
  102.     if @item_max > 0
  103.       self.contents = Bitmap.new(width - 32, row_max * 32)
  104.       self.contents.clear
  105.       for i in 0...@item_max
  106.         draw_item(i)
  107.       end
  108.     end
  109.   end
  110. #——— 单类物品的个数 ————
  111.   def item_number
  112.     return @item_max
  113.   end
  114. #——— 项目内容的描画 ————
  115.   def draw_item(index)
  116.     item = @data[index]  
  117.     #—— 取得具体物品数量 ——
  118.     case item   
  119.     when RPG::Item
  120.       number = $game_party.item_number(item.id)
  121.     when RPG::Weapon
  122.       number = $game_party.weapon_number(item.id)
  123.     when RPG::Armor
  124.       number = $game_party.armor_number(item.id)
  125.     end
  126.     #—— 给出物品的颜色 ——
  127.     if item.is_a?(RPG::Item)
  128.       if $game_party.item_can_use?(item.id)
  129.         self.contents.font.color = normal_color
  130.       else
  131.         self.contents.font.color = disabled_color
  132.       end
  133.     else
  134.       self.contents.font.color = normal_color
  135.     end
  136.    
  137.     #—— 描绘物体图标、物体名、数量 ——
  138. #   x = 4 + index % 2 * 173
  139. #   y = index / 2 * 32
  140.     x = 4
  141.     y = index*32
  142.     bitmap = RPG::Cache.icon(item.icon_name)
  143.     opacity = self.contents.font.color == normal_color ? 255 : 128
  144.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  145.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  146.     self.contents.draw_text(x + 300, y, 16, 32, "×", 1)
  147.     self.contents.draw_text(x + 314, y, 24, 32, number.to_s, 2)
  148.   end
  149. #——— 更新帮助窗口 ————
  150.   def update_help
  151.     @help_window.set_text(make_description(self.item))
  152.   end
  153. end
  154. #############################################################################
  155. #############################################################################
  156. #==============================================================================
  157. # ■ Scene_Item
  158. #------------------------------------------------------------------------------
  159. #  处理物品画面的类。
  160. #==============================================================================
  161. #############################################################################
  162. #############################################################################
  163. class Scene_Item
  164. #——— 主处理 ————
  165.   def main
  166.     cmd = Window_Command_New.new($game_party.actors.size)
  167.     cmd.index = 1
  168.     cmd.active = false
  169.    
  170.     # 右边命令窗口
  171.     @itemcommand_window = Window_ItemCommand.new
  172.     @itemcommand_window.opacity = HS::OPACITY
  173.     @itemcommand_window.y = 672

  174.     @item_command_index = @itemcommand_window.index
  175.     # 物品窗口
  176.     @itemlist_window = Window_ItemList.new
  177.     @itemlist_window.opacity = HS::OPACITY
  178.     @itemlist_window.active = false
  179.     @itemlist_window.set_item(@item_command_index)
  180.     @itemlist_window.x = -378
  181.     # 帮助窗口
  182.     @item_help_window = Window_Help_New.new
  183.     @item_help_window.x = -580
  184.     @item_help_window.y = 396
  185.     @item_help_window.opacity = HS::OPACITY

  186.     # 关联帮助窗口
  187.     @itemcommand_window.help_window = @item_help_window
  188.     @itemlist_window.help_window = @item_help_window
  189.     # 目标窗口
  190.     @item_target_window = Window_Target.new
  191.     @item_target_window.y = 480
  192.     @item_target_window.opacity = HS::OPACITY
  193.     @item_target_window.visible = false
  194.     @item_target_window.active = false
  195.     # 目标装备窗口
  196.     @item_target_window_equip = Window_Target_Equip.new
  197.     @item_target_window_equip.y = 480
  198.     @item_target_window_equip.opacity = HS::OPACITY
  199.     @item_target_window_equip.visible = false
  200.     @item_target_window_equip.active = false
  201.     #—— 主循环 ——
  202.     Graphics.transition
  203.     # 窗口的滑动
  204.     for i in 1..8
  205.       @item_help_window.x += 76
  206.       @itemcommand_window.y -= 60
  207.       @itemlist_window.x += 51
  208.       if i == 8
  209.         @item_help_window.x = 30
  210.         @itemcommand_window.y = 190
  211.         @itemlist_window.x = 30
  212.       end
  213.       Graphics.update
  214.     end

  215.     loop do
  216.       Graphics.update
  217.       Input.update

  218.       # 更新item
  219.       update_item_scene
  220.       if $scene != self
  221.         break
  222.       end
  223.     end
  224.     #—— 释放窗口 ——
  225.    
  226.     # 窗口的滑动
  227.     for i in 1..9
  228.       @item_help_window.x -= 76
  229.       @itemcommand_window.y += 60
  230.       @itemlist_window.x -= 51
  231.       Graphics.update
  232.     end
  233.    
  234.     Graphics.freeze
  235.     cmd.dispose
  236.     @itemcommand_window.dispose
  237.     @itemlist_window.dispose
  238.     @item_help_window.dispose
  239.     @item_target_window.dispose
  240.     @item_target_window_equip.dispose
  241.   end

  242.   #—— update的定义 ——
  243.   def update_item_scene
  244.     @itemcommand_window.update
  245.     @itemlist_window.update
  246.     @item_help_window.update
  247.     @item_target_window.update
  248.     @item_target_window_equip.update
  249.    
  250.     if @item_command_index != @itemcommand_window.index
  251.       @item_command_index = @itemcommand_window.index
  252.       @itemlist_window.set_item(@item_command_index)
  253.     end
  254.    
  255.     #—— 当某窗体在active的时候,更新之 ——
  256.     if @itemcommand_window.active
  257.       item_update_itemcommand
  258.       return
  259.     end
  260.     if @itemlist_window.active
  261.       item_update_itemlist
  262.       return
  263.     end
  264.     if @item_target_window.active
  265.       item_update_target
  266.       return
  267.     end
  268.     if @item_target_window_equip.active
  269.       item_update_target_equip
  270.       return
  271.     end
  272.   end  # update的

  273. #————具体更新定义————
  274.   def item_update_itemcommand
  275.   
  276.     if Input.trigger?(Input::B)
  277.       # 演奏取消 SE
  278.       $game_system.se_play($data_system.cancel_se)
  279.       # 切换到菜单画面
  280.       $scene = Scene_Menu.new(1)
  281.       return
  282.     end
  283.    
  284.     if Input.trigger?(Input::C)
  285.       if @itemlist_window.item_number == 0
  286.         $game_system.se_play($data_system.buzzer_se)
  287.         return
  288.       end
  289.       $game_system.se_play($data_system.decision_se)
  290.       @itemcommand_window.active = false
  291.       @itemlist_window.active = true
  292.       @itemlist_window.index = 0
  293.       return
  294.     end
  295.   end

  296. #————具体更新定义————
  297.   def item_update_itemlist
  298.     if Input.trigger?(Input::B)
  299.       $game_system.se_play($data_system.cancel_se)
  300.       @itemcommand_window.active = true
  301.       @itemlist_window.active = false
  302.       @itemlist_window.index = 0
  303.       @itemcommand_window.index = @item_command_index
  304.       return
  305.     end
  306.    
  307.     if Input.trigger?(Input::C)
  308.       @item = @itemlist_window.item
  309.       if @item.is_a?(RPG::Item)
  310.         unless $game_party.item_can_use?(@item.id)
  311.           $game_system.se_play($data_system.buzzer_se)
  312.           return
  313.         end   
  314.         $game_system.se_play($data_system.decision_se)
  315.         if @item.scope >= 3
  316.           @itemlist_window.active = false
  317.           # 先打开目标窗口的显示,才开始滑动
  318.           @item_target_window.visible = true
  319.           @item_target_window.active = true
  320.           for i in 1..8
  321.             @item_target_window.y -= 39
  322.             if i==8
  323.               @item_target_window.y = 164
  324.             end
  325.             Graphics.update
  326.           end
  327.           if @item.scope == 4 || @item.scope == 6
  328.             @item_target_window.index = -1
  329.           else
  330.             @item_target_window.index = 0
  331.           end
  332.         else
  333.           if @item.common_event_id > 0
  334.             $game_temp.common_event_id = @item.common_event_id
  335.             $game_system.se_play(@item.menu_se)
  336.             if @item.consumable  
  337.               $game_party.lose_item(@item.id, 1)
  338.               @itemlist_window.draw_item(@itemlist_window.index)  
  339.             end
  340.             $scene = Scene_Map.new
  341.             return
  342.           end
  343.         end
  344.         return
  345.       else
  346.         $game_system.se_play($data_system.decision_se)
  347.         @itemlist_window.active = false
  348.         @item_target_window_equip.set_item(@item)
  349.         @item_target_window_equip.visible = true
  350.         @item_target_window_equip.active = true
  351.         for i in 1..8
  352.           @item_target_window_equip.y -= 39
  353.           if i==8
  354.             @item_target_window_equip.y = 164
  355.           end
  356.           Graphics.update
  357.         end
  358.         @item_target_window_equip.index = 0
  359.         return
  360.       end
  361.         
  362.         
  363.         
  364.         
  365.         
  366.     end
  367.   end

  368.   def item_update_target_equip
  369.     if Input.trigger?(Input::B)
  370.       $game_system.se_play($data_system.cancel_se)
  371.       @itemlist_window.active = true
  372.       # 目标窗口滑动,滑动结束后才关闭显示
  373.       for i in 1..9
  374.         @item_target_window_equip.y += 39
  375.         Graphics.update
  376.       end
  377.       @item_target_window_equip.visible = false
  378.       @item_target_window_equip.active = false
  379.       @itemlist_window.set_item(@item_command_index)
  380.       return
  381.     end
  382.     if Input.trigger?(Input::C)
  383.       target_actor = $game_party.actors[@item_target_window_equip.index]
  384.       if target_actor.equippable?(@item) and $game_party.item_can_equip?(target_actor,@item)
  385.         # 演奏装备 SE
  386.         $game_system.se_play($data_system.equip_se)
  387.         if @item.is_a?(RPG::Weapon)
  388.           equip_position = 0
  389.         elsif @item.kind == 0
  390.           equip_position = 1
  391.         elsif @item.kind == 1
  392.           equip_position = 2
  393.         elsif @item.kind == 2
  394.           equip_position = 3
  395.         elsif @item.kind == 3
  396.           equip_position = 4
  397.         end
  398.         
  399.         # 固定装备的情况下
  400.         if target_actor.equip_fix?(equip_position)
  401.           # 演奏冻结 SE
  402.           $game_system.se_play($data_system.buzzer_se)
  403.           return
  404.         end
  405.         
  406.         target_actor.equip(equip_position,@item.id)
  407.         
  408.         @itemlist_window.active = true
  409.         # 目标窗口滑动,滑动结束后才关闭显示
  410.         for i in 1..9
  411.           @item_target_window_equip.y += 39
  412.           Graphics.update
  413.         end
  414.         @item_target_window_equip.visible = false
  415.         @item_target_window_equip.active = false

  416.         @itemlist_window.draw_item(@itemlist_window.index)
  417.         @itemlist_window.set_item(@item_command_index)

  418.       else
  419.         # 演奏冻结 SE
  420.         $game_system.se_play($data_system.buzzer_se)  
  421.       end
  422.       

  423.       
  424.     end
  425.   
  426.   end
  427.   
  428. #———— 更新target窗口————
  429.   def item_update_target
  430.     if Input.trigger?(Input::B)
  431.       $game_system.se_play($data_system.cancel_se)
  432.       unless $game_party.item_can_use?(@item.id)
  433.         @itemlist_window.refresh
  434.       end
  435.       @itemlist_window.active = true
  436.       # 目标窗口滑动,滑动结束后才关闭显示
  437.       for i in 1..9
  438.         @item_target_window.y += 39
  439.         Graphics.update
  440.       end
  441.       @item_target_window.visible = false
  442.       @item_target_window.active = false
  443.       @itemlist_window.set_item(@item_command_index)
  444.       return
  445.     end
  446.     if Input.trigger?(Input::C)
  447.       if $game_party.item_number(@item.id) == 0
  448.         $game_system.se_play($data_system.buzzer_se)
  449.         return
  450.       end
  451.       if @item_target_window.index == -1
  452.         used = false
  453.         for i in $game_party.actors
  454.           used |= i.item_effect(@item)
  455.         end
  456.       end
  457.       if @item_target_window.index >= 0
  458.         target = $game_party.actors[@item_target_window.index]
  459.         used = target.item_effect(@item)
  460.       end
  461.       
  462.       if used
  463.         $game_system.se_play(@item.menu_se)
  464.         if @item.consumable
  465.           $game_party.lose_item(@item.id, 1)
  466.           @itemlist_window.draw_item(@itemlist_window.index)
  467.           @itemlist_window.set_item(@item_command_index)
  468.         end
  469.         @item_target_window.refresh
  470.         if $game_party.all_dead?
  471.           $scene = Scene_Gameover.new
  472.           return
  473.         end
  474.         
  475.         if @item.common_event_id > 0
  476.           $game_temp.common_event_id = @item.common_event_id
  477.           $scene = Scene_Map.new
  478.           return
  479.         end  
  480.       end
  481.    
  482.       unless used
  483.         $game_system.se_play($data_system.buzzer_se)
  484.       end
  485.     return
  486.     end
  487.   end   
  488. end
复制代码
我又回来打酱油了

Lv1.梦旅人

赤瞳

梦石
0
星屑
50
在线时间
132 小时
注册时间
2010-11-28
帖子
515
2
发表于 2011-2-7 20:35:11 | 只看该作者
在显示这个窗口的那个界面里,
参考Scene_Menu里的句子,
加上显示金钱窗口的部分就好了嘛~

点评

不知道怎么写坐标  发表于 2011-2-7 20:43
回复 支持 反对

使用道具 举报

Lv1.梦旅人

神之首

梦石
0
星屑
65
在线时间
200 小时
注册时间
2011-2-7
帖子
220
3
发表于 2011-2-7 20:35:53 | 只看该作者
本帖最后由 陆娘 于 2011-2-7 20:37 编辑

如果你是要显示窗口样式的就显示
在处理那里
window_gold
释放窗口添加
@gold_window.dispose
在刷新画面那里然后刷新这个窗口
@gold_window.update
如果是想要直接显示他的文字就
  cx = contents.text_size($data_system.words.gold).width
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)

点评

看你发的脚本我更加晕。  发表于 2011-2-7 20:52
有点晕啊  发表于 2011-2-7 20:43
回复 支持 反对

使用道具 举报

Lv2.观梦者

虚構歪曲

梦石
0
星屑
334
在线时间
1196 小时
注册时间
2010-12-18
帖子
3928

贵宾

4
发表于 2011-2-7 20:45:07 | 只看该作者
添加显示金钱窗口。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
57
在线时间
161 小时
注册时间
2011-2-2
帖子
469
5
 楼主| 发表于 2011-2-7 20:46:55 | 只看该作者
弄不清坐标

点评

???什么意思啊  发表于 2011-2-7 22:13
嗯,君最好把你写进金钱脚本的那个脚本帖出来~  发表于 2011-2-7 21:24
xxx.x = xxx.y =  发表于 2011-2-7 20:54
回复 支持 反对

使用道具 举报

Lv1.梦旅人

赤瞳

梦石
0
星屑
50
在线时间
132 小时
注册时间
2010-11-28
帖子
515
6
发表于 2011-2-7 21:05:09 | 只看该作者
@nnn.x = xxx
这样的格式


银·乌尔于2011-2-7 21:23补充以下内容:
我得知道你脚本是怎么写的...

点评

弄了半天也没弄清坐标在哪  发表于 2011-2-7 21:10
回复 支持 反对

使用道具 举报

Lv3.寻梦者

小柯的徒弟

梦石
0
星屑
1500
在线时间
1157 小时
注册时间
2008-5-24
帖子
3085

贵宾

7
发表于 2011-2-7 22:32:41 | 只看该作者

点评

太感谢了  发表于 2011-2-7 23:43
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
57
在线时间
161 小时
注册时间
2011-2-2
帖子
469
8
 楼主| 发表于 2011-2-7 22:51:29 | 只看该作者
本帖最后由 坚强的羁绊 于 2011-2-7 22:53 编辑

这该怎么办?和说明重叠了

222.png (3.42 KB, 下载次数: 1)

222.png

点评

怎么移啊,已经没有位置了  发表于 2011-2-7 23:12
把窗口移走...  发表于 2011-2-7 23:02
我又回来打酱油了
回复 支持 反对

使用道具 举报

Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9542
在线时间
2756 小时
注册时间
2008-9-5
帖子
3544

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

9
发表于 2011-2-7 23:19:26 | 只看该作者
本帖最后由 cinderelmini 于 2011-2-7 23:19 编辑

好吧,在羁绊君写@gold_window = Window_Gold.new
这个句子的下面一行
写上: @gold_window.y = 64
就避开说明窗口了~

点评

还是不行哎  发表于 2011-2-7 23:47

评分

参与人数 1星屑 +300 收起 理由
「旅」 + 300 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者

虚構歪曲

梦石
0
星屑
334
在线时间
1196 小时
注册时间
2010-12-18
帖子
3928

贵宾

10
发表于 2011-2-8 11:08:16 | 只看该作者
本帖最后由 忧雪の伤 于 2011-2-8 12:53 编辑
坚强的羁绊 发表于 2011-2-7 22:51
这该怎么办?和说明重叠了


没有位置了可以缩小其他窗口的大小。






这样的话依然会遮住哦,窗口之间。



默认帮助窗口第14行。
  1. if $scene.is_a?(Scene_Item)
  2.   self.width = X
  3. end
复制代码

点评

对。  发表于 2011-2-9 11:56
直接加上马?  发表于 2011-2-8 23:41
该怎样改啊?  发表于 2011-2-8 13:48
加一个窗口需要改变很多排版。  发表于 2011-2-8 13:46
我不知道你怎么改的……  发表于 2011-2-8 13:45

评分

参与人数 1星屑 +300 收起 理由
「旅」 + 300 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2025-7-21 07:38

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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