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

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