Project1
标题:
存放腳本
[打印本页]
作者:
熊喵酱
时间:
2013-8-29 09:01
标题:
存放腳本
純屬給LBQ腳本:
=begin #=======================================================================
2 ] S. d2 W+ g! h: J
, P4 U- K! E& q5 j6 `2 i
Sion Mouse System v1.3e
7 @7 i7 a1 ~% t. R F, g
$ q0 i3 { p9 E+ u* o
Changlog
0 m& @( J y' ]% o* v2 K" h
7 o5 _. H! t( a
2013.4.21 v1.3f
* z* w3 M: G- O2 S' U- y& S
+ \/ q1 i% U' v: G; P
1.3f 卷动地图 bug 修正
! K0 b+ t' `) ]9 b/ d
5 q1 t; ]% e2 ?/ q& r$ a* v
1.3e 逻辑优化;提供解除鼠标固定的接口
5 P3 d# ^8 A! G; q5 E2 Y
在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
" @8 Q. A7 ]( f6 u9 B; `
Mouse.unlock_mouse_in_screen 解除锁定
/ J3 `( G9 v+ u Z0 M
4 @1 u3 n* t7 Z; M4 ^7 E* ]
1.3f bug修正
' g# E8 H5 a( c: u
& r# j! F, u' A+ v. C; p7 D( H1 J
1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
8 M+ E5 k- J' R( ^
关闭菜单时,鼠标是否移动到原来的位置。
# }9 Y& ~) c' M7 T: O' t
. E# ~ x% q( N: X, _ @ M; e# f
1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
7 B( W' R( S& [' H2 P$ f8 O" p
! |" J! P2 \9 p) h
1.3b 修正一些罕见的bug;
3 [- `( r. J' K* O0 U
' f1 m$ W3 [. N: K
1.3a 代码小修改;
7 f) m0 V2 O: V, a3 l
加入了鼠标点击启动事件的功能,
1 I4 Z" u2 q0 x/ V( K2 h; v
在事件中加入“注释”: 鼠标启动 ,
; ^2 {5 T- c- l4 ^. U# t9 J f
该事件将无法用其它方式启动,只能用鼠标左键点击启动。
0 u% u. \: ~. K. e& c/ }/ ~5 }
* I! u! K) p- q" [% M
2013.2.12 v1.2
5 t7 ~* ^3 G/ b9 J/ @5 K+ V; ~
9 P- x% Y- v8 U/ J2 |* ^' |2 M$ G) [
寻路逻辑优化;
6 v$ A$ U8 L, t7 @
优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
4 m7 y& a( ^% [4 d/ p1 y/ k1 q; F
现在支持用鼠标来操作载具了。
' p4 T/ }4 R" \ s
2 Y- I7 _ V; H- G
2013.2.8 v1.1
2 F, x: b0 Y8 `1 M9 w0 g! D- h+ W
3 o) D0 ?- _0 [% S
优化了事件判断,现在可以方便地启动柜台后面的事件;
* g2 J: b9 t) G8 @" b- _) f; G7 g
修复了某些菜单(例如更换装备的菜单)掉帧的问题;
* F5 C6 F1 J+ J% I1 @! G( o
移动时,路径指示点的绘制更加稳定;
. ~" M0 p* p1 j$ X2 f8 `& r& c: g
现在支持默认存档画面的鼠标操作了。
! y/ @( ?* P" w ~# E+ I% P9 T
6 \) [4 ^5 H% ^- S6 f) f* w
, r4 v, X! [5 Q: Y2 O4 _
OrigenVersion
6 U' Q4 `$ r6 b, E9 a
% |# ]; N) s( m
2013.2.7 v1.0
/ y* c e4 y2 |2 Y
4 A2 d% J* s9 d- @9 D8 e
主要功能
" j8 ?( }, A6 W$ q. @
( u% H# W. Y7 Y7 ^
使用鼠标进行各种操作...
7 Z( x- o/ d; U
将鼠标锁定在游戏窗口内
/ _ H6 r- A" J* t, u
自动寻路,按住 D 键可以扩大寻路的范围
) ^1 m( P( A, a* k! ]4 r
双击鼠标进行冲刺
( b1 I O; E8 n; I/ h
更改地图卷动方式以适应鼠标移动
% y, Q9 n; q& x/ o& b
变量输入框改良
$ K6 @- \' o; l- P+ D
5 n8 X- I# ^, W0 ~" t* }9 R: a
★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
[. A8 K: K7 \/ {
; y8 b4 u5 H( \) J+ v2 g, A9 @6 t" ^! g
★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
9 e9 J6 _0 t) Q% R( N
( p. g4 i$ S4 h; t
★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
) V: z9 K3 Z' D5 z) I
8 \4 d5 o: i2 i4 o8 {
; ]! W8 ]2 u) m5 J
=end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
; z; U$ N$ m4 c& s. r# X
, L3 ~6 y- Y, Y. S$ G
* Y. S/ n7 Q! u% m
$no_arrowpic_warn = true # ★ 设置为false不弹出图片缺失提示
! a0 h) {9 a5 f4 b" S4 ^2 e
3 e. @) @6 ?/ N2 _. @
#==============================================================================
' @! I" f9 t$ K8 {- \5 b
# ■ 常数设置
: R2 A" z- h" @! e$ N6 l. E
#==============================================================================
+ V* B2 a$ U+ Q3 G c) S. {+ X2 j" I
module KsOfSion
" F: O& @; J, g! C: I
Clip_Cursor = false # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
; ]6 C; @4 f! v" a
Dbclick_Frame = 20 # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
4 Y* _/ {! c2 z* x. O5 G7 o/ m; P
New_Scroll = false # ★ 更改地图卷动方式,需要关闭设置为false
+ V. F8 D# f1 u- q+ x0 L
Map_Scroll_Spd = 1.0 # ★ 更改地图卷动速率,请确保此值为大于0的float变量
5 i2 c* X. s; [/ s C d6 a
Menu_Set_Pos = true # ★ 打开菜单时将鼠标移动到光标处
1 b( p( ?9 _4 E3 l/ x$ V- U! J2 a' P
Break_Steps = 30 # ★ 鼠标寻路最大步数,防止路径太长导致卡帧
% |- j9 |$ u7 i6 J* q: Q" B# j& b O
# “30” 是默认显示格子数 长(17) + 宽(13)
. ~9 l; z; N" H/ j- h
Find_Path_Key = Z # ★ 扩大寻路范围至全地图按键 Z 对应 D键
/ w6 T4 U- p9 E. v% B1 s
# RM几个内置的空键位 (X = A)(Y = S)(Z = D)
, W2 i: g( h5 [7 O
end
3 r. k- g) a& {, l$ E8 r/ g
' o$ n5 b8 J/ O
#==============================================================================
: j' h' T% Y2 y" h# c/ \2 M* @
# ■ 用来显示路径点的类
1 o) ^% m9 i3 W9 g; d
#==============================================================================
9 a9 w; c7 t+ r) h
class Move_Sign Game_Character
; S1 j6 z0 E7 X; x
#--------------------------------------------------------------------------
& J. X" @6 p. z4 T( \5 I3 U
# ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
7 C+ L5 Y3 H0 e
#--------------------------------------------------------------------------
5 _( b) \( @) m* b) @; l6 o2 e0 v- ?4 }
def init_public_members
2 Z% _5 t, I' n9 j" x$ e
@character_name = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
5 j" _* d8 P: u9 U7 W
@character_index = 0 # ★ 图片索引。$开头的行走图设为0
0 |7 ~+ ?* A4 E% B7 T- q2 c; M5 M& u
@move_speed = 5 # ★ 踏步速度
, Z, ^! c c6 L4 [
@step_anime = true # ★ 踏步动画(如果想使用静态图标就关闭这个)
4 r/ K2 n% I0 R$ g1 m' c& J
[url=home.php?mod=space&uid=316553]@opacity[/url] = 255 # ★ 不透明度
( H8 a# `0 S8 ~4 G9 e/ Y
@blend_type = 0 # ★ 图片合成方式,默认为0(正常)
. J8 Z3 n# D$ n+ ]9 B
@direction = 2 # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
}9 [/ g' {" f
@priority_type = 1 # ★ 优先级(默认与人物同级:1)
7 j& }, a7 ^- V2 m9 g$ ]
; ~% q. ^3 K& [/ f9 W1 X! t1 \% ?
; d, P* d" n# H; h, ~ D: |( P
# ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
$ _& a& K: ]9 h9 v' a+ n) f! X
V* i) [' h9 `0 C3 B5 _3 ~; P! f5 }' b
" e0 p. Y+ ?7 J% E7 y
# 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
' t. r/ ~3 J8 J# q% h& i
unless File.exist('GraphicsCharacters' + @character_name + '.png')
- m& J( A6 X) k2 Q0 b- v5 D
0 @+ e0 G' O1 n2 m/ \
if $no_arrowpic_warn
! E) ^: n% H3 a' Y
MouseShow_Cursor.call(1)
4 e( U5 v$ J4 E; p5 |
msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
" ^/ C0 D9 o0 d4 V0 G: p
' {. j4 _2 w0 E2 e V
“路径指示点”将使用游戏自带图片
1 t$ r+ n& f( N/ G O
0 h @, c2 x, n, n2 z% i! z9 y
该提示可以在脚本内关闭')
7 ^; n, v: ]; ]) Q
MouseShow_Cursor.call(0)
1 w- |; o) Z( s3 D! I5 X3 ^
$no_arrowpic_warn = false
% \8 h" Q8 n0 J9 z" j9 C w2 t( T2 ^
end
2 c% D! ?0 a2 F3 E7 }* i& p/ Q
@character_name = '!Flame'
' R9 c6 P! s+ T; F w
@character_index = 6
; d% x: U; a4 T& w
8 e6 ]" e) S# b. t5 A
end
, t8 |/ B0 m; N) n# M9 l( J
@direction_fix = false # 固定朝向
$ o2 Z" c1 ~* O* ]' s( n1 ~4 `
@move_frequency = 6 # 移动频率
# u# p; u6 O) k" d+ v
@walk_anime = true # 步行动画
! w& e& A" K, N7 W" q
@pattern = 1 # 图案
2 Z/ @4 \ f' z; `( a8 Y( w& ~
@through = true # 穿透
5 @0 s( m' }4 Z2 Y" f5 }
@bush_depth = 0 # 草木深度
! R7 n, d4 j: v6 e8 H7 t% z, z
@animation_id = 0 # 动画 ID
% j+ I5 r3 k$ X3 ]
@balloon_id = 0 # 心情 ID
7 ?9 I( S/ \! s4 U
@transparent = true # 透明
; k, [/ ~0 Q+ @
@id = 0
% z% |# r2 N/ o$ Y( b, l$ K! Q
@x = 0
) G# h# `' }/ \5 k5 ?
@y = 0
; Q3 b& w/ R. \, [; F
@real_x = 0
r" j) x/ {' s5 _# F% l* T
@real_y = 0
6 R: r* x% x4 B$ n4 G- o
@tile_id = 0
% }$ ?- H5 f/ e( t/ v& [0 z
end
/ B2 z' _3 G1 X, @
#--------------------------------------------------------------------------
3 Q: {; W h, z! o2 p% Y
# ● 定义实例变量
: V3 a/ S2 {7 K |) `
#--------------------------------------------------------------------------
/ e2 |5 y3 J) F! Q
attr_accessor direction
' n6 t0 X4 n, U: e7 F: ]
end
2 r6 `$ u2 ^0 g- n0 i4 C1 t; `
4 i0 o8 o3 x4 k7 ]
#==============================================================================
$ c$ e' x* [( i# W& I
# ■ Module Mouse
/ K. l& @# G- l. ^% U2 Z8 p: ~
#==============================================================================
$ z. x/ X/ n9 ]
module Mouse
9 f( T5 B0 p8 @& Z @% Z0 r
#--------------------------------------------------------------------------
) g! `3 F( _1 {
# ● API
) P2 {$ [; x, v: J1 s L3 J5 H
#--------------------------------------------------------------------------
; v! ?4 }3 T$ ~: G! s, l. y/ h" g
Show_Cursor = Win32API.new('user32', 'ShowCursor', 'i', 'l')
* ]) e. Q" |! P
Get_Cursor_Pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
* T2 h0 ^6 [. c, }! n
Set_Cursor_Pos = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
7 x: f( z3 J+ H
Screen_To_Client = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
) a8 ]5 ~: b2 s* s# A0 D4 _3 `
Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
0 e" X/ s- ?: @6 y
Clip_Cursor = Win32API.new('user32', 'ClipCursor', 'p', 'l')
2 }/ S+ E5 D6 Z+ ]2 V/ n/ Z3 Z
Get_Key_State = Win32API.new('user32', 'GetKeyState', 'i', 'i')
& {6 {5 U+ k+ j: s+ s* y# Z# I
Window_Hwnd = Get_Active_Window.call
" f. S( T' n. O! V! T
, h) i5 }1 H4 ?+ Y( d( o" }6 E
class self
$ z8 P# M. d3 m/ P6 ~ e
#--------------------------------------------------------------------------
8 S" X0 H1 E( ]' U' u0 B2 R h! ^. b
# ● 初始化
8 a- _8 y% H" _1 k+ W/ D
#--------------------------------------------------------------------------
2 k, v# C$ Y6 n4 F" L
def init
. J$ S4 y `5 ?( G% [; x
lock_mouse_in_screen if KsOfSionClip_Cursor
; \" |0 b6 I6 X5 R' x9 Z) [
@left_state = 0
7 P& ?; V0 G/ u0 l9 y' k) o# t1 P
@right_state = 0
/ I) v h6 F6 F/ z9 z
@ck_count = 0 # 帧数计,单击以后从0开始
- q6 E9 w/ F% T- r
@dk_count = 0 # 用于双击的判定
9 q ?& t. u3 l
@clicked = false
% C. g; w1 v- Z/ f* S' t3 C* R
creat_mouse_sprite
. `" Q) q6 n# ^4 a/ e8 B" a$ o
update
7 ]; l- ?. b2 i" d6 z
end
4 W( e" ^" M: `3 q7 F4 X
#--------------------------------------------------------------------------
% c1 Y8 s' \: f
# ● 鼠标指针精灵
2 v* t+ [& B7 v, {
#--------------------------------------------------------------------------
: l& V5 i/ V2 B1 x1 D+ m" n
#~ def creat_mouse_sprite
! r$ M! A/ \) O% p: B) L* h1 D
#~
4 S* D9 N, }4 Q- i7 Y- Y0 R
#~ @mouse_sprite = Sprite.new
8 G0 H' W' P# N( m7 J
#~ panda = 2#rand(2)+1
! T H. U# f' h0 g7 H) r
1 _9 T& J+ e: Q5 A; p
#~ if panda = 1
; |3 l+ ?" E" t6 F6 Z: r8 b8 a
#~ if File.exist('GraphicsSystemCursor2.png')
) y" z+ x- [7 [/ K: p
#~ @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
( e* d5 F* w; P! T+ V) Q) M! m" S
#~ end#with if File.exist
, r; H9 c$ U$ y5 g
#~
3 ^+ G& Z+ m. \/ N
#~ else if panda = 2 #with if panda=1
. P( Q, O/ W: c9 a3 C) t) H6 k
#~
/ }! V: i1 [* c D5 Y
#~ if File.exist('GraphicsSystemCursor2.png')
5 n O* h [' o; G
#~ @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
9 W2 x) {7 M i7 g
#~ end#with if File.exist
: f; a' j8 a3 R( \# H9 |
#~
: ?& G3 m+ g! i" a
#~ else #with if panda=1
" F; V& p f" |7 B
#~ @mouse_sprite.bitmap = Bitmap.new(24, 24)
+ R5 m- V; K; t+ r9 J+ W" O) g( E
#~ @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
6 ]& J- |: ?! o* F4 n% [
#~ Rect.new(5 24, 24 24, 24, 24))
' E* w$ g8 S4 E+ i
#~ end#with if panda=1
* |1 q3 i& [7 H) G
#~
6 @, I! X. b# e3 d( V: |
#~ #with def
. j+ l" A: U! G& R l, M! I
#~ end
$ s7 E: \5 _; N/ J* ~- q
def creat_mouse_sprite
% X- H1 z6 b7 J
@mouse_sprite = Sprite.new
' M+ Z9 F7 w. X1 t! R
@mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
% E& [- \9 F- g
@mouse_sprite.z = 9999
/ Z. D% v+ D* y. F( v
Show_Cursor.call(0)
x5 }0 |( E7 z+ g
end
. g- U% r2 f/ e0 L- R$ W5 F i
3 @/ @% k- F! J$ L
#--------------------------------------------------------------------------
" ~1 I& ]5 a- R. Y7 d
# ● 更新
4 l* s8 [$ X" i$ Q6 s: s- V
#--------------------------------------------------------------------------
0 t: u3 ^. W( _2 ]5 V' v& K
def update
) d' |6 {2 v/ D/ h# X) C
@mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
+ _" R. f" g9 ~. ]
left_state = Get_Key_State.call(0x01)
+ r' z8 h8 V: B
left_state[7] == 1 @left_state +=1 @left_state = 0
: |4 j9 A/ b9 [3 t7 w- O J# a* c
right_state = Get_Key_State.call(0x02)
: s$ d6 C7 X E# M y
right_state[7] == 1 @right_state +=1 @right_state = 0
" g' b! M9 [& W7 l* g
update_double_click
: t- R) i& {, p/ r3 {( Y( ?- ~3 v2 T
@left_state == 1 @ck_count = 0 @ck_count += 1
# S4 ]5 E3 w9 E& Q, o- q' J
end
6 J& j! K+ \2 P
#--------------------------------------------------------------------------
- V: k! d5 n% X) _# c
# ● 获取鼠标坐标
0 k# \6 ^* z* A: U7 a( l
#--------------------------------------------------------------------------
8 z( i8 [% b2 A$ j
def get_mouse_pos
6 b# X. Q) [; P- R0 v
arg = [0, 0].pack('ll')
! M) b* e$ g, I5 ]
Get_Cursor_Pos.call(arg)
( \) x0 A' y$ A* p0 X) f
Screen_To_Client.call(Window_Hwnd, arg)
I- }7 S5 `3 |: G
x, y = arg.unpack('ll')
) I$ Q& `! J/ D
return x, y
3 b* b" C6 D1 d- ^- n# h
end
; `# ^7 a) p5 |: L! H" M: ?3 h
#--------------------------------------------------------------------------
7 _" l8 y8 y+ J" R% I, M% H2 i
# ● 将鼠标固定在屏幕内
: w, h* _/ [) |/ z
#--------------------------------------------------------------------------
7 g/ B& n/ X) d% l V* E, h0 Q6 _
def lock_mouse_in_screen
# ^# h& m) q! j$ J& w7 Q# u3 ?
arg = [0, 0].pack('ll')
/ o/ ]8 I2 A% q% D5 S! I9 v4 p
Screen_To_Client.call(Window_Hwnd, arg)
+ e6 [, `- h. G$ m f6 K
x, y = arg.unpack('ll')
8 _6 }- U' L8 m
Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
1 U/ Q/ q* H( T L1 o
end
9 b& ]( F3 z- M% h
#--------------------------------------------------------------------------
% [ K8 p, r$ C
# ● 解除鼠标固定
; }- x2 ^, t, J
#--------------------------------------------------------------------------
) A. y$ x% l; n9 k
def unlock_mouse_in_screen
9 l; \5 E6 {' y* F2 \# k* E
Clip_Cursor.call(0)
- o: G( a, x1 j$ e
end
" l7 p) S+ }4 A4 ^2 h5 Y
#--------------------------------------------------------------------------
+ w" I) E+ X. H2 I2 k8 @
# ● 鼠标双击判定
+ }: w. V/ `- L. i8 y
#--------------------------------------------------------------------------
- v3 q" ?8 Q9 @
def update_double_click
W# C+ S8 T& K- |/ ]9 i) D" R+ [
@clicked = true if @left_state == 1
" F: n5 ? Y% Z* J/ m1 K
if @dk_count 0 && @left_state == 1
$ m9 v, d4 y- {6 d+ V
@dk_count = 0; @clicked = false
+ B$ v5 |+ s; ]5 a: O
return @double_click = true
5 i' T1 [% O; ^: E; j5 ]
elsif @clicked
3 j2 J+ [! I, |
if @dk_count KsOfSionDbclick_Frame
# A* d& |4 ^1 s2 l5 `7 U
@dk_count += 1
" Q; [5 M' y5 `) @
else
! F3 G! B! ]$ N A7 X, ?$ m+ D6 N% h
@dk_count = 0; @clicked = false
7 w9 w! T2 d! b1 H& a
end
o0 } Q1 c& W4 \/ u
end
# J1 `+ G6 f) |, {
@double_click = false
' H6 f2 Q9 [* x6 Q% x$ K% T
end
$ x; z: \( E% I! S# s8 {5 w- P
#--------------------------------------------------------------------------
^1 A& P2 C/ D. |5 }4 S. |
# ● 按键被按下就返回true
% c- L$ Z u0 ]2 e; \
#--------------------------------------------------------------------------
2 l2 `! F k! u% m5 \
def press(button)
, F# A) x l6 a( `
case button
) _' I4 n- q$ T/ X6 J
when 0x01; return !@left_state.zero
' x; Y5 g: }$ M H; p* X+ a
when 0x02; return !@right_state.zero
& x- U5 x( [! t8 p" y/ U( ]6 U
end
, ^0 b* _ m' {) Z, H: n
return false
. _! m7 w5 ]1 z! ]2 ]/ f7 D
end
) L& _5 G, H' ~4 ?. j0 G( I
#--------------------------------------------------------------------------
$ q+ K( k5 c4 M1 m
# ● 按键刚被按下则返回true
5 E" x& t) G! q
#--------------------------------------------------------------------------
# M4 u1 I' }7 B X) d+ ]
def trigger(button)
, X+ g4 O3 A; M) H3 \5 W
case button
% C9 b9 P# _9 q$ \; j: T
when 0x01; return @left_state == 1
. b6 @! a( y, Y) c2 d/ I
when 0x02; return @right_state == 1
1 I, [& C* a+ w5 F8 v. [3 N% @
end
( L4 z3 Y% N/ D3 B$ k; G
return false
. d2 Y3 O. L2 d* f
end
5 m, T7 f1 E1 P, h5 |/ q" |
#--------------------------------------------------------------------------
7 V3 M' B7 R- c5 J% D0 ^
# ● 持续按住键一段时间的话,每隔5帧返回一次true
6 f) j& w3 Q. a. ]
#--------------------------------------------------------------------------
/ e3 f2 _ {8 ^8 P
def repeat(button)
+ |/ [- q$ _, x3 O9 L: j; a8 l
case button
% ~0 n! h- R; v
when 0x01; return @left_state == 1
# R+ o: O+ b0 t( [+ n5 R2 q
(@left_state 22 && (@left_state % 6).zero)
7 s' u& u) d3 g: K( _# _
when 0x02; return @right_state == 1
1 v4 c. ~' s& X5 O
(@right_state 22 && (@right_state % 6).zero)
, V5 k/ p1 u+ e& y+ h5 n
end
- c1 U- ^* r4 s& R
return false
2 O% d' u+ a+ Z$ j7 H
end
6 l5 W& g& Z# Z0 j9 N
#--------------------------------------------------------------------------
5 {& Z& }0 R) g1 \% _
# ● 判断是否双击鼠标
2 {/ M. z- q D) S, C
#--------------------------------------------------------------------------
' [/ B! ~# O" X `) g
def double_click
% t, j: V) d/ K _0 k9 D
@double_click
$ j2 u0 s. t: C% W! O
end
/ ?3 Q4 b/ u) W
#--------------------------------------------------------------------------
4 A- d$ q; c/ `4 D% C+ ^! v! o
# ● 获取@ck_count(每一帧+=1,单击后重置为0)
( W% c6 U) o) Q9 s' O) T
#--------------------------------------------------------------------------
3 ^5 V6 s: H+ t, L
def click_count
& K4 g8 Y7 q9 F5 y7 Y( G& b
@ck_count
: N* e i( @7 |0 |# ~7 G
end
+ t X* o% R7 B) h. P" h$ _+ t
#--------------------------------------------------------------------------
n7 _8 Y0 G h/ @% ^0 {
# ● 获取@left_state(按住左键每一帧+=1)
. o+ A% ~) T: P! d3 r9 y/ {4 M; z9 J
#--------------------------------------------------------------------------
, b6 ]! `! Z3 A. h8 o
def left_state
7 F* ~6 d* Q: t- ^3 |9 u& w a
@left_state
+ v* [7 h- n% C2 z) J
end
$ ~* I, ?& r4 g% s7 V D: ]
#--------------------------------------------------------------------------
6 H' m3 o5 J) J B
# ● 获取鼠标的x坐标
: b( U$ @) J* ?* `4 C* h
#--------------------------------------------------------------------------
$ E7 C- t7 W F2 k. z$ M
def mouse_x
* {" e& k& l9 r; x; C+ Y
@mouse_sprite.x
* [0 i% C8 Y) R
end
$ N; r/ q1 }! q. G6 T
#--------------------------------------------------------------------------
( b% y/ E% j: E5 {; A# C% G3 }+ Z
# ● 获取鼠标的y坐标
" M+ ]; Y) S+ u: K: R+ L
#--------------------------------------------------------------------------
% _2 R0 l, z3 b5 \8 w( V
def mouse_y
/ d1 Q6 F- R* _. s, b/ S
@mouse_sprite.y
' U, h! U- g8 _- g- i" Y' h
end
0 V' N3 I7 K/ i7 Y" R
#--------------------------------------------------------------------------
3 y* F$ s) l- i8 T, A; s/ O2 e2 l
# ● 设置鼠标坐标
2 @6 g0 ~) H; @4 {
#--------------------------------------------------------------------------
1 |0 m# }' [- O- b1 \, N% R% Y
def set_mouse_pos(new_x, new_y)
) L- w1 R% r' O" b$ ^
arg = [0, 0].pack('ll')
+ z& F+ M* s2 u7 j2 j7 K0 t7 [
Screen_To_Client.call(Window_Hwnd, arg)
# a8 f6 t7 m5 C* v- k
x, y = arg.unpack('ll')
" o0 H5 a2 H" Y2 N
Set_Cursor_Pos.call(new_x - x, new_y - y)
. r1 v2 w2 n, c5 p9 d/ }
end
( G$ c+ Q: A8 z+ q6 J5 D6 s% G; V
end #end of class self
' R' u, Y1 ?- O F+ x* M- z! `! ?4 t
" z0 c% \! @( o3 m
end
7 J/ g, v8 O" _3 }2 j, C: ]
& F7 ^. m: t# n' m- o7 K! h5 o
#==============================================================================
' x {* ]5 K" T6 l6 l
# ■ SceneManager
8 b3 d2 [6 V9 {# f. {8 u& h
#==============================================================================
) j6 ?7 j( y: Y/ ~. e
class SceneManager
& I# w) p( u: T$ h
#--------------------------------------------------------------------------
/ S+ a' K a: K1 b6 L
# ● alias
- L8 `4 {2 m5 `; K# v
#--------------------------------------------------------------------------
* B) d& z/ U$ b( Y4 v2 b$ }
unless self.method_defined(sion_mouse_run)
1 i Y5 Q* `9 Z$ r3 K X J# \2 w9 s
alias_method sion_mouse_run, run
- P' v7 H; E( o. l+ U
alias_method sion_mouse_call, call
5 a. q" M# J' D% g* j1 o' t+ h
alias_method sion_mouse_return, return
+ b4 s5 N/ {2 L' g* t! ^4 d4 Q
end
) P6 v: M1 M5 u# ~0 B: f! V. J& p
#--------------------------------------------------------------------------
c% p1 r, w8 n8 e
# ● 运行
# H6 T0 E0 {' D
#--------------------------------------------------------------------------
. {5 j s5 z/ ~0 n( u
def run
% s3 C3 k/ t( v2 t
Mouse.init
/ q- H5 k) {0 e( ~: \, n
sion_mouse_run
) l" \6 [' \0 L7 V: F: X1 ~
end
]: |% i; S9 R2 b) m# F8 f
#--------------------------------------------------------------------------
3 z) ]7 f$ N' D% ]" v
# ● 切换
: \1 T* M: z0 H( C0 x# C/ @0 k
#--------------------------------------------------------------------------
& | L7 o8 w: F1 i! a; Z- ~/ @4 d- ]
def call(scene_class)
, O# ]" }6 S: ^
$game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
+ a, z. j5 l3 |* ^9 g5 w; ?
sion_mouse_call(scene_class)
: {) u- t5 Y6 n
end
8 F" o, G1 x; K
#--------------------------------------------------------------------------
7 j/ t7 o+ X9 Q# ?
# ● 返回到上一个场景
* u# T0 t/ ?6 C, {
#--------------------------------------------------------------------------
9 H, k2 E4 Q3 X0 V
def return
# k: d( c& e7 d1 b' i4 U3 m7 d2 Q7 {
sion_mouse_return
1 x- J6 Z) G6 k
$game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
4 i1 g0 S; V. ^( C
@scene.instance_of(Scene_Map)
7 G( N J0 J' Z! Q
end
9 B) P7 U' a7 E
end
) D5 P2 K. l4 r
, s5 ]0 c* f; {$ ^" F. t
#==============================================================================
) ^5 e0 k0 N& ]9 Q
# ■ Module Input
4 a( T- \" h7 k5 n; g
#==============================================================================
& N8 l( ]0 Y4 R0 }8 X) o6 G0 ?
class Input
* w3 o( Z, t1 A& `( ~
#--------------------------------------------------------------------------
6 F6 `$ z+ D S8 K, C3 u; N
# ● alias
* S1 e9 T0 `% Y6 h/ P1 R
#--------------------------------------------------------------------------
5 @$ D# Z4 o- f; o' q0 \& i
unless self.method_defined(sion_mouse_update)
6 ~$ R6 r2 ~( P; g, u) Z' _% O
alias_method sion_mouse_update, update
1 F9 c* @5 a2 O, T. t8 g% D
alias_method sion_mouse_press, press
3 H/ r2 k8 U( K7 }
alias_method sion_mouse_trigger, trigger
5 X1 V% v7 h: G, c; W! g+ x
alias_method sion_mouse_repeat, repeat
# r- h1 D$ M8 _! U& v% m' {7 D
end
* ]( t0 E1 m8 M& b+ p' R0 G7 L- d3 C
#--------------------------------------------------------------------------
$ Z+ y/ [9 b7 f) y# N3 {
# ● 更新鼠标
; W( H& M1 p9 T
#--------------------------------------------------------------------------
4 a8 Y5 c0 J8 B9 t
def update
$ [# C, R( r7 f2 g
Mouse.update
$ M5 C/ Y4 Z. G
sion_mouse_update
# r) p$ d M: K- U8 P' E
end
+ ]' p6 }# Z }
#--------------------------------------------------------------------------
% r" |! |9 Q, Q, }% L! k8 G
# ● 按键被按下就返回true
2 x* X" @3 [6 l& j. l2 ~
#--------------------------------------------------------------------------
& x, g7 r; B$ }4 E ` s# | N/ [
def press(key)
# S1 C* `! {9 u0 |9 J
return true if sion_mouse_press(key)
/ _/ C& M7 h6 g4 r0 ?; h
return Mouse.press(0x01) if key == C
/ A3 F( R2 K& I. @7 ~ r+ r
return Mouse.press(0x02) if key == B
% {) g- l: D/ Z0 \
return false
. R# V, q/ ?# q- G5 H# T9 \- z
end
( {0 }" e- B* |3 g( L o6 z: }( Y
#--------------------------------------------------------------------------
5 S$ g4 E1 X9 U2 L
# ● 按键刚被按下则返回true
1 z b, P5 z/ V" W" M- E# h3 M
#--------------------------------------------------------------------------
# p: k, p4 e; s9 r& Q
def trigger(key)
7 E# O! f+ `9 ^; I( W2 ~2 M, _, `
return true if sion_mouse_trigger(key)
- E6 L, |( E% ` f5 Y+ _) q* C
return Mouse.trigger(0x01) if key == C
4 C; ?* c8 W$ H
return Mouse.trigger(0x02) if key == B
5 q9 d8 u& R e* X+ t; W& S
return false
1 _+ \1 k6 ]6 r( _" i2 U
end
) Q S" `7 s3 @ a
#--------------------------------------------------------------------------
) _. e2 t+ {4 g( l) D
# ● 持续按住键一段时间的话,每隔5帧返回一次true
) l) k/ t6 }$ e5 f: |! X6 [. `' ^/ M; q
#--------------------------------------------------------------------------
# \7 b6 z0 R# g/ y3 v( {: v& K
def repeat(key)
" E& a: s g2 y9 t# ^
return true if sion_mouse_repeat(key)
) v* n: S+ y1 m4 l% j1 i0 e
return Mouse.repeat(0x01) if key == C
/ o% H) [+ V/ _3 j# Z$ P. M
return Mouse.repeat(0x02) if key == B
; b# A! H/ c& [9 t
return false
! t; J, ?4 W$ W- c# X% ^& \+ n
end
' S" `) w) W% [ g, ?! N! k z
end
: ?" J& }& C |
; ~7 h9 G+ @2 P9 Z5 T& `7 \
- F. V& j2 {( `( t+ b+ `
#==============================================================================
6 M! w# f" Z% a
# ■ Window_Selectable
* Q4 a" w9 u% r
#------------------------------------------------------------------------------
& G+ W# r$ b$ x2 A3 {/ v
# 拥有光标移动、滚动功能的窗口
2 T3 r& M' G! V/ y8 }
#==============================================================================
) a Q+ I4 E3 E Y. [
class Window_Selectable
6 a( r% e' Q6 b6 n) b+ W5 B
#--------------------------------------------------------------------------
2 s, t, e$ X! [4 E9 ~
# ● 初始化
4 Q0 i- s8 @" s, ?& [
#--------------------------------------------------------------------------
% x+ c% j$ z% p
alias sion_mouse_initialize initialize
# r$ ^2 `7 j! M* [8 D+ M( _ a
def initialize(x, y, width, height)
' U5 D! c3 j1 W! D, F
sion_mouse_initialize(x, y, width, height)
# y' k, ]$ q- u0 r, ?; J% W; F6 U) M
@move_state = 0
7 C* v* \ }0 l1 P( U# j8 [1 S
end
: Y4 S, L9 F# z8 F; \% E* g
#--------------------------------------------------------------------------
/ N$ _- H* \; J1 f( g
# ● 更新
' v2 S, `3 p2 a9 y' Y0 q! v
#--------------------------------------------------------------------------
; R- O6 U+ s4 _' W
alias sion_mouse_update update
7 v; e9 @1 q3 k9 N
def update
7 z# x) K/ y4 I( s* S
sion_mouse_update
0 P' [( i$ s% y9 V( R% U/ u
update_mouse_cursor
+ h$ Y2 H3 u! i4 p
end
) W! t+ V" W9 R6 ~8 Z- r& n; Z
#--------------------------------------------------------------------------
]* J( D$ w3 n& v
# ● 启动后设置鼠标到index位置
8 x/ ^$ J/ C% ^- [
#--------------------------------------------------------------------------
: f7 n( P ~8 e: D( ~" b) p% f
def activate
( X4 X; w& B" |* g1 B# v
@need_set_pos = true if KsOfSionMenu_Set_Pos
$ ?+ r, R* W, t$ J4 d$ b
super
6 O+ g& A6 I9 r" J8 T6 m
end
; t# q, X+ d2 w
#--------------------------------------------------------------------------
( N5 w' z8 x. c3 H
# ● 更新鼠标和光标的位置
O; H# ~! F9 U: k6 @
#--------------------------------------------------------------------------
. G( A; Z/ l( n K, ~0 E* G
def update_mouse_cursor
$ E D2 {5 Z: U9 [% T/ K
if active
4 _0 n+ L E/ x" }" Z( Y7 k" m# S( X
if @need_set_pos
# k7 z- I6 u4 I2 L9 U
@need_set_pos = nil
- ]( ]0 n; ~# A% L3 Z
set_mouse_pos
) @; g8 q h' o: I' {
elsif cursor_movable
+ `6 P9 @1 P h k
Input.dir4.zero set_cursor set_mouse_pos
8 J; u7 @" ]$ L: C4 X. e$ N: W) J
end
- o2 M z8 v! x1 R$ m/ x2 k9 W
end
9 j! a- r% Q+ X
end
* n/ Z# w" O ]* U+ ?
#--------------------------------------------------------------------------
: J. W7 W: R9 e# |+ y% V2 S
# ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
; O+ W- s' X, W1 x. \, K7 z& g
#--------------------------------------------------------------------------
{. s$ q6 A3 \( T
def set_cursor
T# X; M [1 b& m4 j# q
mouse_row, mouse_col = mouse_window_area
2 x8 m4 U# b# L, ~: w
if mouse_row == -1
1 x, j8 ?6 z0 r' Z, U& t# W
@move_state += 1 if need_scroll
( C9 {& {% N, M/ [
cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
4 l, k' @* F' L5 e+ i" H
elsif mouse_row == -2
+ @$ u, f3 Q1 f8 X7 {6 u% P
@move_state += 1 if need_scroll
, T( J' I( z) t% ^/ }1 R5 t4 W
cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
6 e4 o% d# P! _2 f8 N
elsif mouse_col == -1
+ a: H" R+ n! g$ W" |6 E
@move_state += 1 if need_scroll
* O) }5 i+ _1 j3 u% u1 Q. G9 I
cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
* J3 M) h3 k4 S q. ] W7 m4 l' b. {
elsif mouse_col == -2
, i% r- z7 P. ~) g+ [" o
@move_state += 1 if need_scroll
; C3 l0 U' t) I% K( ?
cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
6 Y, Z/ [% m! S, ?. r$ B: Y/ v! c
else
+ J7 l L: U, S6 L
@move_state = 0
6 r0 e: M- [, G+ |+ B8 E& {
new_index = (top_row + mouse_row) col_max + mouse_col
7 W5 |/ [7 X' `$ k# U9 p* p+ S
select(new_index) if new_index item_max && new_index != @index
) S3 F/ P* ?$ _6 q9 T4 a( m
end
2 _0 N0 r, }& p$ v
end
! x) \: t. f" v; E
#--------------------------------------------------------------------------
& F* ^2 S3 O) u: b0 y: H
# ● 判断鼠标位于菜单的第几行、第几列
/ t Z5 L2 m7 z) g4 c! N
#--------------------------------------------------------------------------
" y0 }6 b0 @* M8 A2 l8 W
def mouse_window_area
8 U: b3 w9 f( @: w) O0 f
if viewport.nil # necessary!
/ v5 H! L: k6 B2 ]
vp_x, vp_y = 0, 0
: a- w( [( t7 k6 s/ J
else
1 I4 R5 Q# P2 N9 s1 }, Y @7 J
vp_x = viewport.rect.x - viewport.ox
7 t* A5 w) N5 J
vp_y = viewport.rect.y - viewport.oy
4 W/ }9 R" E7 N( f, G1 k
end
; T3 T" C! m- R* k; _
mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
9 y1 ?" s$ x2 A# v9 J5 Z+ t( s9 C
item_x1 = vp_x + x + standard_padding
* ?% O2 R5 A; ~9 o
item_y1 = vp_y + y + standard_padding
! V+ o5 |; d; f: e# u9 n6 _
item_x2 = vp_x + x - standard_padding + width
8 }5 u* y u8 a7 `
item_y2 = vp_y + y - standard_padding + height
3 D; B* T$ E, T2 C" f; n% _
if mouse_x item_x1
6 u- k/ f" S( c" \7 p: H
mouse_col = -1
* O, z. m/ v% L9 `: g
elsif mouse_x item_x2
) S! t1 h9 P' N
mouse_col = -2
* Q: c0 |4 L4 ]/ t3 _; @
else
5 b& g" p- p; Y: o" Z* t! |4 q. D
mouse_col = col_max (mouse_x - item_x1) (item_x2 - item_x1)
( R" i5 R: M, a
end
0 ]2 l5 E% f1 Z3 T D
if mouse_y item_y1
+ }; g+ j3 w7 v) B
mouse_row = -1
) ?0 M5 \9 Y! \
elsif mouse_y item_y2
- M- \% g6 f$ w: B+ b5 v0 I
mouse_row = -2
& N# ]$ ?" y4 [0 x; `4 j- w, S
else
8 [' a, t7 h u+ h& N! h, {
mouse_row = page_row_max (mouse_y - item_y1 - 1) (item_y2 - item_y1)
& ], E# r' { J( m |% A9 _
end
1 b) D+ O; V0 E
return mouse_row, mouse_col
* s& u; a8 G9 w3 u1 M4 ~, n
end
& w$ m0 a* J* f- \' L4 Z
#--------------------------------------------------------------------------
0 X2 h" f. { O5 `1 k3 t9 y
# ● 方向键移动光标时将鼠标移动到对应的光标位置
5 w2 a, A+ P% v4 _
#--------------------------------------------------------------------------
3 `+ u# ~+ t+ |, ?6 H- C
def set_mouse_pos
" i6 i/ |0 A9 N" @/ C
if viewport.nil # necessary!
- m. _+ W! u$ U, d4 |, J! I2 s
vp_x, vp_y = 0, 0
1 h! E7 v( ?( i5 C5 V5 q, @
else
, Q/ w5 U0 p1 F% \# J) y! \
vp_x = viewport.rect.x - viewport.ox
5 \$ _( W( t. T7 i A' I
vp_y = viewport.rect.y - viewport.oy
3 K9 H& d/ x2 ]- ]6 w
end
" i% U8 n; U! m9 W. w" f
item_x1 = vp_x + x + standard_padding
" O: x" ~5 J- i) H& g! g7 _. a
item_y1 = vp_y + y + standard_padding
% [, _& X9 X5 Z2 _9 r- i3 t4 [
get_index = [url=home.php?mod=space&uid=370741]@Index[/url] 0 0 @index
$ H' Q( h* z# c. E6 h
row = get_index col_max - top_row
3 y9 R" I6 V" _" O# u! C
col = get_index % col_max
9 [0 h# `/ h/ q5 }7 i1 `' y
new_x = item_x1 + item_width (col + 0.5)
" d" ]4 F0 I& A, @3 m
new_y = item_y1 + item_height (row + 0.5)
; S0 U { ?9 s4 _
Mouse.set_mouse_pos(new_x, new_y)
) g& n5 Y% T+ \4 _6 y3 x( K
end
' r1 E: p4 }' r4 }
#--------------------------------------------------------------------------
) l4 k# N F9 Y( O& c' u# _
# ● 判断菜单是否需要卷动
' W1 h( S. b5 H" @1 x$ j9 Z" `
#--------------------------------------------------------------------------
/ E g3 h* ` S2 O$ s% q/ u
def need_scroll
0 ~# L( B& H( }8 a
item_max col_max page_row_max
! Y9 t& _# F6 V2 }
end
* \8 K" P9 S; c: u0 {; ]
#--------------------------------------------------------------------------
5 E/ k2 f5 P; }. |9 F2 g x. A/ A
# ● 判断是否为水平卷动菜单
) }, _" B% G5 ~* E) Y
#--------------------------------------------------------------------------
9 L/ q# ~1 u2 c8 R7 @4 z; j" [4 `6 X
def is_horzcommand
5 E# t* m& O( K6 L; l7 ^& y
return false
+ S; `) S, m) c/ c9 b
end
. f- p3 X0 Z, @1 v
end
; A( y- k% p6 r0 g2 {/ ]3 A, K& U$ `
) A. n8 [+ M" t0 Z: T/ A, ^
class Window_HorzCommand
% V, O9 B$ U7 t" U" b' _* \
#--------------------------------------------------------------------------
, b8 t1 A4 x6 F2 s+ N+ k. R
# ● 判断是否为水平卷动菜单
% j' n4 l" W3 C# S/ T: m# o$ e. O
#--------------------------------------------------------------------------
# X; D* `/ l$ m/ G, R+ v! `
def is_horzcommand
1 Y2 F6 i! W; r. T" a5 j
return true
! M+ w) W( u( W L/ I9 O$ \6 X
end
2 t6 d* j3 K1 s3 \
end
( Z9 x& H- T( n$ b; U A) E. A5 V8 k
' d, g i: Y; d: F
#==============================================================================
6 e! x2 f! }0 t, r
# ■ Window_NameInput
1 z. C8 i+ |7 v4 X5 g8 F$ z
#------------------------------------------------------------------------------
. |- A# v+ S/ p$ Q( |) t9 }9 R" e2 z
# 名字输入画面中,选择文字的窗口。
8 U4 l. Z1 l) s
#==============================================================================
2 f q# U- G' l7 o% U# K
class Window_NameInput
! N8 b1 D+ [% [6 R* z8 N
#--------------------------------------------------------------------------
' Z3 ~9 b+ z* e' r6 C7 n
# ● 设置列数
6 _! g+ F% ^3 u/ g2 C
#--------------------------------------------------------------------------
$ q: u8 b) r! R( _* d8 l
def col_max
$ R0 B5 e& y4 t9 ~6 T! y
return 10
& z6 s7 P Q4 j# \! _1 n3 g4 Z7 _. G/ t
end
: H% s0 ?, Q& h1 U C6 J
#--------------------------------------------------------------------------
# [4 p* d' A% A; x
# ● 设置填充的Item个数
% S: r0 W R7 a( u1 g# N6 z
#--------------------------------------------------------------------------
6 c( w% z2 Z/ s/ f1 O
def item_max
+ l% s" o4 J: ~
return 90
, Y1 O8 z, q. y+ D' R; \
end
: y6 ` G% `4 |8 \
#--------------------------------------------------------------------------
/ a# }; n( n3 v/ h
# ● 设置填充的Item个数
/ z. v0 a2 @2 H0 `7 s6 y! r h
#--------------------------------------------------------------------------
: q) ^5 e: n. ?
def item_width
$ t1 C$ B+ s1 Q5 v
return 32
' M3 R1 h8 d& M' H
end
/ e! c/ P7 b$ \& u3 M1 f+ _
#--------------------------------------------------------------------------
* [4 A) A: c% y: m$ e4 X1 e
# ● 判断鼠标位于菜单的第几行、第几列
# @8 N4 G( i4 o3 F) }" }: v
#--------------------------------------------------------------------------
/ i% i2 U/ Y' L( O# f( h* C+ H
def mouse_window_area
8 ~( F* M3 E: Q$ ]; f% s
if viewport.nil
5 |: y) b/ Z! G. e8 Q. k
vp_x, vp_y = 0, 0
0 U: N; P& t' w5 g* U
else
0 J% G2 B9 t* a( q
vp_x = viewport.rect.x - viewport.ox
# P& ~ ?" [8 {1 ~6 ?) Q4 [3 ]$ |; L3 p
vp_y = viewport.rect.y - viewport.oy
& P, V% P7 Z- Y, j: ?
end
8 V( z# K, i2 T6 @
mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
& {/ U/ ~4 q. B6 O) t5 i
item_x1 = vp_x + x + standard_padding
: E; w% r/ r) O
item_y1 = vp_y + y + standard_padding
0 o: `! Q; D: x; N& Z% a& I: e
item_x2 = vp_x + x - standard_padding + width
/ W8 N. B3 o& }
item_y2 = vp_y + y - standard_padding + height
: K' K* I7 L. T8 x- t+ G9 i
if mouse_x item_x1
( m* F, P: P4 m6 Q) b
mouse_col = -1
" e+ p: u" a( H9 Y" _
elsif mouse_x item_x2
\( V. q7 B" ^2 i
mouse_col = -2
8 E9 J, w `% a. a+ o
elsif mouse_x item_x1 + 160
* y% I+ m% j2 l
mouse_col = (mouse_x - item_x1)32
# H$ ~+ I0 T, p6 k# i
elsif mouse_x item_x2 - 160
( n4 @2 V0 V0 }; K! _
mouse_col = 9 - (item_x2 - mouse_x)32
) z3 V# j; a2 n( X; x7 T, I2 M
else
6 B5 m/ d9 D. x1 Y, R: b
mouse_col = mouse_x x + width2 5 4
, q0 ]1 c' @7 K% {8 R9 A
end
: X2 p3 T4 e9 Q5 X
if mouse_y item_y1
; H5 @6 O9 e6 }, |, ~- G# |. ?
mouse_row = -1
) _% i1 V3 p$ u0 a$ X+ o
elsif mouse_y item_y2
, n( T6 \: U! m) g& I, r" O5 R8 {
mouse_row = -2
6 E! Y. n) b) f& D) T8 E: w
else
- Y6 o9 P2 C" D1 T1 i1 K
mouse_row = page_row_max (mouse_y - item_y1 - 1)(item_y2 - item_y1)
0 c2 Q' T; B: s2 ?1 A7 l V
end
; x3 u7 [+ d0 F" Z6 \
return mouse_row, mouse_col
7 o" P) i t. E6 u$ }+ E; ]6 Q7 v
end
, Z0 Y% E$ P& ` S5 ]2 M! L9 ~
#--------------------------------------------------------------------------
/ f# Q, U! v- l( P! a
# ● 方向键移动光标时将鼠标移动到对应的光标位置
0 r% E# D9 u2 C" O+ L
#--------------------------------------------------------------------------
/ O- ]6 s3 A7 Y- ^
def set_mouse_pos
! d2 z$ e3 E- E0 a
if viewport.nil # necessary!
. U3 Z6 A- t# j5 E
vp_x, vp_y = 0, 0
6 p* [ L0 p9 b9 F
else
) ^/ W: E( T f
vp_x = viewport.rect.x - viewport.ox
0 T* F l% X' |( {; ? T# C& g
vp_y = viewport.rect.y - viewport.oy
' L/ }/ R) f! q
end
- y* P9 Y" V% s _6 [) H( B' L
item_x1 = vp_x + x + standard_padding
4 g3 v$ \# b- d6 \! ~5 l
item_y1 = vp_y + y + standard_padding
7 m6 I1 g+ _5 t8 P
get_index = @index 0 0 @index
; x5 [9 N' o* ^; I, T* {: _
row = get_index col_max - top_row
]3 s# ~3 F! L5 r# g8 a3 Y( x6 k
col = get_index % col_max
0 Y+ t; Z1 T* T2 A- @3 C+ b
new_x = item_x1 + item_width (col + 0.5)
( y1 d4 y0 l5 w
new_y = item_y1 + item_height (row + 0.5)
! g4 K. Q7 e k' u: e" p8 E' F/ G
new_x += 14 if col 4
. m% I# Q0 B. H2 w8 D* o+ Z) X
Mouse.set_mouse_pos(new_x, new_y)
: V; |+ [. L2 j6 o
end
2 e$ v$ n) _) Y4 E4 t
end
) H+ c6 q3 r' b+ ]5 K1 N2 m' c
3 r p, s% H7 o; z
#==============================================================================
8 J8 m: K' i4 p% ~; Q% Z
# ■ Window_NumberInput
3 v* L# O( t% e4 r# N
#------------------------------------------------------------------------------
. X a) z2 A ?) k0 g) |# `
# 重写了数值输入的方法以适应鼠标
1 y- ]" b) P6 @! `$ R, Y! h
#==============================================================================
" d4 ]! B; z0 w6 ~ E& K
class Window_NumberInput Window_Base
/ v t- e9 S+ h
#--------------------------------------------------------------------------
# M: e1 z! T! h/ e! H
# ● 定义实例变量
) a" j, p2 {0 Q3 b* A
#--------------------------------------------------------------------------
4 ` s1 D8 r7 S; M4 w# w
attr_reader extra_window
* G; T% B! c1 i9 R
#--------------------------------------------------------------------------
, Y! k' W3 `: m! b+ i
# ● 初始化
1 R/ M) B) D6 O3 e! H% B, R1 n6 ?
#--------------------------------------------------------------------------
" k7 h4 U/ I2 c7 ?8 w
alias sion_mouse_initialize initialize
0 H1 [8 K/ p0 u( {
def initialize(arg)
6 x$ d6 f4 K6 S2 R2 @' ?
sion_mouse_initialize(arg)
# m) t5 G: W; i% t$ U
create_extra_window
, G% l8 l4 w6 ]2 G+ O, n1 c
end
5 ]" y1 H' y6 \, w; F @/ K
#--------------------------------------------------------------------------
) j0 {. B; z- E' f) e6 D a& z
# ● 启动
" X3 N% B8 }6 v' E; p
#--------------------------------------------------------------------------
0 W3 p, V' h5 ]+ n' M( N$ o: u0 @! C
alias sion_mouse_start start
" d" p5 q3 c3 S- _
def start
+ a" i9 ]1 z! [ o% [) m3 v
sion_mouse_start
3 E5 l/ Q: g- R. ~1 d
deactivate
# R: x W& t' |. M @; b+ y0 W
extra_start
7 e- ^0 @6 y* S: u& {/ s1 `
end
5 p' O, y: C/ `1 `$ W! z. |. |
#--------------------------------------------------------------------------
7 |5 j, o' [7 c. d/ p
# ● 创建新的数值输入窗口
+ U' f- z9 K% ]! G W
#--------------------------------------------------------------------------
; T$ J: c: v5 k4 ]& u5 G$ i3 a
def create_extra_window
- k k# F9 V* d0 Z% ?- {" G6 |
@extra_window = Window_NumberInput_Ex.new
1 V9 T2 C0 c( q- |; p" T
@extra_window.x = (Graphics.width - @extra_window.width) 2
6 P' e' M, T# a4 d2 w2 P
@extra_window.number_proc = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
9 x) h4 p, T( Z5 F. F3 c" F
@extra_window.index_proc = Proc.new {n @index = n }
5 W3 q3 }& r. L
@extra_window.close_proc = Proc.new { close }
" t' ]% E9 I" P ^* |/ H/ Z
@extra_window.refresh_proc = Proc.new { refresh }
$ g6 k+ y7 i Z6 I! w
end
7 Z! a5 _5 R8 m* L
#--------------------------------------------------------------------------
4 {: o1 a8 B: } D# Q3 u& V& |% S8 S
# ● 激活新窗口
& _( q9 _; P1 J
#--------------------------------------------------------------------------
; ^7 ^! M) A# `: ^
def extra_start
. ], q/ l; g) z9 u. Q1 c6 N: k
case $game_message.position
2 w2 D2 X% w& T* J, |; p) c
when 0; @extra_window.y = y + height + 4
3 ?* W( ^% g" ^# ^
when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
+ t0 b4 c$ `& W( c& N2 o
when 2; @extra_window.y = y - @extra_window.height - 4
# F, E8 f$ N5 R1 Y; g8 D
else ; @extra_window.y = 8
/ D, r: R. C2 \7 A
end
9 X* }" D2 c! q: w0 q8 j- D& @
@extra_window.variable_id = $game_message.num_input_variable_id
9 V, S6 k/ U3 ~: J2 D
@extra_window.digits_max = @digits_max
3 p2 Q; |# N: ]
@extra_window.number = @number
+ o& r2 G* a- Z* p5 K. v
@extra_window.open
1 L7 u, M+ N9 c7 N* ^" c/ g
@extra_window.activate
1 l7 x! C8 `# }% m1 ]
end
4 I# Z+ D: R9 B' t% I
#--------------------------------------------------------------------------
- \" s( b6 ~# O6 i
# ● 更新
7 w2 K& ]' K, N* J- r' h) V
#--------------------------------------------------------------------------
, i& u( h R& d1 O7 Z! I8 C- }' Q& {
def update
7 w' D- X* A/ O0 D6 l0 q
super
! A6 |8 G; o+ ?% `
@extra_window.update
7 H9 c# m+ l5 O; ]' p+ [
update_cursor
N o' v" u/ _/ q: l! Q
end
6 ~9 p% q/ Q3 v" \
#--------------------------------------------------------------------------
H; m ^7 e9 o# \% A2 n
# ● 关闭窗口
# x3 O; {1 B0 N, y: w4 U* j
#--------------------------------------------------------------------------
; v4 r$ v, d6 t6 D* u
def close
% y! K) O" E5 A9 J
super
- t$ x* L3 j. G' u$ m! T' B0 C$ ]
@extra_window.close
$ Y% S" p+ p- W7 Z% T3 q6 R# i
@extra_window.deactivate
% O) g- S0 C/ I5 X
end
/ R: V* v! m- ?/ V/ I8 h& {
end
4 g1 l. P! V& A" }
5 K# o8 V% M6 `& y6 U) q
#==============================================================================
) V; j" a( r) D k4 F. }
# ■ Window_NumberInput_Ex
. m2 ^1 v9 S/ ?- i
#------------------------------------------------------------------------------
6 e, G9 q K# N; H
# 新的数值输入窗口(NewClass)
* I4 L0 L6 t4 D9 @( M/ T
#==============================================================================
. Q$ C# P& e7 z1 p! u* M* R0 G8 O6 {
class Window_NumberInput_Ex Window_Selectable
8 x% U* a, V8 ~5 g t" U
#--------------------------------------------------------------------------
( e% Q H- @$ ]
# ● 定义实例变量
! o- }, V) N+ u- j4 k" O
#--------------------------------------------------------------------------
9 E3 @) E( y9 N' q* Q, \
attr_accessor number_proc
. i% H- x5 L2 c1 }% ]
attr_accessor index_proc
- I8 v) j; ~+ o2 q/ D
attr_accessor close_proc
, I! E( T3 _ E3 l7 }4 }) q
attr_accessor refresh_proc
/ O( `* u7 L) m7 g4 c
attr_accessor number
# h0 o1 _3 ] I3 h4 s$ R
attr_accessor digits_max
( _: F, x0 o. P2 ?3 y
attr_accessor variable_id
, W9 v, u% ` _1 I6 t. E
#--------------------------------------------------------------------------
! j* ~, o( G6 ]1 _* P3 u
# ● 数字表
7 L; H( c. a4 Z4 g! P# `
#--------------------------------------------------------------------------
/ I8 l( j+ [" ]- Q
TABLE = [ 7, 8, 9,
% |" j5 x/ d' ?0 D
4, 5, 6,
* o; v1 N+ [& ~0 k3 ^+ Y
1, 2, 3,
$ m, ^. O4 g1 M( B2 b0 U8 j" E0 t& [9 A
'←',0,'确定',]
4 l" k' T. ^) ~( ]( ~. n7 s
#--------------------------------------------------------------------------
; h, N6 Z& q3 @$ J
# ● 初始化对象
% I/ m. M2 i. `8 _# E
#--------------------------------------------------------------------------
1 u/ @/ y* I; m `7 }) R3 k
def initialize
( Y+ V- Q8 l8 s: s$ J; o
super(0, 0, 120, fitting_height(4))
& U% Y; f5 ~5 f" J7 o8 X
self.openness = 0
6 Y3 ?/ W3 c4 \$ O# _8 O1 R1 I: R2 P
@index = 0
$ Y: ^, W0 W- j. q: Z
@number = 0
. ~+ X" v7 }2 C- T9 v
@old_window_index = 0
/ J7 X" o7 G- X# u( T
@digits_max = 0
3 i, M* L3 E: ~- W( u" R+ S
12.times {i draw_text(item_rect(i), TABLE[i], 1) }
) w# O" X3 `2 g6 x% `
end
- G. K, E0 k. e* e5 ^: I5 _2 k$ G
#--------------------------------------------------------------------------
8 _, n- ]3 Q/ M" e; r
# ● 获取项目的绘制矩形
; A ?8 J# Y& O$ _4 P8 \
#--------------------------------------------------------------------------
5 I; {# i( d1 h: ?3 v
def item_rect(index)
3 j) t* g Z6 g9 ~9 ~7 p( C
rect = Rect.new
) v" G/ D! L4 p% S
rect.x = index % 3 32
9 f3 ]3 {8 V3 |" }4 K# x1 {
rect.y = index 3 line_height
, P; _' X: j! a( l
rect.width = 32
9 d. U/ G( ?3 Q) K
rect.height = line_height
, O8 l* a3 ^2 E1 v3 ]- B
return rect
& \ Q9 L7 R) M
end
5 I% _) k) h/ o- [0 f9 g6 T6 q5 l1 o1 [& R
#--------------------------------------------------------------------------
0 o+ ?# m) t* t B6 C
# ● 将光标设置到鼠标所在的位置
/ e {$ _ y2 L- A3 A
#--------------------------------------------------------------------------
( G3 h& b C; q- v( |
def set_cursor
# L5 h$ b9 ?7 }, Q
mouse_row, mouse_col = mouse_window_area
( z/ f5 @# U, e1 N4 N9 n
if mouse_row = 0 && mouse_col = 0
# H4 g+ `4 h: r5 ?$ A
new_index = mouse_row 3 + mouse_col
5 Q& J7 z" {! ~7 ^( ^8 ^) m. B
select(new_index) if new_index = 11
$ E" ^1 p6 `0 V% P s
end
7 {! Z. p) t# e9 E; Y
end
; y' W! D, T" K$ L) j
#--------------------------------------------------------------------------
8 ?. Y+ L* z7 ^2 `3 {, ?
# ● 判断鼠标位于新数值输入窗口的第几行、第几列
( X- b( f$ @7 Z. D8 X
#--------------------------------------------------------------------------
; N: H: z8 K1 F! e) \! E
def mouse_window_area
% B \) w3 A4 X, Y
if viewport.nil
9 i/ y" w9 @( @7 c; v; D! v' s$ e
vp_x, vp_y = 0, 0
% U4 k. P/ E) t1 _3 k5 l5 H
else
% v0 y/ x7 p8 `9 U3 y
vp_x = viewport.rect.x - viewport.ox
# I' l' d0 s: v/ q) O1 f9 Z
vp_y = viewport.rect.y - viewport.oy
+ R( z; P6 b7 h3 J, A* u9 q" K2 x" ^) y
end
+ N; V7 ]2 O% W
mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
8 v2 s3 P+ [9 v0 N4 q) v7 y
item_x1 = vp_x + x + standard_padding
' }% ~4 x$ U1 C4 I5 Q+ z! _# K
item_y1 = vp_y + y + standard_padding
9 P z; a q6 M/ a0 m
item_x2 = vp_x + x - standard_padding + width
: f! b$ d$ M, `8 O
item_y2 = vp_y + y - standard_padding + height
2 q: u' j- e) y: h' B
if mouse_x item_x1
0 B0 B5 w' {* j) R2 n- r) r3 {( s
mouse_col = -1
m( \. m4 a; D$ M/ I2 g6 q. l
elsif mouse_x item_x2
# Y! o& I7 D) S+ b. M! W& B
mouse_col = -2
) L! |1 r+ p2 m7 ~2 E# M3 X0 k
else
4 g# d6 x' p7 Z
mouse_col = (mouse_x - item_x1) 32
f4 c' m* {! g. X; ?1 O
end
3 y8 C, @8 _' w% ~- s3 `
if mouse_y item_y1
7 I" }8 U% J2 u8 @
mouse_row = -1
) u" r) R# q( M8 u3 `, M4 ?
elsif mouse_y item_y2
. p7 G e9 _& \7 h( L
mouse_row = -2
' F* _6 ? p& Y
else
9 `9 H/ k$ o- K
mouse_row = 4 (mouse_y - item_y1 - 1) (item_y2 - item_y1)
* W" W- ^5 L6 M" c C
end
) v6 a$ L0 {& f2 d1 o7 x/ O' O2 t
return mouse_row, mouse_col
& N0 N% @% \2 E. B
end
* V, W1 f# d B' f9 r
#--------------------------------------------------------------------------
% L; y+ K9 S% ?
# ● 获取文字
) B2 \) T( Q6 |& \3 n( _
#--------------------------------------------------------------------------
S9 U/ Q5 y' M4 w& t* |$ ?
def get_number
2 h- B8 { D% d" c
return false if @index == 9 @index == 11
, C" J" u. R8 J3 k& y P
return TABLE[@index]
% S. e1 T$ F% J5 [
end
6 a# @+ H5 @! [+ A2 c. p
#--------------------------------------------------------------------------
5 v. D& l9 m: J5 A5 h: _9 ?2 E
# ● 判定光标位置是否在“退格”上
- u$ o1 B% H; ]& @6 R" M; H6 G/ M
#--------------------------------------------------------------------------
" K2 _3 o, t2 \+ R- p9 A/ V4 t
def is_delete
$ g1 F) z% l0 ^) j$ Y, O0 T
@index == 9
! c" p |) _' J3 }
end
/ d2 _( y9 ^8 ^4 t0 F
#--------------------------------------------------------------------------
! S3 c* c' ?9 Y6 w( w
# ● 判定光标位置是否在“确定”上
+ _5 \( K9 t- h# z* x5 P( o) O
#--------------------------------------------------------------------------
* m5 L6 {1 w& |* b6 ~
def is_ok
" L# G) e# V+ s5 S" o, r
@index == 11
6 m9 n' d. z! p$ q# K1 s
end
/ Q+ b" P" g. H0 A. n6 X% U3 j
#--------------------------------------------------------------------------
0 Z$ h6 b1 E7 V; s
# ● 更新光标
% b$ f) j0 Q' w" D6 m2 ~
#--------------------------------------------------------------------------
- c: x2 y; U7 l
def update_cursor
- U7 X" G6 F; E7 A* `
cursor_rect.set(item_rect(@index))
4 z1 O, M# w9 r' R& x6 K0 m
end
" }. J, N2 ^1 }) M
#--------------------------------------------------------------------------
! o/ L6 l `# Z: P1 S3 `6 @8 j, |9 d3 J
# ● 判定光标是否可以移动
# P) k7 ?& o& O1 u
#--------------------------------------------------------------------------
% z! D0 w0 D1 L$ ^1 k8 n
def cursor_movable
/ P: W; ~2 d7 u" f8 s' h% \
active
8 {: ?% T4 ~4 J1 H& S
end
8 J, v: [2 A1 A) c+ Q
#--------------------------------------------------------------------------
1 y: x/ i e v, A
# ● 光标向下移动
; v( E D& P: K& K
# wrap 允许循环
j! U: z8 O3 A4 W! W$ [$ A
#--------------------------------------------------------------------------
; E: r" y( |- J* X. U' Q& r; s* s
def cursor_down(wrap)
0 \/ ^% I3 T1 u1 P$ [
if @index 9 or wrap
0 o# Q# ]4 [" G# k$ i
@index = (index + 3) % 12
; d# i, |" J6 s' {. i# d- U2 U
end
8 Y1 {. L a- f. S7 a
end
8 R4 n8 w/ G' X6 O" ]" j
#--------------------------------------------------------------------------
* B. F* [0 m7 [1 ]' k8 m
# ● 光标向上移动
- N( W$ J4 B, C4 r7 U
# wrap 允许循环
' [* K( j/ h4 B( C. D2 ?
#--------------------------------------------------------------------------
3 W8 i w+ Z, A( r* y. I/ g
def cursor_up(wrap)
1 G* a! Q1 K! K- @
if @index = 3 or wrap
" Y; z4 T: s2 s* L! n3 b! e; `1 j
@index = (index + 9) % 12
8 C0 R# p+ N' Q; X, Y- E! L6 }/ I
end
2 T; g1 b( J9 V+ v" D' y
end
* B* G* k+ a9 y2 W: [8 [6 b
#--------------------------------------------------------------------------
1 ^( K. m. ?- j, b' P& K
# ● 光标向右移动
3 h# Z' N) j+ h$ [; c ^
# wrap 允许循环
2 |" d% f* T0 d
#--------------------------------------------------------------------------
k2 O+ w" M2 h9 M) j
def cursor_right(wrap)
" x, `2 c3 ]( Q' G4 d) `, u
if @index % 3 2
- Q8 C& |7 c; B+ m: n
@index += 1
$ I. }6 Y5 N7 ~
elsif wrap
- O6 d; O# m, J9 d# J+ k$ I e
@index -= 2
' y* [+ R1 y( b% r" p" \3 Y" |
end
$ T5 V5 G+ f8 s2 Q0 e
end
1 l; z- c, g9 Y6 w0 U A
#--------------------------------------------------------------------------
. N% v- W1 E$ \% X+ f0 e0 _
# ● 光标向左移动
- M4 z {% _% B! a9 @5 a7 k, H
# wrap 允许循环
8 ?5 c2 n9 K2 \& X$ `! J3 G
#--------------------------------------------------------------------------
5 ]/ S: n& q! h7 u2 j
def cursor_left(wrap)
& G- q* ]( A. t: C+ e4 L" A/ u$ e' k
if @index % 3 0
- e6 U; U% H; W( _
@index -= 1
$ W% @( c0 C' g U
elsif wrap
]; @0 a+ f& a2 D& z Z
@index += 2
) ]7 X+ Z3 B6 h; e9 ]1 [5 D! w! u
end
; _/ o O' g- e1 S; J9 l- T
end
2 x4 v. V2 @; y! @9 I
#--------------------------------------------------------------------------
! n7 J4 L7 o2 A6 ?5 Y4 P# D+ _
# ● 处理光标的移动
( \; u" l W. G ^! C
#--------------------------------------------------------------------------
Z H* V! L3 i* k4 A. _8 h
def process_cursor_move
/ z; r2 A9 \' F& M
super
2 L) U" ]: e1 y* ~! o
update_cursor
~$ R$ i* ^( O5 |' g: g
end
' j' C' T! \& j6 J: B/ h, u3 W
#--------------------------------------------------------------------------
1 d) ?8 Z5 m% f$ V6 S: s
# ● “确定”、“删除字符”和“取消输入”的处理
/ N/ Z) l/ t1 K5 z+ k
#--------------------------------------------------------------------------
" d- x+ G* m. C3 l7 S' i; P2 X
def process_handling
- o. l7 s. d: g' J, m/ _
return unless open && active
+ O; I# ?0 Q7 ?8 A
process_jump if Input.trigger(A)
8 a$ q/ O/ c* @% H. {
process_back if Input.repeat(B)
' b8 ]- \, D3 i' I9 X1 s2 ~% c2 W
process_ok if Input.trigger(C)
8 X+ }$ M! L4 S
end
" Z N$ l) i$ e6 b4 u& n
#--------------------------------------------------------------------------
o, _7 c, _+ `8 E1 a
# ● 跳转“确定”
( i2 t0 [- G2 f; ^
#--------------------------------------------------------------------------
: l% f6 _( O; }, O1 f- b$ |
def process_jump
, p& m. w$ b7 K% k/ T# F. V* P
if @index != 11
' l% z: Y% p# I: {% h, `
@index = 11
4 R1 k: W& r9 p# \* o4 E4 Q
Sound.play_cursor
4 \" p, g6 m9 J; ~: Y8 z
end
0 k4 V; E6 V" j9 l
end
) g; [" F; {% B) m5 ^, L
#--------------------------------------------------------------------------
4 C$ v% z- a6 l+ k4 S* @ t
# ● 后退一个字符
' f$ _1 q9 P% g' Y \; t5 h
#--------------------------------------------------------------------------
B e( b0 ~ Q
def process_back
& {/ u/ u- g9 a: S3 T0 r
Sound.play_cancel
* m4 O* e( H/ k- l1 g
place = 10 (@digits_max - 1 - @old_window_index)
: [2 Y% b$ J7 h" R/ m+ b! Q) k
n = (@number place) % 10
) J& h' K% x3 O) a' v1 n8 J
@number -= n place
; v: j U6 x5 ?" l. U/ J
@number_proc.call(@number)
, i; _+ T0 H- b* I
@old_window_index -= 1 if @old_window_index 0
3 @. e S7 X+ I+ e4 F5 L# L
@index_proc.call(@old_window_index)
: u$ V2 l' f& ~ g& h
@refresh_proc.call
* s9 y9 E7 z( N
end
8 a6 R! Y' A7 o( s7 C8 M2 g( G
#--------------------------------------------------------------------------
* F& n/ v( S& _/ B* E. S$ n
# ● 按下确定键时的处理
/ s# T( m+ K' r: h* o0 r) s0 e: e5 P ~
#--------------------------------------------------------------------------
/ s- I) _- B1 h$ s6 S- y7 ]
def process_ok
+ m+ }& W ]1 F1 Q
if get_number
; d6 Y# D* ]0 D) Y
Sound.play_cursor
7 ?/ n8 N0 U% e( {, {7 ~
place = 10 (@digits_max - 1 - @old_window_index)
0 L [* R- h/ v! p: F! y
n = get_number - (@number place) % 10
+ j. @1 u- |6 R7 p3 y/ M! K; O" x! }
@number += n place
! D: H. |! z0 {! a7 f& v: n4 s
@number_proc.call(@number)
. H' R9 X1 m8 e7 m
@old_window_index += 1 if @old_window_index @digits_max - 1
9 F8 T- n9 c/ ~% n
@index_proc.call(@old_window_index)
2 j: w! q# U3 @; V% g4 _
@refresh_proc.call
! k& L, y) @- g4 G) c1 E& p& d* f
elsif is_delete
7 R4 i' f. N+ P: ]
process_back
2 d- K, j4 r8 U+ \6 r' D: L
elsif is_ok
% x$ U! }% B. T2 D
on_input_ok
% d! o. I& g: j6 c2 m: Z; L
end
1 h4 X, }' d0 |
end
& X! u5 m: t5 X' H
#--------------------------------------------------------------------------
4 l" R5 H* h, D9 G3 {( t) r0 L
# ● 确定
# K" Y5 h& L" ^1 M0 |. ], S( `+ }( c
#--------------------------------------------------------------------------
* \5 r+ T, w" a- O- a& m2 m
def on_input_ok
6 X* h+ q& W3 J8 X+ h M
@index = 0
; o0 p* i0 |7 y2 N; Z
@old_window_index = 0
7 b* {, ^% s7 h" @6 i k
$game_variables[@variable_id] = @number
0 y* y" Y: V% s- w( R- `) k' U
Sound.play_ok
# R' O2 m. J/ _- {& e" s$ v# u
@close_proc.call
/ u6 i( h4 Y7 T+ \8 e
end
3 O; i/ j2 S I" v' O9 A2 ? D) _ y
#--------------------------------------------------------------------------
7 V: b/ m: y- e+ V) y1 D
# ● 方向键移动光标时将鼠标移动到对应的光标位置
9 A! `; _4 C5 L" H
#--------------------------------------------------------------------------
: q% r7 a$ W, b
def set_mouse_pos
! h- Y7 e2 V/ R/ `0 K) {: p
if viewport.nil # necessary!
, w4 k5 p, W- j7 C/ S9 B
vp_x, vp_y = 0, 0
- P% R9 y0 Z' D n* B7 I$ t$ \; S
else
, E/ _* Q( d1 d- D
vp_x = viewport.rect.x - viewport.ox
) N) _. |: ^7 `: u
vp_y = viewport.rect.y - viewport.oy
- K, D2 |2 G" S2 o
end
% V: G8 M1 y8 K
item_x1 = vp_x + x + standard_padding
: P2 {- ?+ r" P* y& f( |/ c
item_y1 = vp_y + y + standard_padding
2 C+ c* ~3 k# K% f+ L8 t* y
get_index = @index 0 0 @index
, p! c- o0 \8 a; i/ a, E N
new_x = item_x1 + 32 (get_index % 3 + 0.5)
: I8 o, l/ [# b
new_y = item_y1 + 24 (get_index 3 + 0.5)
) [ L! Z. v' D$ t) q4 f
Mouse.set_mouse_pos(new_x, new_y)
5 t% o& A+ w9 c, ~
end
. w9 W, v$ X. b6 {! n* x3 E
end
5 j) Q6 @4 C3 e* N l
3 k( Q' n6 |0 h& p- K
#==============================================================================
' H; E/ A3 B9 k: r8 y& _! d& N
# ■ Window_Message
$ H- h$ {6 ^3 t8 ~7 d# J
#------------------------------------------------------------------------------
. Z9 ]5 h5 o4 `- C8 f
# 显示文字信息的窗口。
3 s, I% Y" Y4 ~0 k' x6 k
#==============================================================================
, J4 O! O$ S3 v( o3 R
class Window_Message Window_Base
! V' [) T6 O( y$ Q* u2 L
#--------------------------------------------------------------------------
: F1 Z7 y: I! E) A
# ● 处理数值的输入(覆盖原方法)
9 x& `) @2 i! Q. e) d
#--------------------------------------------------------------------------
; F9 F6 e- Q2 z o# K! x4 I4 R
def input_number
# j1 e; K% K( N# e
@number_window.start
1 ~/ W( V2 n5 y: V
Fiber.yield while @number_window.extra_window.active
& E, O# h! P- M) g) K6 L
end
) c2 d6 o! k N) _. q
end
( a5 m9 c+ ~5 s( h% W' T
8 j2 u' [9 s m, ]0 T9 t
#==============================================================================
. w5 j9 W- u1 a2 X4 R0 W' D6 @
# ■ Window_PartyCommand
. d7 B5 L$ j) {% Q- d4 ]
#------------------------------------------------------------------------------
1 C5 U) N7 j( s# q' J# g2 Z4 a
# 战斗画面中,选择“战斗/撤退”的窗口。
& t& X r0 }! C+ s4 P
#==============================================================================
$ U8 I D" W) C# s% D, m
class Window_PartyCommand Window_Command
, H% a& A g( S- ?2 u5 f0 E8 C7 H
#--------------------------------------------------------------------------
' Z# Q' L3 p5 U+ ^" G9 G: [. y, r
# ● 方向键移动光标时将鼠标移动到对应的光标位置
$ Z) z5 W# f- l' W: B W4 t5 \" z
#--------------------------------------------------------------------------
) B7 e3 |1 R4 _4 \2 D1 n
def set_mouse_pos
9 L6 u8 g7 z& b. v& n+ @) x. f
if viewport.nil
' ?- \% j6 V; I1 [3 M8 N# Y
vp_x, vp_y = 0, 0
) n9 S/ Z5 `" g3 U+ }# d6 G" i2 |
else
5 k7 y1 G1 O- U8 [! d
#vp_x = viewport.rect.x - viewport.ox
7 V! ~7 x! _; C; p% j4 h' X/ C
vp_y = viewport.rect.y - viewport.oy
- h8 ]+ @% s0 w8 z! O2 G5 O
end
0 {( p! x& N5 s- @! L T0 X; \
item_x1 = x + standard_padding
8 r* z6 b- `6 ~/ ]6 J
item_y1 = vp_y + y + standard_padding
# ?" J1 ^+ `( o& ~& z6 Y" ~& e2 o
get_index = @index 0 0 @index
- u6 J! E* q d/ W1 m
row = get_index col_max - top_row
* T5 Z$ I. e! L# e) g. ^4 c
col = get_index % col_max
* J7 _. M: Y5 L# j* J3 O7 L: K0 G
new_x = item_x1 + item_width (col + 0.5)
7 e* J6 B0 i: q% w( f0 n( w
new_y = item_y1 + item_height (row + 0.5)
7 r8 o1 Q. o& \' d8 E) Q" w& L g
Mouse.set_mouse_pos(new_x, new_y)
4 ]9 y8 n$ Y6 v7 E6 ?5 V
end
1 h* Y" g/ U3 j2 y, \. e
end
' _7 A5 L) _+ Q+ w* R
, M0 H& t7 b6 z; ?
#==============================================================================
9 K; o% t. i( W- t$ S& _- t
# ■ Window_ActorCommand
9 H% [7 Y) y3 s
#------------------------------------------------------------------------------
$ _7 I* ]3 V! t8 F! ]8 P1 N
# 战斗画面中,选择角色行动的窗口。
) b+ j' U5 U8 g+ Z9 r
#==============================================================================
8 j* ]- V" }, \
class Window_ActorCommand Window_Command
6 t1 M4 l9 f# M% Z5 f4 a) j6 ~ U
#--------------------------------------------------------------------------
2 W5 t$ W8 o! Z0 f& {% `" j
# ● 方向键移动光标时将鼠标移动到对应的光标位置
1 o$ A; A1 N/ v' P4 [% i
#--------------------------------------------------------------------------
& {+ ]5 ]" s0 @8 g, R3 l& y
def set_mouse_pos
6 @9 ~& i3 ]! a; R" f5 g9 u
if viewport.nil
& m8 [& t7 R' v& _
vp_x, vp_y = 0, 0
7 v' ^% E @, j0 A
else
" R: R* G9 b2 l
#vp_x = viewport.rect.x - viewport.ox
' A4 Q* ]1 d9 x
vp_y = viewport.rect.y - viewport.oy
0 n* q+ V/ U/ I' t! V1 {
end
) t5 ?0 [, z3 ^$ |+ X; G
item_x1 = Graphics.width - width + standard_padding
/ T4 v8 Z: H7 o& V
item_y1 = vp_y + y + standard_padding
q; W8 W1 v9 [: o6 }
get_index = @index 0 0 @index
4 d1 N1 H/ o5 E! x* a- {
row = get_index col_max - top_row
# x- G% r2 V% K1 j: W. R4 |
col = get_index % col_max
( l- T: w! L, q6 C8 e
new_x = item_x1 + item_width (col + 0.5)
% z- Q2 {# V# E' M2 p+ B U1 q
new_y = item_y1 + item_height (row + 0.5)
# K8 A: Y* |1 v" z& k: U) K- D% t6 h
Mouse.set_mouse_pos(new_x, new_y)
; u, w6 m# @; Y8 [' M
end
/ W0 a5 [0 h" I& ?, r
end
$ [8 o2 Z' T' I4 Q1 |* t
' s% D" D& G; C! y7 G3 g
#==============================================================================
2 P3 R9 A2 n) g1 u4 {: k1 R; i
# ■ Game_Player
0 N+ e! h, k9 t; C; L
#------------------------------------------------------------------------------
+ p5 e F6 d" X6 e6 N
# 处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
. k" }9 @% ?& Y
# 本类的实例请参考 $game_player 。
9 E s N. n/ v! H
#==============================================================================
3 e$ B) `9 s1 T+ d
class Game_Player Game_Character
% d7 U& s: ~5 Z/ @+ [9 K2 S( K
#--------------------------------------------------------------------------
6 c" C* N" u1 e5 _# R; t
# ● 由方向移动(覆盖原方法)
0 g. ?% \+ ?2 }8 Z! @% r F
#--------------------------------------------------------------------------
1 N* G& \) s: A: ^9 l
def move_by_input
# b6 o( O8 m" @6 O, j% b O
return if !movable $game_map.interpreter.running
8 D( G9 H; U' L* \. l) V
if Input.dir4 0
' e3 O/ D7 ~# ?
move_straight(Input.dir4)
9 D" x5 F h# c9 a2 n
reset_move_path
, c) n& X4 e5 j: b
else
& t& R' e8 ]' R; T5 @; I: S
move_by_mouse
- Y" j) i! n0 A! p. |
end
( [. a1 Z0 P' f# u
end
0 U& M* Y3 d6 q7 `5 |) v
#--------------------------------------------------------------------------
" _0 {# a ^+ `& ]2 i0 @. K$ K: S- O
# ● 非移动中的处理(覆盖原方法)
$ E7 ^. f5 p8 t' M
# last_moving 此前是否正在移动
4 J2 R2 ]" n# u3 Z! c$ {. H5 }
#--------------------------------------------------------------------------
8 Q+ P9 W, i P( P. ~
def update_nonmoving(last_moving)
- @' }: t. [4 _* v; ~1 J
return if $game_map.interpreter.running
3 I; a* [$ r4 \7 A
if last_moving
8 D$ M4 I, M. q/ U$ K: d) M0 V
$game_party.on_player_walk
6 h1 o! `1 v1 P, U
return if check_touch_event
3 |$ v3 w9 W2 m% E r6 z
end
/ @& X5 y D* \$ g3 P% T/ G: s3 i" d
if movable && Input.trigger(C)
( @. _# z7 h5 ]8 |6 G
return if Mouse.press(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换
$ C. |6 g# G$ ]* D9 ]
return if get_on_off_vehicle
9 E+ U( \: U' ]* o; C- R
return if check_action_event
9 d" ~. H. ]2 _3 @& l
end
6 W5 c( J; V2 W" ?7 g
update_encounter if last_moving
0 `3 ?8 G( W$ S6 C5 ]
end
5 H/ F& C9 H/ N! t5 o# W8 B
#--------------------------------------------------------------------------
& p1 Z) e7 j K! d: D; X
# ● 判定是否跑步状态(覆盖原方法)
4 i0 I% x7 w! j: h( T5 r. w7 e+ P/ d, y
#--------------------------------------------------------------------------
; N4 O7 Z; q- d! ?, F
def dash
, _" `8 d& z! J) }! Y$ Y0 G$ I
return false if @move_route_forcing
7 j y7 k- }4 L; `# G3 c
return false if $game_map.disable_dash
1 g0 [7 p f% j/ @: R
return false if vehicle
4 a5 b$ W/ u3 H0 c
return Input.press(A) @mouse_dash
2 F$ l7 e9 X6 t' I) ?% L
end
5 P `; E" J! Y9 U
#--------------------------------------------------------------------------
2 q7 l: A6 M! J2 {- v) R
# ● 初始化
8 c4 y# I- Q* v& P% i L3 s4 o
#--------------------------------------------------------------------------
$ m6 C# S6 E7 U
alias sion_mouse_initialize initialize
3 K" Z; ]' R w: [( l
def initialize
3 J0 J7 ^& @) r% J/ Y
sion_mouse_initialize
$ W- J- T$ {3 |& _7 x8 T0 E
reset_move_path
- d' w# D9 F9 Y3 l: X, o$ h
@moveto_x = 0
8 a$ F, B, U: S, Q' f
@moveto_y = 0
, ?- y# U) G, ]* f
end
9 c y! a$ t6 C9 | V! R, s2 C w
#--------------------------------------------------------------------------
; F( v; B' z# L
# ● 更新
; h/ u5 B) o3 G/ ]* d
#--------------------------------------------------------------------------
% C: Z& [9 p/ f6 C' F/ {! r$ X
alias sion_mouse_update update
6 R7 J- T3 B' T/ G- K& r
def update
- f( J2 ]) L x" c
sion_mouse_update
2 L% {- K2 S8 \. K! K/ ~9 u# C
clear_unreachable_sign
( N9 \! L; c4 ?+ D6 p2 w* L7 N, L
end
- q$ o% Y) z: _# r2 O
#--------------------------------------------------------------------------
' @) k& m( {% M. N
# ● 处理卷动
]* M( c8 ^( t: m6 [8 @
#--------------------------------------------------------------------------
7 B! i# J& s4 i) g7 v: |; Q
alias sion_mouse_update_scroll update_scroll
~- ^0 x U8 o0 o8 ~
def update_scroll(last_real_x, last_real_y)
1 g1 C$ a" y( J
return if $game_map.scrolling
+ S; m/ w2 l" h- r5 v D& `0 z% K
KsOfSionNew_Scroll new_update_scroll
4 h1 t0 b" r5 a4 X
sion_mouse_update_scroll(last_real_x, last_real_y)
5 Y2 Z9 K2 E9 I) `; Z4 A) D
end
8 p% L+ A m0 n! B% D: M) Z H
#--------------------------------------------------------------------------
+ f) G) M* J$ l% D, b0 s) L1 ~2 W
# ● 重置移动路径相关信息
) T* r6 I. ]- D- d/ p7 X Y$ X4 x
#--------------------------------------------------------------------------
# ?+ \+ F" t. N, W3 z: \6 h! h
def reset_move_path
; S2 R2 y- s" R" N% c9 X, G- Y
@mouse_dash = false
, y0 e/ y O% t+ H1 [
@mouse_move_path = []
0 M, P+ `6 [9 ]* D: w2 y
$mouse_move_sign.transparent = true
# ` u2 E- H: c) x% T
end
" S& }! k1 n+ Q: e% @' b
#--------------------------------------------------------------------------
. ~* O/ m, _, D' b6 v: k* t' o
# ● 新的卷动地图方法
1 ?3 N8 K' ^4 x
#--------------------------------------------------------------------------
" ~" H( r+ u9 e5 h0 k) D6 K
def new_update_scroll
* Y) r; z' F' o! `) }" E
horz_speed = 2 @move_speed KsOfSionMap_Scroll_Spd Graphics.width
) b1 {( I$ x4 \4 j3 `, G, m
vert_speed = 2 @move_speed KsOfSionMap_Scroll_Spd Graphics.height
6 x3 j# l7 j3 h3 z( T
ax = $game_map.adjust_x(@real_x)
) v! ~* B2 a* L, c" A
ay = $game_map.adjust_y(@real_y)
# z! | u3 f, @, d+ } ?
$game_map.scroll_down (vert_speed (ay - center_y)) if ay center_y
3 r, c6 q( ^8 x1 e+ B' ]7 q, d: z
$game_map.scroll_left (horz_speed (center_x - ax)) if ax center_x
Z# {/ Y$ A+ y/ Q
$game_map.scroll_right(horz_speed (ax - center_x)) if ax center_x
g! T8 N0 v7 \( Y! h) i
$game_map.scroll_up (vert_speed (center_y - ay)) if ay center_y
9 |" V3 T- D; Z- d- c& D' y9 P: s
end
0 F7 h& {# q( }, [
#--------------------------------------------------------------------------
, w8 y' K7 [, H# A% v' h; f# X
# ● 消除不能抵达图标
/ j& n; Q0 ^( T* V3 b
#--------------------------------------------------------------------------
$ b0 Q7 I: ]+ u& `% Q
def clear_unreachable_sign
; ~. [# a7 a7 A0 k
return if Mouse.press(0x01)
6 }! g# Q: Q& [4 t* u; F
if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0
: X0 ?% ~, p' u$ A/ H
$mouse_move_sign.transparent = true
- ^: h. m) M8 O \" @$ e O0 f% v$ y
$mouse_move_sign.direction = 2
2 k6 W' ~* }7 m' K |6 }" e
end
. h- c9 U H+ w% u
end
# w/ ]) \: M7 U4 \5 z
#--------------------------------------------------------------------------
+ `# I4 W: V) E: [# P( s G
# ● 由鼠标移动
; ^1 [/ b$ M3 ?9 X2 l) W; V! g! i( F
#--------------------------------------------------------------------------
4 c1 d8 k+ w( t5 `: r
def move_by_mouse
M" v- Q' j# M7 v% M6 M, h0 w) [
unless @mouse_move_path.empty # 移动路线数组不为空则执行移动
1 }! L# f/ d- ^7 o
dir = @mouse_move_path.shift
8 R3 G* X, ?( Y- V- N$ B+ ?
if passable(x, y, dir) && !@mouse_move_path.empty
+ ^, R0 [% w3 j5 o, {! Z; \
move_straight(dir)
, D2 f) a; Q+ x8 |) ^4 L
elsif @mouse_move_path.empty # 判断是否是最后一步
. i) k0 ]* Q! w) y. L' n7 k
x2 = $game_map.round_x_with_direction(x, dir)
+ V# d+ Q' A4 d3 i% q
y2 = $game_map.round_y_with_direction(y, dir)
: N+ E' T; N& M4 J7 ^
move_straight(dir) unless dir.zero
+ P' {9 `/ V# R4 p# g/ S
unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
7 @2 m% m) p2 F0 C) I
check_event_trigger_there([0,1,2])
3 C& f" L5 |$ ^# { D4 F E
get_on_off_vehicle unless $game_map.setup_starting_event
! I5 U, b, q3 Z/ ^ R
end
, ~1 X4 H& {/ |
$mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2
0 q1 L$ n+ d( s2 l6 j3 x
@mouse_dash = false
/ r1 R. k' _, h' d9 R/ @
elsif @mouse_move_path[0].zero # 目标点无法抵达,调整朝向→目标点
4 z( \1 c3 q7 Q
@mouse_move_path.shift
0 d* R6 P8 l! F' l! }
@direction = dir
& r+ Y' d: Z: Y& G8 b2 q) k
@mouse_dash = false
4 e r* a& H; i6 m7 Q' X2 i
else
/ t$ e1 `0 r* C3 |; \, p% }/ E7 v
draw_move_path
/ m- a9 d2 ~: `* w9 W& i1 H6 F/ Z/ Z
end
% k$ s' Q& C3 @$ \
end
9 O+ {2 u h: N `: u/ s8 x1 s/ R
end
0 f0 {7 i2 q! G% X' u
#--------------------------------------------------------------------------
& q4 ?2 w0 L2 o' f- Q8 a; w
# ● 地图界面按下鼠标左键的处理
9 L: S7 o: n' D, E( g
#--------------------------------------------------------------------------
0 @4 G8 B K6 S" z% t5 O: i W
def left_button_action
T3 M$ N& k2 @7 c; f. o$ s
return if !drawable $game_map.interpreter.running
$ E( @+ U; F. G. y# E X
get_mouse_pos
2 J1 a' k [3 y
$mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图
( D( X: w+ J: a% Q& {( [& O# M4 T
if @shift_event
0 [% Y9 O& [8 X5 Q) g
if Mouse.trigger(0x01)
/ X/ {) l* O4 `& t! y4 }' s/ ]
@shift_event.jump(@moveto_x - @shift_event.x,
5 I" s7 k9 U# W$ _
@moveto_y - @shift_event.y)
: w8 u, U9 x( _5 K( L8 ^0 S
@shift_event = nil
- X; J6 M$ j$ p6 J0 d9 b9 e' e( _
end
) u; N+ y: N3 _9 b' y! ]
return
# ?3 W$ _% O8 N. `: \# g& x& t
end
w( |( ?: M0 W# o3 l* z
if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合
$ [5 @# g2 Q" y1 N T# `
return if moving (vehicle && !vehicle.movable)
6 o& H/ o0 O) D/ i+ A! P! f
check_event_trigger_here([0]) # 判断是否触发重合点事件
+ {( `; D, H6 f, K; B' G f9 k* V
get_on_off_vehicle if !$game_map.setup_starting_event &&
* S4 g, N4 T* s3 i; X6 p/ b
$game_map.airship.pos(x, y) # 判断是否要上、下飞艇
" H; m z6 x% I% u( K: S- @
return
7 @5 b2 U k8 C' t r) P9 f
end
' d& x2 |8 {) u6 j& A
# 判断是否用鼠标启动事件
0 L0 j' ?( N) g( f. Q
$game_map.events_xy(@moveto_x, @moveto_y).each do event
3 R% m5 D% i+ @8 ?& P* |7 D
if event.mouse_start
# d& q/ L" {+ \
reset_move_path
* Y0 D) R" @# u! @; \
event.start if Mouse.trigger(0x01)
9 J6 s2 s2 M1 a* S& v
return
+ }. V1 c- Q1 E5 \* F; X
end
. k5 v5 e2 F1 g6 M+ S% m/ C
end
( m1 K7 M/ A! l
@mouse_dash = true if Mouse.double_click # 双击冲刺
- c0 y5 d% m; D& T& @' C. f
return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径
5 \! N2 |6 i6 _) _, n, l
for i in 1..4 # 判断目标点是否为角色周围四点
4 C; {! z3 `# i! E" h
if x == $game_map.round_x_with_direction(@moveto_x, i 2) &&
! {- B7 E3 Y$ k
y == $game_map.round_y_with_direction(@moveto_y, i 2)
4 ]: j6 t: c9 B: B; t6 f1 ?
$mouse_move_sign.transparent = true
: n4 T) F# p+ K
@mouse_move_path = [10 - i 2] if Mouse.trigger(0x01)
5 \3 j+ o: a* D7 ~$ a: q) F' | @
return; end
0 X; b/ i; V! R
end
. }. ]1 q2 c9 {5 @& \
draw_move_path
7 ]0 m9 S% n& t1 E( J5 P
end
, c3 L% q7 x+ h
#--------------------------------------------------------------------------
+ F. S6 p) O; m! i
# ● 取得鼠标处对应地图坐标点
- y5 H6 w7 E, ~) L% j- ^( @
#--------------------------------------------------------------------------
; I1 a- e2 Y( j
def get_mouse_pos
3 d0 e( e" P$ ~) s
$game_map.get_mouse_map_xy
, M, z r# ?" Y3 f \. X6 w) y
@moveto_x = $game_map.mouse_map_x
. [6 _. ^! c& L6 v
@moveto_y = $game_map.mouse_map_y
% S; t* P3 U, F; A
#mouse_x, mouse_y = Mouse.get_mouse_pos
' c; J7 i5 X' b1 Y. e! E% D! ^
#@moveto_x = $game_map.round_x(x + (mouse_x -
+ _7 T% r" F% k+ t& I( N: y
# ($game_map.adjust_x(x) 32 + 16).to_i + 16) 32)
! i6 Z" ?0 A |: K' P: }
#@moveto_y = $game_map.round_y(y + 1 + (mouse_y -
9 v$ F/ M" N8 E. G0 u
# ($game_map.adjust_y(y) 32 + 16).to_i - 16) 32)
: G) Q7 ~# q- `# \* s; N% S
end
7 s+ J( ?% t' c* j2 @+ w
#--------------------------------------------------------------------------
6 Z" c4 T5 ?5 m
# ● 绘制移动路径 @array[move_directions...]
/ l. l1 H2 U2 V2 V/ f0 \( N; v |
#--------------------------------------------------------------------------
/ a1 F$ _- C% B$ ~, x: U* `" T$ C- {
def draw_move_path
; [7 a8 [$ a) g! Q
#temp = Time.now
) x. D& ^% |* J+ B
case @vehicle_type
" \- N3 P7 k: f; u, s( h7 C* f
when walk
' b: t0 _9 J; g) C; i2 i9 v
draw_walk_path
Y& L' w) _3 v, E: W
when boat
9 i1 C0 ]6 ~ M' f) k; m: |
draw_boat_path
5 I: D) E! l& P6 z% H
when ship
' ]1 K2 x N: |) @4 R6 h
draw_ship_path
6 W0 ?% X5 ~/ V) D# W
when airship
7 t$ j( c( c/ [$ e0 x
draw_air_path
/ q# |, H. _1 J ?& @+ S
end
9 F5 \- p7 Z- s; }
#p (Time.now.to_f - temp.to_f) # 测试效率
, x& s$ j0 v ~; H c; j# _
end
5 p+ m2 k q7 V8 C
#--------------------------------------------------------------------------
1 l4 a" t3 R: r/ {
# ● 判定是否可以绘制移动路径
9 R2 W/ t2 A) J( e$ k5 m
#--------------------------------------------------------------------------
7 H6 l+ X" [; b7 F
def drawable
1 g( j4 [; o; J' A3 y8 B4 a
return false if @move_route_forcing @followers.gathering
4 `8 O: p" `& G6 `) p
return false if @vehicle_getting_on @vehicle_getting_off
( E. |# a/ r, T
return false if $game_message.busy $game_message.visible
! S2 l. s1 _/ j. E( l- ` ~* i+ X) z
return true
' _! _4 g( K$ q5 B+ @
end
* c! V$ A8 i [* ^8 W! B! d4 ]
#--------------------------------------------------------------------------
* T5 W$ a; g% W2 a. R
# ● 绘制walk移动路径 @array[move_directions...]
# S1 X5 ]& S9 m8 a: k q9 ?3 L
#--------------------------------------------------------------------------
5 P% L Y* q. c1 b2 P7 M* _
def draw_walk_path
) w8 @! W4 H+ \8 f( l) }& Y5 Q% r
# 准备绘制路径表格
: z3 A ~: z- T+ s4 ?5 \
sheet = Table.new($game_map.width, $game_map.height)
$ U9 a+ P$ h4 g, O3 S$ w! `
reversed_chase_path = []; chase_path = []
' C2 Q" Q: O8 h7 P# C/ b2 y
reversed_chase_point = []; chase_point = []
8 _& U0 @3 Y. x* @5 H2 G! p6 w
new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
7 V0 r* s. M' K# o8 J3 L
sheet[x, y] = 1; sheet[@moveto_x, @moveto_y] = 2
5 Y5 n6 i0 t/ |+ L1 c
reach_point = false
% ^7 P% C+ h3 |# F. |( u9 g; F
step = 3
, [0 |: Q+ L- L2 c( m9 f% r
loop do #loop1 开始填充表格
+ ~4 n7 X7 }" `: k7 `
draw_path = false
- r1 L+ T0 ~7 i. Y
check_points = new_start_points
/ H& ?1 g$ M" ^* ^1 W
new_start_points = []
0 r+ S& O1 `- F7 O, Q' q
loop do #loop2 从起点开始正向填充
$ [ L) U9 T( B; z, S M/ E
point_x = check_points.shift
% n/ C8 ]# H: r: N
break if point_x == nil
J L, e0 p: f: V! @
point_y = check_points.shift
4 V" S2 o% v- \ t/ u
left_x = $game_map.round_x(point_x - 1)
0 e6 @2 C) P$ @, j* M
right_x = $game_map.round_x(point_x + 1)
6 f$ j+ I3 V! e5 W9 w
up_y = $game_map.round_y(point_y - 1)
" Z# W2 e- { }+ z+ n! J
down_y = $game_map.round_y(point_y + 1)
# d4 N' T% e1 g/ H B+ b& {
# 判断路径是否连通
$ i( j% @1 m) ]1 Q
path_step = step - 1
, i# T4 P _3 E% C% I* D
if sheet[left_x, point_y] == path_step &&
3 g6 U* Y# m: q3 \3 N
$game_map.passable(left_x, point_y, 6) &&
* O3 A% u" x; D" _9 Y) N& K. C+ `
$game_map.passable(point_x, point_y, 4)
! |% Z* U G8 _, p. T/ A% ?3 ?' N6 S7 N
chase_path.push(4)
$ ]8 f9 a* s2 D9 v! B
chase_point = [left_x, point_y]
: K% R9 Z9 o9 s0 E( y
reversed_chase_point = [point_x, point_y]
+ O) u1 z$ M6 ?9 O6 k0 J
reach_point = true; break
/ {5 U" b0 D. T3 i1 O
elsif sheet[right_x, point_y] == path_step &&
/ D" H3 j* C; g: y
$game_map.passable(right_x, point_y, 4) &&
% b) F) b/ w. e6 G' p p6 L- a
$game_map.passable(point_x, point_y, 6)
8 ]1 j7 v+ L) Z8 s* n6 i/ F. Z9 S
chase_path.push(6)
+ Y: `4 @$ {! E% x; g5 L4 ] ~
chase_point = [right_x, point_y]
6 a4 H6 z, x1 x- U" Z/ m7 w
reversed_chase_point = [point_x, point_y]
, H5 \" h X: @0 f
reach_point = true; break
; G3 l+ h r( q. {; |7 {4 j' J9 S
elsif sheet[point_x, up_y] == path_step &&
% O1 F" n& N( H( E2 ^
$game_map.passable(point_x, up_y, 2) &&
3 o7 }+ z5 q$ @$ J7 I5 _5 Q' F8 I
$game_map.passable(point_x, point_y, 8)
5 S& {8 ^& Z) a+ N! W0 g( `
chase_path.push(8)
$ E$ C1 _% t. b% c, _8 {/ _3 H
chase_point = [point_x, up_y]
) S( }% w2 ^0 Q6 s. s. j1 ^6 V5 M7 [ h
reversed_chase_point = [point_x, point_y]
9 b, B5 E5 @+ r/ t3 s+ Y3 S
reach_point = true; break
! `* R3 ? P3 E( ^7 O
elsif sheet[point_x, down_y] == path_step &&
; S$ f( [) ^) F) t4 M
$game_map.passable(point_x, down_y, 8) &&
, G# k# J3 v/ N) L1 S* w9 C n2 c# |
$game_map.passable(point_x, point_y, 2)
2 u* U7 O5 h3 ]3 \1 d& R
chase_path.push(2)
( }( h; x* k7 R- _) ?
chase_point = [point_x, down_y]
$ |6 S& e* I, Y
reversed_chase_point = [point_x, point_y]
5 o) I, y. K; C# D K
reach_point = true; break
+ g7 m3 m0 ^6 S& N G
end
7 @% X R, W% a s7 h2 ?% W
# 以需要抵达该点的步数填充路径表格 #
9 J8 ~, |, r* w6 N( X0 N( u
if sheet[left_x, point_y] == 0 &&
- W; k v1 u% N( P7 ]% \
$game_map.passable(left_x, point_y, 6) &&
7 k. k5 M% z$ O4 A+ C- _
!collide_with_events(left_x, point_y) &&
) x: D) d/ ]1 J9 q
$game_map.passable(point_x, point_y, 4) &&
3 V! L: z" X* h5 C& [+ J/ g) m* ^. R
!collide_with_vehicles(left_x, point_y) #judge_end
: I2 [8 U( i: ?7 w& Q
sheet[left_x, point_y] = step
3 D9 x5 |( W4 r* f) d7 k
draw_path = true
1 o# m# o/ j4 `9 ]) h O
new_start_points.push(left_x, point_y)
6 ?3 Q6 Q& P9 H$ n1 e: m
end
% R$ y. P& ^0 N0 P! L1 T8 P
if sheet[right_x, point_y] == 0 &&
. o% T% X, y( g: D& c" }0 f! q% _
$game_map.passable(right_x, point_y, 4) &&
9 Y. O0 ]- k, Z; N9 n x w$ {
!collide_with_events(right_x, point_y) &&
9 V6 U7 n# e. t$ f0 T" y
$game_map.passable(point_x, point_y, 6) &&
7 F% g3 \3 K( y- E
!collide_with_vehicles(right_x, point_y)#judge_end
; x0 ?- O" M5 E) V3 \" L R7 d3 m
sheet[right_x, point_y] = step
- B* q& [0 v" n- F0 l- M
draw_path = true
# n1 n; F Q$ J: z$ M
new_start_points.push(right_x, point_y)
W. p$ c' u t# ]9 x! }* n
end
. W( s, ?7 z" u* Z
if sheet[point_x, up_y] == 0 &&
% W+ F$ f4 }; b2 B( z R
$game_map.passable(point_x, up_y, 2) &&
" d$ t R4 p9 x. S
!collide_with_events(point_x, up_y) &&
* i9 j) @/ t5 {! y
$game_map.passable(point_x, point_y, 8) &&
* K! s+ ~" e6 a0 t1 q7 }
!collide_with_vehicles(point_x, up_y) #judge_end
/ e; H _! Z4 f! Z1 h
sheet[point_x, up_y] = step
% U+ g9 J* R# A
draw_path = true
' K# {8 h3 V) n$ d h' \" R! ]
new_start_points.push(point_x, up_y)
% s# h& D3 K4 D9 o" }
end
S3 K% x* f, i0 L7 i# W& U
if sheet[point_x, down_y] == 0 &&
+ f* Z; C' l. F ]# W" [0 W9 M+ n
$game_map.passable(point_x, down_y, 8) &&
. X. y, _( T6 q ~
!collide_with_events(point_x, down_y) &&
9 J7 r" w& C- y! R
$game_map.passable(point_x, point_y, 2) &&
k5 h& y" G Z! a: `1 y6 O
!collide_with_vehicles(point_x, down_y) #judge_end
1 e* t, b6 \% y# n) a
sheet[point_x, down_y] = step
% {5 }2 `& Q8 l3 m2 ^4 c0 M2 A. E9 I
draw_path = true
& M8 b9 @" O6 p s
new_start_points.push(point_x, down_y)
* w* [7 ~( c2 g( Y0 S
end
\ t4 P& i( Y) d& K7 w
end#endOfLoop2
5 g* U6 M" z* \* F! \
break if !draw_path reach_point
3 v, G3 f4 f5 T( V& x$ \
draw_path = false
! V0 Z; N. C o! Q
check_points = new_end_points
8 a( y( G- D) N" G! P
new_end_points = []
{: B# }+ T# P% c
step += 1
6 w; }+ R! k, C' X
break if step KsOfSionBreak_Steps &&
$ g' W4 h9 {) M. m0 E- x% @
!Input.press(KsOfSionFind_Path_Key)
; t+ ~4 o) q) I- \3 v; a& D$ R9 b
loop do #loop3 从终点开始反向填充
: j' c$ d, X6 `) U7 D& D5 v# F5 t
point_x = check_points.shift
m7 L8 R" h1 u7 B8 p
break if point_x == nil
L5 T$ }1 T) J" |
point_y = check_points.shift
! T- f! n k& Y, ]
left_x = $game_map.round_x(point_x - 1)
: ~- `5 z% Z: w+ @
right_x = $game_map.round_x(point_x + 1)
8 ]6 l$ j1 j; R, B& t* |- K
up_y = $game_map.round_y(point_y - 1)
! L" D; Y% M9 Z- ]4 h. r* ?" x
down_y = $game_map.round_y(point_y + 1)
, ]; V* _7 L4 o- R$ {+ r+ H0 {
# 判断路径是否连通
2 C( I% ^! V4 a6 C
path_step = step - 1
8 p/ ]; O- n( L/ d
if sheet[left_x, point_y] == path_step &&
9 |& x9 H) m: F9 f' b& R
$game_map.passable(left_x, point_y, 6) &&
7 h7 N# \/ |. r" L7 n1 Q% `! ?
$game_map.passable(point_x, point_y, 4)
) i6 c# [% R0 f; ?" _1 w4 {
chase_path.push(6)
j; N6 k5 x. e3 W, ?
chase_point = [point_x, point_y]
; Z( R0 f3 p- d- Q# q$ l
reversed_chase_point = [left_x, point_y]
: c1 w6 O; l' S6 \) `- W1 q6 e
reach_point = true; break
l0 u, O" X4 T0 z
elsif sheet[right_x, point_y] == path_step &&
# H i2 Q2 [! {) t, V
$game_map.passable(right_x, point_y, 4) &&
' T0 F+ Z3 _' e* [
$game_map.passable(point_x, point_y, 6)
! R$ K3 z0 W9 i+ `3 {
chase_path.push(4)
X/ @4 o& g0 A
chase_point = [point_x, point_y]
0 `% \" g7 S4 V9 m5 D9 E
reversed_chase_point = [right_x, point_y]
- Y6 W" M% P" Z$ Z* n
reach_point = true; break
0 _5 G4 x# s' }/ S
elsif sheet[point_x, up_y] == path_step &&
7 h0 D5 P+ g, ?4 S$ Y! E+ l4 T
$game_map.passable(point_x, up_y, 2) &&
* W( K2 V n/ ~! w
$game_map.passable(point_x, point_y, 8)
4 N. g! d$ o$ y% w. m; W
chase_path.push(2)
- X3 o9 S6 v( ~: s& s
chase_point = [point_x, point_y]
) @( y& D) L8 N8 }2 C! e. w
reversed_chase_point = [point_x, up_y]
# }) p Y8 v( N7 R; r- v2 Q5 S
reach_point = true; break
' K2 x% r5 d9 O! o& F' U
elsif sheet[point_x, down_y] == path_step &&
3 a6 Z/ h% g% \; F
$game_map.passable(point_x, down_y, 8) &&
( u& @% Q. [7 o0 h; X9 _' X: B
$game_map.passable(point_x, point_y, 2)
7 l" m( ~4 s# V+ F/ c( U, F( I9 Z
chase_path.push(8)
% k' a, K7 z6 P, W) P: `, X7 s
chase_point = [point_x, point_y]
: W. N1 F L9 j8 u3 }# c
reversed_chase_point = [point_x, down_y]
; R) D2 F* Q4 [8 j, w% F7 n, `
reach_point = true; break
+ w8 _* r. F9 l- v# C0 Q
end
' R" O' c% s0 \7 }
# 以需要抵达该点的步数填充路径表格 #
: K& u" B: s. B) @
if sheet[left_x, point_y] == 0 &&
# ^/ Z* h2 ?% }5 N' G8 }! b
$game_map.passable(left_x, point_y, 6) &&
; T+ S O$ B) @9 Q: R3 I% e
!collide_with_events(left_x, point_y) &&
) N5 l/ f" z6 f8 Q
$game_map.passable(point_x, point_y, 4) &&
, [+ Z. ]9 C- z w9 o
!collide_with_vehicles(left_x, point_y) #judge_end
9 J% j* g* {" @( e0 I# ~1 B
sheet[left_x, point_y] = step
- w, f5 p4 V. V% ]8 ]) [
draw_path = true
( z: U; X' h! a9 R0 R/ C
new_end_points.push(left_x, point_y)
6 S# p% R1 z& {& c3 w: R5 {- i
end
- C: ?) b4 a( f: D& a' N. d
if sheet[right_x, point_y] == 0 &&
$ X- w; _ V/ Z( F! ?; ~, s
$game_map.passable(right_x, point_y, 4) &&
% S* \2 s% e0 I6 Y
!collide_with_events(right_x, point_y) &&
8 u1 B- T9 L2 p( T8 P0 K
$game_map.passable(point_x, point_y, 6) &&
7 Q& s* J5 g- z0 E
!collide_with_vehicles(right_x, point_y)#judge_end
( a {' C" v, p0 E0 a5 X
sheet[right_x, point_y] = step
" |# I& x% u8 Y0 E
draw_path = true
! y$ c; v4 A. ]- y
new_end_points.push(right_x, point_y)
2 G4 U/ U; o) {6 i* N' _
end
- y h1 N7 n) ~. y2 v% Y# s
if sheet[point_x, up_y] == 0 &&
- y9 j' `8 Y; R$ |
$game_map.passable(point_x, up_y, 2) &&
9 ~' Q3 e- p" |8 B
!collide_with_events(point_x, up_y) &&
: P! H+ r9 H: K$ Z8 U& a6 F" X% o+ R; J
$game_map.passable(point_x, point_y, 8) &&
6 M! h% c; C8 U8 ^5 V2 G/ [. P
!collide_with_vehicles(point_x, up_y) #judge_end
1 Y. x1 T6 D+ t# ^ B' N
sheet[point_x, up_y] = step
' L, u1 ?: y, f: P, ~
draw_path = true
/ X9 D V5 k$ l0 A
new_end_points.push(point_x, up_y)
" Y' E4 q" G& y
end
1 x% y6 n* Z6 [$ c; |8 C5 `
if sheet[point_x, down_y] == 0 &&
! a/ V/ s4 v/ T2 x9 `$ e
$game_map.passable(point_x, down_y, 8) &&
/ d$ ~: d* E1 Y5 A" Z
!collide_with_events(point_x, down_y) &&
; S+ x) V% M% M( Z' E( f. t; a/ W
$game_map.passable(point_x, point_y, 2) &&
' A3 ^& B$ A$ s! i4 l5 I
!collide_with_vehicles(point_x, down_y) #judge_end
) {: f4 S |/ z+ i1 Z
sheet[point_x, down_y] = step
) _- o5 p; T# o3 H" x: P/ X' p
draw_path = true
6 s/ A; m2 N7 c* n
new_end_points.push(point_x, down_y)
4 E; S6 w6 L5 [( H/ W6 o: |
end
1 a$ b+ L, c5 ~
end#endOfLoop3
3 a; h( u# w* z- l% b9 |
break if !draw_path reach_point
: @8 A! R; i) l4 o, ]) W, ]
step += 1
% A; k& O- d6 B7 I% H# u8 z% i
end #endOfLoop1 路径表格填充完毕
3 T+ W# y; h) v, I3 @4 o
$mouse_move_sign.transparent = false
, \ ~" j0 C. Z1 v& s: v- N
# 判断指定地点能否抵达
/ _. D# j0 o+ \0 m! @9 w3 q
if reach_point
8 k0 S; J, a$ n. W* ]% `% ]
$mouse_move_sign.direction = 2
/ A5 X( ~! E8 p: q* U
else
, {1 Z! s8 o2 X. b9 Z) ^
not_reach_point
9 |# W7 i5 o; R& f; N7 g( O* p# Q
return
$ a. j2 t3 z6 R+ j( J* ^
end
4 P& z" C0 U- K4 u' [
# 根据路径表格绘制最短移动路径(反向)
2 U4 I+ ]: ?+ T' G. X- h
steps = step 2 2 + 1
" b" }" F5 @* { K+ @4 d9 _. D
loop_times = step 2
& H$ a6 X, ?: Z$ O( i
point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
; {- ?8 F8 n. y; P" T1 c/ X! O
for i in 1..loop_times # forLoop
$ s/ J2 K1 D/ I N
steps -= 2
; w. `5 ^, X+ c& Y9 Q i
if (@moveto_x - point_x).abs (@moveto_y - point_y).abs #反过来?蛋疼了……
0 D# E6 _% c" d5 L8 }4 ^& w5 i
if sheet[$game_map.round_x(point_x - 1), point_y] == steps &&
4 S5 d& [" y& ]+ L7 Q' P( K
$game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
/ V4 H4 W0 A( f2 I
$game_map.passable(point_x, point_y, 4) #judge_end
. J: E% D: r7 W
reversed_chase_path.push(6)
- `: Q: }$ i( |; a7 {; d3 R! r9 ~
point_x = $game_map.round_x(point_x - 1)
0 S! G B' s& ^& s* q7 V& v& M
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps &&
& T$ F+ |9 f6 a1 q+ u
$game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
7 e# y9 t! [' f V4 t$ b: L8 U. E+ {
$game_map.passable(point_x, point_y, 6) #judge_end
: R& \' @7 R$ G! i
reversed_chase_path.push(4)
+ x) h# R9 K) s, L" Q" q+ s1 L
point_x = $game_map.round_x(point_x + 1)
- x8 L! y* d0 ~1 M
elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps &&
, }- r; r& B$ q0 w! U4 B
$game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
8 B, w( O/ i* g2 W' x7 z9 c
$game_map.passable(point_x, point_y, 2) #judge_end
% u3 d0 `# e2 {, v C6 b% c# w
reversed_chase_path.push(8)
: x2 N I; L2 u# Y! E3 W, ~
point_y = $game_map.round_y(point_y + 1)
& G) L+ W$ o$ x4 q
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps &&
$ g. v# i/ N$ _" Q
$game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
5 {! i9 K. n# s4 b' c; o
$game_map.passable(point_x, point_y, 8) #judge_end
1 R$ @- q5 U. q* H; t7 ^
reversed_chase_path.push(2)
5 i; p, J: U S- x1 F" R. h- l5 O
point_y = $game_map.round_y(point_y - 1)
0 l! P$ J- m* M7 p7 S6 w
end
1 T" D9 ^3 ]4 k8 B# M1 |
else
) |; x! e9 E, z. F$ B7 Q
if sheet[point_x, $game_map.round_y(point_y + 1)] == steps &&
: d5 _, i0 a% C" a
$game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
( Q; S% Z1 B0 K
$game_map.passable(point_x, point_y, 2) #judge_end
, h2 }/ {9 y6 o. u
reversed_chase_path.push(8)
. h) U8 t! P3 h/ e( ?
point_y = $game_map.round_y(point_y + 1)
# q; o5 y' `0 I) K; t8 w ?3 ?
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps &&
7 D. | c( {1 A5 M
$game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
b% g @! g( i
$game_map.passable(point_x, point_y, 8) #judge_end
5 R- I' H3 [2 [7 G/ q
reversed_chase_path.push(2)
1 ^6 E# g! ^- {
point_y = $game_map.round_y(point_y - 1)
7 I$ N3 I8 M7 H0 p2 n+ [
elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps &&
# A; p% ^2 l1 v# O' A
$game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
8 m+ W! V9 E# T1 r1 v7 W. ], F& y6 Z
$game_map.passable(point_x, point_y, 4) #judge_end
* ^ _1 h( F0 m4 E& P2 s
reversed_chase_path.push(6)
4 J* L/ e9 C" l4 h8 ^
point_x = $game_map.round_x(point_x - 1)
1 c) U+ y" y1 Y3 O
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps &&
' o" b0 t" y' K2 ]) x
$game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
8 o" B' l. t2 L9 q- B7 \# F7 |1 [
$game_map.passable(point_x, point_y, 6) #judge_end
8 i; b( `* x9 s9 D2 I
reversed_chase_path.push(4)
g: H% v( S9 X: u6 t' b
point_x = $game_map.round_x(point_x + 1)
% d8 A, k, j3 l
end
( \( I2 q3 G) c% @0 G1 f
end
- W7 C* R5 x! I% j, e" j0 Q( a
end #endOfForLoop
( {" S0 l3 {! V6 T! Z
# 根据路径表格绘制最短移动路径(正向)
; B8 {5 p/ R- d) u; f+ Z& F$ e
steps = step 2 2
w& D% J9 E6 n. o. q4 `
loop_times = step 2
$ \. r5 ~% z( Y" x# \; W
point_x, point_y = chase_point[0], chase_point[1]
) p+ r; Z. J0 r( i
for i in 2..loop_times # forLoop
! L" c! C( B$ A% D0 U
steps -= 2
5 t4 U- @7 f$ Q! `" O2 ?+ w( b
if (@moveto_x - point_x).abs (@moveto_y - point_y).abs
% t( T0 e9 x7 U8 `1 j( y2 `9 Y+ s
if sheet[point_x, $game_map.round_y(point_y + 1)] == steps &&
' Y/ H4 O: ~' T! Q
$game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
% f! z1 F! E; R' D6 Z
$game_map.passable(point_x, point_y, 2) #judge_end
* i* k) v' g# v9 ~
chase_path.push(2)
" ]+ M0 j Q- G) @' A( h
point_y = $game_map.round_y(point_y + 1)
2 O$ o2 N/ e$ W& y- m
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps &&
( ~& z( U ]3 U
$game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
/ ~/ q. L% ~+ ? b1 x+ Y; \( X
$game_map.passable(point_x, point_y, 8) #judge_end
) P) I% h A3 l9 y
chase_path.push(8)
( c& Y& M, j* ]
point_y = $game_map.round_y(point_y - 1)
& n8 W7 }- \% n/ b2 F
elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps &&
: n* r7 z( Q- F- y' k: c
$game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
$ N; f( b8 u, v6 F# [8 S/ N
$game_map.passable(point_x, point_y, 4) #judge_end
8 i+ o# z9 m5 x/ q
chase_path.push(4)
; p# W- p+ N3 B# D4 `
point_x = $game_map.round_x(point_x - 1)
/ a5 E! A/ W) R3 x' W/ |
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps &&
: ?0 q! s/ V% L* i6 B
$game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
- Y" A9 K5 { O' Z5 N
$game_map.passable(point_x, point_y, 6) #judge_end
0 e6 |2 Q# M) h& M& p
chase_path.push(6)
3 J$ \$ ]& h+ }% f7 T9 W
point_x = $game_map.round_x(point_x + 1)
. t* K, J) C' j: _! J$ p: Z* }0 c$ _
end
. m. M7 O7 Q2 I: O7 i4 S) J5 p
else
; }' Z5 k2 a% c. p# J
if sheet[$game_map.round_x(point_x - 1), point_y] == steps &&
' [. g6 d* P! }- D8 v( F$ a ~
$game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
4 r3 t6 z. q' j: i0 v
$game_map.passable(point_x, point_y, 4) #judge_end
9 c9 p/ M1 }/ l$ T* w9 o( |
chase_path.push(4)
4 s6 q- z+ g$ J% O3 w
point_x = $game_map.round_x(point_x - 1)
; Q$ p, L: a. c3 C5 `2 x I+ m* U" P
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps &&
0 p1 ^" ~6 c! {% e. l& G
$game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
. Q3 F" E, C/ L* `
$game_map.passable(point_x, point_y, 6) #judge_end
' P: U) r/ P1 s) J- j
chase_path.push(6)
# } U( p5 u, _6 C8 r2 H$ j( T0 L
point_x = $game_map.round_x(point_x + 1)
; o- O, w& o) K5 M3 {
elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps &&
& Q" G1 n3 b" W
$game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
# y" x; C, p; i! N
$game_map.passable(point_x, point_y, 2) #judge_end
' P# r: N* `) z$ s
chase_path.push(2)
( X8 k* \9 G: Q" ~: F' E5 \
point_y = $game_map.round_y(point_y + 1)
7 M& j, x( @ Q
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps &&
! E6 b+ ^' T' L* F
$game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
0 y& u5 f' L: b: o G) u
$game_map.passable(point_x, point_y, 8) #judge_end
8 U$ g, c, R4 C' i
chase_path.push(8)
% _1 }1 ]/ H& v* j7 z4 @
point_y = $game_map.round_y(point_y - 1)
& p6 k3 h# Y7 F2 O! G
end
* b3 `0 x) K* L
end
* j% j5 u) J7 ~6 L% }7 j3 o
end #endOfForLoop
* |# A: {6 e. ?2 H1 T9 I8 `
@mouse_move_path = reversed_chase_path.reverse + chase_path
) D% q! A& x! A+ O1 M' D
end#walk
& Z+ j, ^' }2 Z; v3 ]4 j
#--------------------------------------------------------------------------
9 `5 T5 b/ v1 L4 Y& H0 o' [ ^
# ● 绘制boat的移动路径 @array[move_directions...]
/ A q: v1 d% a
#--------------------------------------------------------------------------
7 x1 P% x% a# `4 K# Y0 Z+ r' R
def draw_boat_path
# O; a6 J+ l1 d. {8 b5 S3 K" g4 d2 |
# 准备绘制路径表格
4 d3 W+ W$ m# b0 V4 f+ J: ^5 k
sheet = Table.new($game_map.width, $game_map.height)
; w0 g. r$ I! ?
reversed_chase_path = []; chase_path = []
0 n% K0 ]+ t0 E0 ~
reversed_chase_point = []; chase_point = []
( j4 E, k8 s2 o1 ^& W
new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
5 p& h6 r) J; K$ Q. L# O
sheet[x, y] = 1; sheet[@moveto_x, @moveto_y] = 2
2 n/ M" f0 E) [' \8 Y2 S; p) t
reach_point = false
" {0 g+ ^$ q7 m, x9 P" `
step = 3
* J w* ` R, X2 L. I- P( o
loop do #loop1 开始填充表格
) H I+ G# O7 I B$ ?& t
draw_path = false
! V0 B. B! j0 h! v3 w+ E2 K$ U* Z
check_points = new_start_points
, ^% t* A( I4 h& x
new_start_points = []
- _0 A2 I8 N2 T2 } X
loop do #loop2 从起点开始正向填充
4 [4 _- S& k1 ?3 U% |! U
point_x = check_points.shift
; E! q/ R1 C; {& j) Q/ W5 s5 I# K- |. L: f4 N
break if point_x == nil
6 ~2 Y' }: [; @, z
point_y = check_points.shift
' m3 a, P. j" @% E7 y( T; k e
left_x = $game_map.round_x(point_x - 1)
$ l8 k' l9 W; z! _( Q h7 J" e/ w
right_x = $game_map.round_x(point_x + 1)
$ L1 d, O- h; H" X
up_y = $game_map.round_y(point_y - 1)
* c) B/ ~) ?6 i3 b2 | |& H* C
down_y = $game_map.round_y(point_y + 1)
0 ?% M z7 N2 l2 B8 z& C7 J
# 判断路径是否连通
' k% K J% r* q- i
path_step = step - 1
, H' N. k' p3 s# K& [6 M N, [
if sheet[left_x, point_y] == path_step
2 s8 F4 s. C2 J( Y4 ?% T- J2 B! t
chase_path.push(4)
" G Q5 }$ n, p: `0 ?0 w, S
chase_point = [left_x, point_y]
6 }4 g0 `+ n: d
reversed_chase_point = [point_x, point_y]
8 z/ c$ J' k+ \( j2 x$ d0 d0 e
reach_point = true; break
9 w5 f2 w! c! B' ^& U) b( _! i
elsif sheet[right_x, point_y] == path_step
; C0 K. x- }6 d+ z8 E% G' w9 F& c
chase_path.push(6)
* R9 K( {+ W1 l- ~$ H
chase_point = [right_x, point_y]
/ e- e {2 V# }
reversed_chase_point = [point_x, point_y]
; @" f6 X+ j5 ]
reach_point = true; break
5 H" J P. l/ k4 Y# s7 U% [
elsif sheet[point_x, up_y] == path_step
; H9 m% f/ @# ^ M; g5 }
chase_path.push(8)
' K4 _! s$ @+ _" R
chase_point = [point_x, up_y]
# I4 o9 @& [- G* }5 b9 |
reversed_chase_point = [point_x, point_y]
) ~" Z2 N# N& M9 |$ e" Y
reach_point = true; break
1 i8 v8 e: U8 I2 B
elsif sheet[point_x, down_y] == path_step
4 F4 w- Z7 F( C* Z: P7 U) l- g; r5 {
chase_path.push(2)
/ W, a o" ^" f& E% b3 G& J) u
chase_point = [point_x, down_y]
& Y- V& R: q! l; p
reversed_chase_point = [point_x, point_y]
# v% G; n! {# }9 w9 s7 |; Y/ m, V
reach_point = true; break
. C" J# K5 q1 m$ ]4 L& Q0 U% L
end
7 a) B: U! O/ d
# 以需要抵达该点的步数填充路径表格 #
5 v" B& [5 y7 e8 @4 v# T8 c
if sheet[left_x, point_y] == 0 &&
' ]1 E1 m M% V: \9 ~* W' D$ C
$game_map.boat_passable(left_x, point_y) &&
3 m& T- x0 s! r8 \7 K2 ]
!collide_with_events(left_x, point_y) &&
. R! M9 s5 d4 K) V9 \
!collide_with_vehicles(left_x, point_y) #judge_end
+ d2 s9 R" K: t: W
sheet[left_x, point_y] = step
% d' ^0 ?3 C' r+ W3 n) Q& J: }0 @
draw_path = true
9 a+ q$ H+ M# {* w
new_start_points.push(left_x, point_y)
4 L5 j x, s" `* H
end
0 ?# u3 U, j& O- f8 U& P) D, @7 x
if sheet[right_x, point_y] == 0 &&
; R2 Q$ T4 [: W7 @
$game_map.boat_passable(right_x, point_y) &&
0 A! d* C$ P, L7 I! P2 s+ Z' t* u: L
!collide_with_events(right_x, point_y) &&
) S% k( F( ]+ d: ^3 v
!collide_with_vehicles(right_x, point_y) #judge_end
5 p; ^) v% ?' T5 ~
sheet[right_x, point_y] = step
2 k( O h6 W- m c! x: ~' g
draw_path = true
% z, p# x/ L& H2 |: w. }
new_start_points.push(right_x, point_y)
2 r9 j2 f: Y( y0 `, m9 Z
end
+ c0 L J5 B% }+ h
if sheet[point_x, up_y] == 0 &&
6 z: p) Y9 M) Z) ^7 Q$ l2 U2 V, x
$game_map.boat_passable(point_x, up_y) &&
- \" y& ~) c8 D; G" l
!collide_with_events(point_x, up_y) &&
, q2 R/ N5 T* D P5 l+ J% O% |1 B
!collide_with_vehicles(point_x, up_y) #judge_end
4 O+ B/ ]# v" C: k4 H6 G
sheet[point_x, up_y] = step
7 S0 h9 ]; a" e& Y2 P/ y3 }
draw_path = true
& \" X5 {2 L1 g
new_start_points.push(point_x, up_y)
* f4 g! w7 i1 y2 H% m7 H8 ~0 R
end
1 N1 c7 v7 }/ H5 _% o s/ r
if sheet[point_x, down_y] == 0 &&
5 h6 T" x7 [. p; X9 I; \
$game_map.boat_passable(point_x, down_y) &&
1 U; p- n" m' X8 I+ g' F4 s- |2 A
!collide_with_events(point_x, down_y) &&
7 x% n8 q, V; s
!collide_with_vehicles(point_x, down_y) #judge_end
4 l; @- W! {" r, C
sheet[point_x, down_y] = step
. I K) J( R- E2 l( ?% i C( P5 b- \
draw_path = true
" D! i2 R3 ^& E3 B' }; s
new_start_points.push(point_x, down_y)
2 j- Z+ E' N2 s( V* t; O
end
) M' l+ a! C- G2 f' ]! B. K" [+ A
end#endOfLoop2
r0 }* h- M" i% b
break if !draw_path reach_point
% N# G% b: N9 B( s: o& @* b
draw_path = false
5 w* H C! M( N, |
check_points = new_end_points
9 U. J! g. q# w. J4 X/ m
new_end_points = []
9 B! ], I0 _2 _7 m" g- @ b
step += 1
! k" v( c+ B! {+ K8 c$ n& k
break if step KsOfSionBreak_Steps &&
" m! h9 M7 k+ ]* t
!Input.press(KsOfSionFind_Path_Key)
) \% W7 q6 ^- l) \
loop do #loop3 从终点开始反向填充
: t% Z2 S8 Q1 e8 N. y7 L
point_x = check_points.shift
, J6 v, T' D$ Z7 T
break if point_x == nil
1 l" |( A4 L. |
point_y = check_points.shift
6 p0 ]! |, Y+ n Z. k0 w
left_x = $game_map.round_x(point_x - 1)
! ?: @/ `5 [& H& d3 P, x
right_x = $game_map.round_x(point_x + 1)
6 D" v) M+ g1 D& E7 T! j
up_y = $game_map.round_y(point_y - 1)
( i4 a: @4 c: g0 v# I9 M
down_y = $game_map.round_y(point_y + 1)
5 w, s* V+ e; r# r
# 判断路径是否连通
6 I8 u2 B* T4 p' g' F5 x
path_step = step - 1
$ X' n3 v% D. f; J! W& }1 C# F
if sheet[left_x, point_y] == path_step
2 }; L' _% H; ]( h: F0 ^+ E4 R A! F
chase_path.push(6)
. `- e4 R" ~3 J9 J( B3 y; G
chase_point = [point_x, point_y]
- u% H# ^3 \$ I: P" K$ n. h6 Q
reversed_chase_point = [left_x, point_y]
( E4 k- ^2 G6 P
reach_point = true; break
# ]" T& M9 n0 J: q# x& j7 v
elsif sheet[right_x, point_y] == path_step
: F, [! j! A0 z- s6 e
chase_path.push(4)
! K. B: u D& Y5 j+ d' T) F2 @
chase_point = [point_x, point_y]
7 [# c& ~0 g7 x3 C9 p' }: D
reversed_chase_point = [right_x, point_y]
. X0 b& Z' L) L2 K: X
reach_point = true; break
, l/ [2 v% b/ N, o6 l
elsif sheet[point_x, up_y] == path_step
8 V% ^3 b t# v5 m- U8 u
chase_path.push(2)
# f3 S8 M& M# N$ b) f& E
chase_point = [point_x, point_y]
# {. A8 r s" R9 o3 B; W7 v
reversed_chase_point = [point_x, up_y]
3 ^0 C* T* S' c8 [
reach_point = true; break
$ ^" u4 h3 \5 ?# x: g
elsif sheet[point_x, down_y] == path_step
' y+ Z9 }, r8 b" F. A, Z
chase_path.push(8)
3 O `$ A9 X9 ^& p; ?
chase_point = [point_x, point_y]
9 W9 W6 e) X1 F5 a% [- r; x
reversed_chase_point = [point_x, down_y]
$ s: O( m# S! y2 z; v
reach_point = true; break
* ^- @3 w/ w0 B9 [
end
8 s. y7 D% u. I" u, m; W1 {+ L6 Y
# 以需要抵达该点的步数填充路径表格 #
. s, Z2 |7 g7 E" K7 o
if sheet[left_x, point_y] == 0 &&
5 i8 w, `4 l/ |5 X
$game_map.boat_passable(left_x, point_y) &&
) l; i, _* ?$ Q- A9 R; ]
!collide_with_events(left_x, point_y) &&
# `% p( L+ a$ Q& ^" I* G
!collide_with_vehicles(left_x, point_y) #judge_end
" @1 ^8 `! O8 {9 U" h1 u: w9 s0 P
sheet[left_x, point_y] = step
# g: V. M0 ?) V, ]& X
draw_path = true
. G+ Q6 y& ?# D- V
new_end_points.push(left_x, point_y)
8 |- Q& i; A1 T9 L. L! H
end
/ B" I( P- x5 F3 i' [! c
if sheet[right_x, point_y] == 0 &&
3 Y; O; [3 V! Z/ U! `# F3 ?
$game_map.boat_passable(right_x, point_y) &&
1 k9 d/ u# O- ^2 p S" y5 T
!collide_with_events(right_x, point_y) &&
3 Y2 m6 q1 K; R- G/ B4 ?1 M
!collide_with_vehicles(right_x, point_y) #judge_end
, @' h k- J! P1 y6 f
sheet[right_x, point_y] = step
; q9 L9 N- J5 o
draw_path = true
. _$ ~3 `9 T- \' a1 {! O) @0 U" b
new_end_points.push(right_x, point_y)
% c- |4 M5 c9 b, B6 V
end
% ^8 Y. l1 d# B* d2 U. B
if sheet[point_x, up_y] == 0 &&
% Z+ N- { X9 P# `8 H0 e
$game_map.boat_passable(point_x, up_y) &&
4 l# j/ s: p d4 R
!collide_with_events(point_x, up_y) &&
5 L, `) N3 ]2 ]4 L+ H0 ]7 _
!collide_with_vehicles(point_x, up_y) #judge_end
9 Z5 d& r6 l% y5 |- m" e! E5 c$ Z
sheet[point_x, up_y] = step
. B* E. A* C9 ]$ i( e7 T
draw_path = true
( P! K2 j" F2 [
new_end_points.push(point_x, up_y)
8 v3 W5 W+ X( A' B
end
# a* W, b' `) V$ v/ C
if sheet[point_x, down_y] == 0 &&
2 ~0 M" a, D2 U, U- j$ R$ c
$game_map.boat_passable(point_x, down_y) &&
) S n- {. C9 x( m
!collide_with_events(point_x, down_y) &&
; {3 F% d+ b1 y
!collide_with_vehicles(point_x, down_y) #judge_end
0 h* {" V m" o
sheet[point_x, down_y] = step
- w. v3 Y x# f$ F
draw_path = true
4 o( o& t7 p0 w: c( I5 V7 B1 k
new_end_points.push(point_x, down_y)
9 C$ m7 l+ U2 O: m2 p8 g
end
# ~% L, B6 S. n
end#endOfLoop3
: j0 }& A# V# {' M2 i6 Z
break if !draw_path reach_point
- P w7 R2 W5 t- V4 \" h* V
step += 1
; Q1 J8 d" k4 g: W1 x$ a: Y
end #endOfLoop1 路径表格填充完毕
( i5 i! y! r5 w4 s; p T" g) O
$mouse_move_sign.transparent = false
/ H6 @* s4 c6 u4 J, P
# 判断指定地点能否抵达
{* O! F/ {5 O- K9 F) b: ? W# f0 T
if reach_point
4 T) T/ e7 B" b$ \# y; O
$mouse_move_sign.direction = 2
- M+ _/ o5 R6 Y: U
else
3 V; t* k: C. f- p
not_reach_point
5 X) e: W x% `9 B) W4 O
return
# R/ b% r) G! r: W: T5 F3 e# p2 r
end
4 E* }, D2 K* E3 ^
# 根据路径表格绘制最短移动路径(正向)
# R; j: b* D/ N( Y
steps = step 2 2
5 @' p% i! q2 f) Q7 x5 R3 @. A
loop_times = step 2
, @# w# O/ Q+ `8 _3 N* M) _0 w
point_x, point_y = chase_point[0], chase_point[1]
. @) ]5 Q2 r P4 x+ u* N
for i in 2..loop_times # forLoop
1 z" f* |. B* V* \& S% X2 X% L, s! f
steps -= 2
4 Z: \, f6 _' Z% a: j7 w' j! W" D
if (@moveto_x - point_x).abs (@moveto_y - point_y).abs
( X1 u4 |& X& e$ U" s* T: n& y
if sheet[point_x, $game_map.round_y(point_y + 1)] == steps
) z* v( L9 z+ C6 [
chase_path.push(2)
7 v# Q8 z# M" F
point_y = $game_map.round_y(point_y + 1)
; L1 ]- b* J8 c/ V% u+ Z
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
$ \# E- k9 k$ ^" t3 o+ l/ j3 v
chase_path.push(8)
( o J% g6 [, H$ A; f8 Z& q
point_y = $game_map.round_y(point_y - 1)
! I1 J' s; u, }: M; ^: B
elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
/ |9 U( A# F$ E- r* D
chase_path.push(4)
/ }" Q5 r3 I) z! O
point_x = $game_map.round_x(point_x - 1)
2 Y+ Z* n+ f6 Z9 E" R+ X6 l9 s
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
8 Y7 _5 N, D! Y! U1 U$ h ^
chase_path.push(6)
% _6 b3 R+ Y1 d, D" w
point_x = $game_map.round_x(point_x + 1)
0 K; a ~3 b5 p$ E" u
end
( n1 _. }/ H; D1 @& z7 A* e
else
s$ Z( j s9 Z1 l
if sheet[$game_map.round_x(point_x - 1), point_y] == steps
9 l" t- u9 h7 u: c' Z U) i2 f
chase_path.push(4)
( T' @" o" v& i+ n
point_x = $game_map.round_x(point_x - 1)
. @ `$ e- m4 L' ]( E7 V
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
* ~* y" m6 Z, H' ~
chase_path.push(6)
, o" B9 I1 u; F5 e1 k
point_x = $game_map.round_x(point_x + 1)
3 G& q% V4 {& v5 \* c/ ~* Y6 X
elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
* L1 q# W: f4 i! \9 e: |% E5 ?. J) j
chase_path.push(2)
& y8 t# I& p% b: Q
point_y = $game_map.round_y(point_y + 1)
' l" t, `# c @3 s
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
7 `. t4 M8 a$ O( Q+ ?: w
chase_path.push(8)
/ f2 n+ x/ t4 x* [/ b4 i7 l
point_y = $game_map.round_y(point_y - 1)
q( m% f$ J3 \) `+ t9 S, e+ J4 {& R
end
+ C9 H3 B1 U: x8 y
end
, f3 o0 @5 m0 }2 G8 `) O' P+ s
end #endOfForLoop
) X* e% y' u/ V/ y* l
# 如果指定点无法抵达或者登陆
3 q/ m' Q- r7 H) k4 V5 @
return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
. E# N2 o+ f, g, C; s& Y) b
# 根据路径表格绘制最短移动路径(反向)
+ R1 q' [ @, `' J/ F, e+ ?
steps = step 2 2 + 1
2 g# _4 s y" A' L0 o% t" B1 E
loop_times = step 2
+ G7 c: N" p# i& p9 v; L9 ^
point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
6 \# S; L' D: i1 m( \ N- L
for i in 1..loop_times # forLoop
4 ?( ?5 A# ~$ m' K S, X1 Q. v
steps -= 2
# F ^# u1 Y+ O6 U, c2 b
if (@moveto_x - point_x).abs (@moveto_y - point_y).abs
+ m9 F/ q2 h+ u2 q0 P
if sheet[$game_map.round_x(point_x - 1), point_y] == steps
7 f0 C% I/ a. o6 U, m' P9 g
reversed_chase_path.push(6)
' [- ~3 X" T6 z3 |8 I* w
point_x = $game_map.round_x(point_x - 1)
- S* a+ T. z4 V: M% _( q. z* }
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
' l" e) f' K7 l. L" B' d+ J! C
reversed_chase_path.push(4)
4 y0 k) j) I7 Y6 V/ ?2 q4 \" k e% I" F
point_x = $game_map.round_x(point_x + 1)
- B) ?0 y. F# X! Y. C
elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
" d/ ^' \( L6 N8 f) [) N# x
reversed_chase_path.push(8)
% `$ Q E8 G8 e: C6 o# y9 q! ]
point_y = $game_map.round_y(point_y + 1)
7 P/ c# o# z/ J# k
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
. E/ u' A$ _) k$ D+ X( j
reversed_chase_path.push(2)
2 h, x0 E! g9 {! V! s) `# q/ W
point_y = $game_map.round_y(point_y - 1)
% a, D/ ~! x r, b
end
9 @( u- n5 N' N: @
else
# t; S* t' z r0 _+ k8 ^
if sheet[point_x, $game_map.round_y(point_y + 1)] == steps
$ H/ j0 l% l8 S2 T, p8 T9 p. v
reversed_chase_path.push(8)
* l: ]9 E7 M+ n( ^. l" [2 ?
point_y = $game_map.round_y(point_y + 1)
/ E; E" _1 G3 D! M4 @* D
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
2 S- ?$ d, w2 B" j9 x- ]$ d
reversed_chase_path.push(2)
L: j6 M% m" {5 |! I+ G3 Q7 c
point_y = $game_map.round_y(point_y - 1)
+ f/ A7 _8 }' O p% r& w; k) B
elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
& N% p5 j n8 h' @0 Z% P6 f
reversed_chase_path.push(6)
" b4 A% B" H% I2 M
point_x = $game_map.round_x(point_x - 1)
5 N5 f) T2 T) B
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
3 `" \* g- F/ B" E2 o
reversed_chase_path.push(4)
7 B w3 U b6 j: @9 p
point_x = $game_map.round_x(point_x + 1)
- ]6 S* ~6 ?3 Z
end
; x2 p3 g" }0 k# P8 t p c
end
1 B% f( s* ^" F4 k. l
end #endOfForLoop
1 E/ _1 c' t) E- f) b& K! ~
@mouse_move_path = reversed_chase_path.reverse + chase_path
5 n3 g9 I* z Q
end#boat
5 @5 d$ A7 r# P9 M1 c0 W
#--------------------------------------------------------------------------
8 x c* `; j' r7 B' N* G; f! I
# ● 绘制ship的移动路径 @array[move_directions...]
" j. }! Y+ y3 A# J# A+ ?6 T
#--------------------------------------------------------------------------
. Y/ p- X! T0 t9 T
def draw_ship_path
z% ?3 X+ u ^5 L2 `
# 准备绘制路径表格
# q9 @8 T$ D8 |1 o( F1 g
sheet = Table.new($game_map.width, $game_map.height)
9 f: q! A+ M4 y
reversed_chase_path = []; chase_path = []
+ l2 s# Y* w m
reversed_chase_point = []; chase_point = []
+ ` F$ t7 y7 b2 ?9 N
new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
! D: I: r5 n+ [* j8 }
sheet[x, y] = 1; sheet[@moveto_x, @moveto_y] = 2
6 H+ a/ L" r6 h0 ]' i
reach_point = false
1 R) d5 U. e- a; d( P t( t8 x, F: q
step = 3
. ]! G& ?5 s/ @& q3 q" R o' ~
loop do #loop1 开始填充表格
- x( d/ V3 k _$ z
draw_path = false
6 [( `7 g7 G8 [- I
check_points = new_start_points
# F2 Z* B+ e j [ s' J! q
new_start_points = []
0 V, k4 f* e$ ~8 X
loop do #loop2 从起点开始正向填充
/ T9 q* w. |: X4 {3 E, O* d9 d
point_x = check_points.shift
# w1 H& e2 |5 E: }+ t: c( y* v& |0 f
break if point_x == nil
- o3 q8 z) X% F! I* R2 x
point_y = check_points.shift
j, U- h" m/ q. Y8 S& `( f
left_x = $game_map.round_x(point_x - 1)
- q, h8 z U. ^" T! d" l- s+ r3 M: B
right_x = $game_map.round_x(point_x + 1)
2 y* h- @" ?& b
up_y = $game_map.round_y(point_y - 1)
8 D( c% h& T7 n, p# ~( N$ h6 n
down_y = $game_map.round_y(point_y + 1)
0 m; s7 ?8 C u' }' c
# 判断路径是否连通
& w/ L$ [: R2 x
path_step = step - 1
. B# y, Y0 l2 U3 t7 Q
if sheet[left_x, point_y] == path_step
6 s0 S( e/ }8 m4 k# F4 J% w, P s
chase_path.push(4)
2 N; v: D0 U ?
chase_point = [left_x, point_y]
8 N* R& }% z# H( b
reversed_chase_point = [point_x, point_y]
6 l, `1 W3 B, S7 { u3 K' c) k
reach_point = true; break
' q% G4 }4 X$ e" H
elsif sheet[right_x, point_y] == path_step
, k7 v" d- N$ M: K/ V, h
chase_path.push(6)
1 c8 {# {2 x6 e% v7 R5 d
chase_point = [right_x, point_y]
$ C' _! S1 F* Z( b
reversed_chase_point = [point_x, point_y]
4 }* A6 p) @& B9 w! V1 ]
reach_point = true; break
7 p% V+ |7 O) q+ B, d0 z/ L
elsif sheet[point_x, up_y] == path_step
. S6 j5 s- a# Z1 `
chase_path.push(8)
' w2 E5 p: y5 F, e/ g/ M
chase_point = [point_x, up_y]
^, N9 h; {: G
reversed_chase_point = [point_x, point_y]
2 F! r% C! L' p, C
reach_point = true; break
# Y: H& e* H- `6 S
elsif sheet[point_x, down_y] == path_step
; r# {% i* Q8 f" j5 C; h
chase_path.push(2)
0 V4 d+ n9 p/ ?+ _8 K3 I
chase_point = [point_x, down_y]
7 J" M) `5 q( ~4 |
reversed_chase_point = [point_x, point_y]
% |2 i" O L: M* }6 b, d, o
reach_point = true; break
) G) O+ ~5 Y" |9 j; l% d( Q
end
5 f+ m$ ^8 {; T% X
# 以需要抵达该点的步数填充路径表格 #
: i' P; E8 U/ H
if sheet[left_x, point_y] == 0 &&
' l i; ?* U$ v4 w0 L
$game_map.ship_passable(left_x, point_y) &&
9 a" l8 ]& O* S! H) [0 H* t
!collide_with_events(left_x, point_y) &&
: J$ d2 S& t+ Y
!collide_with_vehicles(left_x, point_y) #judge_end
+ C) C$ x2 K9 ~+ ?
sheet[left_x, point_y] = step
" p: `( ^2 S. M+ M
draw_path = true
( U$ W# ~/ ]3 R5 d3 @; W* r
new_start_points.push(left_x, point_y)
- m9 N/ p( f, Z
end
) u/ U$ s1 z3 I/ }+ n
if sheet[right_x, point_y] == 0 &&
' g" F( Z/ r' h
$game_map.ship_passable(right_x, point_y) &&
% B5 Z# s u4 h! [3 u" ~
!collide_with_events(right_x, point_y) &&
' |" v- F, r% V# M: N- c
!collide_with_vehicles(right_x, point_y) #judge_end
* ?' v& j$ r& w i
sheet[right_x, point_y] = step
7 h( X2 s7 E3 v+ N( X" f9 [6 r
draw_path = true
6 d- \" Z* z6 Z X- N: D) `
new_start_points.push(right_x, point_y)
* v3 Y6 {" N7 Y2 P S
end
' H. `" z+ J& Y, b- t- P
if sheet[point_x, up_y] == 0 &&
/ c* O9 E) Y3 q- d2 v
$game_map.ship_passable(point_x, up_y) &&
0 h# i. L( S3 b. S
!collide_with_events(point_x, up_y) &&
3 [, S; G* G- t6 C
!collide_with_vehicles(point_x, up_y) #judge_end
2 ]4 M. W+ z. N7 b- d/ H7 c, I
sheet[point_x, up_y] = step
8 F. A! _* i3 w, V0 X
draw_path = true
a& z; f- G q
new_start_points.push(point_x, up_y)
$ c6 Z/ e8 D+ ~4 V: I
end
) _; Z1 Y$ L3 z$ x
if sheet[point_x, down_y] == 0 &&
r; S1 _+ v. D6 N$ O+ r- \4 w
$game_map.ship_passable(point_x, down_y) &&
: E5 c3 z8 r5 h) Z: ]
!collide_with_events(point_x, down_y) &&
/ p" a8 e# h; q3 u5 S! H: q
!collide_with_vehicles(point_x, down_y) #judge_end
% ?6 P, j$ V; Q: G8 q% r
sheet[point_x, down_y] = step
, A8 L# F* F) F$ M* X& @
draw_path = true
8 J5 X! }$ n! |/ U- x" P
new_start_points.push(point_x, down_y)
1 S$ X3 b. S+ k5 z. T
end
( u) ]; T2 b0 H$ E( m/ }
end#endOfLoop2
) S2 B, _1 u* n2 y$ u; e; i+ x
break if !draw_path reach_point
& E) J3 W1 `2 Y. F: G. ^
draw_path = false
( \% c r2 X7 y F3 @) N
check_points = new_end_points
+ R$ U" y1 M* ]- _
new_end_points = []
4 {! Q/ p0 Y V! @/ @
step += 1
* t- v4 l U2 _ @- o8 Y
break if step KsOfSionBreak_Steps &&
4 Y) W0 n8 a; k4 H6 c% Z: {
!Input.press(KsOfSionFind_Path_Key)
; r) d h* w% [1 R2 l3 D' M
loop do #loop3 从终点开始反向填充
# A6 h& c+ I: x5 T! i- }
point_x = check_points.shift
2 t7 }; z7 n! V) G4 }; F) c
break if point_x == nil
3 `2 q; s" P) V' X3 a1 W
point_y = check_points.shift
8 i/ R6 a, `% m# X, j; D* z: J
left_x = $game_map.round_x(point_x - 1)
3 n1 y. y# v6 H, x, t/ D* p
right_x = $game_map.round_x(point_x + 1)
6 Y# S: @5 l* q7 V; h3 G
up_y = $game_map.round_y(point_y - 1)
4 q7 p9 K! o' W7 w4 H5 {
down_y = $game_map.round_y(point_y + 1)
) _4 v! {9 ]% d# X
# 判断路径是否连通
- j0 B9 V# u( P5 p/ c
path_step = step - 1
( g1 ~3 Z; n1 m6 k9 |
if sheet[left_x, point_y] == path_step
0 y Q& u9 t) t" F m. H
chase_path.push(6)
) f0 J+ x+ N1 u6 b* U
chase_point = [point_x, point_y]
# H! |9 q2 h7 b
reversed_chase_point = [left_x, point_y]
+ D; W7 r4 t( ~
reach_point = true; break
2 p3 E; w, W; y( Z0 S
elsif sheet[right_x, point_y] == path_step
2 M6 e( |. Z5 G1 l, ] ]
chase_path.push(4)
* B. l& t' a! y0 k6 g1 ^
chase_point = [point_x, point_y]
1 R& A5 Y8 G- H8 g
reversed_chase_point = [right_x, point_y]
) }" f( }, w: U/ _6 O. x
reach_point = true; break
4 w; ~: z5 V9 _+ G6 x0 h2 \
elsif sheet[point_x, up_y] == path_step
, @3 @4 ^7 G5 v1 Q" J
chase_path.push(2)
# d" S6 G J& @! k' ]
chase_point = [point_x, point_y]
) k5 p! T' o1 v: [. n- n% ^! T
reversed_chase_point = [point_x, up_y]
% i) G/ `! \- p8 `8 x: M/ K- H
reach_point = true; break
2 [8 Y s; J+ L; @" e
elsif sheet[point_x, down_y] == path_step
- F2 F5 L. V9 B2 `' z7 h5 O
chase_path.push(8)
2 X2 q! Q( d% }8 G5 Z
chase_point = [point_x, point_y]
3 y' e. Q% E3 d2 F* }
reversed_chase_point = [point_x, down_y]
4 H+ G0 G& Z8 F, R: p
reach_point = true; break
* c+ h. O( h6 k! l3 g; l' J+ h
end
( {7 m/ ]/ s, E
# 以需要抵达该点的步数填充路径表格 #
( g! J0 b( R Y5 m8 q& C
if sheet[left_x, point_y] == 0 &&
! m" \- Q/ l. F$ s
$game_map.ship_passable(left_x, point_y) &&
[" ~; K3 N( J+ F+ M5 j
!collide_with_events(left_x, point_y) &&
5 m5 E. D( @# L7 |) v
!collide_with_vehicles(left_x, point_y) #judge_end
, G( B5 u& o* P0 J! v% a, ]
sheet[left_x, point_y] = step
/ b- ^' w2 s/ R( K7 E
draw_path = true
' e; d8 f$ F/ q, Q& z! a
new_end_points.push(left_x, point_y)
$ t3 k$ ~! h. [5 p8 _
end
( \7 R$ ~# f' r3 @5 o w4 N
if sheet[right_x, point_y] == 0 &&
7 g" P; K: w5 i, n$ P' R* ?
$game_map.ship_passable(right_x, point_y) &&
+ ^, C5 g" W4 @
!collide_with_events(right_x, point_y) &&
0 [. s5 X$ d* m2 `% |, Y# {- n
!collide_with_vehicles(right_x, point_y) #judge_end
3 G5 r# ~1 y6 k. s4 s6 [5 @8 J
sheet[right_x, point_y] = step
( S) ?# D5 p8 U. F; G a0 }
draw_path = true
$ L% Q4 z3 h$ _9 \5 h8 [
new_end_points.push(right_x, point_y)
! n9 s( ^% M8 K2 K
end
. ^# b) {% _5 H2 b% q
if sheet[point_x, up_y] == 0 &&
% f9 s: B- `% h' k1 B! w
$game_map.ship_passable(point_x, up_y) &&
* l5 r/ ~6 Q* |9 r f$ w0 n, p8 E$ Y
!collide_with_events(point_x, up_y) &&
5 x0 E0 H) O# t- y: x1 F( V
!collide_with_vehicles(point_x, up_y) #judge_end
4 }( C& p! l2 f" r. t
sheet[point_x, up_y] = step
2 Y) k7 ^, R7 ]3 x3 N$ K# U2 I
draw_path = true
9 e2 H. J8 o+ X4 J; e
new_end_points.push(point_x, up_y)
+ ^: T" M! i) Q+ l. b" H; h
end
& P( }/ L$ V4 B. A% ? ]* G K/ B
if sheet[point_x, down_y] == 0 &&
7 q( b! C* ~& c. V, A1 M9 Z; p
$game_map.ship_passable(point_x, down_y) &&
- p. U0 x- f8 |' W, G
!collide_with_events(point_x, down_y) &&
0 P) @0 M- y( W
!collide_with_vehicles(point_x, down_y) #judge_end
9 `7 C B5 A5 J. J: W
sheet[point_x, down_y] = step
1 i) @( k1 Z. O. `
draw_path = true
4 N4 C1 B2 U( ?& O$ Q$ k
new_end_points.push(point_x, down_y)
' `9 ], c3 u& W+ s/ j* h2 d
end
3 R' T) _; C* c& Y+ P5 u0 N# ~( R
end#endOfLoop3
6 B2 N* w) N9 P; q, T7 T# v5 J
break if !draw_path reach_point
9 C) R$ w( D2 z0 G5 m# V( e% n
step += 1
% ^$ E9 e8 |- |8 s1 R
end #endOfLoop1 路径表格填充完毕
! C3 g' ^0 a. ?1 G; K
$mouse_move_sign.transparent = false
+ Q. w) O7 Z- Y5 |3 L
# 判断指定地点能否抵达
) w) e: B0 U9 x- v/ d8 E0 P
if reach_point
1 d' N2 l: m6 |. K! o# H: ^6 x
$mouse_move_sign.direction = 2
' ^0 A) F4 r e4 k) Y. D6 ]! p0 h
else
% E: y5 g+ A& @: A
not_reach_point
) c# V+ Z% I* [: P
return
# O+ ]. V; K' m9 N: H( {
end
: G& }) W0 ~2 B* b# C1 W! W; s3 W
# 根据路径表格绘制最短移动路径(正向)
' N$ X8 s! O1 x3 e
steps = step 2 2
, |" [$ E% @1 n1 P% q& o
loop_times = step 2
5 m$ } I3 F7 z
point_x, point_y = chase_point[0], chase_point[1]
4 ?1 ^$ v3 d6 i7 B8 Y; r- h1 E
for i in 2..loop_times # forLoop
L7 D( I, ] `; ?4 Y5 ^) R
steps -= 2
, @4 D8 R. {3 y2 r9 C
if (@moveto_x - point_x).abs (@moveto_y - point_y).abs
& M. X, D+ w3 U2 K* {; q
if sheet[point_x, $game_map.round_y(point_y + 1)] == steps
2 R/ J6 v* z6 L1 F
chase_path.push(2)
7 n! L9 I* h$ `5 R* s+ G% |+ {3 V
point_y = $game_map.round_y(point_y + 1)
8 M' ~% [0 S4 s: k* R
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
: j* M5 N* K3 g0 N
chase_path.push(8)
; p7 P" y% E+ T6 E, N
point_y = $game_map.round_y(point_y - 1)
3 R9 a. J3 C6 x, ^- S: p
elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
" k0 V6 x. {1 ^ \
chase_path.push(4)
; ~5 i4 T) `) z1 q3 d0 k0 U! f( \
point_x = $game_map.round_x(point_x - 1)
9 ~ | ~. D+ m4 V2 Z" Z) O
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
2 m( \6 w3 J0 Q6 H n2 W
chase_path.push(6)
3 V5 ]+ J" V6 ]
point_x = $game_map.round_x(point_x + 1)
* X' k8 a* B' a, f# C9 N. T
end
5 s2 F, {3 x4 S( W9 Z. n* O
else
: J6 m9 R [1 \4 K ~7 {
if sheet[$game_map.round_x(point_x - 1), point_y] == steps
7 V; ~7 _3 X9 B* O8 r% @! `
chase_path.push(4)
. O; g( t# H4 x+ M4 y+ v0 K: q( [
point_x = $game_map.round_x(point_x - 1)
+ K+ [0 n7 }8 \4 P) N
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
- R5 E) S, b5 C$ \$ T- m
chase_path.push(6)
- e$ I5 | |+ `9 q9 q- F
point_x = $game_map.round_x(point_x + 1)
/ `9 P7 g1 Y, V* X0 y; _% D
elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
* H1 e! Y3 a# o% i. U* A
chase_path.push(2)
6 @- ]5 \: E1 a/ s: P
point_y = $game_map.round_y(point_y + 1)
; o! v% p9 V/ f
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
! h- q8 B$ [" F Q
chase_path.push(8)
% ~1 Q! N! y1 Z
point_y = $game_map.round_y(point_y - 1)
5 z) G+ N* g7 s H
end
6 w t' z: d% K x; U
end
0 ^+ X9 R( B" J
end #endOfForLoop
3 m% K: D7 P( `" B: r3 D& d2 A$ a% l
# 如果指定点无法抵达或者登陆
3 J5 a# f: J- H& V$ ?
return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)
) m: h# f; p7 b( m% f
# 根据路径表格绘制最短移动路径(反向)
. e' d, V" J5 t6 K5 Q; o2 @, T/ F
steps = step 2 2 + 1
. O. |& P; P" U
loop_times = step 2
: m3 o& O$ H2 e9 `& J. F
point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
% k7 U7 z9 W/ P, a' [* {
for i in 1..loop_times # forLoop
1 y/ ~5 S2 M% V0 b3 d
steps -= 2
# T9 H8 D5 f2 V
if (@moveto_x - point_x).abs (@moveto_y - point_y).abs
5 u3 {6 U4 e# G/ q
if sheet[$game_map.round_x(point_x - 1), point_y] == steps
- a9 j; y) P l
reversed_chase_path.push(6)
6 A# A7 l) b" ]8 L
point_x = $game_map.round_x(point_x - 1)
# Q0 y. `2 q& R3 T- L
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
2 s( q4 [4 i2 ]& ]; Q( h! G
reversed_chase_path.push(4)
& W$ J) p* a" B! u/ g
point_x = $game_map.round_x(point_x + 1)
: s* p& z2 |! {( ?6 \& X9 G
elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
/ s8 R9 n! y8 Z( l
reversed_chase_path.push(8)
8 r1 u6 T# N$ \6 K
point_y = $game_map.round_y(point_y + 1)
" r2 { R; w0 R* Q \/ r Q
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
4 w2 P2 v( s% w, M* i0 d
reversed_chase_path.push(2)
( A" w/ S( v- b# C3 F& {
point_y = $game_map.round_y(point_y - 1)
. f6 L, q) d5 y: o% ?
end
0 p' b# D7 r/ K! O2 U# n( {
else
* @$ ~4 r) o: l9 e' V! A
if sheet[point_x, $game_map.round_y(point_y + 1)] == steps
( Z8 U- e z7 n# z8 C- p: P
reversed_chase_path.push(8)
5 }; M/ s$ [5 z0 }* m, x+ ?8 d( B
point_y = $game_map.round_y(point_y + 1)
$ `4 _4 n- ]. i- f3 q) m
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
1 ^+ v& e7 S3 N" E
reversed_chase_path.push(2)
" q6 [# ?# Y; n9 S
point_y = $game_map.round_y(point_y - 1)
# p; q! ]/ j: s3 M! j" L
elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
D; {# R" Y" x" i& @* @
reversed_chase_path.push(6)
8 h9 p5 ?% D1 T! L5 H
point_x = $game_map.round_x(point_x - 1)
+ Z0 M, [2 K( v. Q$ `) {9 v
elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
$ o1 Z; o2 U1 \3 ~6 i& V4 R1 [
reversed_chase_path.push(4)
! R3 H8 P( j" B* Q( `; D( s J# K3 h
point_x = $game_map.round_x(point_x + 1)
8 j5 [. M2 W0 O6 T- P
end
, F2 i* S* b2 Q3 c) t/ C5 ?
end
' ]& P8 m6 O; B9 v! s; R: f
end #endOfForLoop
4 E$ q5 d3 ]5 w0 H- H
@mouse_move_path = reversed_chase_path.reverse + chase_path
$ O2 n8 R3 ]8 a3 i# S7 L
end#ship
7 f. A, {$ L% x0 ~% Y8 h
#--------------------------------------------------------------------------
- b- J) z; b2 U. ^6 O G6 a8 f6 ~
# ● 绘制airship的移动路径 @array[move_directions...]
0 ~: G, i) h0 K* W% n3 [; c: A- G8 M
#--------------------------------------------------------------------------
; Y1 s0 T# X/ c) A A! q) e$ z
def draw_air_path
8 q, ?' @1 i3 v, z7 c7 n! [
$mouse_move_sign.transparent = false
$ ]6 V x" J6 g$ }
# 准备绘制路径表格
9 ~" k! a, I4 W' _8 z6 d% t
sheet = Table.new($game_map.width, $game_map.height)
2 _1 G7 B5 n! A6 u& Q2 g& X
new_check_point = [x, y]; sheet[x, y] = 1
# S7 h, x1 i' r; o" y2 @
reach_point = false; step = 2
* v* j5 B7 b1 B0 B$ D' i: Y
loop do #loop1
( k4 N& C! A6 z& }* @( e" k
check_point = new_check_point
. l0 S- h3 |( t- K- R7 }5 Q' `
new_check_point = []
+ E6 |, h8 @3 G; B" l
loop do #loop2
# p) _ ~8 J) ^2 ^: y9 W" [0 x; M
point_x = check_point.shift
2 U ^/ n* \0 g: a; u) n7 e# i
break if point_x == nil
. B# F/ [3 h3 M# X6 t: [
point_y = check_point.shift
/ b8 J( }/ O' F+ G0 x4 l/ Y9 n
if point_x == @moveto_x && point_y == @moveto_y
! o N1 k( `& V
reach_point = true; break
- c" e# H' e6 B% N" c4 P
end
$ v; t1 B6 s' R; R' I
left_x = $game_map.round_x(point_x - 1)
' [: C7 Y- }' l7 [+ J
right_x = $game_map.round_x(point_x + 1)
( t% W; K; P X4 R
up_y = $game_map.round_y(point_y - 1)
6 S3 f4 }; P1 y
down_y = $game_map.round_y(point_y + 1)
' j2 N( s: c. u. ?/ d, [! q/ C) {
# 以需要抵达该点的步数填充路径表格 #
! ~7 o* |4 p. Z* n( _4 J
if sheet[left_x, point_y] == 0
3 z$ ]3 B# m; ?: d8 a
sheet[left_x, point_y] = step
+ g) q4 v' A/ T2 B- v
new_check_point.push(left_x, point_y)
+ z- V a% ]" E( B4 P/ ^7 {
end
8 U. @* c7 X8 U3 W( @; b* n
if sheet[right_x, point_y] == 0
0 T0 _3 r- M' \
sheet[right_x, point_y] = step
' |+ _( i- M) _- [( `* E, r
new_check_point.push(right_x, point_y)
* j* v+ g, |2 y$ G7 n z
end
% h4 ]' r& e$ R( I b# _( D
if sheet[point_x, up_y] == 0
; A" ~& w; C0 L( t0 S( J
sheet[point_x, up_y] = step
% P: O1 C4 P! R# G1 Q+ i0 q
new_check_point.push(point_x, up_y)
- H) z; A4 m$ j1 U3 \) W" m! S
end
. X; P9 E( a% u
if sheet[point_x, down_y] == 0
; k; \3 y4 K! G. J
sheet[point_x, down_y] = step
& G. |% @: I6 \% T7 ?
new_check_point.push(point_x, down_y)
: q, @5 C5 E) H& {* S% P
end
! T5 k, _, c+ {0 R* A: G
end#endOfLoop2
. G: M, p K# }( _
break if reach_point
4 k" N2 R: \1 ~. _
step += 1
1 a- Y: a) C* X+ S7 u
end #endOfLoop1
: k. i* \4 {/ ~ d6 G2 p* u/ n
# 根据路径表格绘制最短移动路径 #
* F9 r2 e+ o, E/ {& T4 s; `
reversed_chase_path = []; step -= 1
0 W; \4 E. `4 E/ e9 V
point_x, point_y = @moveto_x, @moveto_y
8 C- R' U6 x4 a& @
for i in 2..step
. E( O. N, G5 s) _0 V
step -= 1
* F$ z4 ~* t) G7 l
if (@moveto_x - point_x).abs (@moveto_y - point_y).abs
, M; X1 R! x X; ?- D6 b3 ^
if sheet[$game_map.round_x(point_x - 1), point_y] == step
( D8 K- ~$ n" A% l- G) |% G; W+ K% d: F
reversed_chase_path.push(6)
0 F% ^) ]; F" b( |5 d
point_x = $game_map.round_x(point_x - 1)
A7 d. @/ `2 V, \
elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
5 e3 ]" Q6 v+ |3 g2 b( E: L
reversed_chase_path.push(4)
\3 _4 O" X( e- B5 o
point_x = $game_map.round_x(point_x + 1)
~/ @7 q2 }3 w+ r
elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
) P" B5 d1 m% M, q7 M2 V, D4 J
reversed_chase_path.push(8)
& C: s' M1 |. c: _
point_y = $game_map.round_y(point_y + 1)
8 T4 H; w: x$ I# E+ k8 @" P# d a
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
1 m) F, V; S+ p0 D5 ^3 z
reversed_chase_path.push(2)
. w. U" Q+ U1 ~1 a" U. g
point_y = $game_map.round_y(point_y - 1)
( m1 K0 T8 t; p }5 W! d
end
5 Y v0 {0 D' {
else
1 U( Q( f6 w' [* V4 \0 u/ x
if sheet[point_x, $game_map.round_y(point_y + 1)] == step
: Y6 _8 o- i$ h v4 p* S2 w' L6 j
reversed_chase_path.push(8)
2 M8 f. O, T; x3 r1 P- v6 c
point_y = $game_map.round_y(point_y + 1)
5 T; o6 h9 N3 W0 |' c
elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
. k& J* T2 P) e* `' d* q S8 _
reversed_chase_path.push(2)
3 ^9 P5 S, N+ J1 W. l
point_y = $game_map.round_y(point_y - 1)
4 M0 M7 u5 Q+ ^$ u A" l* _
elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
4 _0 h: ?" N! N: |# e5 P, t! P
reversed_chase_path.push(6)
3 f, Y# w( J8 w' T& @* t( I, k
point_x = $game_map.round_x(point_x - 1)
, u2 O. A% T3 P6 @+ ]( O4 S: z" o
elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
( L5 ~( A3 u4 `6 t- X2 z
reversed_chase_path.push(4)
) \* A3 u2 M, Y E: M6 H
point_x = $game_map.round_x(point_x + 1)
2 y, O; p/ k3 \% \1 w( I( F+ ]- w
end
3 X. G, w, n; w. f
end
( a9 @2 x# N4 m8 x; m* ^
end #endOfForLoop
0 |, R: [: {1 H
@mouse_move_path = reversed_chase_path.reverse
& Y" [& e5 t" D! L
end#airship
3 P+ k% c+ B6 Q0 f Y
#--------------------------------------------------------------------------
9 U, _4 s- a& I8 }: {
# ● 目标点无法抵达时的处理,用于各路径绘制方法内部
" N$ \5 L/ b8 z) d1 j
#--------------------------------------------------------------------------
# Q' s z7 r1 |( b% m" M: q
def not_reach_point
Q. X0 i# G& N
$mouse_move_sign.direction = 4
, a$ t6 K+ F0 Y+ x* a' T* g
dx = 0; dy = 0; dir = 0
7 R- M" L m! q9 ^" C Z0 `
if @moveto_x - x 0
4 o. o( Q8 {# L
if @moveto_x - x $game_map.width - @moveto_x + x &&
, H- d7 |" X# H2 r
$game_map.loop_vertical
1 v+ d0 d) t% T1 _" |$ _1 C
dx = $game_map.width - @moveto_x + x; dir = 4
/ z4 \: }; I0 X9 C0 O. f
else
6 N8 U) X7 @: V$ c) s* k
dx = @moveto_x - x; dir = 6
1 q' y$ ?/ C2 R/ F0 _* k! U& K+ H# D
end
/ j3 ?% j6 o4 J4 h& z" _- p% p% D
else
6 R5 X; ?2 p4 Z. y! `% V3 ?
if x - @moveto_x $game_map.width - x + @moveto_x &&
: D5 B: m! F! D6 K8 o0 ~7 R+ F
$game_map.loop_vertical
6 n& c& P Q e; K' g F
dx = $game_map.width - x + @moveto_x; dir = 6
6 ]; T3 H$ ^( i+ O
else
; T$ e* f% q) F3 f2 V
dx = x - @moveto_x; dir = 4
- H4 x+ J" P+ v1 o2 [; U h0 C
end
# X7 s2 }* K8 ?% {: ^# T' S
end
6 R k( E* I5 F( c& v2 A3 Q5 l
if @moveto_y - y 0
) t4 k: I) i% v% J+ N8 j
if @moveto_y - y $game_map.height - @moveto_y + y &&
. f/ b. w; Z: Y0 ]6 f1 D7 g
$game_map.loop_horizontal
: }: o& o5 }/ s$ a% |3 F) g( P
dy = $game_map.height - @moveto_y + y
4 _& p6 d9 u, P$ M, e6 D9 ]/ X/ y# j* T
dir = 8 if dy dx
+ c: u7 z. ?5 t/ `" n5 M5 X
else
% k( g. h) h ^+ n
dy = @moveto_y - y
' J8 l7 x+ I) F4 P: f1 _
dir = 2 if dy dx
# ?- S7 [3 B" [) D! L
end
; u7 {. _8 W7 L
else
" i* c9 P$ s4 ^( t% u5 L: Q3 B
if y - @moveto_y $game_map.height - y + @moveto_y &&
2 e$ W8 { z! ?& ~
$game_map.loop_horizontal
+ W# r" {: u7 _
dy = $game_map.height - y + @moveto_y
! D ~1 A+ T3 v. F; M# T
dir = 2 if dy dx
4 ~# b5 ]6 y* L2 h
else
{: Y! Z( j2 x) m" }+ A5 F
dy = y - @moveto_y
j. q6 |1 s% ^% M: C" n
dir = 8 if dy dx
0 o$ Z4 A$ a% l! _0 P% I$ ?
end
+ ?; {9 s% @$ \/ E( s# J" m8 `/ R) j. m
end
/ C5 [6 _/ C- _/ @8 Z
@mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件
) r, H* @& u! F1 Y
end
, `8 U( C) I M& Z1 s
#--------------------------------------------------------------------------
0 ~2 C! N; m o9 |& l* I
# ● 判断目标点是否能抵达、登陆,用于船只路径绘制
( `8 i g4 B' G j w/ b
#--------------------------------------------------------------------------
z5 [: g* V4 ?& o5 B( T6 m
def landable(x, y, path)
+ b7 C" ^3 l8 |5 R
case @vehicle_type
# Y0 i! A3 F, r4 x3 k; K2 u& R
when ship; return $game_map.ship_passable(x, y)
1 ^" a1 {4 O! }2 ~: N8 w0 L
$game_map.passable(x, y, 10 - path[-1])
3 U/ I+ F% \+ S8 I2 F& _
when boat; return $game_map.boat_passable(x, y)
, N3 S2 ` f1 g9 p1 ^* y
$game_map.passable(x, y, 10 - path[-1])
9 W1 m/ j# v; M0 W
end
P0 U2 Z' `% d# ^) e6 w
end
$ i6 P/ X( h/ h% T- q
end
6 e4 A. w& v5 k$ f8 W1 O
" g2 K% L/ c' m4 i* q& W6 O
#==============================================================================
, }9 g3 z, j; m/ O
# ■ Game_Map
g$ v' n2 O1 @
#------------------------------------------------------------------------------
" J% j+ }; q, l: v, @& L6 E9 {
# 管理地图的类。拥有卷动地图以及判断通行度的功能。
* i4 o6 e. O& D0 V; [
# 本类的实例请参考 $game_map 。
5 ?" n% [1 Q# N' y0 y
#==============================================================================
2 m' i* V) u3 b A. ~
class Game_Map
/ B. i$ w7 Z* w. x: w6 ~
#--------------------------------------------------------------------------
, H' L- b# D; ]+ M
# ● 定义实例变量
h7 ^. P5 j! }- I1 y* E
#--------------------------------------------------------------------------
) r2 ^+ ?5 \; L& H, U: c8 {/ s
attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
1 e5 g/ P) k' [9 ^# V3 i% ^" J
attr_reader mouse_map_y # 同上
0 q$ |4 k) h% h. g; C' j3 J- m( t. x
#--------------------------------------------------------------------------
9 ~% n# V- [/ b+ X9 P4 V+ k
# ● 初始化对象
1 Z+ @! Y& c) A3 o3 d) S0 A
#--------------------------------------------------------------------------
- ]# Z* T0 t$ d4 F) J
alias sion_mouse_initialize initialize
' f# K' `- L. K9 J0 F) t3 `
def initialize
0 s7 p5 y7 {/ G1 r0 C' @5 W
sion_mouse_initialize
9 O6 F2 f. Q+ e5 i6 ^/ ~
creat_move_sign ###
; M6 `) q; w- B
set_constants
5 M; Z# S: D& w+ @; H) T8 I
end
, h9 I& J7 q2 a, Y0 D( [* U
#--------------------------------------------------------------------------
+ Q+ Z/ i7 W; e& `* f
# ● 更新画面
4 N1 z$ S% A1 j8 H
# main 事件解释器更新的标志
, i. j7 L8 |3 ~9 L# y1 Z
#--------------------------------------------------------------------------
- `( b7 i6 F/ C+ J8 i
alias sion_mouse_update update
! l2 Y: z5 P# r4 `- h+ R
def update(main = false)
; f, Y" Q; C+ H+ r* i4 h% g
sion_mouse_update(main)
, V8 y, R3 D$ K- w7 Q2 U
update_move_sign
7 \4 Q- n$ ^$ a1 @" w
end
p2 N" Y# K9 x9 P9 m# X; K
#--------------------------------------------------------------------------
" {; B/ l! m5 i# m
# ● 创建显示路径点的事件
, F3 W6 ?% N" J7 Q3 d& a7 [
#--------------------------------------------------------------------------
m( r6 p0 X0 p n
def creat_move_sign
# Y2 J3 f/ o% b2 q: [7 ~7 @
$mouse_move_sign = Move_Sign.new
, m" x/ R, x/ ]
end
! i, f! @# `# l4 H, m
#--------------------------------------------------------------------------
+ @* N: a6 i* G1 w7 v8 [' u
# ● 更新显示路径点的事件
1 b3 e3 H2 C8 k9 \$ l6 h
#--------------------------------------------------------------------------
! u/ s' z$ Y& f
def set_constants
3 c# c1 i c- _
@mouse_pos_setted = true
/ a, k: g% f, m/ ?
@set_pos_prepared = false
# f1 E7 q( K3 }% H' }
@mouse_old_x = 0
6 p/ L/ q! j2 k% |, \2 W
@mouse_old_y = 0
' Q6 \6 E4 q2 N/ v P+ c! k" C
end
. v0 R. u& U" P2 z6 A
#--------------------------------------------------------------------------
( P- k3 ~4 z9 L, T0 y9 \ Z
# ● 更新显示路径点的事件
. Y: K) S- u$ Q3 @# Z1 t
#--------------------------------------------------------------------------
6 Q9 F7 l# `) `7 q% \( H
def update_move_sign
+ o2 A+ a) K" F( d1 x. S/ }2 m
$mouse_move_sign.update
* M. h" u$ @# j" k
end
( z$ I3 N* m& _6 S% u
#--------------------------------------------------------------------------
2 _' _# `' e- v9 e
# ● 获取鼠标位于的地图块的x、y坐标
* f) W3 K( u9 W$ y( U
#--------------------------------------------------------------------------
4 v0 P: r& w. P8 E T( K) w' {1 A& B
def get_mouse_map_xy
+ ?8 [, C: b& O p" K6 }
mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
7 |3 U* \2 ^3 u3 U
@mouse_map_x = round_x((@display_x + mouse_x 32.0).to_i)
I. F- D7 [$ f
@mouse_map_y = round_y((@display_y + mouse_y 32.0).to_i)
& \, h3 [9 k# q. y( ~
end
: X) U, }+ @6 ~+ s: Y7 G, u
#--------------------------------------------------------------------------
, }$ @. J4 N( Y( J8 w; H
# ● 返回地图画面时重设鼠标坐标
/ _% w( S* F1 z9 V, ?/ o# h! } v) y
#--------------------------------------------------------------------------
0 R- S; a1 W5 a( C) F' b
def reset_mouse_pos
: ]9 U( y: {$ \0 ? e
return if @mouse_pos_setted
( y1 o: O4 x7 W9 f2 x" `
Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
$ N4 Z5 M5 M2 p9 E
@mouse_pos_setted = true
7 c9 g' K( Z4 }
@set_pos_prepared = false
3 Z: H y# w& ~) U
end
% ?) P* b, g3 J' e1 v
#--------------------------------------------------------------------------
) ] ?' R! J" u8 w- U
# ● 重设鼠标的坐标
6 I7 @3 g, x3 ^4 F. I
#--------------------------------------------------------------------------
( F0 Z+ H/ r* Y4 x- C: \
def prepare_reset_mouse_pos
5 \5 O. |) ]- D, w* {9 I7 e
return if @set_pos_prepared
2 O; N( c8 U# Y1 k
@mouse_pos_setted = false
* J) h* [0 ]1 w, W) s
@mouse_old_x = Mouse.mouse_x
4 g. ]. ^/ p' C! h5 z; J
@mouse_old_y = Mouse.mouse_y
. }: o7 Z- {0 K+ q' K" w0 w: O
@set_pos_prepared = true
: f* g# F. _3 P7 I) \) B
end
& ^, x, _/ N' N% F9 l& s
end
B3 |% r8 N+ s6 h7 t2 D' j! C
+ l% P8 P! @! {3 j4 d, q
#==============================================================================
; R1 I( ^% ^& g0 m' ~
# ■ Spriteset_Map
7 B' I" \, t: m, p, {( m+ c
#------------------------------------------------------------------------------
O, }& ?7 ~+ g- x* f3 j. Y+ R
# 处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
. x O& f! c$ E5 b( E
#==============================================================================
! p: i1 y' H& t, U6 ^1 I- ^7 \
class Spriteset_Map
9 k) C( Q9 L5 e: A! K7 l
#--------------------------------------------------------------------------
2 a9 H* f# K+ A d5 Q
# ● 生成路径点精灵
, y" s7 ]. D p
#--------------------------------------------------------------------------
# E/ N! u" s+ _
alias sion_mouse_create_characters create_characters
6 [9 P0 x6 j( n+ }$ O; V
def create_characters
$ N) g3 ?2 L# s3 H. v2 y" L+ {
sion_mouse_create_characters
8 G" T9 ]7 X7 j; M
@character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
6 W7 S( o) e; ?. g
end
" n) W' r- |& w5 \9 d2 [
end
/ }5 G! z2 ~/ F; [6 H- E
3 t6 x( F3 p- i h- T
#==============================================================================
, L: m$ _1 f- _ G$ \% V; O
# ■ Scene_Map
, T5 B; j+ T3 z0 x2 P
#------------------------------------------------------------------------------
& {" a; R$ u) _" I7 p% W; r
# 地图画面
5 |& I @& Z. W0 v7 l6 q0 B
#==============================================================================
0 m( c" U+ A: W( y9 x4 ]
class Scene_Map Scene_Base
, L' h6 s O8 N ^
#--------------------------------------------------------------------------
( g b" Q( v7 p% B
# ● 画面更新
/ O" z( q* O% w/ R4 o
#--------------------------------------------------------------------------
2 H' j' u, j; P; g" t/ S7 C
alias sion_mouse_update_scene update_scene
% N1 |; g% f* |6 v7 c
def update_scene
, P) S5 Z- w! E4 I- j. p
sion_mouse_update_scene
! ]" z! o' R: Y7 D- ^
update_mouse_action unless scene_changing
1 v: p7 {9 O* K& f9 k8 `8 s
end
2 \' R9 [/ @/ w" ^& x
#--------------------------------------------------------------------------
* d6 I1 ~" q# v. m8 i; z5 i
# ● 场所移动前的处理
' ]% p) d. w# U% |
#--------------------------------------------------------------------------
* l! k, T( Y8 S6 L9 G. s# ~
alias sion_mouse_pre_transfer pre_transfer
0 a5 B V6 W' E; Z' s. [
def pre_transfer
8 n8 o+ A0 M/ @& V2 r
$game_player.reset_move_path
. |% G5 ], z f6 {8 c
sion_mouse_pre_transfer
- [- F; A) h& o' M$ c! f- K/ f
end
1 o0 c9 P$ O- b& H" l
#--------------------------------------------------------------------------
$ Y3 f6 ~9 Y% Y) }1 _: x
# ● 监听鼠标左键的按下
# U% K3 x0 I+ @ L/ Z* S
#--------------------------------------------------------------------------
! e/ m2 t, M9 K3 H2 M2 O
def update_mouse_action
7 l$ w! `4 _8 S; ^! i7 b3 N3 C4 K% u
$game_player.left_button_action if Mouse.press(0x01)
# p; g8 I$ Z/ L* U9 G1 b' T& `
end
; C# ]% `4 L' f
end
( X, [* g3 _ X( U6 \. L- D, [
4 G0 a3 ?$ G4 _# U0 a
#==============================================================================
S& F: s* Z* Z' Z4 A( L
# ■ Scene_File
* j4 \0 [) k Y1 O
#------------------------------------------------------------------------------
! Y/ \8 z0 L- t) t/ o5 Z
# 存档画面和读档画面共同的父类
( h8 O* E d$ s5 k! A* M: [
#==============================================================================
# P; u# X6 i# i& h& r0 g6 B, p0 u
class Scene_File Scene_MenuBase
# z) p! W: {1 C6 q5 ^0 j
#--------------------------------------------------------------------------
5 M2 g9 s+ F7 h. q% z4 z
# ● 开始处理
$ ?! A& D! [3 h' q! T& e) ]: J/ |1 A
#--------------------------------------------------------------------------
S. T8 y9 j0 ?+ X4 `/ \0 b* ?- G
alias sion_mouse_start start
& T+ K- D' V" R+ q' q- x
def start
% e" _1 M- q: m2 ]2 E
sion_mouse_start
% `) c P9 S# E9 ~; j: k
@move_state = 0
( T+ ^( x- P% G9 H: g- z5 v
set_mouse_pos
% q+ Z; b# M1 }/ s
end
6 }1 G0 O5 p& F- ^4 p7 r1 H0 ^
#--------------------------------------------------------------------------
' L/ W1 L2 C+ u7 f8 v# P6 `
# ● 更新画面
- s+ z8 f5 f, Z
#--------------------------------------------------------------------------
/ ~/ W$ |& \; B: h9 F4 G
alias sion_mouse_update update
5 m( G: B4 H0 Q" ?9 ~
def update
# U" R8 o3 X, n: Y' _7 `5 t5 _
sion_mouse_update
. ~+ G2 x8 K( L1 d
Input.dir4.zero set_cursor set_mouse_pos
9 z5 @" Q5 { y$ H N& }% Y
end
& j5 A, J) |) Q; b) O3 C
#--------------------------------------------------------------------------
3 Y4 a. ]+ L- o) [ ~# L, l
# ● 更新光标
/ ~6 \; B& \ c1 V! m
#--------------------------------------------------------------------------
# z- F& X* b. {5 D1 s
def set_cursor
1 ~; h: J: N; j% o F& J4 ]
@move_state += 1
6 d! @9 R# n$ w2 R& l. G
last_index = @index
! c0 w0 O, f. U' w
if mouse_which_window == -2
5 W% B& u5 o6 i* O
if (@move_state - 1) % 6 == 0
4 m& q) P9 Y/ A4 L& d. M
@index = (@index + 1) % item_max if @index item_max - 1
! K* m, R8 Q3 i A; U; f C7 @
end
3 \* h+ k P) h' p* x) E
elsif mouse_which_window == -1
) x9 W |$ g# P1 M5 s9 }+ N
if (@move_state - 1) % 6 == 0
6 D4 U0 K0 s9 t, t0 n+ E" b' C. J y+ v
@index = (@index - 1 + item_max) % item_max if @index 0
* k4 y1 x' ~. Q7 Q6 k" R1 ^0 C$ l
end
' }' p( g" U( U. u3 q: H/ {) U
else
$ E6 {$ \) S% X9 A: d6 Q6 W. C+ Q0 f
@move_state = 0
9 `( @/ Z" e& p, n/ @
@index = top_index + mouse_which_window
A1 \' P5 j8 G: K% e3 f
end
7 W! V8 }2 h$ E% |+ l
ensure_cursor_visible
- T/ j, D; P8 W f
if @index != last_index
8 {3 Z$ s; w- c
@savefile_windows[last_index].selected = false
: i$ Z* U0 W) f# D* T/ [
@savefile_windows[@index].selected = true
/ Z/ I/ {5 T2 q
end
, ?" [& }- Y% J* B% o+ T* x5 H
end
# Y! K- a- L: o V( q# D
#--------------------------------------------------------------------------
. g; v9 F- x p" j5 {9 v
# ● 判断鼠标位于哪个窗口
, U4 n. E4 E. V2 u
#--------------------------------------------------------------------------
- R. p, {# o, d9 W% q- |3 ~
def mouse_which_window
9 H, A- l8 N: V/ i# b7 V0 I
mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
, `3 G }, Y r3 e% z! `! H
if mouse_y @help_window.height + 14
M3 q9 F5 i9 T3 Y
mouse_row = -1
1 B9 u+ J; a' S- X
elsif mouse_y Graphics.height - 14
4 Y' |) N% ]2 e, r4 G& r$ k
mouse_row = -2
7 L% c ?: K$ m
else
/ M7 c$ B+ f! V! N" o8 v
mouse_row = 4 (mouse_y - @help_window.height)
- S1 X4 x9 U" h! ~0 s9 B
(Graphics.height - @help_window.height)
# H8 T" I9 y* \$ N% t8 y
end
& D8 w0 f9 S3 ?# a8 I
return mouse_row
! y/ W) L( B7 V* o9 I
end
" h8 g! c4 Y9 ~3 y) @
#--------------------------------------------------------------------------
2 s% S6 l3 K a$ q q- n
# ● 方向键移动光标时将鼠标移动到对应的光标位置
; m2 e3 n; v X9 m7 ?
#--------------------------------------------------------------------------
+ y' H1 Y+ e: V
def set_mouse_pos
+ c7 t- f& O$ @; v9 b7 I
new_x = 40
' n# Q( w( |: j" k
new_y = @help_window.height + savefile_height (@index - top_index) + 24
9 p4 d! N# B0 p- z4 _1 e7 ?
Mouse.set_mouse_pos(new_x, new_y)
. b1 e0 ^: o9 u8 Z: [# z: @
end
( R& M( n6 X9 z& Z6 y
end
* E; Z p7 I- x9 f9 {: B0 \
# o) F/ H4 I; O3 W% i* W& R
#==============================================================================
& V* W$ U! g# C: x1 p! Z$ O
# ■ Game_Event
0 a f( g4 V* p1 D" k
#------------------------------------------------------------------------------
( b% m% b; J2 j$ v8 }5 B
# 处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
% H, I* G1 M! I1 @9 Z3 W* ]
# 在 Game_Map 类的内部使用。
6 m" M6 C) o+ i+ V
#==============================================================================
n, {3 g. ]+ F7 h2 |
class Game_Event Game_Character
8 @; g% H. `8 b6 j8 O0 e
#--------------------------------------------------------------------------
* N8 k3 x: X; p& K+ M- B
# ● 事件启动
: M! D x7 ~1 c# |: M$ A' a
#--------------------------------------------------------------------------
- D" Z k* n5 M0 A$ `% F$ K
alias sion_mouse_start start
. Z; N7 }0 O0 M* ^
def start
, a/ i0 V0 A6 z V, P
return if mouse_start && !Mouse.press(0x01)
9 k) V4 p! M& b g8 R
sion_mouse_start
( f* b' K1 {+ w9 r. J8 P+ \
end
# ]/ t' O8 ]# I7 \; j, Z
#--------------------------------------------------------------------------
( m7 \- r a- Y* i$ \+ \
# ● 判断事件是否由鼠标启动
: ~! R' Z- c2 `6 ~+ H
#--------------------------------------------------------------------------
& i% Y" k' `: b0 C
def mouse_start
3 h. u7 {5 `7 [
return false if empty
. }' y& @$ f6 T1 N: _, ?
@list.each do index
" [1 Z M; t6 J: J" X
return true if (index.code == 108 index.code == 408) &&
6 G2 X2 j3 i* u$ @9 }- u* e
index.parameters[0].include('鼠标启动')
( d! x' r9 C: r+ f
end
0 V! g# E2 q' d3 {- V k' o
return false
+ r I' `4 n2 t$ Z7 m8 U# ]
end
- C7 z; _& k/ c! ]# x
end
7 x& d- u ~2 x$ b7 k
; d& i4 d; c2 a' p
####泥煤的height
, ?4 [7 q, x+ S, Z3 U, |
# @height = height
% e* H7 w' [* p# c
0 x2 L7 ~' m* i0 v7 S! ?
class Area_Response
6 q+ W: e. X/ c# m) a9 @/ m' n
attr_accessor type
! R4 E( u+ J# x
attr_reader ox
4 s3 s. Y) E. l N
attr_reader oy
/ T, c \& J" F/ e$ h0 S: ^. A3 g
attr_reader width
* o. T2 I9 n* ?5 o& n( _! b1 m' r
attr_reader height
( Q7 N" o2 o2 u5 [
attr_reader switch_id
, o" g. v/ \& W5 n, }- [$ s" C
def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
& c+ Y5 i# b$ \2 a- w
@type = type
7 l+ t% C+ D0 ?* x
@ox = ox
0 h( {% o" E1 U; A# S: R- k
@oy = oy
( t, t$ m$ u$ ~2 z& ]' d
@width = width
; b, V8 w2 P3 X; i" X
@height = height
5 V% a @$ t' ` [
@switch_id = switch_id
2 N( p. V$ a, v) V% W5 P
end
6 T2 ^& Q6 a: d5 J% I+ e" {
end
( U2 h4 u7 }4 E+ X
" z5 D/ g5 t' F& i* e1 e7 r
$area_responses = []
% z. U0 g7 X4 D! E+ v+ ^
; c# C4 R& K: B2 A- b5 U
class Scene_Map
2 P; @% k( f# k9 Z# X+ W
alias update_mouse_2013421 update_mouse_action
: `% A) |. s+ z& M
def update_mouse_action
h( }$ N# f8 y G# u
update_area_response
7 z r: V- I% f# a/ H( d0 Z/ F7 O
update_mouse_2013421
- K( J& D% J4 ~
end
1 z5 I! y4 l4 @; \- d
def update_area_response
4 x8 g! }4 n; }. h4 k- z
responses = $area_responses
) S7 c) d% G( V% M
responses.each {response
6 ?: K; N0 Q, Y: g
ox = response.ox
, e. w. k6 _! w, P: L4 [% @
oy = response.oy
; k8 Z' i+ D' T, N
width = response.width
* s! C( n2 Y/ j( p0 ~0 @$ P# a
height = response.height
, x7 h& ~: l8 q" ~$ \" d' {
switch_id = response.switch_id
7 t/ i0 { Y; C
case response.type
. {& }" G1 l9 A9 E) b' A
when 0
7 D' c4 C) d) t( ~2 ~5 U: M
if mouse_in_area(ox, oy, width, height)
, s5 R9 [& t+ O& f. F9 A/ G9 z
$game_switches[switch_id] = true
4 m: i! i; c; Y, e- P* I
$area_responses.delete(response)
: }9 B4 [+ }. q4 l; W" B
end
7 f- }5 d2 U: l% J% y2 C/ T
when 1
# ~3 Q+ e8 O$ z' X9 L' }$ r/ Y
if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)
! ^5 G; H" E7 G% s; Z
$game_switches[switch_id] = true
# x+ G7 b3 B7 S1 k8 `6 ]4 [/ R9 e
$area_responses.delete(response)
7 w3 e6 b, O1 y
end
) a3 ]' w i4 _) W
when 2
1 \1 t0 q. K! ~% }7 e! L0 j4 M
if mouse_in_area(ox, oy, width, height)
( `; ~- w7 N& a8 s0 o
$game_switches[switch_id] = true
, ?$ T7 m1 V, n
else
1 s: E8 x' X8 ~% n' S) B
$game_switches[switch_id] = false
& g- H! T7 R. T- \% R* i1 a
end
. Z2 q" V- q [; Q1 D
when 3
# @$ E2 {$ A; ]3 V% l+ \& t; K1 F
if mouse_in_area((ox - $game_map.display_x) 32 ,
/ m0 W! m) \9 K: M! ~7 f
(oy - $game_map.display_y) 32, width, height)
5 Q7 x( y6 i" @( k8 @. ?5 F x
$game_map.events_xy(ox, oy).each {event
! G' w- S3 J' u/ C' x
event.start
2 c$ l- |2 p6 X- O
$area_responses.delete(response)
; G' \: H; ^3 Z. H4 e% j/ r+ h
return
1 n% I5 M3 A0 [, A6 X( I* U9 @
}
C. A- g) B1 r' `% c
end
" N, h3 c- J/ v
when 4
7 v; `+ \0 u* t* J7 l/ y8 B5 N
if mouse_in_area((ox - $game_map.display_x) 32,
0 X& W- Q% _& W) R! X) d
(oy - $game_map.display_y) 32, width, height)
9 G x" q2 e" _6 u$ B# J
$game_map.events_xy(ox, oy).each {event
$ } V }$ F) G" A n7 x
event.start
1 b% [% q/ f9 U/ N
return
. c1 r! H" L8 W& u3 `
}
4 L; h* E; l) T- d, p
end
. Q) g: K1 m O8 D p
end
+ A3 E" I9 u$ P6 ?1 P6 t9 {
}
" ?0 K* z' Z2 v2 ^) v8 b7 t3 d
end
- W. a9 K7 t6 C- ]
def mouse_in_area(ox, oy, width, height)
4 ^& W7 A2 b+ o+ t' U3 y
Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
3 S. S) O$ H5 R7 K' s, P5 @/ O
Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
; O' I1 ^1 s% L
end
/ f! P, x8 D' M6 f5 |# k
end
/ B' [' Q& K! ` J! r& R
class Game_Interpreter
! S6 R- t# a6 t! q, u4 F
def area_response(arg)
( h0 k* B+ r6 H
$area_responses.push(Area_Response.new(arg))
1 }* M- g8 Y; H# V, R# D+ A7 q
end
7 _- C. K- V' h8 D' Z3 }2 q
end
% C( ]" I- O2 _' p4 X7 k
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1