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