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

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