赞 | 153 |
VIP | 10 |
好人卡 | 39 |
积分 | 93 |
经验 | 146191 |
最后登录 | 2024-5-6 |
在线时间 | 2504 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9280
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 帖子
- 15389
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
#环菱形 when 4 delete = [] p delete for i in more_step x = position[i][0] y = position[i][1] # 无视障碍物的场合 if through # 下 if !position.include?([x, y + 1]) position.push([x, y + 1]) route.push(route[i] + [2]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [2])) if route[i].size + 1 < max-1 delete.push(position.push([x, y + 1]),route.index(route[i] + [2])) end end end # 左 if !position.include?([x - 1, y]) position.push([x - 1, y]) route.push(route[i] + [4]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [4])) if route[i].size + 1 < max-1 delete.push(position.push([x - 1, y]),route.index(route[i] + [4])) end end end # 右 if !position.include?([x + 1, y]) position.push([x + 1, y]) route.push(route[i] + [6]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [6])) if route[i].size + 1 < max-1 delete.push(position.push([x - 1, y]),route.index(route[i] + [6])) end end end # 上 if !position.include?([x, y - 1]) position.push([x, y - 1]) route.push(route[i] + [8]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [8])) if route[i].size + 1 < max-1 delete.push(position.push([x, y - 1]),route.index(route[i] + [8])) end end end p delete for i in delete position.delete(i) end return position # 非无视障碍物的场合 else # 下 if !position.include?([x, y + 1]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 2) or (on_area?(x, y + 1, type) and type != 4)) position.push([x, y + 1]) route.push(route[i] + [2]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [2])) end end # 左 if !position.include?([x - 1, y]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 4) or (on_area?(x - 1, y, type) and type != 4)) position.push([x - 1, y]) route.push(route[i] + [4]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [4])) end end # 右 if !position.include?([x + 1, y]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 6) or (on_area?(x + 1, y, type) and type != 4)) position.push([x + 1, y]) route.push(route[i] + [6]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [6])) end end # 上 if !position.include?([x, y - 1]) and !on_area?(x, y, type) and (@battler.passable?(x, y, 8) or (on_area?(x, y - 1, type) and type != 4)) position.push([x, y - 1]) route.push(route[i] + [8]) if route[i].size + 1 < max more_step.push(route.index(route[i] + [8])) end end end end
#环菱形
when 4
delete = []
p delete
for i in more_step
x = position[i][0]
y = position[i][1]
# 无视障碍物的场合
if through
# 下
if !position.include?([x, y + 1])
position.push([x, y + 1])
route.push(route[i] + [2])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [2]))
if route[i].size + 1 < max-1
delete.push(position.push([x, y + 1]),route.index(route[i] + [2]))
end
end
end
# 左
if !position.include?([x - 1, y])
position.push([x - 1, y])
route.push(route[i] + [4])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [4]))
if route[i].size + 1 < max-1
delete.push(position.push([x - 1, y]),route.index(route[i] + [4]))
end
end
end
# 右
if !position.include?([x + 1, y])
position.push([x + 1, y])
route.push(route[i] + [6])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [6]))
if route[i].size + 1 < max-1
delete.push(position.push([x - 1, y]),route.index(route[i] + [6]))
end
end
end
# 上
if !position.include?([x, y - 1])
position.push([x, y - 1])
route.push(route[i] + [8])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [8]))
if route[i].size + 1 < max-1
delete.push(position.push([x, y - 1]),route.index(route[i] + [8]))
end
end
end
p delete
for i in delete
position.delete(i)
end
return position
# 非无视障碍物的场合
else
# 下
if !position.include?([x, y + 1]) and !on_area?(x, y, type) and
(@battler.passable?(x, y, 2) or (on_area?(x, y + 1, type) and type != 4))
position.push([x, y + 1])
route.push(route[i] + [2])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [2]))
end
end
# 左
if !position.include?([x - 1, y]) and !on_area?(x, y, type) and
(@battler.passable?(x, y, 4) or (on_area?(x - 1, y, type) and type != 4))
position.push([x - 1, y])
route.push(route[i] + [4])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [4]))
end
end
# 右
if !position.include?([x + 1, y]) and !on_area?(x, y, type) and
(@battler.passable?(x, y, 6) or (on_area?(x + 1, y, type) and type != 4))
position.push([x + 1, y])
route.push(route[i] + [6])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [6]))
end
end
# 上
if !position.include?([x, y - 1]) and !on_area?(x, y, type) and
(@battler.passable?(x, y, 8) or (on_area?(x, y - 1, type) and type != 4))
position.push([x, y - 1])
route.push(route[i] + [8])
if route[i].size + 1 < max
more_step.push(route.index(route[i] + [8]))
end
end
end
end
脚本是这样···正常效果是要获得一个空心的菱形,可是实际应用效果却是无论怎么定义都获得一个最小的菱形··· |
|