查看: 1636|回复: 2

[結帖]敵人繼承的問題

[复制链接]
david_ng223 该用户已被删除
发表于 2016-1-22 18:25:01 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2016-1-22 18:35:37 | 显示全部楼层
@state_turns 是以状态 ID 为键的 Hash,不是数组。另外,35行那里的循环很有问题,能吐槽的地方太多以至于不知道怎么说了……
回复

使用道具 举报

寒

梦石
0
星屑
1049
在线时间
1391 小时
注册时间
2010-8-9
回帖
3301
发表于 2016-1-22 21:58:38 | 显示全部楼层
[pre lang="ruby"]class Game_Temp
  attr_accessor :boss_data
end

Data_BattleData = Struct.new(:hp, :mp, :states, :state_turns)

class Game_Battler < Game_BattlerBase
  def save_battle_data(index)
    $game_temp.boss_data ||= Hash.new
    $game_temp.boss_data[index] = Data_BattleData.new(@hp,@mp,@states.clone,@state_turns.clone)
  end
  
  def load_battle_data(index)
    data = $game_temp.boss_data
    return if (data.nil? || data[index].nil?)
    @hp, @mp, @states, @state_turns = *data[index]
  end
end[/pre]

评分

参与人数 1梦石 +1 收起 理由
taroxd + 1 直接存 Marshal.dump(self) 得了…….

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部