Project1

标题: Enemy所拥有的的技能列表保存在哪里呢? [打印本页]

作者: tai_tan    时间: 2014-3-29 10:24
标题: Enemy所拥有的的技能列表保存在哪里呢?
本帖最后由 tai_tan 于 2014-3-29 10:36 编辑

单个敌人所拥有的的技能列表保存在哪里呢?就是在数据库里添加的技能,在哪里用何种方式保存呢?保存的是技能的id吗?

不在RPG::Enemy
  1. class RPG::Enemy < RPG::BaseItem
  2.   def initialize
  3.     super
  4.     @battler_name = ''
  5.     @battler_hue = 0
  6.     @params = [100,0,10,10,10,10,10,10]
  7.     [url=home.php?mod=space&uid=13302]@exp[/url] = 0
  8.     [url=home.php?mod=space&uid=236945]@gold[/url] = 0
  9.     @drop_items = Array.new(3) { RPG::Enemy::DropItem.new }
  10.     @actions = [RPG::Enemy::Action.new]
  11.     @features.push(RPG::BaseItem::Feature.new(22, 0, 0.95))
  12.     @features.push(RPG::BaseItem::Feature.new(22, 1, 0.05))
  13.     @features.push(RPG::BaseItem::Feature.new(31, 1, 0))
  14.   end
  15.   attr_accessor :battler_name
  16.   attr_accessor :battler_hue
  17.   attr_accessor :params
  18.   attr_accessor :exp
  19.   attr_accessor :gold
  20.   attr_accessor :drop_items
  21.   attr_accessor :actions
  22. end

复制代码
而RPG::Enemy::Action里只有个初始化。。。。。

  1. class RPG::Enemy::Action
  2.   def initialize
  3.     @skill_id = 1
  4.     @condition_type = 0
  5.     @condition_param1 = 0
  6.     @condition_param2 = 0
  7.     @rating = 5
  8.   end
  9.   attr_accessor :skill_id
  10.   attr_accessor :condition_type
  11.   attr_accessor :condition_param1
  12.   attr_accessor :condition_param2
  13.   attr_accessor :rating
  14. end

复制代码

作者: taroxd    时间: 2014-3-29 10:29
RPG::Enemy有一个属性叫做actions,见你的第一段代码的第21行
作者: tai_tan    时间: 2014-3-29 10:32
actions是一个数组吗?要如何访问呢?
作者: tai_tan    时间: 2014-3-29 10:35
哦,是了。。。。
  1.   #--------------------------------------------------------------------------
  2.   # ● 生成战斗行动
  3.   #--------------------------------------------------------------------------
  4.   def make_actions
  5.     super
  6.     return if @actions.empty?
  7.     action_list = enemy.actions.select {|a| action_valid?(a) }
  8.     return if action_list.empty?
  9.     rating_max = action_list.collect {|a| a.rating }.max
  10.     rating_zero = rating_max - 3
  11.     action_list.reject! {|a| a.rating <= rating_zero }
  12.     @actions.each do |action|
  13.       action.set_enemy_action(select_enemy_action(action_list, rating_zero))
  14.     end
  15.   end
  16. end
复制代码
谢谢哇




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1