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

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: 玄月
打印 上一主题 下一主题

如何增加一个分类?

 关闭 [复制链接]

Lv3.寻梦者

小柯的徒弟

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

贵宾

11
发表于 2008-8-18 08:07:09 | 只看该作者
#把171行前的内容,也就是"#——— 单类物品的个数 ————"这行字以上全换成以下内容
#==============================================================================
# ■ Window_ItemTitle
#------------------------------------------------------------------------------
#  选择类别
#==============================================================================
class Window_ItemTitle < Window_Base  #"使用物品"四个字的窗口
def initialize
   super(0, 0, 160, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.clear
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
end
end
#==============================================================================
# ■ Window_ItemCommand
#------------------------------------------------------------------------------
#  选择类别
#==============================================================================
class Window_ItemCommand < Window_Selectable

#———— 初始化 ————
def initialize
   super(0, 64, 160, 260)
   self.contents = Bitmap.new(width - 32, height - 32)
   @item_max = 7
   
   #——各类物品的判别标志————
   #——药物:分散度0 ——————
   #——食物:分散度1 ——————
   #——书报杂志:分散度2 ——————
   #——装备:根据原本类push———
   #——曲谱:分散度3 ——————
   #——特殊:分散度4 ——————
   @commands = ["药物类", "食物类", "书报杂志", "各种装备", "曲谱乐谱", "特殊道具","好人卡"]
   refresh
   self.index = 0
end

#———— 刷新 ————
def refresh  
   self.contents.clear
   for i in 0...@item_max
   draw_item(i, normal_color)
   end
end

#—— 描绘项目 ——| index:编号,color:颜色——————
def draw_item(index, color)
   self.contents.font.color = color
   y = index * 32
   self.contents.draw_text(4, y, 128, 32, @commands[index])
end
#—— 帮助部分更新 ————
def update_help
   case self.index
   when 0
     @text = @commands[0]
   when 1
     @text = @commands[1]
   when 2
     @text = @commands[2]
   when 3
     @text = @commands[3]
   when 4
     @text = @commands[4]
   when 5
     @text = @commands[5]
   when 6
     @text = @commands[6]
   end
   @help_window.set_text(@text)
end  
end  # Window_ItemCommand的



#==============================================================================
# ■ Window_ItemList
#------------------------------------------------------------------------------
#  物品窗口。 item.variance是物品的"分散度",借来用做分类
#==============================================================================

class Window_ItemList < Window_Selectable

#———— 初始化 ————
def initialize
   super(160, 0, 480, 416)
   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 = []
end


#—— 设置不同类别的物品 ———
def set_item(command)
   refresh
   
   #—— 根据现在的选项决定物品 ——
   case command  
   when 0            #药品,特点是分散度为0
     for i in 1...$data_items.size
       if ($data_items.variance == 0 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
   when 1            #食物类,特点是分散度为1  
     for i in 1...$data_items.size
       if ($data_items.variance == 1 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
   when 2            #杂货类,特点是分散度为2
     for i in 1...$data_items.size
       if ($data_items.variance == 2 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
   when 3            #各种装备:根据原本类push
     for i in 1...$data_weapons.size
       if $game_party.weapon_number(i) > 0
         @data.push($data_weapons)
       end
     end
     for i in 1...$data_armors.size
       if $game_party.armor_number(i) > 0
         @data.push($data_armors)
       end
     end
   when 4            #各类曲谱:特点是分散度为3
     for i in 1...$data_items.size
       if ($data_items.variance == 3 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
   when 5            #特殊物品:特点是分散度为4
     for i in 1...$data_items.size
       if ($data_items.variance == 4 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
   when 6
     for i in 1...$data_items.size
       if ($data_items.variance == 5 and $game_party.item_number(i) > 0)
         @data.push($data_items)
       end
     end
   end

   @item_max = @data.size  
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, row_max * 32)
     self.contents.clear
     for i in 0...@item_max
       draw_item(i)
     end
   end
end
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-25 12:14

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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