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

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