ALLMAP = 1 #记录已开启地图的变量的ID。
FR = 20 #聚焦半径,当交叉点的坐标离地图目标距离在20个像素以内时,会自动移动靠近。
module SATEMAP
#定义目标地图,举例:
#TAGMAP[1] = [400,139,14,4,8]
#1表示地图ID,400和139表示点在大地图上的坐标,14和4表示场所移动后的坐标。8是朝向。
#也就是说,当横轴与纵轴的交叉点坐标为400,139时,玩家按下确定键,角色就会面朝上移动到
#1号地图坐标为14,4的地点。
TAGMAP = []
TAGMAP[2] = [97,149,1,7,6]#森林,面朝右
TAGMAP[3] = [319,270,1,22,6]#山村,面朝右
TAGMAP[4] = [209,97,5,28,8]#沉默,面朝上
TAGMAP[5] = [565,328,10,1,2]#悬崖,面朝下
TAGMAP[6] = [505,84,1,9,6]#极北,面朝右
TAGMAP[7] = [395,136,1,9,6]#体内,面朝右
TAGMAP[8] = [477,206,20,30,8]#海港,面朝上
TAGMAP[9] = [453,341,11,32,8]#深渊,面朝上
end
#==============================================================================
# ■ Scene_Satellite
#------------------------------------------------------------------------------
# 处理卫星地图画面
#==============================================================================
class Scene_Satellite
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
@allmap_id = $game_variables[ALLMAP]
@focus = 0
@map_id = $game_map.map_id
@tag_lock = false
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 创建背景
@back = Sprite.new
@back.bitmap = Bitmap.new("Graphics/Systems/back")
# 创建X轴
@mm_x = Sprite.new
@mm_x.bitmap = Bitmap.new("Graphics/Systems/mm_x")
@mm_x.y = SATEMAP::TAGMAP[@map_id][1]
# 创建Y轴
@mm_y = Sprite.new
@mm_y.bitmap = Bitmap.new("Graphics/Systems/mm_y")
@mm_y.x = SATEMAP::TAGMAP[@map_id][0]
# 创建地点缩略图
@mm_icon = Sprite.new
@mm_icon.bitmap = Bitmap.new("Graphics/Systems/Icon/"+@map_id.to_s)
@mm_icon.x = 15
@mm_icon.y = 232
# 创建地名
@mm_name = Sprite.new
@mm_name.bitmap = Bitmap.new("Graphics/Systems/Name/"+@map_id.to_s)
@mm_name.x = 60
@mm_name.y = 380
# 执行过度
Graphics.transition(30, "Graphics/Transitions/019-Whorl01" )
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放窗口
@back.dispose
@mm_x.dispose
@mm_y.dispose
@mm_name.dispose
@mm_icon.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
@mm_icon.bitmap = Bitmap.new("Graphics/Systems/Icon/"+@map_id.to_s)
@mm_name.bitmap = Bitmap.new("Graphics/Systems/Name/"+@map_id.to_s)
disjudge
# 按下 X 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
#值可以随便定,但是要比校正范围小一定的值。
if Input.press?(Input::LEFT)
if @mm_y.x>0
@mm_y.x -= 3
end
end
if Input.press?(Input::RIGHT)
if @mm_y.x<640
@mm_y.x += 3
end
end
if Input.press?(Input::UP)
if @mm_x.y>0
@mm_x.y -= 3
end
end
if Input.press?(Input::DOWN)
if @mm_x.y<480
@mm_x.y += 3
end
end
if Input.trigger?(Input::C)
if @tag_lock
$game_system.se_play($data_system.decision_se)
$game_screen.start_tone_change(Tone.new(-255,-255,-255,0), 0)
$scene = Scene_Map.new
$game_temp.player_transferring = true
$game_temp.player_new_map_id = @map_id
$game_temp.player_new_x=SATEMAP::TAGMAP[@map_id][2]
$game_temp.player_new_y=SATEMAP::TAGMAP[@map_id][3]
$game_temp.player_new_direction = SATEMAP::TAGMAP[@map_id][4]
$game_screen.start_tone_change(Tone.new(0,0,0,0), 10)
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
#--------------------------------------------------------------------------
# ● 实时判断
#--------------------------------------------------------------------------
def disjudge
for i in @allmap_id
ax = SATEMAP::TAGMAP[i][0]
ay = SATEMAP::TAGMAP[i][1]
x = @mm_y.x
y = @mm_x.y
f = FR**2
dis = (x-ax)**2 + (y-ay)**2
#自动校正范围,默认16个像素,根据大地图来定。
if dis <= f
if x> ax
@mm_y.x-=1
elsif x< ax
@mm_y.x+=1
end
if y> ay
@mm_x.y-=1
elsif y< ay
@mm_x.y+=1
end
@map_id = i
end
dis2 = (x-SATEMAP::TAGMAP[@map_id][0])**2 + (y-SATEMAP::TAGMAP[@map_id][1])**2
if dis2 < f
@tag_lock = true
else
@tag_lock = false
end
end
end
end