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

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