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

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