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

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