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

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