赞 | 1 |
VIP | 255 |
好人卡 | 52 |
积分 | 1 |
经验 | 77416 |
最后登录 | 2016-1-18 |
在线时间 | 1269 小时 |
Lv1.梦旅人 薄凉看客
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 1269 小时
- 注册时间
- 2010-6-20
- 帖子
- 1316
|
本帖最后由 恋′挂机 于 2014-1-5 08:10 编辑
不知道有没有理解错。。
武器决定行走图?
class RPG::Weapon
attr_accessor :pic
end
然后根据下方的方法直接随机或者根据材质其他方面给“嵌入”一张图
再然后 武器.pic就能获取这张图的名- # 随机武器 by 薄凉看客
- # 好吧不是一次看到随机装备的问题了
- # 其实很简单
- # 原理
- # 由于RPG::Weapon中定义的属性均可写可读,因此可以如此
- weapon_hash = {}
- for i in 1..999
- weapon_hash[i] = RPG::Weapon.new
- weapon_hash[i].id = i
- # ----------------------
- # 名字随机的简单示例
- random_name = ""
- # 武器材质
- str_1 = ["铜", "钢", "精铁", "石", "木"]
- yy = str_1[rand(str_1.size)]
- # 武器类型
- str_2 = ["剑", "刀", "枪", "棍", "弓"]
- mm = str_2[rand(str_2.size)]
- random_name << yy << mm
- # 根据材质生成说明
- description = ""
- description << yy << "锻造的" << mm << "。"
- # 根据材质好坏判断价格
- case yy
- when "木"
- price = (a=[*100..200])[rand(a.size)]
- when "石"
- price = (a=[*201..300])[rand(a.size)]
- when "铜"
- price = (a=[*401..500])[rand(a.size)]
- when "精铁"
- price = (a=[*501..600])[rand(a.size)]
- when "钢"
- price = (a=[*601..700])[rand(a.size)]
- end
- # 根据材质好坏判断atk
- case yy
- when "木"
- atk = (a=[*50..100])[rand(a.size)]
- when "石"
- atk = (a=[*101..150])[rand(a.size)]
- when "铜"
- atk = (a=[*151..200])[rand(a.size)]
- when "精铁"
- atk = (a=[*251..300])[rand(a.size)]
- when "钢"
- atk = (a=[*301..400])[rand(a.size)]
- end
- # 示例 0 也可自行随机
- # 物理防御
- pdef = 0
- # 魔法防御
- mdef = 0
- # 力量+
- str_plus = 0
- # 灵巧+
- dex_plus = 0
- # 速度+
- agi_plus = 0
- # 魔力+
- int_plus = 0
- # 附加的属性id的数组
- element_set = []
- # 附加的状态id的数组
- plus_state_set = []
- # 解除的状态id的数组
- minus_state_set = []
- # ----------------------
- weapon_hash[i].name = random_name
- # ----------------------
- # 图标随机的简单示例
- random_icon_name = ""
- str = ["001-Action01.png", "002-Action02.png", "003-Attack01.png",
- "004-Attack02.png", "005-Attack03.png"]
- random_icon_name << str[rand(str.size)]
- # ----------------------
- weapon_hash[i].icon_name = random_icon_name
- weapon_hash[i].icon_name = random_icon_name
- weapon_hash[i].description = description
- # --------------------------------------------
- # 攻击方动画id 示例为 1-10 号动画为特定攻击动画
- # 对象方动画id 示例为 11-20 号动画为特定攻击动画
- # --------------------------------------------
- weapon_hash[i].animation1_id = [*1..10][rand(10)]
- weapon_hash[i].animation2_id = [*11..20][rand(10)]
- weapon_hash[i].price = price
- weapon_hash[i].atk = atk
- weapon_hash[i].pdef = pdef
- weapon_hash[i].mdef = mdef
- weapon_hash[i].str_plus = str_plus
- weapon_hash[i].dex_plus = dex_plus
- weapon_hash[i].agi_plus = agi_plus
- weapon_hash[i].int_plus = int_plus
- weapon_hash[i].element_set = element_set
- weapon_hash[i].plus_state_set = plus_state_set
- weapon_hash[i].minus_state_set = minus_state_set
- end
- # 直接改Data
- file = File.open("Data/Weapons.rxdata", "wb")
- Marshal.dump(weapon_hash, file)
- file.close
- print "成功,请重新打开工程查看数据库中的随机效果吧"
- exit
复制代码 |
|