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