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

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