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

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