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

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