赞 | 1 |
VIP | 57 |
好人卡 | 17 |
积分 | 1 |
经验 | 57584 |
最后登录 | 2019-10-17 |
在线时间 | 832 小时 |
Lv1.梦旅人 沉睡的八宝粥 
- 梦石
- 0
- 星屑
- 64
- 在线时间
- 832 小时
- 注册时间
- 2011-4-22
- 帖子
- 2996
|
jkgf2010 发表于 2012-6-29 23:03
但是啊,请你想想
你把跳改成向左
然后面向右跳起来
(覆盖Game_Player)你试试行么?- #==============================================================================
- # ** Game_Player
- #------------------------------------------------------------------------------
- # 这个类用来操控地图,它所定义的内容包括决定事件执行的条件和地图视域滚动功能。
- # 这个类的实例被全局变量 $game_map 所引用。
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # * 常数
- #--------------------------------------------------------------------------
- CENTER_X = (544 / 2 - 16) * 8 # 屏幕中心X坐标 * 8
- CENTER_Y = (416 / 2 - 16) * 8 # 屏幕中心Y坐标 * 8
- #--------------------------------------------------------------------------
- # * 声明实例变量
- #--------------------------------------------------------------------------
- attr_reader :vehicle_type # 目前正在乘坐的交通工具类型
- #--------------------------------------------------------------------------
- # * 对象初始化
- #--------------------------------------------------------------------------
- def initialize
- super
- @vehicle_type = -1
- @vehicle_getting_on = false # 判定登上交通工具的标帜
- @vehicle_getting_off = false # 判定登下交通工具的标帜
- @transferring = false # 场所移动标帜
- @new_map_id = 0 # 目标地图编号
- @new_x = 0 # 目标地图X坐标
- @new_y = 0 # 目标地图Y坐标
- @new_direction = 0 # 场所移动后的最终朝向
- @walking_bgm = nil # 记忆场景BGM
- end
- #--------------------------------------------------------------------------
- # * 判定交通工具是否正在停止运动
- #--------------------------------------------------------------------------
- def stopping?
- return false if @vehicle_getting_on
- return false if @vehicle_getting_off
- return super
- end
- #--------------------------------------------------------------------------
- # * 场所移动设置预定
- # map_id : 地图编号
- # x : 地图X坐标
- # y : 地图Y坐标
- # direction : 场所移动后的最终朝向
- #--------------------------------------------------------------------------
- def reserve_transfer(map_id, x, y, direction)
- @transferring = true
- @new_map_id = map_id
- @new_x = x
- @new_y = y
- @new_direction = direction
- end
- #--------------------------------------------------------------------------
- # * 判定场所移动是否被预定设置
- #--------------------------------------------------------------------------
- def transfer?
- return @transferring
- end
- #--------------------------------------------------------------------------
- # * 执行场所移动指令
- #--------------------------------------------------------------------------
- def perform_transfer
- return unless @transferring
- @transferring = false
- set_direction(@new_direction)
- if $game_map.map_id != @new_map_id
- $game_map.setup(@new_map_id) # 移动到其他地图
- end
- moveto(@new_x, @new_y)
- @walking_bgm = $game_map.map.bgm
- end
- #--------------------------------------------------------------------------
- # * 判定地图是否可以通行(总判定)
- # x : 地图X坐标
- # y : 地图Y坐标
- #--------------------------------------------------------------------------
- def map_passable?(x, y)
- case @vehicle_type
- when 0 # 舟
- return $game_map.boat_passable?(x, y)
- when 1 # 船
- return $game_map.ship_passable?(x, y)
- when 2 # 飞艇
- return true
- else # 行走
- return $game_map.passable?(x, y)
- end
- end
- #--------------------------------------------------------------------------
- # * 判定地图是否可行走
- # x : 地图X坐标
- # y : 地图Y坐标
- #--------------------------------------------------------------------------
- def can_walk?(x, y)
- last_vehicle_type = @vehicle_type # 移除交通工具类型
- @vehicle_type = -1 # 暂时设置为步行状态
- result = passable?(x, y) # 判定通行度
- @vehicle_type = last_vehicle_type # 还原交通工具类型
- return result
- end
- #--------------------------------------------------------------------------
- # * 判定飞艇是否可着陆
- # x : 地图X坐标
- # y : 地图Y坐标
- #--------------------------------------------------------------------------
- def airship_land_ok?(x, y)
- unless $game_map.airship_land_ok?(x, y)
- return false # 地图通行度设定为不允许空艇着陆
- end
- unless $game_map.events_xy(x, y).empty?
- return false # 有事件块的地方无法着陆
- end
- return true # 可以着陆
- end
- #--------------------------------------------------------------------------
- # * 判定是否正在驾驶某种交通工具
- #--------------------------------------------------------------------------
- def in_vehicle?
- return @vehicle_type >= 0
- end
- #--------------------------------------------------------------------------
- # * 判定是否正在驾驶空艇
- #--------------------------------------------------------------------------
- def in_airship?
- return @vehicle_type == 2
- end
- #--------------------------------------------------------------------------
- # * 跑步状态判定
- #--------------------------------------------------------------------------
- def dash?
- return false if @move_route_forcing
- return false if $game_map.disable_dash?
- return false if in_vehicle?
- return Input.press?(Input::A)
- end
- #--------------------------------------------------------------------------
- # * 判定是否处于DEBUG状态下无视通行度的状态
- #--------------------------------------------------------------------------
- def debug_through?
- return false unless $TEST
- return Input.press?(Input::CTRL)
- end
- #--------------------------------------------------------------------------
- # * 将地图显示位置设置于荧幕正中央
- # x : X坐标
- # y : Y坐标
- #--------------------------------------------------------------------------
- def center(x, y)
- display_x = x * 256 - CENTER_X # 计算坐标
- unless $game_map.loop_horizontal? # 不横向循环?
- max_x = ($game_map.width - 17) * 256 # 计算最大值
- display_x = [0, [display_x, max_x].min].max # 坐标调校
- end
- display_y = y * 256 - CENTER_Y # 计算坐标
- unless $game_map.loop_vertical? # 不纵向循环?
- max_y = ($game_map.height - 13) * 256 # 计算最大值
- display_y = [0, [display_y, max_y].min].max # 坐标调校
- end
- $game_map.set_display_pos(display_x, display_y) # 调整地图显示位置
- end
- #--------------------------------------------------------------------------
- # * 移动至指定位置
- # x : 地图X坐标
- # y : 地图Y坐标
- #--------------------------------------------------------------------------
- def moveto(x, y)
- super
- center(x, y) # 居中
- make_encounter_count # 初始化地雷遇敌模式
- if in_vehicle? # 乘坐交通工具?
- vehicle = $game_map.vehicles[@vehicle_type] # 获取交通工具资讯
- vehicle.refresh # 更新内容资讯
- end
- end
- #--------------------------------------------------------------------------
- # * 增加步数统计值
- #--------------------------------------------------------------------------
- def increase_steps
- super
- return if @move_route_forcing
- return if in_vehicle?
- $game_party.increase_steps
- $game_party.on_player_walk
- end
- #--------------------------------------------------------------------------
- # * 获取地雷遇敌统计资讯
- #--------------------------------------------------------------------------
- def encounter_count
- return @encounter_count
- end
- #--------------------------------------------------------------------------
- # * 统计地雷遇敌资讯
- #--------------------------------------------------------------------------
- def make_encounter_count
- if $game_map.map_id != 0
- n = $game_map.encounter_step
- @encounter_count = rand(n) + rand(n) + 1 # 譬如掷两个骰子
- end
- end
- #--------------------------------------------------------------------------
- # * 判定主角是否在雷区(遇敌区域)内
- # area : 遇敌区域数据(RPG::Area)
- #--------------------------------------------------------------------------
- def in_area?(area)
- return false if area == nil
- return false if $game_map.map_id != area.map_id
- return false if @x < area.rect.x
- return false if @y < area.rect.y
- return false if @x >= area.rect.x + area.rect.width
- return false if @y >= area.rect.y + area.rect.height
- return true
- end
- #--------------------------------------------------------------------------
- # * 创建地雷遇敌队伍编号
- #--------------------------------------------------------------------------
- def make_encounter_troop_id
- encounter_list = $game_map.encounter_list.clone
- for area in $data_areas.values
- encounter_list += area.encounter_list if in_area?(area)
- end
- if encounter_list.empty?
- make_encounter_count
- return 0
- end
- return encounter_list[rand(encounter_list.size)]
- end
- #--------------------------------------------------------------------------
- # * 更新内容资讯
- #--------------------------------------------------------------------------
- def refresh
- if $game_party.members.size == 0
- @character_name = ""
- @character_index = 0
- else
- actor = $game_party.members[0] # 获取领队主角资讯
- @character_name = actor.character_name
- @character_index = actor.character_index
- end
- end
- #--------------------------------------------------------------------------
- # * 判定与主角处于相同位置的事件块是否被触发
- # triggers : 触发阵列
- #--------------------------------------------------------------------------
- def check_event_trigger_here(triggers)
- return false if $game_map.interpreter.running?
- result = false
- for event in $game_map.events_xy(@x, @y)
- if triggers.include?(event.trigger) and event.priority_type != 1
- event.start
- result = true if event.starting
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # * 判定正面的事件块是否被触发
- # triggers : 触发阵列
- #--------------------------------------------------------------------------
- def check_event_trigger_there(triggers)
- return false if $game_map.interpreter.running?
- result = false
- front_x = $game_map.x_with_direction(@x, @direction)
- front_y = $game_map.y_with_direction(@y, @direction)
- for event in $game_map.events_xy(front_x, front_y)
- if triggers.include?(event.trigger) and event.priority_type == 1
- event.start
- result = true
- end
- end
- if result == false and $game_map.counter?(front_x, front_y)
- front_x = $game_map.x_with_direction(front_x, @direction)
- front_y = $game_map.y_with_direction(front_y, @direction)
- for event in $game_map.events_xy(front_x, front_y)
- if triggers.include?(event.trigger) and event.priority_type == 1
- event.start
- result = true
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # * 判定一触即发的事件块是否被触发
- # x : 地图X坐标
- # y : 地图Y坐标
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- return false if $game_map.interpreter.running?
- result = false
- for event in $game_map.events_xy(x, y)
- if [1,2].include?(event.trigger) and event.priority_type == 1
- event.start
- result = true
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # * 通过方向键输入资讯来处理主角移动
- #--------------------------------------------------------------------------
- def move_by_input
- return unless movable?
- return if $game_map.interpreter.running?
- case Input.dir4
- when 4; move_left
- when 6; move_right
- end
- end
- #--------------------------------------------------------------------------
- # * 判定通行度
- #--------------------------------------------------------------------------
- def movable?
- return false if moving? # 移动中?
- return false if @move_route_forcing # 受移动轨迹指令控制?
- return false if @vehicle_getting_on # 正在登上交通工具?
- return false if @vehicle_getting_off # 正在登下交通工具?
- return false if $game_message.visible # 正在显示文本讯息?
- return false if in_airship? and not $game_map.airship.movable?
- return true
- end
- #--------------------------------------------------------------------------
- # * 更新帧
- #--------------------------------------------------------------------------
- def update
- last_real_x = @real_x
- last_real_y = @real_y
- last_moving = moving?
- move_by_input
- super
- update_scroll(last_real_x, last_real_y)
- update_vehicle
- update_nonmoving(last_moving)
- end
- #--------------------------------------------------------------------------
- # * 更新视域移动内容资讯
- #--------------------------------------------------------------------------
- def update_scroll(last_real_x, last_real_y)
- ax1 = $game_map.adjust_x(last_real_x)
- ay1 = $game_map.adjust_y(last_real_y)
- ax2 = $game_map.adjust_x(@real_x)
- ay2 = $game_map.adjust_y(@real_y)
- if ay2 > ay1 and ay2 > CENTER_Y
- $game_map.scroll_down(ay2 - ay1)
- end
- if ax2 < ax1 and ax2 < CENTER_X
- $game_map.scroll_left(ax1 - ax2)
- end
- if ax2 > ax1 and ax2 > CENTER_X
- $game_map.scroll_right(ax2 - ax1)
- end
- if ay2 < ay1 and ay2 < CENTER_Y
- $game_map.scroll_up(ay1 - ay2)
- end
- end
- #--------------------------------------------------------------------------
- # * 更新交通工具资讯
- #--------------------------------------------------------------------------
- def update_vehicle
- return unless in_vehicle?
- vehicle = $game_map.vehicles[@vehicle_type]
- if @vehicle_getting_on # 正在登上交通工具?
- if not moving?
- @direction = vehicle.direction # 调整方向
- @move_speed = vehicle.speed # 调整移动速度
- @vehicle_getting_on = false # 完成登上交通工具的操作
- @transparent = true # 主角步行图透明化处理
- end
- elsif @vehicle_getting_off # 正在登下交通工具?
- if not moving? and vehicle.altitude == 0
- @vehicle_getting_off = false # 完成登上交通工具的操作
- @vehicle_type = -1 # 当前所乘交通工具值清零
- @transparent = false # 取消主角步行图透明化处理
- end
- else # 正在驾驶交通工具?
- vehicle.sync_with_player # 与主角同时同方向移动
- end
- end
- #--------------------------------------------------------------------------
- # * 未移动时的处理
- # last_moving : 事先移动了么?
- #--------------------------------------------------------------------------
- def update_nonmoving(last_moving)
- return if $game_map.interpreter.running?
- return if moving?
- return if check_touch_event if last_moving
- if not $game_message.visible and Input.trigger?(Input::C)
- return if get_on_off_vehicle
- return if check_action_event
- end
- update_encounter if last_moving
- end
- #--------------------------------------------------------------------------
- # * 更新地雷遇敌倒数步数资讯
- #--------------------------------------------------------------------------
- def update_encounter
- return if $TEST and Input.press?(Input::CTRL) # 测试游戏中按下Ctrl键?
- return if in_vehicle? # 正在驾驶交通工具?
- if $game_map.bush?(@x, @y) # 在草木茂密处?
- @encounter_count -= 2 # 倒数步数-2
- else # 不在草木茂密处?
- @encounter_count -= 1 # 倒数步数-1
- end
- end
- #--------------------------------------------------------------------------
- # * 判定一触即发的事件块 (重叠判定)
- #--------------------------------------------------------------------------
- def check_touch_event
- return false if in_airship?
- return check_event_trigger_here([1,2])
- end
- #--------------------------------------------------------------------------
- # * 判定按下[确定]键触发的事件块
- #--------------------------------------------------------------------------
- def check_action_event
- return false if in_airship?
- return true if check_event_trigger_here([0])
- return check_event_trigger_there([0,1,2])
- end
- #--------------------------------------------------------------------------
- # * 登上/登下交通工具
- #--------------------------------------------------------------------------
- def get_on_off_vehicle
- return false unless movable?
- if in_vehicle?
- return get_off_vehicle
- else
- return get_on_vehicle
- end
- end
- #--------------------------------------------------------------------------
- # * 登上交通工具
- # 假使条件:当前主角未在驾驶交通工具
- #--------------------------------------------------------------------------
- def get_on_vehicle
- front_x = $game_map.x_with_direction(@x, @direction)
- front_y = $game_map.y_with_direction(@y, @direction)
- if $game_map.airship.pos?(@x, @y) # 与飞艇坐标重叠?
- get_on_airship
- return true
- elsif $game_map.ship.pos?(front_x, front_y) # 主角前面有舟?
- get_on_ship
- return true
- elsif $game_map.boat.pos?(front_x, front_y) # 主角前面有船?
- get_on_boat
- return true
- end
- return false
- end
- #--------------------------------------------------------------------------
- # * 登上舟
- #--------------------------------------------------------------------------
- def get_on_boat
- @vehicle_getting_on = true # 正在登上交通工具的标帜
- @vehicle_type = 0 # 设置交通工具种类
- force_move_forward # 主角前进一步
- @walking_bgm = RPG::BGM::last # 记忆场景BGM
- $game_map.boat.get_on # 处理登上交通工具的进程
- end
- #--------------------------------------------------------------------------
- # * 登上船
- #--------------------------------------------------------------------------
- def get_on_ship
- @vehicle_getting_on = true # 正在登上交通工具的标帜
- @vehicle_type = 1 # 设置交通工具种类
- force_move_forward # 主角前进一步
- @walking_bgm = RPG::BGM::last # 记忆场景BGM
- $game_map.ship.get_on # 处理登上交通工具的进程
- end
- #--------------------------------------------------------------------------
- # * 登上飞艇
- #--------------------------------------------------------------------------
- def get_on_airship
- @vehicle_getting_on = true # 开始登上飞艇的操作标帜
- @vehicle_type = 2 # 设置交通工具种类
- @through = true # 启用通行度开放状态
- @walking_bgm = RPG::BGM::last # 记忆场景BGM
- $game_map.airship.get_on # 处理登上交通工具的进程
- end
- #--------------------------------------------------------------------------
- # * 登下交通工具
- # 假使条件:当前主角正在驾驶交通工具
- #--------------------------------------------------------------------------
- def get_off_vehicle
- if in_airship? # 飞艇?
- return unless airship_land_ok?(@x, @y) # 不能着陆?
- else # 舟/船?
- front_x = $game_map.x_with_direction(@x, @direction)
- front_y = $game_map.y_with_direction(@y, @direction)
- return unless can_walk?(front_x, front_y) # 不能登陆?
- end
- $game_map.vehicles[@vehicle_type].get_off # 处理登下交通工具的进程
- if in_airship? # 飞艇?
- @direction = 2 # 方向朝下
- else # 舟/船?
- force_move_forward # 前进一步
- @transparent = false # 取消主角步行图透明化处理
- end
- @vehicle_getting_off = true # 开始登下交通工具的操作标帜
- @move_speed = 4 # 还原主角移动速度
- @through = false # 禁用通行度开放状态
- @walking_bgm.play # 还原场景BGM
- make_encounter_count # 初始化地雷遇敌资讯
- end
- #--------------------------------------------------------------------------
- # * 强制前进一步
- #--------------------------------------------------------------------------
- def force_move_forward
- @through = true # 启用通行度开放状态
- move_forward # 前进一步
- @through = false # 禁用通行度开放状态
- end
- end
复制代码 |
|