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