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