赞 | 0 |
VIP | 22 |
好人卡 | 2 |
积分 | 1 |
经验 | 12544 |
最后登录 | 2017-9-7 |
在线时间 | 380 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 380 小时
- 注册时间
- 2010-8-11
- 帖子
- 68
|
- def passable?(x, y, d)
- # 求得新的坐标
- new_x = x + (d == 6 ? 2 : d == 4 ? -1 : 0)
- new_y = y + (d == 2 ? 1 : d == 8 ? -2 : 0)
- # 坐标在地图以外的情况
- unless $game_map.valid?(new_x, new_y)
- # 不能通行
- return false
- end
- # 穿透是 ON 的情况下
- if @through
- # 可以通行
- return true
- end
- # 移动者的元件无法来到指定方向的情况下
- unless $game_map.passable?(x, y, d, self)
- # 通行不可
- return false
- end
- # 从指定方向不能进入到移动处的元件的情况下
- if d == 2 or d == 8
- unless $game_map.passable?(new_x, new_y, 10 - d) and $game_map.passable?(new_x + 1, new_y, 10 - d)
- return false
- end
- elsif d ==4 or d == 6
- unless $game_map.passable?(new_x, new_y, 10 - d) and $game_map.passable?(new_x , new_y - 1, 10 - d)
- return false
- end
- end
- # 循环全部事件
-
- for event in $game_map.events.values
- # 事件坐标于移动目标坐标一致的情况下
- if (d == 2 or d == 8)and(event.x == new_x or event.x + 1 == new_x or event.x == new_x + 1) and (event.y == new_y or event.y - 1 == new_y ) or ((d == 4 or d == 6)and(event.x == new_x or event.x + 1 == new_x ) and (event.y == new_y or event.y - 1 == new_y or event.y == new_y - 1))
- # 穿透为 ON
- unless event.through
- # 自己就是事件的情况下
- if self != $game_player
- # 不能通行
- return false
- end
- # 自己是主角、对方的图形是角色的情况下
- if event.character_name != ""
- # 不能通行
- return false
- end
- end
- end
- end
- # 主角的坐标与移动目标坐标一致的情况下
- if (d == 2 or d == 8)and($game_player.x == new_x or $game_player.x + 1 == new_x or $game_player.x == new_x + 1) and ($game_player.y == new_y or $game_player.y - 1 == new_y ) or ((d == 4 or d == 6)and($game_player.x == new_x or $game_player.x + 1 == new_x ) and ($game_player.y == new_y or $game_player.y - 1 == new_y or $game_player.y == new_y - 1))
- # 穿透为 ON
- unless $game_player.through
- # 自己的图形是角色的情况下
- if @character_name != ""
- # 不能通行
- return false
- end
- end
- end
- # 可以通行
- return true
- end
复制代码 替换相同部分就可以 |
|