Project1
标题:
Enemy所拥有的的技能列表保存在哪里呢?
[打印本页]
作者:
tai_tan
时间:
2014-3-29 10:24
标题:
Enemy所拥有的的技能列表保存在哪里呢?
本帖最后由 tai_tan 于 2014-3-29 10:36 编辑
单个敌人所拥有的的技能列表保存在哪里呢?就是在数据库里添加的技能,在哪里用何种方式保存呢?保存的是技能的id吗?
不在RPG::Enemy
class RPG::Enemy < RPG::BaseItem
def initialize
super
@battler_name = ''
@battler_hue = 0
@params = [100,0,10,10,10,10,10,10]
[url=home.php?mod=space&uid=13302]@exp[/url] = 0
[url=home.php?mod=space&uid=236945]@gold[/url] = 0
@drop_items = Array.new(3) { RPG::Enemy::DropItem.new }
@actions = [RPG::Enemy::Action.new]
@features.push(RPG::BaseItem::Feature.new(22, 0, 0.95))
@features.push(RPG::BaseItem::Feature.new(22, 1, 0.05))
@features.push(RPG::BaseItem::Feature.new(31, 1, 0))
end
attr_accessor :battler_name
attr_accessor :battler_hue
attr_accessor :params
attr_accessor :exp
attr_accessor :gold
attr_accessor :drop_items
attr_accessor :actions
end
复制代码
而RPG::Enemy::Action里只有个初始化。。。。。
class RPG::Enemy::Action
def initialize
@skill_id = 1
@condition_type = 0
@condition_param1 = 0
@condition_param2 = 0
@rating = 5
end
attr_accessor :skill_id
attr_accessor :condition_type
attr_accessor :condition_param1
attr_accessor :condition_param2
attr_accessor :rating
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
哦,是了。。。。
#--------------------------------------------------------------------------
# ● 生成战斗行动
#--------------------------------------------------------------------------
def make_actions
super
return if @actions.empty?
action_list = enemy.actions.select {|a| action_valid?(a) }
return if action_list.empty?
rating_max = action_list.collect {|a| a.rating }.max
rating_zero = rating_max - 3
action_list.reject! {|a| a.rating <= rating_zero }
@actions.each do |action|
action.set_enemy_action(select_enemy_action(action_list, rating_zero))
end
end
end
复制代码
谢谢哇
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1