赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 409 |
最后登录 | 2015-11-10 |
在线时间 | 19 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 19 小时
- 注册时间
- 2014-3-1
- 帖子
- 23
|
3楼
楼主 |
发表于 2014-3-8 22:28:38
|
只看该作者
- class Window_EnemyType < Window_HorzCommand
- include Snstar::EnemyList
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(x, y, min_height=48)
- super(x, y)
- @min_height = min_height
- @max_height = window_height
- end
- #--------------------------------------------------------------------------
- # ● 定义窗口宽度
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width
- end
- #--------------------------------------------------------------------------
- # ● 定义栏数
- #--------------------------------------------------------------------------
- def col_max
- return 6
- end
- #--------------------------------------------------------------------------
- # ● 窗口更新
- #--------------------------------------------------------------------------
- def update
- super
- @item_window.category = current_symbol if @item_window
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人类型列表
- #--------------------------------------------------------------------------
- def make_command_list
- add_command(ALL_CATEGORY_TEXT, :all) if INCLUDE_ALL_CATEGORY
- ENEMY_TYPE.each{ |type|
- add_command(type, type.to_sym)
- }
- end
- #--------------------------------------------------------------------------
- # ● 设置敌人列表窗口
- #--------------------------------------------------------------------------
- def item_window=(item_window)
- @item_window = item_window
- update
- end
- #--------------------------------------------------------------------------
- # ● 窗口有效化
- #--------------------------------------------------------------------------
- def activate
- super
- return unless @max_height
- self.height = @max_height
- end
- #--------------------------------------------------------------------------
- # ● 窗口失效
- #--------------------------------------------------------------------------
- def deactivate
- super
- return unless @min_height
- self.height = @min_height
- @item_window.select_last_index
- end
- end
- class Window_EnemyList < Window_ItemList
- include Snstar::EnemyList
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @last_index = {}
- end
- #--------------------------------------------------------------------------
- # ● 选择上次索引
- #--------------------------------------------------------------------------
- def select_last_index
- select(@last_index[@category])
- end
- def select(index)
- super(index)
- @info_window.enemy = @data[@index]
- end
- #--------------------------------------------------------------------------
- # ● 窗口失效
- #--------------------------------------------------------------------------
- def deactivate
- super
- return unless @last_index
- @last_index[@category] = @index # 纪录当前敌人类型的索引
- end
- #--------------------------------------------------------------------------
- # ● 最大栏数
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # ● 生成敌人列表
- #--------------------------------------------------------------------------
- def make_item_list
- @data = []
- @last_index[@category] = 0 if @last_index[@category].nil?
- selected_type = ENEMY_TYPE.index(@category.to_s)
- $data_enemies.each{ |enemy|
- next if enemy.nil?
- next if enemy.name == "" # 名字为空的敌人跳过
- next if enemy.no_list? # 指定不列入的敌人跳过
- if @category == :all or (enemy.list_type == selected_type)
- @data.push(enemy)
- end
- }
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人项目
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y)
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人名称
- #--------------------------------------------------------------------------
- def draw_item_name(item, x, y, enabled = true, width = 172)
- return unless item
- if DRAW_ENEMY_ICON
- draw_icon(item.icon_index, x, y, enabled)
- x += 24
- end
- change_color(normal_color, enabled)
- per = $game_party.enemy_percent(item.id)
- if per >= NAME_DISPLAY_PERC
- text = item.name
- else
- text = NO_DISPLAY_MASK
- end
- draw_text(x, y, width, line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 资讯窗口更新
- #--------------------------------------------------------------------------
- def update_info
-
- end
- #--------------------------------------------------------------------------
- # ● 设置资讯窗口
- #--------------------------------------------------------------------------
- def info_window=(info_window)
- @info_window = info_window
- # call_update_info
- end
-
- end
- class Window_EnemyDetail < Window_Base
- include Snstar::EnemyList
- attr_reader :enemy
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize
- super(160, 48, Graphics.width-160, Graphics.height-48)
- @enemy = nil
- end
- #--------------------------------------------------------------------------
- # ● 设置当前敌人
- #--------------------------------------------------------------------------
- def enemy=(e)
- @enemy = e
- if enemy
- @percentage = $game_party.enemy_percent(e.id) # 获取当前敌人辨识度
- else
- @percentage = 0
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 检查当前辨识度百分比
- #--------------------------------------------------------------------------
- def checkPercent?(per)
- return @percentage >= per
- end
- #--------------------------------------------------------------------------
- # ● 窗口刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- return unless @enemy # 无敌人时返回
- return unless checkPercent?(NAME_DISPLAY_PERC) # 不显示名称时返回
- @partial = false
- draw_enemy_image(0, 0) # 绘制敌人图像
- draw_enemy_name(0, ENEMY_IMAGE_MAX_HEIGHT) # 绘制敌人名称
- #draw_enemy_features(0, ENEMY_IMAGE_MAX_HEIGHT+line_height)
- draw_enemy_percentage(0, ENEMY_IMAGE_MAX_HEIGHT+line_height*5) # 绘制敌人辨识度
- partial_refresh
- x = 0
- y = 192
- e_na = $1.to_s if enemy.note =~ /<note1:\s*(.*?)>/i
- e_nb = $1.to_s if enemy.note =~ /<note2:\s*(.*?)>/i
- e_nc = $1.to_s if enemy.note =~ /<note3:\s*(.*?)>/i
- e_nd = $1.to_s if enemy.note =~ /<note4:\s*(.*?)>/i
- change_color(system_color)
- draw_text(x, y, 500, line_height, "简介:")
- change_color(normal_color)
- draw_text(x+36, y + line_height * 1, 500, line_height, e_na)
- draw_text(x, y + line_height * 2, 500, line_height, e_nb)
- draw_text(x, y + line_height * 3, 500, line_height, e_nc)
- draw_text(x, y + line_height * 4, 500, line_height, e_nd)
- end
- #--------------------------------------------------------------------------
- # ● 窗口半刷新
- #--------------------------------------------------------------------------
- def partial_refresh
- return unless @enemy # 无敌人时返回
- rect = Rect.new(ENEMY_IMAGE_MAX_WIDTH+8, 0,
- contents.width-(ENEMY_IMAGE_MAX_WIDTH+8), contents.height-line_height)
- contents.clear_rect(rect)
- if ENEMY_MORE_INFO && @partial
- Sound.play_cursor
- draw_other_info
- @partial = false
- else
- draw_enemy_hp(ENEMY_IMAGE_MAX_WIDTH+8, 0) # 绘制敌人体力
- draw_enemy_mp(ENEMY_IMAGE_MAX_WIDTH+8, line_height) # 绘制敌人魔力
- 2.upto(7){ |n|
- draw_enemy_param(ENEMY_IMAGE_MAX_WIDTH+8, line_height*n, n) # 绘制敌人能力
- }
- #~ draw_enemy_gold(ENEMY_IMAGE_MAX_WIDTH+8, line_height*8) # 绘制敌人掉落金
- draw_enemy_item(ENEMY_IMAGE_MAX_WIDTH+8, line_height*9) # 绘制敌人掉落物
- @partial = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人特征
- #--------------------------------------------------------------------------
- # def draw_enemy_features(x, y)
- # text = $1.to_s if enemy.note =~ /<intro>((?:[^<]|<[^\/])*)<\/intro>/i
- # change_color(system_color)
- # draw_text(x + 24, y - line_height, text_width(text), line_height, "简介:")
- # change_color(normal_color)
- # draw_text_ex(x + 24, y, text)
- # end
- #--------------------------------------------------------------------------
- # ● 获取敌人特征
- #--------------------------------------------------------------------------
- def get_feature(feature)
- code = feature.code
- id = feature.data_id
- value = feature.value
- return "", 0 unless [11, 31].include?(code)
- if code == 11
- if value < 1.00
- label = FEA_RES_ELE_RATE
- elsif value > 1.00
- label = FEA_WEAK_ELE_RATE
- else
- return "", 0
- end
- element = $data_system.elements[id]
- return_value = element + "×" + " #{(value * 100).truncate}%"
- elsif code == 31
- label = FEA_ATK_ELEMENT
- return_value = $data_system.elements[id]
- end
- return label, return_value
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人图像
- #--------------------------------------------------------------------------
- def draw_enemy_image(x, y)
- image_name = @enemy.list_image # 获取指定图像
- if image_name.nil? # 指定图像为空时
- image = Cache.battler(@enemy.battler_name, @enemy.battler_hue) # 获取战斗图
- else
- hue = ENEMY_HUE_SYNC_DB ? @enemy.battler_hue : 0
- image = Cache.load_bitmap(ENEMY_IMAGE_FOLDER, image_name, hue) # 获取战斗图
- end
-
- ix = (image.width/2-ENEMY_IMAGE_MAX_WIDTH/2).abs # 获取中心点
- # 敌人图像宽度在显示范围外
- if image.width > ENEMY_IMAGE_MAX_WIDTH
- # 居中对齐
- rx = ix
- cx = x
- # 敌人图像宽度在显示范围外
- else
- # 居中对齐
- rx = 0
- cx = ix
- end
- # 敌人图像高度在显示范围外
- if image.height > ENEMY_IMAGE_MAX_HEIGHT
- cy = y
- # 敌人图像高度在显示范围内
- else
- cy = ENEMY_IMAGE_MAX_HEIGHT - image.height - 8 # 向下对齐
- end
- rect = Rect.new(rx, 0, ENEMY_IMAGE_MAX_WIDTH, ENEMY_IMAGE_MAX_HEIGHT)
- contents.blt(cx, cy, image, rect, 255)
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人辨识度
- #--------------------------------------------------------------------------
- def draw_enemy_percentage(x, y)
- width = contents.width
- change_color(system_color)
- text = ENEMY_PERCENT_VOCAB
- draw_text(x, y, text_width(text), line_height, text)
- # 绘制辨识度进度槽
- # draw_gauge(x+96, y, width- 96, @percentage.to_i/100,
- # ENEMY_PERCENT_BASE_COLOR, ENEMY_PERCENT_FILL_COLOR)
- # 绘制百分比
- change_color(normal_color)
- text = "#{@percentage}%"
- draw_text(x+96, y, text_width(text), line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人名称
- #--------------------------------------------------------------------------
- def draw_enemy_name(x, y)
- y = 277
- change_color(system_color)
- text = "名称"
- draw_text(x, y, text_width(text), line_height, text)
- # 绘制名称
- change_color(normal_color)
- text = @enemy.name
- draw_text(x+48, y, text_width(text), line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人体力
- #--------------------------------------------------------------------------
- def draw_enemy_hp(x, y)
- change_color(system_color)
- text = Vocab::hp
- draw_text(x, y, 108, line_height, text)
- change_color(normal_color)
- hp = @enemy.params[0]
- # 判断显示百分比
- if checkPercent?(HP_DISPLAY_PERC)
- text = hp
- elsif checkPercent?(HP_EST_DISPLAY_PERC)
- # 计算体力约值
- ahp = [(hp/10) * 10 - @enemy.params[3], 10].max * (rand(11)+89)/100
- text = sprintf(EST_DISPLAY_MASK, ahp)
- else
- text = NO_DISPLAY_MASK
- end
- draw_text(x+72, y, text_width(text), line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人魔力
- #--------------------------------------------------------------------------
- def draw_enemy_mp(x, y)
- change_color(system_color)
- text = Vocab::mp
- draw_text(x, y, 108, line_height, text)
- change_color(normal_color)
- mp = @enemy.params[1]
- # 判断显示百分比
- if checkPercent?(MP_DISPLAY_PERC)
- text = mp
- elsif checkPercent?(MP_EST_DISPLAY_PERC)
- # 计算魔力约值
- amp = [(mp/10) * 10 - @enemy.params[5], @enemy.params[4], 5].max * (rand(11)+89)/100
- text = sprintf(EST_DISPLAY_MASK, amp)
- else
- text = NO_DISPLAY_MASK
- end
- draw_text(x+72, y, text_width(text), line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 绘制敌人能力值
- #--------------------------------------------------------------------------
- def draw_enemy_param(x, y, param_id)
- # 能力值ID为1或2时,调用绘制体力/魔力方法
- draw_enemy_hp(x, y) if param_id==0
- draw_enemy_mp(x, y) if param_id==1
- return if param_id < 2
- change_color(system_color)
- # 绘制能力值名称
- draw_text(x, y, 108, line_height, Vocab::param(param_id))
- change_color(normal_color)
- # 获取能力值百分比
- param_percent = [ATK_DISPLAY_PERC, DEF_DISPLAY_PERC, MAT_DISPLAY_PERC,
- MDF_DISPLAY_PERC, AGI_DISPLAY_PERC, LUK_DISPLAY_PERC ]
- # 判断显示百分比
- if checkPercent?(param_percent[param_id-2])
- text = @enemy.params[param_id]
- else
- text = NO_DISPLAY_MASK
- end
- draw_text(x+72, y, text_width(text), line_height, text)
- end
- #~ #--------------------------------------------------------------------------
- #~ # ● 绘制敌人掉落金钱
- #~ #--------------------------------------------------------------------------
- #~ def draw_enemy_gold(x, y)
- #~ change_color(system_color)
- #~ draw_text(x, y, 96, line_height, DROP_GOLD_VOCAB)
- #~ change_color(normal_color)
- #~ # 判断显示百分比
- #~ if checkPercent?(GOLD_DISPLAY_PERC)
- #~ draw_currency_value(@enemy.gold, Vocab.currency_unit, x+12, y+24, 108)
- #~ else
- #~ draw_text(x+72, y+24, 96, line_height, NO_DISPLAY_MASK)
- #~ end
- #~ end
- #--------------------------------------------------------------------------
- # ● 绘制敌人掉落物
- #--------------------------------------------------------------------------
- def draw_enemy_item(x, y)
- change_color(system_color)
- draw_text(x, y+24, 96, line_height, DROP_ITEM_VOCAB)
- change_color(normal_color)
- # 判断显示百分比
- if checkPercent?(ITEM_DISPLAY_PERC)
- nn_di = 0
- for i in 0..2 do
- di = item_object(@enemy.drop_items[i]) # 获取掉落物物件
- if di
- ly = y+line_height*(nn_di+1)+24 # 计算绘制高度
- draw_item_name(di, x+24, ly)
- nn_di += 1 # 计数器+1
- end
- end
- return if nn_di > 0 # 计数器大于0时返回
- draw_text(x+80, y+line_height+24, 96, line_height, "无")
- else
- draw_text(x+72, y+line_height+24, 96, line_height, NO_DISPLAY_MASK)
- end
- end
- #--------------------------------------------------------------------------
- # ● 计算敌人掉落物
- #--------------------------------------------------------------------------
- def item_object(drop_item)
- kind = drop_item.kind
- data_id = drop_item.data_id
- return $data_items [data_id] if kind == 1
- return $data_weapons[data_id] if kind == 2
- return $data_armors [data_id] if kind == 3
- return nil
- end
- #--------------------------------------------------------------------------
- # ● 绘制其他资讯
- #--------------------------------------------------------------------------
- def draw_other_info
- fy = y
- change_color(system_color)
- draw_text(x+66, fy-45, 500, line_height, "详细属性")
- if checkPercent?(ELEMENT_DISPLAY_PERC)
- for i in 0..20 do
- feature = @enemy.features[i]
- next unless feature
- label, value = get_feature(feature)
- next if label==""
- change_color(system_color)
- draw_text(x+18, fy-45+line_height*2, text_width(label), line_height, label)
- change_color(tp_cost_color)
- draw_text(x+100, fy-45+line_height*2, text_width(value), line_height, value)
- fy+=line_height
- end
- else
- change_color(normal_color)
- draw_text(x+90, y-line_height+24, 96, line_height, "???")
- draw_text(x+90, y+line_height+24, 96, line_height, "???")
- draw_text(x+90, y+line_height*3+24, 96, line_height, "???")
- end
- end
- #--------------------------------------------------------------------------
- # ● 获得文字宽度
- #--------------------------------------------------------------------------
- def text_width(text)
- return text_size(text).width + 5
- end
- end
复制代码 |
|