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

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