| 赞 | 1 |
| VIP | 171 |
| 好人卡 | 21 |
| 积分 | 4 |
| 经验 | 59678 |
| 最后登录 | 2015-5-11 |
| 在线时间 | 1291 小时 |
- 梦石
- 0
- 星屑
- 397
- 在线时间
- 1291 小时
- 注册时间
- 2013-1-12
- 帖子
- 3590

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