以下引用Iselia雪于2008-3-15 1:52:19的发言:
以下引用艾铃于2008-3-15 0:42:31的发言:
怎么这么麻烦喵.
把Scene_Item复制一份出来两个Scene读取数据库的不同部分就好了咩~修改一下Scene_Menu,用开关来控制显示两个不同的Scene_Item~
可以看看这个:http://rpg.blue/web/htm/news428.htm
这...能行吗?
还是用$a = $game_party.items记录
这个还原吧。
for i in $a.keys
$game_party.get_item(i,$a)
end
以下引用禾西于2008-3-15 13:25:51的发言:
這樣吧……好像比較簡單(雖然方法比較幼稚)
class Game_Party
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
alias ori_ini initialize
def initialize
ori_ini
@gold_w0 = 0
@gold_w1 = 0
@gold_w2 = 0
@steps_w0 = 0
@steps_w1 = 0
@steps_w2 = 0
@items_w0 = {}
@items_w1 = {}
@items_w2 = {}
@weapons_w0 = {}
@weapons_w1 = {}
@weapons_w2 = {}
@armors_w0 = {}
@armors_w1 = {}
@armors_w2 = {}
@world_id = 1
end
#--------------------------------------------------------------------------
# ● 增加金钱 (减少)
# n : 金额
#--------------------------------------------------------------------------
def gain_gold(n)
case @world_id
when 0
@gold = [[@gold + n, 0].max, 9999999].min
@gold_w0 = @steps
when 1
@gold = [[@gold + n, 0].max, 9999999].min
@gold_w1 = @steps
@gold_w0 = [[@gold_w0 + n, 0].max, 9999999].min
when 2
@gold = [[@gold + n, 0].max, 9999999].min
@gold_w2 = @steps
@gold_w0 = [[@gold_w0 + n, 0].max, 9999999].min
end
end
#--------------------------------------------------------------------------
# ● 增加步数
#--------------------------------------------------------------------------
def increase_steps
case @world_id
when 0
@steps = [@steps + 1, 9999999].min
@steps_w0 = @steps
when 1
@steps = [@steps + 1, 9999999].min
@steps_w1 = @steps
@steps_w0 = [@steps_w0 + 1, 9999999].min
when 2
@steps = [@steps + 1, 9999999].min
@steps_w2 = @steps
@steps_w0 = [@steps_w0 + 1, 9999999].min
end
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
case @world_id
when 0
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
@items_w0[item_id] = @items[item_id]
when 1
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
@items_w1[item_id] = @items[item_id]
@items_w0[item_id] = @items_w0[item_id].nil? ? n : [[@items_w0[item_id] + n, 0].max, 99].min
when 2
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
@items_w2[item_id] = @items[item_id]
@items_w0[item_id] = @items_w0[item_id].nil? ? n : [[@items_w0[item_id] + n, 0].max, 99].min
end
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
case @world_id
when 0
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
@weapons_w0[weapon_id] = @weapons[weapon_id]
when 1
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
@weapons_w1[weapon_id] = @weapons[weapon_id]
@weapons_w0[weapon_id] = @weapons_w0[weapon_id].nil? ? n : [[@weapons_w0[weapon_id] + n, 0].max, 99].min
when 2
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
@weapons_w2[weapon_id] = @armors[armor_id]
@weapons_w0[weapon_id] = @weapons_w0[weapon_id].nil? ? n : [[@weapons_w0[weapon_id] + n, 0].max, 99].min
end
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
case @world_id
when 0
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
@armors_w0[armor_id] = @armors[armor_id]
when 1
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
@armors_w1[armor_id] = @armors[armor_id]
@armors_w0[armor_id] = @armors_w0[armor_id].nil? ? n : [[@armors_w0[armor_id] + n, 0].max, 99].min
when 2
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
@armors_w2[armor_id] = @armors[armor_id]
@armors_w0[armor_id] = @armors_w0[armor_id].nil? ? n : [[@armors_w0[armor_id] + n, 0].max, 99].min
end
end
end
#--------------------------------------------------------------------------
# ● 世界之轉換 (n)
# n : 世界ID
#--------------------------------------------------------------------------
def world_change(n)
@world_id = n
case n
when 0
@gold = @gold_w0
@steps = @steps_w0
@items = @items_w0
@weapons = @weapons_w0
@armors = @armors_w0
when 1
@gold = @gold_w1
@steps = @steps_w1
@items = @items_w1
@weapons = @weapons_w1
@armors = @armors_w1
when 2
@gold = @gold_w2
@steps = @steps_w2
@items = @items_w2
@weapons = @weapons_w2
@armors = @armors_w2
end
end
end
腳本放在main之前
世界的轉換調用方法$game_party.world_change(n)
n是世界的ID,0就是全部物品相加,1就是第一個世界,2就是第二個世界
PS。那個因爲順手,把步數,金錢,武器,物品,防具全部數據都根據世界的不同分開了。如果不需要就删去吧
[本贴由作者于 2008-3-15 13:55:25 最后编辑]
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |