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

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