赞 | 27 |
VIP | 400 |
好人卡 | 13 |
积分 | 17 |
经验 | 69730 |
最后登录 | 2025-8-2 |
在线时间 | 3039 小时 |
Lv3.寻梦者 (暗夜天使) 精灵族の天使
- 梦石
- 0
- 星屑
- 1707
- 在线时间
- 3039 小时
- 注册时间
- 2007-3-16
- 帖子
- 33731
 
|
以下引用TERENCE于2008-6-19 22:51:03的发言:
多定义新的passable?叫new_passable?
貼在main前即可
- class Game_Character
- #--------------------------------------------------------------------------
- # ● 新通行判定方法
- # x : X 坐标
- # y : Y 坐标
- # d : 方向 (0,2,4,6,8) ※ 0 = 全方向不能通行的情况判定 (跳跃用)
- #--------------------------------------------------------------------------
- def new_passable?(x, y, d)
- # 求得新的坐标
- new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
- new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 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
- # 从指定方向不能进入到移动处的元件的情况下
- unless $game_map.passable?(new_x, new_y, 10 - d)
- # 不能通行
- return false
- end
- # 循环全部事件
- for event in $game_map.events.values
- # 事件坐标于移动目标坐标一致的情况下
- if event.x == new_x and event.y == new_y
- # 穿透为 ON
- unless event.through
- # 自己就是事件的情况下
- if self != $game_player
- # 不能通行
- return false
- end
- # 自己是主角、对方的图形是角色的情况下
- if event.character_name != ""
- # 不能通行
- return true
- end
- end
- end
- end
- # 主角的坐标与移动目标坐标一致的情况下
- if $game_player.x == new_x and $game_player.y == new_y
- # 穿透为 ON
- unless $game_player.through
- # 自己的图形是角色的情况下
- if @character_name != ""
- # 不能通行
- return false
- end
- end
- end
- # 可以通行
- return true
- end
- end
复制代码
调用方式:
$game_player.new_passable?($game_map.events[a].x,$game_map.events[a].y,方向)
范例:
http://rpg.blue/upload_program/files/Project2_94344311.rar
龙皇的设计思路和我的很接近,经测试没有多余的现象。恩恩。
hiterson的设计思路已接近了游戏的基本要求,但是运行似乎没有龙皇的效果好。
如果能两者综合起来就太好了。
察察的那个判断有问题,有障碍的时候仅仅挡住了一个人,而不是所有人都不可行动。 |
|