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

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