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