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