设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 629|回复: 0
打印 上一主题 下一主题

存放腳本

[复制链接]

梦石
0
星屑
362
在线时间
1292 小时
注册时间
2013-1-12
帖子
3590

贵宾

跳转到指定楼层
1
发表于 2013-8-29 09:01:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    . W8 P5 R4 }/ X- Z

  2. ( z% P7 [6 f+ V9 ]: I( K! ]
  3.   Sion Mouse System v1.3e! `0 m: ~. f, Y
  4.     g; R) y9 q1 Y
  5.   Changlog
    ! S4 P  y5 i0 X: ~( {: Z
  6.   
    . w6 w( l4 p" g- K
  7.   2013.4.21 v1.3f
    5 z. F4 `5 u/ A7 D/ P& p
  8.    
    / V( c+ i  a% O" X8 S; E
  9.     1.3f 卷动地图 bug 修正  I4 D7 C/ u/ z5 W6 J" u1 }3 l* e
  10.     - A$ }8 L- k* U4 @* N
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    5 F% d4 T  j1 m; v
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    3 h0 |# {# @5 Q  S% A
  13.                               Mouse.unlock_mouse_in_screen 解除锁定9 o. f" _. X' U# h1 f5 V
  14. $ @5 v2 C8 x& _% w: {7 F
  15.     1.3f bug修正: Z- S2 n$ r+ S( W8 x2 V
  16.   6 A3 c% @% ?, g+ w& X- ~( p1 [
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及! V* z, V; ~+ C! l0 a+ |
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    ; X( |! ~" r4 {9 \& T8 G
  19. % G$ a& O/ L' `+ @
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处- r9 J. V: X) ?; k
  21. ) k, j8 b9 H6 Q
  22.     1.3b 修正一些罕见的bug;
    & u. l0 B( `6 K7 {( a
  23. ) v$ e* N( |+ w( [! d' R" I0 m7 r4 ]
  24.     1.3a 代码小修改;
    , a1 X2 q* T1 `& p
  25.           加入了鼠标点击启动事件的功能,, v# R1 P; ]$ m" I6 m
  26.           在事件中加入“注释”: 鼠标启动  ,
    $ W) Z: E1 a4 M  d$ }: R
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。  Q+ U6 U1 Z  {  |$ G
  28.   
    : W  L0 p/ D- x# E% l) r1 I; y+ z
  29.   2013.2.12 v1.2& I: k* }: t% M3 O4 J

  30. , w5 U( F. X) i
  31.     寻路逻辑优化;
    ( p( i6 v0 M2 c7 ^8 x# Q' d
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    # w4 j0 F) B( U) K: }
  33.     现在支持用鼠标来操作载具了。
    1 n# Y! D  T. j& ?
  34. - i, e2 e" g* E& z0 x- A, R( v
  35.   2013.2.8 v1.1
    & b  b! ]  @+ p2 \# Q0 X
  36. ( M, L. t5 M% u( C
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;6 D; S; K% h! h1 t" |4 b
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    9 l0 T* l; o" ~, y* V3 S
  39.     移动时,路径指示点的绘制更加稳定;9 c- ^. e# u2 u/ v0 v9 o
  40.     现在支持默认存档画面的鼠标操作了。
    ' d0 T/ K* T1 a9 V' g( E7 j4 i

  41. 3 [7 `) w4 Q' w* U3 O" ^/ r2 L. p0 [

  42. 2 e+ c4 A2 z3 p/ P9 s
  43.   OrigenVersion
    ; P1 y7 \* V0 h8 h" ^  ]& I
  44.   
    5 b- H' T( @7 l5 {& c: V
  45.     2013.2.7 v1.0
    ! u6 V+ Q  W; Z$ K5 V+ F

  46. 9 b4 E+ W) K' n: n
  47.   主要功能+ A: Z/ k5 d1 `1 C7 G

  48. ( L# \( U1 y  F$ F: ~9 v& }/ O
  49.       使用鼠标进行各种操作...
    & O: G, k: X$ \  g
  50.       将鼠标锁定在游戏窗口内1 q& u, w: F2 K/ w
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    9 L1 |6 [# [3 D3 j2 ~  l2 m& u8 i5 a4 `
  52.       双击鼠标进行冲刺/ _, g" w% F% u6 p. i
  53.       更改地图卷动方式以适应鼠标移动
    1 Y- u4 j; O7 b1 Q, u6 {
  54.       变量输入框改良
    8 e6 v& x' ~5 [* H, k* {. ^, F1 }
  55. # i, ~) Z+ _% r2 Z7 |: X# D  ^
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    2 n# _5 q$ L" Q* P# B

  57. ' u, `8 h1 j$ \- M8 H
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
      A! k" p0 h* X; O' Z

  59. 8 _; K9 U/ a# C: x' X) w: _
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    / d  x, E- E& \4 ~

  61. # `( U* e( j4 G9 ?, h/ l
  62. : X% J1 i& ?& d& X3 v. b# `+ q
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    ) v' R; ~5 R2 {3 h$ Y" i
  64. 7 L# M& S4 {/ q6 `  H; y; q
  65. 9 B0 _3 m! z8 u9 w" C
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示# c' K4 @" n/ y$ e- @* f8 H

  67. 7 a" r; Z2 V1 W1 p. y; @1 J
  68. #==============================================================================
    $ a! @& ]' c: e6 P
  69. # ■ 常数设置 ; X+ J. o% l) M( O* o4 x
  70. #==============================================================================
    2 w( S1 I9 W* I8 J- \
  71. module KsOfSion1 x2 z* |' [3 }4 C+ \( J9 u' D
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false3 A+ N  K4 E) I" g( B0 w
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑" l, H0 f- J/ C6 h7 D& z8 W. r
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false: F. U! P; ~+ d' U* I4 C
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    2 A6 k9 D+ H. b5 i) V
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    4 J+ c4 o- g) I4 o
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧6 Z& b9 |/ F+ Z9 D: F0 @
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    + y+ f5 R. h" a  Q. L( k. P! ]: }
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键- d! h% s. @0 U
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)# }2 Z; y) S+ X2 z
  81. end7 z+ \* w% @' _; g" G+ I" g
  82. 3 t* I1 J2 N& {* h
  83. #==============================================================================
    ( L# D- l# x4 _1 g# |9 M* a
  84. # ■ 用来显示路径点的类
    , |& X$ w# W5 U$ ~
  85. #==============================================================================
    6 \9 _0 I8 N- t& s* J9 r
  86. class Move_Sign  Game_Character
    6 Z; G* l" x/ A) V6 O8 P( q
  87.   #--------------------------------------------------------------------------
    2 ]& O8 E8 j  D- E5 ]
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图- _8 Z! V7 j, t2 K. h" @
  89.   #--------------------------------------------------------------------------6 R) {5 h+ W* L4 K) y
  90.   def init_public_members
    9 e2 {; _0 U( b$ a
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹# h, w+ {' t4 ]
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0# O" H2 S# \8 U5 ]! M
  93.     @move_speed      = 5        # ★ 踏步速度9 I$ d5 y& @& [3 ?" {
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个); H# U, ]  N, Y: w3 m, r+ ?7 c# R
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度/ {- B) L3 v5 f
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)- Y& [5 w7 C/ i' P. T' P) Z7 G9 d
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列% W: o' m# @+ @. ]
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)# _; s5 j9 }0 [! w3 p. K: S

  99. 3 H1 Q: o  z: P* a! v* |

  100. 7 i% I- o% f3 g; g0 g" c- ?; r
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★" s* O6 q; z& U) z
  102. - ^: M+ K) S. k& {% n
  103. 7 r0 U, H: J0 ^6 o# q, @
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图% T, v$ v! P3 C  B& [
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    6 }- ]3 [+ V2 B; i

  106. 0 y8 ?# d- C, ]- F
  107.       if $no_arrowpic_warn; u) t. N1 ~1 F: s% h) |8 f
  108.         MouseShow_Cursor.call(1)
    0 Y! o+ C' C1 p( F
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    5 D0 S  q& w# k8 c
  110. 7 B) c, m0 S: F4 V  ]+ @2 E, c
  111. “路径指示点”将使用游戏自带图片8 q% n3 x( M" r9 Z, |

  112. ; c. n) `) A8 V& m3 w) u: b+ y
  113. 该提示可以在脚本内关闭')# N% E1 p3 o0 l& s5 F7 q! N9 M
  114.         MouseShow_Cursor.call(0)
    , o/ _# p  N0 r% t, S
  115.         $no_arrowpic_warn = false% |3 Z" B3 z/ h" a+ j, v/ b
  116.       end$ B) y8 k* z" P! S
  117.       @character_name  = '!Flame'4 A8 O# u3 s2 Y% p+ B  O& V
  118.       @character_index = 6
      a: D; M" j" t9 h6 K) {
  119. ) Q8 B) x. u' O9 Y1 Z  t
  120.     end9 }/ \" K7 Z# c4 J6 V2 ?
  121.     @direction_fix = false  # 固定朝向
    + S) ?( o# M  p9 r; D! A9 N
  122.     @move_frequency = 6     # 移动频率2 m5 V9 b. F* ~5 L1 @0 \
  123.     @walk_anime = true      # 步行动画  e* ?# ~: Y) F
  124.     @pattern = 1            # 图案- T1 D6 g; W% R
  125.     @through = true         # 穿透2 s. L" L+ o& G5 J  y# q, n
  126.     @bush_depth = 0         # 草木深度$ J2 p. G% o/ u6 T  e
  127.     @animation_id = 0       # 动画 ID
    " d- S) \; `% ?' H$ T+ v% s  g6 _
  128.     @balloon_id = 0         # 心情 ID  F" a8 u4 \- [" C3 f
  129.     @transparent = true     # 透明; C, [$ s9 |: d9 b, v
  130.     @id = 0
    1 W) [( M; D* g! ]! K
  131.     @x = 0
    # n* z' w/ x& T3 c5 q
  132.     @y = 0) t1 D; g: a9 m8 @- z2 y: o: e
  133.     @real_x = 0; P, Z) ^5 M; N+ t: {6 ]: {
  134.     @real_y = 0/ b" d% p. j% U1 k3 @" D
  135.     @tile_id = 06 i# J3 u4 t/ @1 d" f: U$ s5 V* ^  m
  136.   end+ D% X6 B$ b2 u+ Y
  137.   #--------------------------------------------------------------------------' e& Y# ?# V8 x+ W4 x0 i; b
  138.   # ● 定义实例变量. a0 n5 W+ T2 G& O" ]
  139.   #--------------------------------------------------------------------------
    3 o) m$ `: k5 l  ^7 K
  140.   attr_accessor direction
    % B$ W2 L8 @5 i  }8 K# G
  141. end
    8 Y' M# Q$ \; F; P+ K- ?9 r' h9 e
  142. * M- n. D9 b4 n2 ]
  143. #==============================================================================" t& X) b  |. Q( x, U+ n# l3 ]
  144. # ■ Module Mouse  h7 A" u( u6 S& m7 o* E5 r0 C
  145. #==============================================================================
    $ ^& W  L8 Y+ m2 f. c  r
  146. module Mouse/ @9 N% q& K6 T3 U. F) i: ~
  147.   #--------------------------------------------------------------------------
    % @9 A1 S) a2 W( h) {* v
  148.   # ● API) K! b' D5 }2 ?, v) O% ?; R
  149.   #--------------------------------------------------------------------------
    8 l5 g- L) _- J1 J% W% |
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    7 @: O  `6 m; l% \2 I
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i'), t- V. b# P: C* a
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    5 j6 o0 d1 M, q, b
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    3 N0 ]0 ^( h: L9 p' e
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')2 R( h* L( a3 b1 X# r& z
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    % C- W, v* ^, t# L# X9 G
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')4 K1 t4 J/ S5 Z  \" Q: u
  157.   Window_Hwnd       = Get_Active_Window.call/ j. L5 H* A4 L" C* Q' A8 g; }9 s
  158. ) p( i: {; J  [, |  @& E9 Q$ X
  159. class  self
    3 M/ h/ L8 K6 ^
  160.   #--------------------------------------------------------------------------4 _+ w) N8 E$ g% d. Y
  161.   # ● 初始化- F- _6 J' G+ `7 ^! n; e6 }. p, Z
  162.   #--------------------------------------------------------------------------
    ( U% v# [& @* |. H% T
  163.   def init5 s; {9 P' M' S) j. ?: O* t  {
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    1 f# X7 E% k" }" v  I' }( h. V$ `
  165.     @left_state = 0
    $ \! J. Z& K, U0 |. o& G
  166.     @right_state = 05 M4 z% Q- h% Q  e, J
  167.     @ck_count = 0 # 帧数计,单击以后从0开始$ @% I1 O* I# y- A4 U
  168.     @dk_count = 0 # 用于双击的判定2 p0 j! N2 Q$ B- m- _& ~: y
  169.     @clicked = false
    / }  O! v" q" k
  170.     creat_mouse_sprite
    # V# n- }/ i2 H7 r# H' r
  171.     update
    2 Y0 J# {  g+ u- Z& i, l5 H/ N
  172.   end
    # J9 N, U' u7 r% d
  173.   #--------------------------------------------------------------------------
    % `7 c, ^) z2 b  w, k
  174.   # ● 鼠标指针精灵
    ; C& ^0 f: m# t# e  L7 q. z* V
  175.   #--------------------------------------------------------------------------
    ' e- Y( {! E3 g) X
  176. #~   def creat_mouse_sprite' g8 F* w* |9 [8 n' v/ t
  177. #~     
    % v1 D6 m' W5 L' a( {1 `1 [
  178. #~       @mouse_sprite = Sprite.new
    * Q+ X4 d/ Z. v: l& q
  179. #~       panda = 2#rand(2)+17 \9 C3 ], }7 M
  180. $ c  Q5 v( y$ c/ h% z
  181. #~      if panda = 1
    " E9 ~8 \, v5 I
  182. #~        if File.exist('GraphicsSystemCursor2.png'); v. I3 K$ h7 H/ v8 H
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')/ n, j5 C, Z0 X- k6 Q
  184. #~        end#with if File.exist5 o7 P  k; X3 O' y6 [
  185. #~   
    ; B$ p* `" Y, m# M/ C) y
  186. #~     else if panda = 2 #with if panda=1( T4 M# f% Y% q4 G
  187. #~      
    ! J* E* S& y  I6 s( Q$ F
  188. #~      if File.exist('GraphicsSystemCursor2.png')  l: ~6 B7 V2 k
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')( m; M# z' T: Y- t1 j: }/ f! C8 o
  190. #~      end#with if File.exist
    8 F  g4 g9 a) Z5 G0 {# y: h# Y6 r
  191. #~      
    4 f6 p. B" i3 L0 U: {
  192. #~     else #with if panda=1- F1 n8 o2 k9 _0 E- H
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24): A1 t$ b& |# d7 G
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    & }9 }/ f: |% b3 n) @# M
  195. #~       Rect.new(5  24, 24  24, 24, 24))
      O9 ~& k9 {) B9 A* k0 q' i% f
  196. #~     end#with if panda=1
    * z0 B5 S6 |0 @
  197. #~     0 w" \/ L: C9 d6 r9 [2 K- q* U
  198. #~     #with def5 S/ b5 K& S; \6 U3 U! j) q* N
  199. #~   end
    ; V* T; g6 b' p
  200. def creat_mouse_sprite
    - |$ z; [2 S% P. s6 {4 c9 V/ `
  201.     @mouse_sprite = Sprite.new
    7 ^+ w# h+ _! A3 Z( ~+ W, Y
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})9 \+ L- ]* @; X. B- w# P
  203.     @mouse_sprite.z = 9999
    3 x4 ~3 I7 R5 }( p
  204.     Show_Cursor.call(0)
    : ^9 r3 h# H2 N! A" r$ k
  205. end, |8 ~+ \+ }4 x) H" p
  206. 0 u+ m& `/ j, I1 G6 e: e
  207.   #--------------------------------------------------------------------------- u+ _: Y3 m! U% B5 O6 d6 O
  208.   # ● 更新
    # t; O' J* ~4 Y2 c3 }/ \& I
  209.   #--------------------------------------------------------------------------- \: p) z- P+ h: ]" z% t' d# t
  210.   def update- }4 z6 j! C8 Y! J; x
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos; O7 F6 X9 z6 ]+ q$ m' ?* S
  212.     left_state  = Get_Key_State.call(0x01)
    : ?: Z& a* n. |& b# j
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    1 L+ \7 n9 y! K2 x. E( X1 ?' o" I5 C
  214.     right_state = Get_Key_State.call(0x02)
    ! ^. }' C) [  }
  215.     right_state[7] == 1  @right_state +=1  @right_state = 04 f! E, ?1 Q" K7 d# M* E; [
  216.     update_double_click
    " V7 k5 P$ D5 z. C
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    ! @" z' S5 Q+ W- B9 q0 U! d* b
  218.   end
    % K, t6 }2 N6 o2 {) ?( w! h  K( q
  219.   #--------------------------------------------------------------------------
    6 |2 E0 \5 b( X( ]* [! S
  220.   # ● 获取鼠标坐标
    # ~; @: ~; o! y3 y
  221.   #--------------------------------------------------------------------------
    * M+ e: i+ d" E& X, K
  222.   def get_mouse_pos
    # l) J& t! a- p+ Y+ k2 S7 @
  223.     arg = [0, 0].pack('ll')0 J. \* N4 m1 B3 g8 Z! B" i& ?
  224.     Get_Cursor_Pos.call(arg)
    / ?& @9 t) y+ Y# D* T. N
  225.     Screen_To_Client.call(Window_Hwnd, arg)( ]# A! v: t5 G" O1 D! a
  226.     x, y = arg.unpack('ll')' s# O/ p/ z4 Q0 s6 k
  227.     return x, y
    5 R# H, q+ R/ n+ J$ V( A
  228.   end: J& }- U! G0 Z# g: x  d% b# u
  229.   #--------------------------------------------------------------------------
    2 f1 U# u# I9 ~# o6 |& W9 X' _
  230.   # ● 将鼠标固定在屏幕内
    & L- Q0 A: t5 a8 y
  231.   #--------------------------------------------------------------------------) k0 O2 X$ k! N) t2 t( E. _) y" q
  232.   def lock_mouse_in_screen0 z* F, x' e: @- i. d; V5 g- S: b
  233.     arg = [0, 0].pack('ll')& d  I' ]7 g, w- M( f* j
  234.     Screen_To_Client.call(Window_Hwnd, arg)& s# B9 M  }, O
  235.     x, y  = arg.unpack('ll')
    ' ^: V% _4 o' `8 I) m
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    3 Q+ W- r( c2 L
  237.   end! Z; u2 e5 w. @# X& S0 g/ s6 }
  238.   #--------------------------------------------------------------------------
    . K+ J' B/ ]- \1 j! E) ~/ E
  239.   # ● 解除鼠标固定3 O6 a6 N( _6 v/ j: P. b  u* x
  240.   #--------------------------------------------------------------------------. ^' R1 S/ s. R" c  V$ ^
  241.   def unlock_mouse_in_screen; k) a& c3 _: n; M
  242.     Clip_Cursor.call(0)
    , U3 O4 o3 F. ]; ?
  243.   end4 Y$ J+ ~# M( T- v1 {) |1 w
  244.   #--------------------------------------------------------------------------( U2 H( Z) T) f* Z/ [$ V, B% N
  245.   # ● 鼠标双击判定9 E% T& Y) n6 c( @
  246.   #--------------------------------------------------------------------------, E" X7 m' p+ [" G
  247.   def update_double_click
    - w0 Z+ \* }) o5 s
  248.     @clicked = true if @left_state == 1
    $ k! f& {5 ^1 q& X! O2 h  K6 v8 L
  249.     if @dk_count  0 && @left_state == 1
    / p" x2 Z: j. q+ N/ J
  250.       @dk_count = 0; @clicked = false
    3 U; ~" |0 o1 C- n. Y- L* E! x7 y
  251.       return @double_click = true
      S$ X4 t7 Y0 h2 O
  252.     elsif @clicked
    6 _. k- r* {. A
  253.       if @dk_count  KsOfSionDbclick_Frame
    8 J$ t; {; w( O" J
  254.         @dk_count += 1
    , f4 g. l0 N$ B! J) Z
  255.       else
    0 ~: |. I0 C4 U5 X9 @1 _8 |
  256.         @dk_count = 0; @clicked = false& H9 ?7 y: b6 o7 \) h7 F
  257.       end, |2 p2 m" ]- Z; P$ K8 e
  258.     end" X/ G- X% W" n3 q6 i
  259.     @double_click = false
    . @+ Q4 C4 F& `$ @+ N
  260.   end: U- q& c; x4 m* }4 t! S: n
  261.   #--------------------------------------------------------------------------
    . l+ k& `" T& n5 Z
  262.   # ● 按键被按下就返回true2 Q, @8 y! c% ]5 X, C2 O
  263.   #--------------------------------------------------------------------------9 m: A- ]# c( Y5 P
  264.   def press(button)! s. g* j; C( t# c/ ?5 z
  265.     case button
    1 v+ X* d! d3 n  d) l
  266.       when 0x01; return !@left_state.zero
    - [% \, f, X8 f: k, X
  267.       when 0x02; return !@right_state.zero
    . M$ F0 R1 k1 ?& l/ j: O) h$ y
  268.     end2 K" L( M, F" {# V, W$ F+ \
  269.     return false( v" o0 ?; `! b
  270.   end; @  A/ Q+ Y6 ~7 k+ m: ~& [
  271.   #--------------------------------------------------------------------------- p0 K6 @7 B; D$ C5 L; [9 c5 d% y7 R
  272.   # ● 按键刚被按下则返回true5 G* `+ q8 C: I& w7 K7 @( i
  273.   #--------------------------------------------------------------------------: g1 R4 j# |" Q' E
  274.   def trigger(button)
    : H& R% O# }, a. \' k1 Z% u$ _" ?: q
  275.     case button
    & _; G# M4 Q  ^, q, T2 [
  276.       when 0x01; return @left_state == 1
    8 ]- q9 t; U# q3 i: U
  277.       when 0x02; return @right_state == 1
    ' H2 L6 N$ Q7 g) D2 P; @
  278.     end
    8 a) u0 {4 {1 }2 a; i' k
  279.     return false
    9 U. F# V) W0 e  m9 u! ^( `0 ^
  280.   end% V# h% L3 a0 [3 G" ]6 t0 N9 _
  281.   #--------------------------------------------------------------------------
      [3 S( _+ L3 Z4 A. a3 q
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    4 D1 b3 t, n1 c) y0 b( E- \. C
  283.   #--------------------------------------------------------------------------5 t3 k0 u. @( b/ ^4 m
  284.   def repeat(button)" z# b* |2 l- z3 D
  285.     case button
    3 r0 G$ t2 b5 Y7 r2 _, `
  286.       when 0x01; return @left_state == 1
    ! @6 K5 H  w% q8 K
  287.         (@left_state  22 && (@left_state % 6).zero)2 n8 @- G4 O7 U/ P  @/ z
  288.       when 0x02; return @right_state == 1 5 s0 P* u0 t% F' @9 G& B6 i. p: d
  289.         (@right_state  22 && (@right_state % 6).zero)3 ]( J. j/ H  v
  290.     end
    3 f7 t- `$ X, p5 }1 l  E$ F
  291.     return false9 k, x. I$ l7 ?
  292.   end
    ) D" R7 q" y; Q* ^; n  b
  293.   #--------------------------------------------------------------------------) J" h+ v- e( ]
  294.   # ● 判断是否双击鼠标. P7 {2 K6 Q& b, \. N
  295.   #--------------------------------------------------------------------------7 p  }6 I- R% ?" K2 d& U* A) T# F
  296.   def double_click1 f! h  O0 ?: P6 z+ f
  297.     @double_click
    3 m/ E4 ^) Q9 b, f$ c5 U+ r& }
  298.   end
    ) ^% x2 u* N  D" `4 u
  299.   #--------------------------------------------------------------------------' s7 C1 {; c/ s' V
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    $ a( B" j: D- v5 e* e
  301.   #--------------------------------------------------------------------------+ Y' h, |6 _- }/ {
  302.   def click_count
    # @) h# |: ~* P1 m
  303.     @ck_count' C% _, W  E. S3 R
  304.   end. F$ R: n6 `# P. l- D4 R
  305.   #--------------------------------------------------------------------------) u4 b- A4 N$ @3 e% F
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    5 \2 N# u" i' y- R2 d
  307.   #--------------------------------------------------------------------------$ s. c) n; F' r' c, a( s
  308.   def left_state
    * \- m  i; Z& {$ T
  309.     @left_state  }- s" Q; O9 ?# _7 n
  310.   end8 k* u% c* h) x, x* Z2 @
  311.   #--------------------------------------------------------------------------8 E- A' {* [% d$ G8 J
  312.   # ● 获取鼠标的x坐标
    - r# e; Z1 S( V$ W. x( w! D
  313.   #--------------------------------------------------------------------------
    7 o+ y% }6 H8 F& J3 I: E/ v
  314.   def mouse_x$ S0 t+ O+ M/ Q+ R' y  v! K
  315.     @mouse_sprite.x
    - Z& z+ j! P7 Y# N: h8 h+ m2 D
  316.   end
    6 H+ d+ b' e7 D
  317.   #--------------------------------------------------------------------------
    + K4 D( B7 }. g* ^2 @, ?  d/ g
  318.   # ● 获取鼠标的y坐标
    4 L9 I; }8 X5 S: P
  319.   #--------------------------------------------------------------------------& E+ l% g% @  [$ ?* ?% B. k, B* ]4 G
  320.   def mouse_y, e# ?. H, [3 c4 Z1 a2 z: Q8 b
  321.     @mouse_sprite.y
    3 B/ R3 Q1 g. Y! R# z; ~* z) ~' t
  322.   end0 @4 @& G) O/ {: v6 R, F1 J
  323.   #--------------------------------------------------------------------------$ n  `- c# R0 u) b4 o5 d' O
  324.   # ● 设置鼠标坐标! @, M$ C' [: I
  325.   #--------------------------------------------------------------------------& _2 g- P  l5 R9 h# }7 L" h- _2 \
  326.   def set_mouse_pos(new_x, new_y)
    8 r  l% g! a! `* Z
  327.     arg = [0, 0].pack('ll')
    ; H4 g$ N. `0 C% X4 K& A6 v* G
  328.     Screen_To_Client.call(Window_Hwnd, arg)1 e& [0 a# d, {  H9 ^4 l+ h2 @3 Y
  329.     x, y  = arg.unpack('ll')/ }. y6 ^5 @0 j: A* E
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    ! B3 |  z" S. o  `( v/ q( R$ r
  331.   end( ^% {- l( P0 D8 ^1 s4 B, Y
  332. end #end of class  self . _6 J2 ?, H3 Z4 ]$ N% j# F
  333. 0 @$ D* y* u7 j& D& B% E: d4 Q# d
  334. end
    ! e% c. u1 X: g- v2 B8 z. K' j1 ]( W

  335. 7 L- ?) `3 f! B, l
  336. #==============================================================================7 k4 V1 e2 I2 Z) u+ z
  337. # ■ SceneManager
    - s, s4 k- d8 A; t9 S, y6 A- p
  338. #==============================================================================
    8 n. |& K- J. g! M5 l
  339. class  SceneManager
    3 N$ x- C4 l2 k" M" n( M2 P
  340.   #--------------------------------------------------------------------------
    : N! n+ e2 p0 a) @
  341.   # ● alias( n3 a; x& R, x  V, `% I/ ^
  342.   #--------------------------------------------------------------------------
    # E+ i  H. ^$ r7 H. C2 ?# e
  343.   unless self.method_defined(sion_mouse_run)
    - s# @7 y( d) [. |
  344.     alias_method sion_mouse_run, run7 E1 Q8 V" k+ h$ }& i
  345.     alias_method sion_mouse_call, call2 @6 ~! @" l6 e$ D  ]
  346.     alias_method sion_mouse_return, return
    + g( n+ T5 f- w, A& r/ r+ h
  347.   end5 X* J. c% I: }. W
  348.   #--------------------------------------------------------------------------/ `# N3 H  s0 J3 L1 N- X
  349.   # ● 运行! m' R; k7 ~: W8 K: l9 C* C
  350.   #--------------------------------------------------------------------------  _/ ~3 Z3 b; z( Q% z  U) S$ I
  351.   def run7 f( z- X1 R4 ?( j$ A) D2 {  N
  352.     Mouse.init) k& y4 L" j6 E- S8 B7 S3 M
  353.     sion_mouse_run
    - v. w0 l1 }+ P! Z; H: e$ n- k
  354.   end
    6 P6 c8 h8 p$ u3 n  U! Q
  355.   #--------------------------------------------------------------------------8 D! ^! d( d0 h- C
  356.   # ● 切换
    ! E! O' l3 v+ L0 Y$ ^+ a
  357.   #--------------------------------------------------------------------------
    " Y  X5 E: `! x4 r' c& C
  358.   def call(scene_class)
    / m/ n3 f" \2 s( i% c
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)& y9 w# A! D; y* h8 r9 e
  360.     sion_mouse_call(scene_class)
    ; P' v% T6 ]( r) z* }" `
  361.   end$ R5 l1 C6 ]8 ]0 q' O
  362.   #--------------------------------------------------------------------------- E( r4 h, F) s! M* K, O0 s8 W
  363.   # ● 返回到上一个场景
    , N. W1 U; V, s
  364.   #--------------------------------------------------------------------------% [; ^3 N$ {7 Q. N* N* z
  365.   def return' J) d9 K. w/ h0 {) p/ f8 _
  366.     sion_mouse_return
    ' Q4 s& D! d3 S" ~2 U, }3 R
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&/ v% y1 F. B( y% d9 V8 _& k
  368.       @scene.instance_of(Scene_Map)
    " p- l2 M/ J5 V1 ]
  369.   end- L" g4 C) _) H  g0 `- V0 {
  370. end
    * E+ m% }. l$ d

  371. 8 a  r0 A* w; {6 C" U
  372. #==============================================================================" d. E8 }7 h- F8 ~1 `# S
  373. # ■ Module Input
    & Q" g! E' _% i* [! I, m
  374. #==============================================================================$ w: Z: }! w0 U# q
  375. class  Input' b1 G8 U  }$ A  f
  376.   #--------------------------------------------------------------------------4 \+ @, a3 R- n! C, L' S9 |+ E+ y
  377.   # ● alias
    / q# Y7 x+ H% M- t5 ~* E/ k( f' H( W
  378.   #--------------------------------------------------------------------------+ D- h( D/ X' M0 q9 l' K9 w+ s
  379.   unless self.method_defined(sion_mouse_update)
    8 a$ J/ K/ }( f6 Z
  380.     alias_method sion_mouse_update,   update
    # c, |* ^9 h3 Z6 w: n
  381.     alias_method sion_mouse_press,   press
    6 U6 f: d9 V: H+ u% u
  382.     alias_method sion_mouse_trigger, trigger' a6 |" @# A$ a8 ~, u
  383.     alias_method sion_mouse_repeat,  repeat
    , a  F* A, q% p. D  W4 a
  384.   end
    & M- x8 c0 C! j7 L4 d
  385.   #--------------------------------------------------------------------------
    / P) w2 ~, i  ~* k8 z
  386.   # ● 更新鼠标
    ( q5 X( w3 w6 _* W  Y: n: i! `( q
  387.   #--------------------------------------------------------------------------
    % D9 l% x. Q/ K5 p
  388.   def update) k5 ]$ i- h+ N. {4 ]% |4 H
  389.     Mouse.update
      o, ^! x8 ]9 F# D$ z9 Z4 Z% z
  390.     sion_mouse_update& b) f  w* l6 H1 L) [! o) f. P
  391.   end, k7 S' W- d* e4 J* c
  392.   #--------------------------------------------------------------------------
    * E$ w5 K; x. h' T
  393.   # ● 按键被按下就返回true
    + w: ?/ J4 T$ k; ~# ~* Q
  394.   #--------------------------------------------------------------------------
    ) w% A2 r. a$ S' s* }0 o
  395.   def press(key)
    7 @2 M- C3 l/ D2 I$ t; Y5 C; H
  396.     return true if sion_mouse_press(key). O$ t! |# U' U6 \
  397.     return Mouse.press(0x01) if key == C
    * u! ~8 `% p5 ^- U" ~5 v! K7 P
  398.     return Mouse.press(0x02) if key == B
    4 _3 \9 S6 g5 N! [
  399.     return false
    + o9 _* K8 o+ `+ q  p! n0 F
  400.   end
    5 s/ \; ]; c) S5 a) D  ~; L( q0 x
  401.   #--------------------------------------------------------------------------
    $ ?7 i% c1 d# |8 N  }- P
  402.   # ● 按键刚被按下则返回true& L% H, g1 ~) F) [2 J) y6 Z
  403.   #--------------------------------------------------------------------------
    . M0 W; u# ]2 t2 f
  404.   def trigger(key)
    % S2 q1 M0 l, F8 H  s
  405.     return true if sion_mouse_trigger(key)
    ; p7 s1 K- r3 n* U3 u
  406.     return Mouse.trigger(0x01) if key == C
    $ P- F0 I+ e$ _: S3 B& P+ M4 O
  407.     return Mouse.trigger(0x02) if key == B
    0 h3 `9 Z5 l; `2 U+ d
  408.     return false
    7 X4 c' u0 x6 x$ {! ^
  409.   end1 b) b0 G0 z( ?& M* L2 M9 F, P% A+ V
  410.   #--------------------------------------------------------------------------" O% S1 Y! _1 U1 G: L8 f, H2 \% S( ~0 N7 K
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    ( s; \% @0 B* g- i" t- {7 t: c
  412.   #--------------------------------------------------------------------------0 S/ x; r8 O% S) V4 p3 @
  413.   def repeat(key)' I  u( u# I/ K
  414.     return true if sion_mouse_repeat(key)& U$ l( k- Y/ \. W5 a2 ]2 F
  415.     return Mouse.repeat(0x01) if key == C, r4 t* y/ U- ^0 T
  416.     return Mouse.repeat(0x02) if key == B
    6 K: C4 ?2 z) }# C
  417.     return false; S/ p* `. B  B  I' E
  418.   end
    9 [% n) Y. w  U  [7 n7 f4 G8 J
  419. end
    & R9 r2 T' }1 }0 ]
  420. 9 X  C4 O, y2 M1 J( P6 G

  421. / l$ O4 e% M+ p- [; k* u' a
  422. #==============================================================================0 Y" {2 n  G! \- W7 L& c' W4 Y
  423. # ■ Window_Selectable/ C, q. p! o+ ?3 _  T
  424. #------------------------------------------------------------------------------8 C9 k5 @4 T* U- s2 B& G# Q# H& Q
  425. #  拥有光标移动、滚动功能的窗口3 t2 s9 T; Y+ K2 ]
  426. #==============================================================================
    6 n3 a+ O# `# v* I
  427. class Window_Selectable
    3 k/ ~. w: X. c
  428.   #--------------------------------------------------------------------------: _/ n; E) j" J1 W% d8 z
  429.   # ● 初始化
    3 y" w4 H! y* K8 X: i" E: X4 ^1 ]" C
  430.   #--------------------------------------------------------------------------
    3 M' b) h9 J5 V* c; B
  431.   alias sion_mouse_initialize initialize  a& `. ~1 _4 E$ w/ n
  432.   def initialize(x, y, width, height)
    % t' b  A) z9 d( M8 `9 X
  433.     sion_mouse_initialize(x, y, width, height)
    9 Z) H7 v, i# Q" o% @4 L5 F
  434.     @move_state = 0
    : l! G+ z% h5 ~# i6 @/ R, I% b
  435.   end
      E0 j7 |' `! ]+ W, w6 e
  436.   #--------------------------------------------------------------------------
    ) R% }1 a2 p  H
  437.   # ● 更新
    ) w2 _- q( M. @' @
  438.   #--------------------------------------------------------------------------5 Q0 ?* i# G: |1 s
  439.   alias sion_mouse_update update
    + p. m5 L' m, r3 p- I* F
  440.   def update$ k5 ?+ G# ]& x6 G6 q5 C; c6 L6 F
  441.     sion_mouse_update' N, V/ @3 ^( P- ?( f5 c% J
  442.     update_mouse_cursor
    7 d( Y/ l0 l/ s" e
  443.   end
    ( L' n' e, }+ ^6 R* U
  444.   #--------------------------------------------------------------------------% d" u- t. Q5 \* W: h' M; J; a
  445.   # ● 启动后设置鼠标到index位置4 D6 [3 W; o# w! I6 o
  446.   #--------------------------------------------------------------------------
    # i% M: i8 I2 g3 n" K
  447.   def activate
    2 R: ^  ]9 L- ?) d5 E! ~
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    6 y2 i* V2 s) |* H4 l1 _! S
  449.     super( X9 B$ y9 g( G7 T3 D$ k( z9 ?2 C) d
  450.   end
    , U* ^9 E0 _- L) d2 o3 w  O
  451.   #--------------------------------------------------------------------------) {2 k+ W' T7 ?
  452.   # ● 更新鼠标和光标的位置
    9 A, p+ T& Z" F) z
  453.   #--------------------------------------------------------------------------8 Z% V8 V  N  y9 N6 b8 F- b) B
  454.   def update_mouse_cursor5 P; C4 D' [: E. i1 \: {0 {: O- x
  455.     if active
    9 C/ k/ Z, j, O. S( i4 x
  456.       if @need_set_pos- b3 M! A: ^7 y( x# h" [
  457.         @need_set_pos = nil5 `0 m8 }& \  V+ i8 _
  458.         set_mouse_pos
    6 h3 v/ T% d- k9 n9 H7 w$ s
  459.       elsif cursor_movable
    2 D0 _5 r- q! e/ C
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    2 U( Y$ L0 b2 i6 H4 f2 a7 b- }
  461.       end; h4 a# V! s! V( v6 [4 ]
  462.     end6 \8 q4 T5 p* _1 Y5 M- T! J5 H& y, l
  463.   end
    $ c" i3 N, ]5 L6 M4 M3 x
  464.   #--------------------------------------------------------------------------: \0 q! J$ n$ J. _
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    : n4 ^9 R1 |! ?) B- ]8 w. P
  466.   #--------------------------------------------------------------------------8 B% Y8 G1 `& e$ s
  467.   def set_cursor  I+ h# B7 w& A9 C$ B7 v9 F
  468.     mouse_row, mouse_col = mouse_window_area
    % T7 S  @' V7 p: g  x
  469.     if    mouse_row == -1
    5 i5 k# T9 z! p& B6 y
  470.       @move_state += 1 if need_scroll
    ; P/ x" M5 @( g0 o' r
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand: G8 J* d! S( H- c
  472.     elsif mouse_row == -2
    + f$ j" K, u8 K) \5 V: d
  473.       @move_state += 1 if need_scroll/ x- s8 Q) }. [% X: D0 I: U  u
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ) p% g' o8 m- i: W
  475.     elsif mouse_col == -1& t4 A& I: l& ^; Q3 @, y5 u
  476.       @move_state += 1 if need_scroll
    2 u+ P' u5 l) L0 i/ Q* ^3 g+ [* T
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    6 a' r9 S! a, h+ ?- u; B
  478.     elsif mouse_col == -24 v: ?& d7 }8 f- C7 _8 B
  479.       @move_state += 1 if need_scroll& ^' S9 g  d! r% ^
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    6 {+ |$ u; }5 u* B
  481.     else- J" d7 h0 i$ T5 w) X2 N' E
  482.       @move_state = 0
    * c  `3 N  N$ l! Y) r
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col/ a' v7 j. ]+ C/ D* \
  484.       select(new_index) if new_index  item_max && new_index != @index5 _2 V! ]4 f. e) B6 S
  485.     end
    4 M% u4 y" ?% R0 e1 I
  486.   end- b4 T: e+ k( u$ j) R
  487.   #--------------------------------------------------------------------------# W5 C3 m. v8 t5 C2 u
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    9 n' O9 v9 M! |& W+ g' B, V4 o* L! T
  489.   #--------------------------------------------------------------------------
    ! `3 w0 y2 q/ S: ]6 v
  490.   def mouse_window_area
    * d; ~, @# Q* _. y$ z+ L; B
  491.     if viewport.nil # necessary!/ J* ^& c0 @! W8 i2 J
  492.       vp_x, vp_y = 0, 0
      f5 ?7 r8 t7 r* x) p  `
  493.     else
    1 \9 z. w6 G8 u6 m4 g( D: n, d7 o' {
  494.       vp_x = viewport.rect.x - viewport.ox# p8 _+ [8 m+ i+ S
  495.       vp_y = viewport.rect.y - viewport.oy
    * C: P# ~$ v. o3 ]8 y' x6 o" q
  496.     end7 u  O  G0 D+ {
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y3 D9 Y2 z0 k' L
  498.     item_x1 = vp_x + x + standard_padding
    3 L3 \( @' I2 l* a& y7 t. j7 P& K
  499.     item_y1 = vp_y + y + standard_padding. P) |. F$ U+ h( q7 {/ T
  500.     item_x2 = vp_x + x - standard_padding + width  Q3 D  s% R* }( W& h: F3 w
  501.     item_y2 = vp_y + y - standard_padding + height7 m5 X9 J9 w! j( W6 `4 \5 ?
  502.     if mouse_x  item_x1
    " w. M6 u9 w0 U: w' p+ V* `0 g# s8 K
  503.       mouse_col = -17 r. ^* g0 k. i2 W' z$ k
  504.     elsif mouse_x  item_x2
    6 b, R0 u  W: `4 {
  505.       mouse_col = -20 I, J+ R  _. F9 [6 J  N! C" D+ j1 b
  506.     else* {5 E) q' E9 V
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)# j0 b  Z& k* D8 F2 c+ W& a$ ^2 I
  508.     end% R# n: L; x' d2 B( Z) S
  509.     if mouse_y  item_y1; S( _3 a! K4 {  E/ u
  510.       mouse_row = -1. ?5 {, N. [( a6 X% x; p( M+ T
  511.     elsif mouse_y  item_y22 @) C1 s6 K4 c7 {9 s$ L4 w. n
  512.       mouse_row = -2* o; T+ ]" U+ a& s6 l2 X: N% R
  513.     else
    - d1 j' \- e2 C4 q8 O) f# ]0 ?& m
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    . ~7 s) {# ~, p9 ^, v' R
  515.     end; j  Y# y5 [1 K2 @5 W( o4 E8 p: g
  516.     return mouse_row, mouse_col
      T9 j* ?  b: N2 d) p0 m
  517.   end
    + R2 M" D. j$ f
  518.   #--------------------------------------------------------------------------
    ) {3 l- Y8 V; p/ x& s: o
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    0 ^$ I+ E2 v3 ^8 a
  520.   #--------------------------------------------------------------------------9 T" c* f7 x- f2 ]7 ]
  521.   def set_mouse_pos
    9 F$ C% v  e. ~5 P9 k1 L
  522.     if viewport.nil # necessary!
    5 u' T- F8 ?1 J" G) j5 x4 Q
  523.       vp_x, vp_y = 0, 0; [. T1 |& v( }* Q  s
  524.     else
    5 m. A4 n* f  J
  525.       vp_x = viewport.rect.x - viewport.ox* n8 _9 b6 T9 I5 |2 ?- m0 h6 e
  526.       vp_y = viewport.rect.y - viewport.oy) s( Q; Z# [* a8 R( m7 O
  527.     end
    6 U) v, e/ R2 w, ]5 F' t3 B/ L
  528.     item_x1 = vp_x + x + standard_padding
    % R2 v3 k! D0 m! N0 X
  529.     item_y1 = vp_y + y + standard_padding
    3 q$ M7 ?2 k& c+ V& q( n3 h
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index 6 W, S( O' r) T
  531.     row = get_index  col_max - top_row
    $ g( B! Q* t+ O4 ]/ D' c
  532.     col = get_index % col_max' E; v, o- t: f
  533.     new_x = item_x1 + item_width  (col + 0.5)2 {' M) f2 T$ i4 P. g
  534.     new_y = item_y1 + item_height  (row + 0.5)# L4 B4 }' I' [( E3 A
  535.     Mouse.set_mouse_pos(new_x, new_y)
    % K! T: Q' l% G+ ]/ ?
  536.   end
    3 I, V- l0 t: c/ i- i2 [$ O* L, ^% Y
  537.   #--------------------------------------------------------------------------2 H0 @; O" v9 R
  538.   # ● 判断菜单是否需要卷动. n7 H: c( ]" k/ a9 v: c  O3 p5 t
  539.   #--------------------------------------------------------------------------4 H: x  e, N* Y) C3 i4 e! [  P
  540.   def need_scroll
    / b" e& m# M! _* h
  541.     item_max  col_max  page_row_max
    4 `" s* f/ K% |( {- }+ f# t
  542.   end" z) O1 M  T$ r0 y3 e6 X
  543.   #--------------------------------------------------------------------------
    ( w! R- M# [( [+ ?7 ?  a
  544.   # ● 判断是否为水平卷动菜单
    . C0 B1 c& [6 y4 C
  545.   #--------------------------------------------------------------------------% k! v% P- A$ O0 n) g0 o7 e
  546.   def is_horzcommand, P! I) W- \7 t: t7 n
  547.     return false
    5 b$ P  J) W8 e( q7 e2 X
  548.   end
    $ t5 Y% q' q* U
  549. end
    ) \& Q5 `5 y7 o3 C" m) N

  550. & I; o6 S( m* A, c5 {9 D
  551. class Window_HorzCommand& _( x6 }- H6 k  w2 b! R: z# e, @4 p8 x5 F
  552.   #--------------------------------------------------------------------------+ X6 c7 I8 C+ _" A( A! s* o& g( L
  553.   # ● 判断是否为水平卷动菜单
    * [% c* \% J9 z! d8 r: y' P( i6 k
  554.   #--------------------------------------------------------------------------
    9 k" e3 F3 S( }2 o
  555.   def is_horzcommand% K0 d3 c( }8 y6 r8 ]
  556.     return true+ B$ ~; U" y. L3 {1 C  j6 E1 F
  557.   end( Q, j2 Q8 {3 \* K6 u3 V$ [
  558. end
    , G0 n9 r! {1 X7 h

  559. 3 {: t3 ]0 v/ A4 P" D% W! ^
  560. #==============================================================================
    + w  `, [: @+ j
  561. # ■ Window_NameInput$ w0 O! u7 |7 y  L
  562. #------------------------------------------------------------------------------7 K( g8 F" P3 U$ L& g  Y# z) ~
  563. #  名字输入画面中,选择文字的窗口。
    7 e3 h) D0 W9 |) @0 g
  564. #==============================================================================
    ' Q4 w" s- T: i/ s; I
  565. class Window_NameInput
    # E2 |7 |( {0 `0 E  U
  566.   #--------------------------------------------------------------------------, Q/ ]/ ]) V3 W9 w5 u
  567.   # ● 设置列数
    & \3 S6 @' B! @/ D6 a
  568.   #--------------------------------------------------------------------------
    3 a7 f3 K; P5 ]/ @& V# q4 y2 M
  569.   def col_max
    ) w, `+ T# P6 H  f3 f9 i4 ~/ _4 ~2 H
  570.     return 10
    ; A% G4 w( P; W. c2 [! i
  571.   end
    + _- Q* C! y; }  b! H$ ?8 y7 `  S/ _, B
  572.   #--------------------------------------------------------------------------
    1 D1 }* K, E8 ]" h2 U6 n4 j
  573.   # ● 设置填充的Item个数* I% _  P/ S! r: S$ I" u
  574.   #--------------------------------------------------------------------------9 _1 l+ n% N$ G. w8 H3 d) {
  575.   def item_max
    ; r: ?* }2 R/ `. }; h$ G0 ?
  576.     return 90) C2 p+ c& d2 E, }: v9 C
  577.   end
    " E' P+ l4 k8 {
  578.   #--------------------------------------------------------------------------8 Y: N, R, \' R. |
  579.   # ● 设置填充的Item个数
    4 U: n! H5 I; t# k( l: Y
  580.   #--------------------------------------------------------------------------- T6 d! h( j6 x2 E
  581.   def item_width
    + R( E$ x, U* E# o4 k5 U" \0 F
  582.     return 32" `. q& b/ m. a( l
  583.   end2 p' P- S7 p5 q. b9 M; B
  584.   #--------------------------------------------------------------------------) F9 z# a+ V5 T# K$ q! z, L- ?. C
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    " F- ~2 L5 Z; o! l3 a
  586.   #--------------------------------------------------------------------------4 ]0 r. d" f# A0 @* j  P  S
  587.   def mouse_window_area
    # W% N! |& d2 Q' w1 t
  588.     if viewport.nil
    / N. ~1 N/ S+ A$ j" @" O
  589.       vp_x, vp_y = 0, 0) d, F6 s3 C0 Z! R# d
  590.     else
    + d+ W' S4 M/ p! h3 j+ w
  591.       vp_x = viewport.rect.x - viewport.ox  f8 L3 O3 k, k9 G5 l, R
  592.       vp_y = viewport.rect.y - viewport.oy& }3 b5 J2 t7 I8 r' @& s9 ?
  593.     end
    6 q3 _7 U$ ]( v! _
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    , g" U* h) @3 ]$ n
  595.     item_x1 = vp_x + x + standard_padding
    , Z: P$ I" x, Y* C
  596.     item_y1 = vp_y + y + standard_padding) h5 A9 s3 Q/ K/ g) T
  597.     item_x2 = vp_x + x - standard_padding + width- F3 M6 t  M# d1 a" ?8 g+ k
  598.     item_y2 = vp_y + y - standard_padding + height
    2 }1 n) E6 k  a- m) }
  599.     if mouse_x  item_x14 Q- {- u. K0 K  K. \* X1 q
  600.       mouse_col = -1; W* b9 ~: k7 G3 G
  601.     elsif mouse_x  item_x2
    $ {; A  m1 K, ^! ~
  602.       mouse_col = -21 D2 Q! L% O- P
  603.     elsif mouse_x  item_x1 + 160# l& @4 b) y4 ^; J8 V/ o7 S  q, l$ k
  604.       mouse_col = (mouse_x - item_x1)32, @4 ], k) }5 A/ p- n% h9 c& d; w2 o
  605.     elsif mouse_x  item_x2 - 160$ K# [% B; W, m- C# j
  606.       mouse_col = 9 - (item_x2 - mouse_x)32- {& P4 `+ |" Z( U# V, i1 J" n
  607.     else
    9 v: D) Y9 Q5 f. ^$ X  U
  608.       mouse_col = mouse_x  x + width2  5  4
    / v- V0 M  \5 E8 t9 D  s
  609.     end5 t  P, O  [  l9 K) u5 P
  610.     if mouse_y  item_y1" {% O8 ~! ~, j
  611.       mouse_row = -1
    ) T; @9 Z' [0 l. x' b7 S3 l* u
  612.     elsif mouse_y  item_y2( Y: T! A1 E0 ?; b
  613.       mouse_row = -2# J, ^) U4 J, [' x
  614.     else' a* Q8 k0 R6 x$ y" {8 o8 T
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    / A. m* o( f9 Z4 d" k! T% y
  616.     end
    2 z; I0 Q2 e1 W
  617.     return mouse_row, mouse_col) s- [8 ~1 z8 {$ T1 P1 f
  618.   end
    & \+ Y; x3 k+ Q2 c8 d: c6 q' m
  619.   #--------------------------------------------------------------------------
    ( ~' h2 |4 x4 M, z9 G
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置& J! W: |- y' Z2 N
  621.   #--------------------------------------------------------------------------
    / P# t1 p1 @* d" k
  622.   def set_mouse_pos5 {3 L0 {. ?6 R
  623.     if viewport.nil # necessary!  p$ X4 c& L' h' C
  624.       vp_x, vp_y = 0, 06 E. |8 A5 C% k# Z
  625.     else1 w- ^  s+ e6 k; @( `( @! n9 v
  626.       vp_x = viewport.rect.x - viewport.ox
    7 R" F$ R3 J3 y4 M
  627.       vp_y = viewport.rect.y - viewport.oy
    9 [8 S/ f3 W6 A. d
  628.     end
    3 w* c. `2 |7 x; c# q: O! u! @/ M
  629.     item_x1 = vp_x + x + standard_padding 3 P* e& [  ]& E3 ]$ ]9 U3 R% T; `
  630.     item_y1 = vp_y + y + standard_padding$ m; Y0 {: v! p/ V; @# R9 _
  631.     get_index = @index  0  0  @index
    5 {5 z3 y# f! |* E
  632.     row = get_index  col_max - top_row
    , V" A$ b& u  p8 g6 y1 a6 m
  633.     col = get_index % col_max9 O8 ~/ [  \* u8 }* g2 \0 B/ M
  634.     new_x = item_x1 + item_width  (col + 0.5)
    7 Y2 S/ T* P' p) P
  635.     new_y = item_y1 + item_height  (row + 0.5)$ f2 ?7 f- ~; X+ g8 i
  636.     new_x += 14 if col  4, d+ B3 l7 B% [* Z6 J: S1 y+ d
  637.     Mouse.set_mouse_pos(new_x, new_y)' ?7 S, d& c. Q2 s: T9 p- X
  638.   end2 K3 v/ S9 \! a; F
  639. end
    # i, M0 z" o8 [
  640. : U) U' v  k, L) }" u
  641. #==============================================================================9 Z% D" z0 C' {& d! B. ?2 q
  642. # ■ Window_NumberInput" W9 n1 I% |5 a- `* \4 a' W3 h+ H: t
  643. #------------------------------------------------------------------------------. T& W1 o7 Y2 @  x6 j3 b4 d
  644. #  重写了数值输入的方法以适应鼠标, d0 Q' h8 [2 ]
  645. #==============================================================================
    0 Q5 ~9 f# D- H/ {9 [
  646. class Window_NumberInput  Window_Base7 W8 D; X* C% ^( b' G5 r
  647.   #--------------------------------------------------------------------------
    , c* G% N- I, N  t5 ?) w- i
  648.   # ● 定义实例变量0 E; ~4 J/ C: D5 ?5 q# B9 i$ N
  649.   #--------------------------------------------------------------------------
    - _0 J  \- B2 A& I- \
  650.   attr_reader extra_window
    0 j0 h; p5 e7 b2 E% D" g5 X
  651.   #--------------------------------------------------------------------------
    " r" ?$ G  w# ^4 D& U/ R8 E
  652.   # ● 初始化
    + x! [2 J, m9 @4 g. o
  653.   #--------------------------------------------------------------------------" p! p4 Y7 t$ M; T& o
  654.   alias sion_mouse_initialize initialize
    ( S) n. L1 D  F8 A! t# g
  655.   def initialize(arg)
    . B- ~9 \) P$ S% q
  656.     sion_mouse_initialize(arg)) n2 \( ]: b( G% O
  657.     create_extra_window" y4 X( d; X. ?  [3 V! W' n
  658.   end& C- n6 C$ H! X2 M1 e' G3 n
  659.   #--------------------------------------------------------------------------- u$ R/ F( e' V' P: ]* Y8 e
  660.   # ● 启动- k; E+ k$ O. q
  661.   #--------------------------------------------------------------------------
    $ G8 w; {* H# l( n+ U( f
  662.   alias sion_mouse_start start* w4 u: E7 m  t+ b1 R& V
  663.   def start+ R' v! \; Y; H% @2 H# F; O! T2 v
  664.     sion_mouse_start
    . p$ R5 p  N. `) F
  665.     deactivate5 c- W$ x6 Q3 o0 P1 w
  666.     extra_start
    ' k" C4 d8 g( n' d# c* f
  667.   end( Z  u: o, A2 C; L
  668.   #--------------------------------------------------------------------------" s) h& e7 ?) B9 B% L
  669.   # ● 创建新的数值输入窗口' H  Z# l; W1 E
  670.   #--------------------------------------------------------------------------
    ! n) D) O- p1 H& V8 U5 [
  671.   def create_extra_window0 v* _1 Y3 N# M% i( e
  672.     @extra_window = Window_NumberInput_Ex.new5 b/ [3 e* q/ r( ^
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    2 r6 ~+ O/ e* \
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    5 k* G7 r7 n2 ~1 B: Q7 [- }" v7 ?
  675.     @extra_window.index_proc   = Proc.new {n @index = n }! P( C( A& y) G+ |7 d9 U
  676.     @extra_window.close_proc   = Proc.new { close }
    ( o5 R. P7 P/ D
  677.     @extra_window.refresh_proc = Proc.new { refresh }' L1 h3 @) X2 N' }5 U  @- j
  678.   end
    * J2 K) r+ J& w" x& x4 i4 V
  679.   #--------------------------------------------------------------------------7 X' ^, q" [% o9 N4 N1 q1 K
  680.   # ● 激活新窗口' v6 [& m3 ?6 B% ?
  681.   #--------------------------------------------------------------------------3 A% o6 l" {* Z# {! b: _2 k8 k. l
  682.   def extra_start
    ) q. \# T" q; V. p9 h
  683.     case $game_message.position
    % I3 y, F+ p3 ~2 o3 o7 f
  684.       when 0; @extra_window.y = y + height + 4, E$ j% o5 F$ a  _' n! U  l
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8& t1 i  d; R! j) T( k3 x
  686.       when 2; @extra_window.y = y - @extra_window.height - 46 Z( ~5 o( c' B2 [& S# A$ V5 C- T
  687.       else  ; @extra_window.y = 8
    3 ^7 Z4 y9 `) _- y& p5 O8 A
  688.     end
    ' |2 l7 J4 G4 b% v5 h
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    9 t- B+ r! ^+ n! u7 H9 V
  690.     @extra_window.digits_max  = @digits_max
    6 s& c, j! F' z+ b0 f: f% P2 t1 ~' A4 Z
  691.     @extra_window.number      = @number
    $ o0 \( K) j, H
  692.     @extra_window.open, ?3 g5 @  X' E. {
  693.     @extra_window.activate& u$ P& c/ p5 ?3 m9 Y3 r
  694.   end  e$ l/ d) N* R
  695.   #--------------------------------------------------------------------------3 F& k5 V+ f) b. ^9 D; X- d
  696.   # ● 更新
    . W) f4 `0 t' q3 q, h4 F
  697.   #--------------------------------------------------------------------------
    * [8 ?& B. j/ J% H/ V$ c
  698.   def update
    & }, ]+ z0 G* w
  699.     super
    / g. N# \& s6 i5 U: A
  700.     @extra_window.update
    # \( l2 B' {" w" ]5 I3 z
  701.     update_cursor' ^! k# e; E# `, K
  702.   end
    2 `9 k* D5 y/ ], B" d4 C) g
  703.   #--------------------------------------------------------------------------
    6 k5 Q# E' T$ l( g4 }
  704.   # ● 关闭窗口) v' l/ z7 H/ {5 v" W: ~! e5 y
  705.   #--------------------------------------------------------------------------
    ( t9 V* U5 @9 J" c% L/ K4 c
  706.   def close
      V" x) v) S7 ~7 x4 r+ }+ J) f' L5 F
  707.     super  T; j6 n' j3 D! b4 ]
  708.     @extra_window.close9 e1 g, `! k  Y" b4 |" {
  709.     @extra_window.deactivate
      N1 ^5 C; v, F+ L# T5 X: h
  710.   end' O: V- o& p( c% T
  711. end
    # U" h( Y$ ?" I
  712. + n) E& a' s2 q, z) d6 F
  713. #==============================================================================5 M3 F; p: d# f- Q
  714. # ■ Window_NumberInput_Ex
    1 Y7 U6 Y8 L5 ?; a
  715. #------------------------------------------------------------------------------6 q+ ?6 a# h0 R: Z/ L# n, A
  716. #  新的数值输入窗口(NewClass)
    2 v7 f  P* ]& n, L9 F4 X
  717. #==============================================================================5 e0 N0 e% Y* T5 y% g( @. M: N1 D
  718. class Window_NumberInput_Ex  Window_Selectable
    3 W, C2 d  q( U+ b
  719.   #--------------------------------------------------------------------------
    7 y. ?/ P- @- N% y6 b
  720.   # ● 定义实例变量
    * G% r# i- n& w% a* @
  721.   #--------------------------------------------------------------------------& }4 I, F* S+ ~4 X
  722.   attr_accessor number_proc2 s- c1 F: z0 O8 x" u4 P0 O: m
  723.   attr_accessor index_proc7 w8 i7 A2 L! ~0 m6 ^+ t
  724.   attr_accessor close_proc
    # V( i; \# B3 M+ W8 Q
  725.   attr_accessor refresh_proc: X4 ?, m9 u& C8 u7 _, d
  726.   attr_accessor number: n7 y5 [* _9 Q+ N
  727.   attr_accessor digits_max
    . p0 q& {: [# e, h% g
  728.   attr_accessor variable_id  i6 {( r) G) g# {2 [' |  B! Y1 R
  729.   #--------------------------------------------------------------------------9 m. r; ]; Z9 v: O) x7 [; ]- r1 ^
  730.   # ● 数字表
    * v# |( P: f0 H8 C8 E
  731.   #--------------------------------------------------------------------------! g7 v9 G& z. H- s' D/ p2 l' i9 m
  732.   TABLE = [  7,  8,  9,
    / @6 n; z! G9 |- r
  733.              4,  5,  6,
    # Q8 D- ]9 ~4 i& n* ]  A
  734.              1,  2,  3,2 l  z: L$ E8 Q' N
  735.             '←',0,'确定',]
    0 b  P7 T9 J& m* }  r+ f+ ~
  736.   #--------------------------------------------------------------------------) O* H( f$ {+ u
  737.   # ● 初始化对象% M& G4 x% g( {
  738.   #--------------------------------------------------------------------------8 E* P/ F- v7 j; k# A  G6 ]
  739.   def initialize
    % r7 B$ D, x" l) x9 i
  740.     super(0, 0, 120, fitting_height(4)); k/ B0 E4 E6 ^& m
  741.     self.openness = 0
    1 b$ z9 z* j: E) |6 F  ^
  742.     @index = 0
    / `8 k5 L% h6 M  s
  743.     @number = 0) d" `$ t7 A; U1 u7 }) D
  744.     @old_window_index = 0
    4 Y3 ?) G% v( E" U0 a$ U$ D# ]
  745.     @digits_max = 0
    6 ~5 s& x, P% j6 S5 ~& e
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }
    , H  J8 b2 ?( [$ B
  747.   end
    ( O5 B( g( ^4 p9 m1 I
  748.   #--------------------------------------------------------------------------$ K8 Q& o2 D1 m9 T+ t: `+ _
  749.   # ● 获取项目的绘制矩形4 s: h6 a; I; _6 @5 d! a
  750.   #--------------------------------------------------------------------------4 Z& D1 W1 f* ~/ V6 b$ l7 f
  751.   def item_rect(index)
    : j) c+ `# ~- z8 j# N, c  R
  752.     rect = Rect.new/ B4 w; D4 _" F1 A
  753.     rect.x = index % 3  32
    5 R. B( D: W& ]+ h8 Q& y; V
  754.     rect.y = index  3  line_height0 i' O  |. O: b, U9 e# r2 O
  755.     rect.width = 32. C! F. S. b* f6 k9 M* }3 U* P
  756.     rect.height = line_height
    7 `; P# {: O* ]/ b% N  ^
  757.     return rect
    , s' o( r9 t) J
  758.   end8 _" X. R% o7 y& P- R' t
  759.   #--------------------------------------------------------------------------
    " Z4 S8 o8 `6 ]: z6 ]
  760.   # ● 将光标设置到鼠标所在的位置
    6 M" T) B- }0 i$ L7 ^# M
  761.   #--------------------------------------------------------------------------
    # F: N. s5 ]+ l& Y3 L  n% `
  762.   def set_cursor
    , @! N" M) e* r- W# c& D5 ^! `0 `) u3 B
  763.     mouse_row, mouse_col = mouse_window_area6 H0 f- I8 G& {. b5 U
  764.     if mouse_row = 0 && mouse_col = 00 C5 b! B0 M, J% t6 h4 `: Y
  765.       new_index = mouse_row  3 + mouse_col
    8 N) `: N  T& |# T  [( h' F
  766.       select(new_index) if new_index = 11
    8 o8 J& a  M( |1 W: N
  767.     end
    2 L& @3 z3 a1 j/ {( v1 f# x. U! ^
  768.   end. V" E: k5 }7 {% B3 S
  769.   #--------------------------------------------------------------------------: Q4 B+ \- @$ |- ?: {8 F
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列4 f5 x/ C. S0 I$ W$ M
  771.   #--------------------------------------------------------------------------4 Q6 H% u4 J  }! Y% Y. d4 k
  772.   def mouse_window_area1 j8 l- ]8 i' `; f
  773.     if viewport.nil9 G. m5 K/ J( N8 G3 [) J8 ]' {) \
  774.       vp_x, vp_y = 0, 00 t( P! _' k$ z! w
  775.     else% M. H( C, s2 _; n3 g3 J& j
  776.       vp_x = viewport.rect.x - viewport.ox
    , N1 ]  B, ~: G1 i  B: m; r& q
  777.       vp_y = viewport.rect.y - viewport.oy
    + a9 }0 {, H, N5 B% ?
  778.     end
    : F7 o; x- m2 n8 {; E6 p
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ! |2 k* h+ c  z% U5 m' e$ U  D
  780.     item_x1 = vp_x + x + standard_padding # d, K" P+ s9 V4 P$ \
  781.     item_y1 = vp_y + y + standard_padding
    1 N# Z# I) \4 E2 a9 s% r2 L# i
  782.     item_x2 = vp_x + x - standard_padding + width$ i3 B& d! B+ \$ ^  L
  783.     item_y2 = vp_y + y - standard_padding + height
    : }: u. j* D7 ?/ o# N
  784.     if mouse_x  item_x1
    8 O+ g  n7 `" ~1 }1 E
  785.       mouse_col = -1
    $ w: L$ y2 l0 s/ u& P( P+ c
  786.     elsif mouse_x  item_x28 W( x5 h0 F* O  z, D2 V
  787.       mouse_col = -2
    4 d3 ]9 F9 {8 x! [/ s% \
  788.     else
    ( _3 H9 T, c8 k: b8 w
  789.       mouse_col = (mouse_x - item_x1)  32' d* u4 O3 R% \$ z1 h  P
  790.     end) z8 L5 G  v) B) _
  791.     if mouse_y  item_y1% G3 ]. C+ J8 b( V
  792.       mouse_row = -1
    6 [: @4 U. {* a) q/ B# ?9 S( _
  793.     elsif mouse_y  item_y2
    3 |" y+ O2 L3 C
  794.       mouse_row = -2
    , k, A& N* C$ s+ B0 v/ d
  795.     else
    7 |: w3 V; g6 ?, G; \
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    3 G; c4 L- a% @" D7 }7 \% c
  797.     end% i3 m3 g" x) T5 n6 k$ ~9 Y; R5 ^
  798.     return mouse_row, mouse_col
    # `5 d+ W; |; G7 @4 P1 u7 h9 X
  799.   end0 F: }* F% K$ L" |0 M7 h
  800.   #--------------------------------------------------------------------------4 T! @, }& B% S, n
  801.   # ● 获取文字
    * F/ _! m; \1 d. l7 P
  802.   #--------------------------------------------------------------------------
    + x2 U1 F$ L- S/ p) p; ^
  803.   def get_number1 E7 M$ D# P" A: E
  804.     return false if @index == 9  @index == 11
    2 ?! N, p: D2 r, _; G! z
  805.     return TABLE[@index]
    7 e) ?  U9 R4 Q& ]7 G: y" ~
  806.   end* S8 K/ y+ I; I, ?- q% X
  807.   #--------------------------------------------------------------------------' y( a0 p. @$ O3 a# U1 I8 ]
  808.   # ● 判定光标位置是否在“退格”上
    ! E3 G# ^3 y2 X7 s' ~
  809.   #--------------------------------------------------------------------------4 ^; k( u3 I7 y2 E8 C+ P; g; T
  810.   def is_delete
    ( R$ h4 T2 v1 C: f: f
  811.     @index == 9
    ) ~$ z5 r, j8 ~% j
  812.   end
    % o; Z9 O& \' \  Q" _
  813.   #--------------------------------------------------------------------------
    8 |# a: C! ~0 c: j
  814.   # ● 判定光标位置是否在“确定”上
    " ?1 O% }9 F) ?4 a2 F. k% f
  815.   #--------------------------------------------------------------------------
    2 O- @! w$ H2 e  l- ]6 `
  816.   def is_ok
    3 Y9 v' d1 F4 _0 w  A+ P
  817.     @index == 11
    " w) q4 ~5 k2 N% U# _; Y
  818.   end# O' V# ]' A2 F, ?; Y% \
  819.   #--------------------------------------------------------------------------6 @5 u& {0 a1 R* D/ j) E# R& G
  820.   # ● 更新光标
    , R7 F2 q- C$ D/ z3 E
  821.   #--------------------------------------------------------------------------
    ) Y5 d0 L6 d& A- T4 I0 y2 d; @
  822.   def update_cursor. Z0 @- o2 W$ g" @  t
  823.     cursor_rect.set(item_rect(@index))% ~2 R* g. y# b* d
  824.   end
    ; I" o7 k6 e- B' t9 \. ~# I
  825.   #--------------------------------------------------------------------------$ v+ E$ Z5 p2 u& y# L4 m! d
  826.   # ● 判定光标是否可以移动# Z4 @1 [9 `2 n: ]" r* x
  827.   #--------------------------------------------------------------------------
    $ Z" a* p; S0 N) x, T0 g: s
  828.   def cursor_movable
    + ?8 N. b; B) {% n8 }
  829.     active: [& A# \+ g0 a$ {* e5 A1 g
  830.   end
    0 N( U: K$ H8 ]- K7 h
  831.   #--------------------------------------------------------------------------4 o5 g: S- v7 L  c
  832.   # ● 光标向下移动. b! R! H5 k) l  Q) G" V
  833.   #     wrap  允许循环
    . E* x% h9 e% K3 b4 _
  834.   #--------------------------------------------------------------------------
      V9 G) l; m/ x  I: @5 ]/ G
  835.   def cursor_down(wrap)# J# i" C" i- X6 p" L) b
  836.     if @index  9 or wrap: B7 N! t1 H, [+ A8 l0 O
  837.       @index = (index + 3) % 12% u/ I1 N3 y, ^. X0 g! j) Y8 L
  838.     end
    : c& j7 O! B/ x! C2 M. ~
  839.   end
    - S/ \  ?! k0 K( Q' N+ {  l" N, w
  840.   #--------------------------------------------------------------------------4 |) E; Q: U: N- a
  841.   # ● 光标向上移动) }/ ~8 Q  ~1 U0 x& R+ V; [
  842.   #     wrap  允许循环. ^; \0 i  ^. M1 J: \* L4 e
  843.   #--------------------------------------------------------------------------
    5 D- q* H% A/ z/ i0 C4 L' Z
  844.   def cursor_up(wrap)' u; n* O% s: ?& |2 T- W/ i  {" X
  845.     if @index = 3 or wrap
    ( s: M" m' {. w) X- Y& V: M. T
  846.       @index = (index + 9) % 12
    . \, N' S1 I( \+ i
  847.     end$ A# l  S+ X' w7 S
  848.   end
    " v+ Z6 e9 U- H& _/ ?7 v8 Y4 H
  849.   #--------------------------------------------------------------------------
    1 M' F1 [/ M* \! p$ m
  850.   # ● 光标向右移动6 y* p6 }/ v8 c; Q
  851.   #     wrap  允许循环# K4 ?# ?  X$ ?6 M+ ]9 G& R
  852.   #--------------------------------------------------------------------------
    5 c1 g; g) B' l4 `4 v3 S. P
  853.   def cursor_right(wrap)
    6 x" g- h9 B3 q: \
  854.     if @index % 3  2
    & C6 S& g' n* U. ?" q
  855.       @index += 1
    : H, K- j- ~0 s$ F5 o/ ?  J+ C
  856.     elsif wrap1 c( w; Y% B; y! n  T7 i* \/ H
  857.       @index -= 2
    " @- h/ L- F6 [, @3 D0 A7 s1 e
  858.     end/ A$ T; \& r; r$ o
  859.   end
    2 V  _1 M3 F6 Y0 u! z+ l- C3 Y9 h
  860.   #--------------------------------------------------------------------------" t* O& w- ?! k& S4 E. e
  861.   # ● 光标向左移动
    ' k* T9 `6 _' C
  862.   #     wrap  允许循环
    ; }- `" p% `, w5 j* B9 v) V- Z1 V
  863.   #--------------------------------------------------------------------------
    ( z, u% U9 S, Q- a. L9 s! m: S
  864.   def cursor_left(wrap)
    # a3 ]1 {5 L. e4 g% P! J0 `; x
  865.     if @index % 3  04 n" q: M& @2 v2 K! D2 p
  866.       @index -= 1, w/ L+ k* ?, g0 T- p3 ~
  867.     elsif wrap
    4 a+ q6 B8 j, R3 ?/ `% N
  868.       @index += 2, W1 Z$ `# w! a! A6 @; i( X9 R: C
  869.     end; r- c4 G! y3 ~) r! }
  870.   end! Y! W! B1 {: f/ w9 q
  871.   #--------------------------------------------------------------------------/ j# v- z; f/ W% U
  872.   # ● 处理光标的移动
      ?  I3 h6 }1 h3 P7 Q
  873.   #--------------------------------------------------------------------------1 f- h2 h1 P! W
  874.   def process_cursor_move' i2 c  P$ s1 o( v- S" ~
  875.     super
    % h: U: j) h* r" v9 |* N% x
  876.     update_cursor4 Q5 g' H' r9 F% R
  877.   end
    & i$ Z$ d: l( c; \
  878.   #--------------------------------------------------------------------------
    . v7 @/ T# a( a8 p& M) Y; }3 N
  879.   # ● “确定”、“删除字符”和“取消输入”的处理4 K- o4 @9 B* k% c
  880.   #--------------------------------------------------------------------------
    ; f& o: X# @2 M! v& O' o
  881.   def process_handling* }( r* ?2 ~; g9 C/ v
  882.     return unless open && active( {, R) `$ p1 F$ @; u1 K% Y; h8 c
  883.     process_jump if Input.trigger(A)" c4 a" ]# P- F# g% w
  884.     process_back if Input.repeat(B)
    1 ~; ]! l4 J- b9 e9 ^7 ]5 U
  885.     process_ok   if Input.trigger(C)1 L' R4 Z% S6 \0 s: m% y+ v
  886.   end  e& `$ W5 j5 d0 o& K
  887.   #--------------------------------------------------------------------------* [: g4 w) j9 c) [% u
  888.   # ● 跳转“确定”4 w7 _( x# q+ P  w# X5 d: Z! ?
  889.   #--------------------------------------------------------------------------
    7 B7 ^3 g7 ^, t% ^! ~% y
  890.   def process_jump* D/ c2 H- i" C, q: c; }
  891.     if @index != 11
    / b- h- Q$ V$ g# ^
  892.       @index = 11( b  X4 K/ E8 k/ L( X9 u
  893.       Sound.play_cursor
    7 P! o& [1 y. M% R2 U  G+ I% D
  894.     end5 p5 [' h& E) y6 p
  895.   end9 N! B; a- v( v7 {3 b% C
  896.   #--------------------------------------------------------------------------
    1 T. k  z* l) Z! R  k: }  j3 Z
  897.   # ● 后退一个字符
    ! I; f% {. \1 {1 p& R3 @. x
  898.   #--------------------------------------------------------------------------
    - i3 _6 ]& S9 z* Q6 I
  899.   def process_back' k6 |" O1 ]2 a* J, K
  900.     Sound.play_cancel8 ^) W1 f7 E( S& e% O
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    / c  m$ \. I( |1 u$ Q" r
  902.     n = (@number  place) % 10; K3 w7 @* M9 g% [
  903.     @number -= n  place
    # m% `, B9 w/ G; m& a5 C% A! `
  904.     @number_proc.call(@number)
    * G: g( d2 [' Q/ H, F9 k" J
  905.     @old_window_index -= 1 if @old_window_index  09 P) V8 ?7 [$ }+ ~& v' ?
  906.     @index_proc.call(@old_window_index)3 l' Y) K# P2 L5 d4 s5 c; h
  907.     @refresh_proc.call
    8 @& a9 e7 \' R, E6 u5 k7 ^
  908.   end
    9 S  H, \, N, ^7 c/ X+ W
  909.   #--------------------------------------------------------------------------
    6 }) }1 z! D* F0 F' i, M
  910.   # ● 按下确定键时的处理5 n. Q% _$ e. ]- C% m- L5 z
  911.   #--------------------------------------------------------------------------" q' J# w; L- F' W* a
  912.   def process_ok) n: X+ p5 }, B, c4 Q) ?& I; C
  913.     if get_number
    ' s1 W6 y$ T; q
  914.       Sound.play_cursor! v7 P- T$ p+ d! X1 {
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    & O- l$ ^: M& |/ D
  916.       n = get_number - (@number  place) % 10
    7 N# n& O! h9 H8 x! B/ i0 z
  917.       @number += n  place$ x2 s9 c! @( b9 O( L  }6 ~
  918.       @number_proc.call(@number)
    / J0 G( J; ]3 n9 u: {
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1
    ( B7 E* Y5 I; r" o; Q( K
  920.       @index_proc.call(@old_window_index): b! a& C* O) {$ }9 @
  921.       @refresh_proc.call
      |8 W! c; _0 ?& _, D
  922.     elsif is_delete7 L2 l4 H- `! H# M+ x
  923.       process_back  |1 \) s6 A% i. R) d
  924.     elsif is_ok
    3 j. D, [  g, l# y
  925.       on_input_ok8 X- J! p, L+ j, j& r9 a8 R( T
  926.     end9 }4 z4 V0 \9 o# L
  927.   end
    ) l6 _' a* I: ^- V+ {6 f7 F- p
  928.   #--------------------------------------------------------------------------
    ) s7 s& S! ]1 W1 U
  929.   # ● 确定
    3 x* i9 }6 ^6 U( n
  930.   #--------------------------------------------------------------------------' J! y4 W" G' X* L
  931.   def on_input_ok
    # C) F" m: }/ \( i8 V- C6 U. h
  932.     @index = 0
    ) r( ^9 x: |  }7 f( {
  933.     @old_window_index = 0
    / T9 |( h% W' v
  934.     $game_variables[@variable_id] = @number
    2 t3 a4 p! l5 S3 L' K
  935.     Sound.play_ok7 U+ b2 {  P4 h, v) g( K
  936.     @close_proc.call5 m. y+ w* A5 Q& t2 M4 F4 j
  937.   end
    & `( n4 G/ ]. v6 a! X, A8 e
  938.   #--------------------------------------------------------------------------2 |1 O) \. f3 z% d$ _- f0 e2 d) ^
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置- ^8 u% b5 p8 x/ y/ G8 ]
  940.   #--------------------------------------------------------------------------
    ! l! A' P( K  s* }% K- ~
  941.   def set_mouse_pos* Y0 u. R4 F8 [
  942.     if viewport.nil # necessary!
    . W2 c: T8 T; r; S% A
  943.       vp_x, vp_y = 0, 04 G6 _+ }. S  r3 z3 `0 N9 W( t
  944.     else3 y1 v) q% C  E5 Q" Y
  945.       vp_x = viewport.rect.x - viewport.ox8 @: X1 W9 ~5 X5 a8 B: g! Q! m
  946.       vp_y = viewport.rect.y - viewport.oy. x/ v' m& N! z8 V6 S: ]) C+ U
  947.     end
    ; }: e. G# {( h7 v
  948.     item_x1 = vp_x + x + standard_padding
    ! b! y# o' V$ u0 @: P
  949.     item_y1 = vp_y + y + standard_padding% [! \7 p7 A1 T
  950.     get_index = @index  0  0  @index
    & W- a1 W4 Y, p. g. N( {
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    2 k; T5 L, s% }: C5 o" K5 p9 b
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)9 Q% J8 K: `/ N
  953.     Mouse.set_mouse_pos(new_x, new_y); p, r+ |% j+ [
  954.   end) O  o! g+ T3 _: b0 K( e
  955. end
    + d9 m) A$ t- t* f! s
  956. " q. \( q; j% I9 U: E3 U5 m6 f
  957. #==============================================================================1 l6 i1 G( S" z8 a
  958. # ■ Window_Message
    3 y' x7 f  Y! n; G
  959. #------------------------------------------------------------------------------  [, Z) o8 v  X; a
  960. #  显示文字信息的窗口。! g1 r1 O) y" ~" t3 }) z& x( e- J" K
  961. #==============================================================================4 p/ z! \8 T7 F# v5 Y: C) b
  962. class Window_Message  Window_Base
    0 {9 z- x2 }8 d8 u# a& L7 \1 W% \
  963.   #--------------------------------------------------------------------------
    , O' j/ b+ y5 k) j; b& J7 S
  964.   # ● 处理数值的输入(覆盖原方法)
    - J# n' s. X1 U: m/ d. w
  965.   #--------------------------------------------------------------------------/ m# _2 [" l2 J$ j6 ^5 d
  966.   def input_number3 e' e. T4 \& O/ x  q
  967.     @number_window.start8 b7 t6 N; F9 _* l2 @
  968.     Fiber.yield while @number_window.extra_window.active
    + l* `  r+ G- U4 a
  969.   end1 r- W/ R- I  ]3 D' ?9 n' b1 e
  970. end3 P+ F# `! h. l6 D/ x: h) D
  971. $ Q2 B) a* i5 p; G0 |; u
  972. #==============================================================================9 _7 z3 ?" \! c. \; s; v; K
  973. # ■ Window_PartyCommand& `; ~& H  h) c+ x
  974. #------------------------------------------------------------------------------, M1 X& @! R3 c4 ^, m0 R
  975. #  战斗画面中,选择“战斗/撤退”的窗口。' S7 k1 y. }0 f* G" `4 ~- O3 A
  976. #==============================================================================- S" P! z+ b% I( }
  977. class Window_PartyCommand  Window_Command: g& C" |7 ?8 k) d0 N+ p% e
  978.   #--------------------------------------------------------------------------, v$ w* m/ r4 z6 F
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置3 p- l3 f# G+ A
  980.   #--------------------------------------------------------------------------: E- J4 l: G6 h' i) h. D
  981.   def set_mouse_pos+ H1 o* v3 N* O+ f1 M/ T9 M. X
  982.     if viewport.nil% B+ K/ ?7 d' z, i( k
  983.       vp_x, vp_y = 0, 0
    6 m3 l0 }! {5 ~4 `: T8 u
  984.     else6 Y- _( M3 |" W! w5 s& J, ]  D5 Q
  985.       #vp_x = viewport.rect.x - viewport.ox# ~% d. s+ F- @$ t- }: T# c  S& I$ I
  986.       vp_y = viewport.rect.y - viewport.oy+ H6 z5 Z6 _4 z, [
  987.     end! y- [9 |3 T9 ?) V  E& ]
  988.     item_x1 = x + standard_padding
    2 u2 D3 k2 E8 T% p& k4 S
  989.     item_y1 = vp_y + y + standard_padding# ^6 v$ V6 Q4 h& l* t2 i6 R! H  |% A
  990.     get_index = @index  0  0  @index " J# h: d. G, P8 [" T
  991.     row = get_index  col_max - top_row
    / K! `5 M) u) r
  992.     col = get_index % col_max- ~. d1 q# f/ v5 L
  993.     new_x = item_x1 + item_width  (col + 0.5)
    ) t. o9 _) C% T$ v: Q! T
  994.     new_y = item_y1 + item_height  (row + 0.5)
    / v0 i) j: `0 a1 C
  995.     Mouse.set_mouse_pos(new_x, new_y)# d  o& U/ X# Q0 Q& p/ I: m
  996.   end
    / j$ l- v, C! W
  997. end
    + }& ]5 e5 Z" ?% P

  998. . J; }* M) B0 B9 Z: |4 U
  999. #==============================================================================4 v; X7 k1 i% N. R/ k4 I
  1000. # ■ Window_ActorCommand
    8 u4 c0 i# W! q' x2 y0 q+ k
  1001. #------------------------------------------------------------------------------
    7 A4 M3 n& }8 x$ p! e
  1002. #  战斗画面中,选择角色行动的窗口。
      `2 l; G7 p$ v- n7 ~+ l8 S* k
  1003. #==============================================================================
    9 F, i9 a# |% z! ~) r+ t6 A
  1004. class Window_ActorCommand  Window_Command
    # X8 }8 @: ]6 W8 o6 s; E
  1005.   #--------------------------------------------------------------------------" |- l! K& Y0 N+ J" l
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    3 E; n4 W- _+ q3 o) c* k; O. f& b& T/ w
  1007.   #--------------------------------------------------------------------------& g$ q2 ~$ G( H1 ^2 ~2 _
  1008.   def set_mouse_pos; n0 r5 v* V/ M9 j7 N6 G# ]2 S6 k
  1009.     if viewport.nil  d& l+ t! I7 H' O$ |* c
  1010.       vp_x, vp_y = 0, 0
    , k8 W6 n8 ]) V$ G
  1011.     else
    / t5 L) S& a$ `, T% G' t
  1012.       #vp_x = viewport.rect.x - viewport.ox
    ; \. \! G. W3 Y  ?2 c0 R
  1013.       vp_y = viewport.rect.y - viewport.oy
      f# G: `  q/ p2 c0 t  P0 f
  1014.     end
    # W& B) u$ F% m( U; V
  1015.     item_x1 = Graphics.width - width + standard_padding
    ' p. t2 u" z* Z1 Q8 w; d
  1016.     item_y1 = vp_y + y + standard_padding* x7 D8 ]# x! y  Q' Q
  1017.     get_index = @index  0  0  @index
    ( o+ U; w3 C. S' ]) k& A$ j# h
  1018.     row = get_index  col_max - top_row1 x7 u1 Z8 L" a4 N  {
  1019.     col = get_index % col_max- K) n, N5 h3 c! ^. W
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    4 L) V  L; f4 W% ]  P
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    7 j' E" A" T& e' X
  1022.     Mouse.set_mouse_pos(new_x, new_y)# M+ x8 w1 z3 G0 _. N+ B- e0 K
  1023.   end0 ?  J# j( ~! d: |# ]( j# K
  1024. end
    , D+ F  Y- A0 e* V' e' Y

  1025.   u1 h. k+ ?$ w8 P0 U' ?6 B, i/ ]
  1026. #==============================================================================" Z/ v  ?4 e* B, ?, ~; b. t
  1027. # ■ Game_Player, V; w; V+ d/ ]! Q0 M# H- a
  1028. #------------------------------------------------------------------------------
    ! h( {9 P, n* E7 }" @" C
  1029. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
    ! j6 H3 \) B" g
  1030. #   本类的实例请参考 $game_player 。4 n# [& `3 M: q
  1031. #==============================================================================
    2 N: h8 y! X$ x# b9 ~
  1032. class Game_Player  Game_Character- F' t6 P3 y$ @, E2 U: y
  1033.   #--------------------------------------------------------------------------, z3 y  t$ p6 ~2 G# n" R
  1034.   # ● 由方向移动(覆盖原方法)8 C% L4 t" M/ p* {) L6 X7 g
  1035.   #--------------------------------------------------------------------------" A/ z2 ?( N7 J+ W& k  f8 s
  1036.   def move_by_input
    ! I; ^) p" ]$ P: u9 S
  1037.     return if !movable  $game_map.interpreter.running
    # y$ m( h) F: D6 O1 \, q7 l5 Z& _* {
  1038.     if Input.dir4  0
    ; }+ j" p) H* q( X
  1039.       move_straight(Input.dir4)
    9 q! a9 t7 u8 l; z0 g  i# @
  1040.       reset_move_path8 i. E, ?: l! Y" V. @4 V
  1041.     else
    * q$ x' N, V/ M0 K# {# a6 N' U
  1042.       move_by_mouse
    ' p0 s5 m* i. @6 `. V  T9 [
  1043.     end
    2 Z! T: G/ q& _8 Y* |( Z6 o9 n, X
  1044.   end
    9 }. W4 C) ^, r: I: [+ w
  1045.   #--------------------------------------------------------------------------$ {% \3 B2 L; x
  1046.   # ● 非移动中的处理(覆盖原方法)& Z$ c+ {3 w6 J8 |
  1047.   #     last_moving  此前是否正在移动
    ! a4 t. b$ W# D# S: t0 A, L9 v
  1048.   #--------------------------------------------------------------------------& j6 U* q3 B' A( s/ T: G; l1 N$ q
  1049.   def update_nonmoving(last_moving)
    $ L. c8 Y) n. }2 c" f2 n
  1050.     return if $game_map.interpreter.running
    1 U2 `, K1 L8 t4 A
  1051.     if last_moving
    8 c3 L0 s6 b  |9 f
  1052.       $game_party.on_player_walk
    ; E7 D$ i3 e, d+ d
  1053.       return if check_touch_event
    . d8 H6 T8 H" A# ^4 t% V  K
  1054.     end
    3 B9 u  D8 Z% b! c
  1055.     if movable && Input.trigger(C)9 G7 w& A* r/ y- X/ d; W) W; V
  1056.       return if Mouse.press(0x01) # 防止按下鼠标左键绘制路径时触发事件或载具切换6 I& e3 m( _( P& R3 g: _8 K
  1057.       return if get_on_off_vehicle
    , Q" |/ e$ k9 c/ w2 r* z
  1058.       return if check_action_event+ }& }8 u3 N2 A5 D6 j
  1059.     end% S6 R. v) Q9 i4 x8 e" G4 g
  1060.     update_encounter if last_moving
    $ D6 f0 {5 u! L# ?  `
  1061.   end3 c* w- v, R2 N
  1062.   #--------------------------------------------------------------------------
    0 `5 g( p8 i: r# E& w0 |: n
  1063.   # ● 判定是否跑步状态(覆盖原方法)( v+ l7 @' o4 ^& ^
  1064.   #--------------------------------------------------------------------------
    " S9 J6 ~$ p0 ]7 N
  1065.   def dash
    . |8 _" B0 o  J5 B
  1066.     return false if @move_route_forcing
    3 r. O% {: P( ]( k! c' |) B1 y
  1067.     return false if $game_map.disable_dash
    # h7 o5 u0 _1 l0 }
  1068.     return false if vehicle* m" u6 ~6 H( m4 B+ H
  1069.     return Input.press(A)  @mouse_dash
    3 v/ o0 v. D  E" h8 P4 Z9 z- Q
  1070.   end1 k5 K# Q* O0 n0 v( G
  1071.   #--------------------------------------------------------------------------  X6 U9 J( H9 G6 L  i! C! [
  1072.   # ● 初始化( B9 u( ^* k3 V. F* W: \% l9 I
  1073.   #--------------------------------------------------------------------------- X+ S/ J- }# x/ h
  1074.   alias sion_mouse_initialize initialize
    8 g- A& f* K( w) Z' y
  1075.   def initialize
    + O$ d2 B; c  q1 q
  1076.     sion_mouse_initialize0 B) y1 z* X9 p0 ^7 ?  I
  1077.     reset_move_path
    ' V* _4 b1 U$ i' W2 g$ L: O
  1078.     @moveto_x = 0  s0 _! ?1 e6 Y' C
  1079.     @moveto_y = 0
    ) E) V$ Y$ w1 O0 E4 @% M; V
  1080.   end* o$ L1 G0 V+ h& r1 X/ P
  1081.   #--------------------------------------------------------------------------7 M1 L0 _+ P) q- j1 k
  1082.   # ● 更新4 g8 J! Z- f7 g' g% I8 t
  1083.   #--------------------------------------------------------------------------. p0 L) z- f1 ?% x4 J* _( a
  1084.   alias sion_mouse_update update# Q( p. V3 l& t: [9 U
  1085.   def update" I$ g; X3 y% v8 a
  1086.     sion_mouse_update
    , _2 o0 }0 d  c
  1087.     clear_unreachable_sign  U- i- D0 J8 C, q3 ?- z
  1088.   end" I+ V" R5 g$ p7 j3 X) S6 P$ e
  1089.   #--------------------------------------------------------------------------
    5 q' p1 \6 k3 }' C& E/ c0 z
  1090.   # ● 处理卷动
    $ W. y, F& _* n: R
  1091.   #--------------------------------------------------------------------------  S' r) E9 g2 k4 G4 n
  1092.   alias sion_mouse_update_scroll update_scroll# V7 I# {, q& L' [% ~+ N0 T
  1093.   def update_scroll(last_real_x, last_real_y)) E! j- y9 O& j7 ~: @
  1094.     return if $game_map.scrolling
    # a  j7 S4 ?) E" W: G
  1095.     KsOfSionNew_Scroll  new_update_scroll / M4 N8 L  `* r) y
  1096.       sion_mouse_update_scroll(last_real_x, last_real_y)
    ) K. i% v( ]/ m, o6 D0 U& c
  1097.   end
    & B, R3 R) }3 V
  1098.   #--------------------------------------------------------------------------
    3 a. d! I1 a. }# `
  1099.   # ● 重置移动路径相关信息
    ' v; y+ b" e5 A8 ~2 ~1 G
  1100.   #--------------------------------------------------------------------------0 m9 @3 z6 h: V7 u# c2 L
  1101.   def reset_move_path
    ; B0 l- s; m: C$ n7 T$ A
  1102.     @mouse_dash = false
    7 Z/ `( U5 y+ ~; q& x- i
  1103.     @mouse_move_path = []; v( @4 w* J. x) \: P
  1104.     $mouse_move_sign.transparent = true
    $ s& o; P3 u& ?/ o% q6 X& p
  1105.   end
    5 J+ u" }( ]0 Y$ _5 m  m! a: E
  1106.   #--------------------------------------------------------------------------
    6 h8 t1 s' ?  |$ z2 }: R2 u# `; U. c
  1107.   # ● 新的卷动地图方法" S4 c$ w8 J" U7 v6 A2 G1 E' k
  1108.   #--------------------------------------------------------------------------
    / S7 V( o9 T# L( N% b: ^* U$ Z* y$ T
  1109.   def new_update_scroll
    ! i4 A# [0 E$ ?5 E$ @+ y
  1110.     horz_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.width* Q' E5 I2 p$ ]- ~
  1111.     vert_speed = 2  @move_speed  KsOfSionMap_Scroll_Spd  Graphics.height% `" T* S+ e  e) H5 `
  1112.     ax = $game_map.adjust_x(@real_x)( W( o( n9 h3 c  d
  1113.     ay = $game_map.adjust_y(@real_y)8 q  {( {- }7 G6 H" v6 c% y
  1114.     $game_map.scroll_down (vert_speed  (ay - center_y)) if ay  center_y
    5 D* f) e& s$ i- j8 ~$ [
  1115.     $game_map.scroll_left (horz_speed  (center_x - ax)) if ax  center_x8 u5 B( x: H' I8 V
  1116.     $game_map.scroll_right(horz_speed  (ax - center_x)) if ax  center_x2 s* v( p0 I7 F; f/ @1 z
  1117.     $game_map.scroll_up   (vert_speed  (center_y - ay)) if ay  center_y
    ; k' h3 L& x+ c: D( X. u
  1118.   end( Y% {5 E3 Y$ b# Z* J
  1119.   #--------------------------------------------------------------------------
    0 E  e8 p6 E. r. t2 f$ N
  1120.   # ● 消除不能抵达图标& m% B/ t2 w' O
  1121.   #--------------------------------------------------------------------------% r0 H0 h9 x6 t7 g1 a
  1122.   def clear_unreachable_sign2 i1 h# A6 v3 [) J
  1123.     return if Mouse.press(0x01): b  w& l+ ^0 ~7 V: I7 ^! H+ D
  1124.     if $mouse_move_sign.direction == 4 && Mouse.click_count % 20 == 0
    " e2 S5 e4 g/ s  g7 U
  1125.       $mouse_move_sign.transparent = true; G, x1 f! g& K" l. D6 V
  1126.       $mouse_move_sign.direction = 2' g; {2 r" Z4 l9 f+ n! ~3 u- J' r
  1127.     end
    9 }. d8 Z% @% o- n. f! U! |4 Q
  1128.   end0 x7 ?8 s$ }1 \# r, {% S4 Y
  1129.   #--------------------------------------------------------------------------
    3 `# n6 s. |+ p0 [' }- e
  1130.   # ● 由鼠标移动
    $ a; \- d8 x7 Z$ v
  1131.   #--------------------------------------------------------------------------
    ) f# Z. A  h+ _: y8 ?# ~
  1132.   def move_by_mouse
    " b; O8 w! J  v: E- \% H
  1133.     unless @mouse_move_path.empty # 移动路线数组不为空则执行移动& k4 O  ]5 K! g; V$ l) w
  1134.       dir = @mouse_move_path.shift8 L- D9 \: ?5 J
  1135.       if passable(x, y, dir) && !@mouse_move_path.empty) `% H" c0 I  g1 |7 m: p2 ~
  1136.         move_straight(dir)1 L3 U) i: u0 ^* ~
  1137.       elsif @mouse_move_path.empty # 判断是否是最后一步  r: z7 b! P% w0 {  N# ^& l( Z
  1138.         x2 = $game_map.round_x_with_direction(x, dir)6 [1 b; ?- C) F# d: H' w) G9 x% E' ]
  1139.         y2 = $game_map.round_y_with_direction(y, dir)4 r" h$ K+ v  _& l" e* C7 B1 ?
  1140.         move_straight(dir) unless dir.zero
    - T6 Z( W) j7 e7 J
  1141.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具: Z' J, k: I3 Z% G! ]
  1142.           check_event_trigger_there([0,1,2])/ j0 B4 [4 G) K9 f) \# K
  1143.           get_on_off_vehicle unless $game_map.setup_starting_event
    * m; @# e/ C7 L, {! D$ M
  1144.         end7 j# I% P( r: g& u" Q
  1145.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2: `6 g" I+ \  _$ t0 U% ?
  1146.         @mouse_dash = false
    ! q0 n) H* t" b' e) [
  1147.       elsif @mouse_move_path[0].zero # 目标点无法抵达,调整朝向→目标点
    # O3 o+ S9 `" c. S, Z- ^
  1148.         @mouse_move_path.shift. v+ Q0 z( v+ _5 X# ^0 V4 x  m
  1149.         @direction = dir
    + L" e/ v  L: m& P& m0 N
  1150.         @mouse_dash = false
    7 f2 P% R* p; @4 m1 r7 M9 g6 z( C
  1151.       else
    & t+ Y; ^, ]( x7 L
  1152.         draw_move_path2 _9 D4 A, ?, K" Y& G
  1153.       end1 \# Z- Y4 f9 ^. ]1 o5 N! o8 A
  1154.     end
    2 N  ~, Z! s1 F6 F
  1155.   end
    , H: ~5 P* ^9 W  p* |
  1156.   #--------------------------------------------------------------------------
    ! @) o' k$ Z( X1 u7 d, x
  1157.   # ● 地图界面按下鼠标左键的处理) }, q& P( Y/ u/ L! `2 \
  1158.   #--------------------------------------------------------------------------+ p% L$ E' q: l( Z1 Y9 y
  1159.   def left_button_action, \, i; i, ~3 Q6 t" G) n
  1160.     return if !drawable  $game_map.interpreter.running% j  D6 T7 b  E3 t
  1161.     get_mouse_pos( i  V& j# A  ?" @- o) x
  1162.     $mouse_move_sign.moveto(@moveto_x, @moveto_y) # 移动路径点指示图
    $ [: Z& @# w$ Q2 ]
  1163.     if @shift_event
    3 d+ O9 P  p, p' |
  1164.       if Mouse.trigger(0x01)
    * ?, n, t9 d; y; {
  1165.         @shift_event.jump(@moveto_x - @shift_event.x,
    ' ]2 v. |+ P6 {, s% z
  1166.           @moveto_y - @shift_event.y)
    * c! D9 X- x9 [# i% e
  1167.         @shift_event = nil
      F6 z( g$ G, f
  1168.       end5 d5 ?+ _9 s2 M6 U* U  Z
  1169.       return
    1 S- y: v4 }2 V
  1170.     end& c1 D  a+ P2 r' {4 g: Y
  1171.     if @moveto_x == x && @moveto_y == y # 判断目标点是否与角色重合
    ' S$ v# C$ `" j0 c* ^# |
  1172.       return if moving  (vehicle && !vehicle.movable)7 O$ s- q0 M- Q1 o
  1173.       check_event_trigger_here([0]) # 判断是否触发重合点事件
    $ G) i1 Y# K# j7 n+ ?
  1174.       get_on_off_vehicle if !$game_map.setup_starting_event && . d8 @- r* I$ c  o7 ~
  1175.         $game_map.airship.pos(x, y)  # 判断是否要上、下飞艇. A$ r7 t  L' H9 {+ `
  1176.       return5 `- q9 J! f: b) Z& h4 G0 u
  1177.     end3 d; b. i. k4 X4 S4 F% R
  1178.     # 判断是否用鼠标启动事件& s; B  o! Q# [% S
  1179.     $game_map.events_xy(@moveto_x, @moveto_y).each do event3 A* p; c- v" ?' ~
  1180.       if event.mouse_start- v0 S6 x3 s! q/ S+ p5 j. w4 Q# I
  1181.         reset_move_path$ r5 V; T- K) X2 g  O
  1182.         event.start if Mouse.trigger(0x01); i$ S- d5 h2 |+ |4 y3 Z
  1183.         return- M- b7 {& P% v! h& I. c& B+ N9 j
  1184.       end
    ; V; J1 t* a5 _
  1185.     end. b. p& q( q# S1 f' |. J
  1186.     @mouse_dash = true if Mouse.double_click # 双击冲刺
    . U) n  H: |" z
  1187.     return if Mouse.left_state % 10 != 1 # 按住鼠标左键10帧绘制1次路径! d8 L$ @! t2 r. R* U9 k8 r$ v7 }2 r8 U
  1188.     for i in 1..4 # 判断目标点是否为角色周围四点* [8 W6 H1 A  }* T9 Q
  1189.       if x == $game_map.round_x_with_direction(@moveto_x, i  2) &&; F3 Y7 N" k* t, y9 F
  1190.          y == $game_map.round_y_with_direction(@moveto_y, i  2)( J! r7 x* H9 G/ e+ r: U( M( N
  1191.       $mouse_move_sign.transparent = true9 b: R8 |5 P& P  ], }8 M. g, M
  1192.       @mouse_move_path = [10 - i  2] if Mouse.trigger(0x01)
    , m: @9 x/ C( n' O4 M
  1193.       return; end+ D6 X7 P5 G0 H
  1194.     end
    3 D; Z$ _0 m3 ~* q. A
  1195.     draw_move_path- W( U5 ~$ b1 V3 R9 A( Q1 Q
  1196.   end2 `1 {8 M. E4 z7 z9 t- }- [4 i  }
  1197.   #--------------------------------------------------------------------------% p- c8 m: b4 N6 F; \$ u
  1198.   # ● 取得鼠标处对应地图坐标点
    . ~4 [9 N" w( ]7 l5 j7 y
  1199.   #--------------------------------------------------------------------------2 Q1 g5 G  k! k' G
  1200.   def get_mouse_pos
    ' }" ~* p! @: r# `9 u: q- g
  1201.     $game_map.get_mouse_map_xy; b" _3 M/ Y+ L( M
  1202.     @moveto_x = $game_map.mouse_map_x
    ! E4 Y$ k8 [- H4 G9 X
  1203.     @moveto_y = $game_map.mouse_map_y6 c/ T( K; Q" {+ A1 p
  1204.     #mouse_x, mouse_y = Mouse.get_mouse_pos* R1 A! h; r- o8 `$ k
  1205.     #@moveto_x = $game_map.round_x(x + (mouse_x - / s3 Y7 ?$ J1 B% o
  1206.     #  ($game_map.adjust_x(x)  32 + 16).to_i + 16)  32)
    " w( Y4 k  C! ^0 p" ]2 ]
  1207.     #@moveto_y = $game_map.round_y(y + 1 + (mouse_y -7 R$ L# U: W8 M5 E/ S
  1208.     #  ($game_map.adjust_y(y)  32 + 16).to_i - 16)  32)
    , j9 n8 f2 I3 S8 M
  1209.   end
    ( |2 k" C# w& K/ R2 G0 h: L
  1210.   #--------------------------------------------------------------------------
    1 L3 C  a  u! [+ R% B3 m
  1211.   # ● 绘制移动路径 @array[move_directions...]
    " e9 n8 z1 d; {& }8 j
  1212.   #--------------------------------------------------------------------------
    . }5 [0 u0 T9 W% a
  1213.   def draw_move_path
    ( n7 [% x% \. X5 m
  1214.     #temp = Time.now& o5 o7 V; @8 A! l. c: A  {
  1215.     case @vehicle_type* S3 S* V" X2 d* N" M5 i6 [( [; _
  1216.     when walk$ Y( W$ e+ ^# J' v, ]7 y" v& `6 t& L
  1217.       draw_walk_path& |# p' c* G' t5 K! V- y7 S
  1218.     when boat5 y6 X3 L# [+ _" D2 T$ \% i5 J
  1219.       draw_boat_path/ F/ z! L3 a3 _! x  G
  1220.     when ship
    6 w% m- y# W0 e! Z# L0 y) S) s
  1221.       draw_ship_path
    - _+ n& \8 D$ y5 k8 y* T2 C: g
  1222.     when airship' U$ w( e( V( J
  1223.       draw_air_path0 h8 C! p3 a0 i5 a4 D6 m0 ~
  1224.     end' K& F" H; H! Q0 D$ N3 R
  1225.     #p (Time.now.to_f - temp.to_f) # 测试效率
    - f5 L+ \6 B- c$ I
  1226.   end
    . G- R  V( i& q: u
  1227.   #--------------------------------------------------------------------------
    3 J2 P. [- x! s( m. u" Q
  1228.   # ● 判定是否可以绘制移动路径
    " A+ p8 i/ G$ R! M8 |( s! y$ G
  1229.   #--------------------------------------------------------------------------
    7 W( [# n, Q+ B& f9 v" |- }9 C
  1230.   def drawable
    # B$ d5 w) A0 Z9 R  s3 e; p1 R
  1231.     return false if @move_route_forcing  @followers.gathering
    8 o! {% r7 ?, u+ Q
  1232.     return false if @vehicle_getting_on  @vehicle_getting_off
    5 n8 f5 ?0 D8 B4 ?& h6 `
  1233.     return false if $game_message.busy  $game_message.visible
    ' |4 z- M  @0 `( u
  1234.     return true
    7 s. \, q( P$ {
  1235.   end% r& M6 O  N/ c# L: N
  1236.   #--------------------------------------------------------------------------3 |% I4 r% p1 j% y+ U, O5 v5 S
  1237.   # ● 绘制walk移动路径 @array[move_directions...]% A+ f( i* k, r3 j, \- w
  1238.   #--------------------------------------------------------------------------
    , [6 r, x- B5 e; c, f
  1239.   def draw_walk_path1 [! {2 E* B! h
  1240.     # 准备绘制路径表格
    3 d( K! p& n, Q9 C
  1241.     sheet = Table.new($game_map.width, $game_map.height)* r6 `9 S% Q& s
  1242.     reversed_chase_path  = []; chase_path  = []* A. H4 ^; _( e7 p
  1243.     reversed_chase_point = []; chase_point = []
    ; ?3 E% L8 q! j$ k% W
  1244.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]
      D3 ]' V1 v, Z  F
  1245.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2/ i% Q/ T; J1 B4 S- X
  1246.     reach_point = false
    4 S6 G  E6 W; _' r0 f
  1247.     step = 3- \4 R( h! v  D. x. q
  1248.     loop do #loop1 开始填充表格# n! h; H. k# J/ N
  1249.      draw_path = false
    ) s3 U' F0 a8 K
  1250.      check_points = new_start_points, h$ h  l" Y; E) a( M' d! T. o: N* F
  1251.      new_start_points = []7 x6 s5 m$ y7 f1 Q) V1 }* `
  1252.       loop do #loop2 从起点开始正向填充
    ' x+ Q. N3 B/ A1 X$ k7 m
  1253.         point_x = check_points.shift
    3 u* }3 y+ l% f% m; Z. j. ?& p
  1254.         break if point_x == nil
    # y  J" o; o; q5 @3 u6 i# A
  1255.         point_y = check_points.shift% I; T4 k0 w% S5 R+ a% s* Z
  1256.         left_x  = $game_map.round_x(point_x - 1)
    1 i4 k2 ?" w2 D
  1257.         right_x = $game_map.round_x(point_x + 1)
    3 q& Y! y" s! e! R, I+ M& Z+ M
  1258.         up_y    = $game_map.round_y(point_y - 1)
    ) l0 k& H/ W, }0 C
  1259.         down_y  = $game_map.round_y(point_y + 1)
    6 r# M/ J/ i4 M0 y* x7 C
  1260.                     # 判断路径是否连通4 c9 l. c1 I7 B& R
  1261.         path_step = step - 1$ h9 h3 T* D! m( }4 q
  1262.         if sheet[left_x, point_y] == path_step     &&0 z4 h- l" q3 q" c0 {8 K
  1263.            $game_map.passable(left_x, point_y, 6) &&
    % m, [2 ?, L! N, {
  1264.            $game_map.passable(point_x, point_y, 4)1 {- L2 V$ [, \9 s' Z
  1265.           chase_path.push(4)
    ! p) i8 [) X% k7 _. _7 q
  1266.           chase_point = [left_x, point_y]( ?( i: V' ^, n+ ]. Y4 q. i& j) o
  1267.           reversed_chase_point = [point_x, point_y]  V1 r7 V* ?9 i" Y7 Q
  1268.           reach_point = true; break
    8 D# N& C7 z) ?. O: E6 u! o$ `" e, @
  1269.         elsif sheet[right_x, point_y] == path_step     &&: R% A: P( w. `8 q8 n5 p" Z
  1270.               $game_map.passable(right_x, point_y, 4) &&
    + i, T0 v5 Z  I. i) C3 f) w9 W
  1271.               $game_map.passable(point_x, point_y, 6)  L3 L$ B/ p0 G1 d  M* K6 O3 h6 x
  1272.             chase_path.push(6)
    ; w) K# E7 c9 l
  1273.             chase_point = [right_x, point_y]
    - z7 T& a- n3 Y# R- t, k. A4 s
  1274.             reversed_chase_point = [point_x, point_y]  ?9 N3 w; f5 @
  1275.             reach_point = true; break
    4 L, h5 s# {8 X: _% y- \, ~( U% ^; p
  1276.         elsif sheet[point_x, up_y] == path_step     &&
    0 u3 {3 B( J2 ]) \. o; v
  1277.               $game_map.passable(point_x, up_y, 2) &&# V! C0 z& k, V* }/ B
  1278.               $game_map.passable(point_x, point_y, 8)( R8 I9 W% ^9 U( D) J% v
  1279.             chase_path.push(8)
    1 t0 R2 I' q% ?& y- g. u! N, b
  1280.             chase_point = [point_x, up_y]0 [" n2 p  A) D! b9 R! P! `
  1281.             reversed_chase_point = [point_x, point_y]
    # w6 G9 y: g, Y* ~
  1282.             reach_point = true; break
    , I' |9 ]9 P/ y7 X4 h3 R6 P9 h
  1283.         elsif sheet[point_x, down_y] == path_step     &&  u8 k- L/ ]' ^
  1284.               $game_map.passable(point_x, down_y, 8) &&9 J- x0 j! f, T: z: O
  1285.               $game_map.passable(point_x, point_y, 2)" h0 n9 w7 [3 i/ Q; v& A
  1286.             chase_path.push(2)
    6 y4 w: a8 C) N
  1287.             chase_point = [point_x, down_y]
    9 a: U2 N3 M) Z6 }9 X
  1288.             reversed_chase_point = [point_x, point_y]" J$ Y4 v' I$ f$ z% B" z
  1289.             reach_point = true; break1 g& q+ S' V% T
  1290.         end3 p" e  `# w. U- s
  1291.         # 以需要抵达该点的步数填充路径表格 #
    7 r0 ~2 N1 i  ?+ K# N9 o5 w+ H
  1292.         if sheet[left_x, point_y] == 0              &&
    # V8 m4 H" h- `
  1293.            $game_map.passable(left_x, point_y, 6)  &&
    & b/ g" n( \: `$ X
  1294.            !collide_with_events(left_x, point_y)   &&, X: ~+ d1 l, L# N, d) q
  1295.            $game_map.passable(point_x, point_y, 4) &&
    0 S$ _+ V! U  D! K
  1296.            !collide_with_vehicles(left_x, point_y) #judge_end; f5 s  |& \5 f; S9 h3 l1 j5 n& j
  1297.           sheet[left_x, point_y] = step+ p( W' e: k) ]& m5 q
  1298.           draw_path = true, Y+ E9 g% M1 w
  1299.           new_start_points.push(left_x, point_y)
    7 I7 Y6 p  n2 n! d7 z" q
  1300.         end, {$ L2 W9 e/ }# k5 C8 X. n
  1301.         if sheet[right_x, point_y] == 0             &&. v5 L1 Y% N; {: l% W
  1302.            $game_map.passable(right_x, point_y, 4) &&
      W) K" j$ `+ E7 ^' M4 L" P# D
  1303.            !collide_with_events(right_x, point_y)  &&
    9 w" S' l$ f6 F1 W- ^) H6 k
  1304.            $game_map.passable(point_x, point_y, 6) &&
    1 E0 z2 F" M+ h" U8 V1 ?$ T0 }
  1305.            !collide_with_vehicles(right_x, point_y)#judge_end
    2 c. x9 O4 P4 e$ s4 n
  1306.           sheet[right_x, point_y] = step& d& K2 Q$ `4 h) ]! s( w5 f" Y
  1307.           draw_path = true
    . `- I0 \) U1 H' W; N6 n- Y
  1308.           new_start_points.push(right_x, point_y)3 Y3 G, I, W, V1 v2 H, M, G
  1309.         end! Q5 X4 P, m$ G$ H: ^+ T
  1310.         if sheet[point_x, up_y] == 0                &&" }! L0 l; L7 l! ]
  1311.            $game_map.passable(point_x, up_y, 2)    &&( w' O& G. P* ~3 P" p% X
  1312.            !collide_with_events(point_x, up_y)     &&
    1 `: G+ ^/ C$ c, `1 N9 j6 [
  1313.            $game_map.passable(point_x, point_y, 8) &&& K( z1 w3 v) Q4 s- V8 u
  1314.            !collide_with_vehicles(point_x, up_y)   #judge_end2 o5 U5 Z- q: B: A, n; U0 L
  1315.           sheet[point_x, up_y] = step
    , u6 d. x& v+ ~8 l/ C
  1316.           draw_path = true  j" S4 M% Y6 f: r# Y) L+ \2 Q
  1317.           new_start_points.push(point_x, up_y)
    * J% _+ A1 }3 a) }' q7 m; d
  1318.         end
    5 _6 b8 e8 p$ K0 `( O1 m
  1319.         if sheet[point_x, down_y] == 0              &&
      s5 v1 }. f3 E; i( m" u4 w
  1320.            $game_map.passable(point_x, down_y, 8)  &&2 c. g, Q8 U3 r+ F
  1321.            !collide_with_events(point_x, down_y)   &&
    + g, n3 x6 h& V4 E1 g7 m
  1322.            $game_map.passable(point_x, point_y, 2) &&
    % |) X; z7 F8 S- X( l
  1323.            !collide_with_vehicles(point_x, down_y) #judge_end( X# ^4 a* K6 f
  1324.           sheet[point_x, down_y] = step, K5 r- ^. I0 B+ i( M7 P: H! e7 s
  1325.           draw_path = true5 v% @# C; e  b- _7 U8 G' K
  1326.           new_start_points.push(point_x, down_y)- G/ L2 \5 s6 n2 B. L, L( `
  1327.         end
    " |$ N) [1 S5 Q0 J6 J' Q
  1328.       end#endOfLoop2
      h  K: ?* Y! U' u, V
  1329.       break if !draw_path  reach_point+ f2 I' N5 |6 F( j4 v
  1330.       draw_path = false
    . E( ^* N/ O8 M) N/ r7 K
  1331.       check_points = new_end_points5 D2 {2 @! d5 m1 U( x( g( D
  1332.       new_end_points = []: r) E% B" o& K; Z: R$ O3 O
  1333.       step += 1  s9 ~$ _9 k1 c
  1334.       break if step  KsOfSionBreak_Steps &&
    2 ^9 b+ ]+ o0 l/ M  N; X
  1335.                !Input.press(KsOfSionFind_Path_Key)
    9 i/ Q, K" X  e+ E. r' i# [- b
  1336.       loop do #loop3 从终点开始反向填充
      }! G  m4 v* D( P% r
  1337.         point_x = check_points.shift
    ; C* Y/ r! m1 l
  1338.         break if point_x == nil
    8 D( ]( T3 j1 D5 y0 s7 G
  1339.         point_y = check_points.shift
    ' r0 v# F' s; v: y# }/ [
  1340.         left_x  = $game_map.round_x(point_x - 1)
    - R% _% L/ p% ^: C3 S
  1341.         right_x = $game_map.round_x(point_x + 1)
    6 c3 O2 @, u$ e! C
  1342.         up_y    = $game_map.round_y(point_y - 1)
    ( F3 [% r' i6 [. K) q; }
  1343.         down_y  = $game_map.round_y(point_y + 1)" C, k2 a6 ~# |' ]) x1 p
  1344.         # 判断路径是否连通) D& Z8 q" o2 t; V9 J3 s  v
  1345.         path_step = step - 1
    : N; E% ~! R- r/ p5 V6 l" s. ?
  1346.         if sheet[left_x, point_y] == path_step     &&
    % p0 l, G9 ^  ], b1 D8 D/ {8 v
  1347.            $game_map.passable(left_x, point_y, 6) &&+ W8 h; v+ F4 g9 c* U. B5 z! i5 J
  1348.            $game_map.passable(point_x, point_y, 4)% a- a. G7 Z: b6 c8 M. M8 M' I# a& ?
  1349.           chase_path.push(6)
    ! ^! Q" q3 `8 }' X: ?
  1350.           chase_point = [point_x, point_y]2 P& i7 g( H" B' G* ~
  1351.           reversed_chase_point = [left_x, point_y]
    $ x( V; E8 W, ]7 w& p" U
  1352.           reach_point = true; break- s5 j5 ?) l( q" T7 N
  1353.         elsif sheet[right_x, point_y] == path_step     &&( D2 E" I% M; g- ~( E3 J
  1354.               $game_map.passable(right_x, point_y, 4) &&9 y, B% ]: M' R9 Y0 j1 ]) A
  1355.               $game_map.passable(point_x, point_y, 6)
    $ l$ H( N: K( q, z' m
  1356.             chase_path.push(4)' `% `( d: |" S+ T; x
  1357.             chase_point = [point_x, point_y]+ [9 v, @8 M) l
  1358.             reversed_chase_point = [right_x, point_y]) U9 O* [- Y2 f) M1 g7 p$ Z2 S
  1359.             reach_point = true; break) I- ?4 v# p' c* Z
  1360.         elsif sheet[point_x, up_y] == path_step     &&
    0 H* v1 T; V6 o
  1361.               $game_map.passable(point_x, up_y, 2) &&+ Q1 z! X5 q- d: v% i5 T% k
  1362.               $game_map.passable(point_x, point_y, 8)
    # m9 h7 y  k: ~% G" g1 s/ J
  1363.             chase_path.push(2)
    $ N, F* Q  G' X  h$ ^7 F8 Y
  1364.             chase_point = [point_x, point_y]$ f, x, u1 J- y$ z
  1365.             reversed_chase_point = [point_x, up_y]
    6 b9 t* m4 l4 C$ S2 Z+ q5 |
  1366.             reach_point = true; break3 {/ o7 Q; h4 w5 H  h) w. ]2 w/ M
  1367.         elsif sheet[point_x, down_y] == path_step     &&; |8 X+ G7 b" I0 A1 b
  1368.               $game_map.passable(point_x, down_y, 8) &&
    , ^% ~$ c2 s: ?
  1369.               $game_map.passable(point_x, point_y, 2); k1 d  B! b& Z& i) I
  1370.             chase_path.push(8)
    2 }( c1 k5 r# ]8 ^4 Z4 m
  1371.             chase_point = [point_x, point_y]
    6 Y( ^2 V! g2 Q2 o8 j
  1372.             reversed_chase_point = [point_x, down_y]  C  @% D* C) X+ Q4 e
  1373.             reach_point = true; break
    , u8 G0 Q1 e0 m# O3 `- ], V+ w$ I8 y$ v
  1374.         end
    & t4 j! \6 O8 j2 c
  1375.         # 以需要抵达该点的步数填充路径表格 #
    : g' b! {9 N  y* U8 _
  1376.         if sheet[left_x, point_y] == 0              &&6 ?' C; {% H0 C" E5 }) H, V; P
  1377.            $game_map.passable(left_x, point_y, 6)  &&: H3 @0 b& }' c( Q; M
  1378.            !collide_with_events(left_x, point_y)   &&
    " |2 w+ E( H+ _5 U9 ]
  1379.            $game_map.passable(point_x, point_y, 4) &&0 v4 w7 A) u4 U! r' A
  1380.            !collide_with_vehicles(left_x, point_y) #judge_end
    5 U" X+ S8 y, R3 F, Q% b
  1381.           sheet[left_x, point_y] = step
      ]$ N; p' R4 b- o6 I
  1382.           draw_path = true2 `9 T$ X7 D3 G$ U! t. q
  1383.           new_end_points.push(left_x, point_y)* f/ R7 `) I' D) c. j
  1384.         end1 S( t% ~/ j7 r4 h
  1385.         if sheet[right_x, point_y] == 0             &&1 d% R( G! c* @# y4 [9 O' Y
  1386.            $game_map.passable(right_x, point_y, 4) &&8 E1 g9 B' G( m8 R8 h/ H1 L) J
  1387.            !collide_with_events(right_x, point_y)  &&
    7 m7 `  u3 r+ L3 r# n
  1388.            $game_map.passable(point_x, point_y, 6) &&! S) {, }: u/ J
  1389.            !collide_with_vehicles(right_x, point_y)#judge_end* N; D: e* Z0 r4 d# O% ^' ]
  1390.           sheet[right_x, point_y] = step9 A4 X( @" r5 T5 o. x
  1391.           draw_path = true  E' ?/ U' ?, l+ j& n
  1392.           new_end_points.push(right_x, point_y)
      y, `2 Y" {* v/ ?' ~7 p# u
  1393.         end& y3 m, \+ Z+ F
  1394.         if sheet[point_x, up_y] == 0                &&" |" V- @) [* E/ _4 Z& o
  1395.            $game_map.passable(point_x, up_y, 2)    &&/ T+ @& h; G  {1 D$ k
  1396.            !collide_with_events(point_x, up_y)     &&
    . A5 w9 f9 A1 R0 z2 Y9 o1 i
  1397.            $game_map.passable(point_x, point_y, 8) &&
    + g4 C- Z. o7 b( d: V* {
  1398.            !collide_with_vehicles(point_x, up_y)   #judge_end* P0 E- D! G* ?# U0 W
  1399.           sheet[point_x, up_y] = step9 {- I' i( h) x9 j2 |% I' ?3 v) F
  1400.           draw_path = true# I7 O' N; Y' }( C8 f! E% B
  1401.           new_end_points.push(point_x, up_y)( N3 q, O) U( h8 s9 B$ O8 q) ^; r
  1402.         end1 }: j: r2 r+ ?0 a; O5 v. c4 `
  1403.         if sheet[point_x, down_y] == 0              &&8 _, E2 Z1 }( m  ~, b* R0 f/ K0 {
  1404.            $game_map.passable(point_x, down_y, 8)  &&2 `1 x* h4 G; c
  1405.            !collide_with_events(point_x, down_y)   &&. Y% ^8 x. x$ K& R! r( E3 t1 X7 x
  1406.            $game_map.passable(point_x, point_y, 2) &&
    1 x! r# j) y: T- ?
  1407.            !collide_with_vehicles(point_x, down_y) #judge_end8 B0 }2 z9 q5 g% A( {
  1408.           sheet[point_x, down_y] = step; ~6 g1 k8 ^1 b: |8 V# C6 ]! P
  1409.           draw_path = true/ m3 }7 |+ n/ ?- h: e
  1410.           new_end_points.push(point_x, down_y)
    $ v2 g4 K8 D/ q: Y  _
  1411.         end) H1 M! o& h: S# p; q% d3 Q
  1412.       end#endOfLoop3
    6 Q0 m% ~6 \9 F* J4 p
  1413.       break if !draw_path  reach_point/ G; J) f5 b$ g
  1414.       step += 14 x; f+ \4 A# b) m6 P
  1415.     end #endOfLoop1 路径表格填充完毕
    1 g0 t! S; u; f- B: J. q" J6 _
  1416.     $mouse_move_sign.transparent = false0 m4 Z. u, d6 Z. t
  1417.     # 判断指定地点能否抵达
    5 w/ h7 y/ x3 S2 |
  1418.     if reach_point
    4 g+ z/ b  n6 T
  1419.       $mouse_move_sign.direction = 2' h- i5 E# e2 K) |9 k
  1420.     else/ Z" E0 S7 d7 P& \5 N/ N
  1421.       not_reach_point
    7 e# ~1 b  P7 [$ k; K1 V
  1422.       return
    # n+ n1 t5 l; Q  b
  1423.     end
    , p- I) M* |. B
  1424.     # 根据路径表格绘制最短移动路径(反向)
    2 S1 A' r2 f; q5 ?) n( V5 [9 h! h
  1425.     steps = step  2  2 + 1) H9 h1 Z( l. Q# @8 w
  1426.     loop_times = step  2
    8 M" }' V7 j4 P( `& G
  1427.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]- S9 R% E" M1 \7 x) [3 _
  1428.     for i in 1..loop_times # forLoop
    ' ~+ Y. C" J, {; h5 K# s
  1429.     steps -= 2# y- Y% Y/ x* V& ]
  1430.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs #反过来?蛋疼了……
    . j- X. k) W( d
  1431.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    - h6 d" C: K& A: N# U( }5 q0 O
  1432.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&, b5 @+ S) W: c% W8 a
  1433.             $game_map.passable(point_x, point_y, 4)                #judge_end7 K# W4 |& O5 P! J! r( x
  1434.         reversed_chase_path.push(6)
    8 P1 ^  s: F0 }% T0 q: r- @
  1435.         point_x = $game_map.round_x(point_x - 1)
    + ^8 p3 \( _) C
  1436.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    & P+ a% }% Z! D+ _( ]2 M; t) }
  1437.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    - Z, C1 H$ d7 F: d& u
  1438.             $game_map.passable(point_x, point_y, 6)                #judge_end
    8 q$ R3 g* L) C. R
  1439.         reversed_chase_path.push(4)
    2 R  ?% n) j, ~% D* w3 S+ ^
  1440.         point_x = $game_map.round_x(point_x + 1)
    8 d8 D; k2 y/ B9 z" q. I6 D
  1441.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&, \4 t  r3 s0 @% c$ P* g/ s" D4 a
  1442.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&. l. M' k1 g* _5 ?+ D0 E
  1443.             $game_map.passable(point_x, point_y, 2)                #judge_end
    : O$ V0 K, s/ ^. |, o8 o
  1444.         reversed_chase_path.push(8)
    + L3 ]8 q% v* g) h6 ~
  1445.         point_y = $game_map.round_y(point_y + 1)0 N7 h" }. E' E( R: w; w7 m5 A
  1446.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&5 W5 p2 i1 ^. ?6 c
  1447.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    ( G1 B3 D8 {& r$ e5 Z8 x' e
  1448.             $game_map.passable(point_x, point_y, 8)                #judge_end
    # k: F7 ~5 t7 s( J7 n/ x4 H" }) ]
  1449.         reversed_chase_path.push(2)
    / ?) K! a3 k; m/ d2 R
  1450.         point_y = $game_map.round_y(point_y - 1)
    ! F: ^+ a# g( s! Q
  1451.       end1 j- k& H, M7 y8 }8 i
  1452.     else. Y$ k' o' v! D+ r( i. b
  1453.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&1 t+ Y# D8 e& ?
  1454.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&4 e: t% Q4 M  H# w1 O
  1455.             $game_map.passable(point_x, point_y, 2)                #judge_end
    / ?  D; K% w8 a; f8 P3 o$ {
  1456.         reversed_chase_path.push(8), _+ ]. H, _) Q" F+ F# L
  1457.         point_y = $game_map.round_y(point_y + 1)7 U- ~% {( `0 m* W1 {2 i- d4 t( F
  1458.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&, n  B) v( I" H
  1459.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&& N: ^) o  l; H6 F: M  `/ b, {
  1460.             $game_map.passable(point_x, point_y, 8)                #judge_end
    8 |  Z. k, @3 f3 ~
  1461.         reversed_chase_path.push(2)6 |  y2 w0 G" K6 [& [5 t2 Z7 S+ L
  1462.         point_y = $game_map.round_y(point_y - 1)! q1 y7 O3 Z4 ^, ^2 b
  1463.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    : g& W) v; @* T6 F' M5 C$ d
  1464.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&
    * z  a5 W. O. p3 o; W% }/ X
  1465.             $game_map.passable(point_x, point_y, 4)                #judge_end
    : q8 a3 D; y' S+ [% u; K5 k* X
  1466.         reversed_chase_path.push(6)1 S3 z' ~1 f+ u8 d8 ~$ Z' e$ ^$ A
  1467.         point_x = $game_map.round_x(point_x - 1)# B+ G4 \  h. [# G6 m. \8 m
  1468.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    1 f+ s" y! E; W$ B
  1469.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&  l8 k( s0 K/ V6 p5 G' L2 u
  1470.             $game_map.passable(point_x, point_y, 6)                #judge_end" U" N9 [3 W) K" v
  1471.         reversed_chase_path.push(4)5 h( a) {% C  @! n; w
  1472.         point_x = $game_map.round_x(point_x + 1)
    , A: s8 {7 }' v& y: K
  1473.       end
    6 o; f$ p/ \! g8 }/ s
  1474.     end
    4 X# {% s9 l6 C) t( \& G
  1475.     end #endOfForLoop+ m1 f1 S% E, ]  F' ~1 C# L; B
  1476.     # 根据路径表格绘制最短移动路径(正向)
      W3 u0 o( W4 d' d' c
  1477.     steps = step  2  2' W2 o8 G) `% s% h1 G+ j
  1478.     loop_times = step  2
    8 h/ g4 P5 `* K, E" d
  1479.     point_x, point_y = chase_point[0], chase_point[1]2 Y$ H* I+ c0 H9 _6 v2 @% l
  1480.     for i in 2..loop_times # forLoop
      i" R, S) [* e: X- N1 m- |
  1481.     steps -= 23 ^  Z- v8 `2 e7 d' y
  1482.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs0 C0 _6 @  S  E1 L) v  Q. f* B( f6 P
  1483.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&. m5 @+ p' h7 I: k: A5 p' S% t1 d! T
  1484.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    , j; d+ u. L. o) ]( H
  1485.             $game_map.passable(point_x, point_y, 2)                #judge_end
    - E7 b) s# B2 Q& l+ d; y
  1486.         chase_path.push(2)* p& ]; P; Q$ ]9 e
  1487.         point_y = $game_map.round_y(point_y + 1)
    ! k7 c/ F# G5 ?  j% @
  1488.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&2 o& e# O4 T. M# _' ^! o: C
  1489.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&- D% W6 G4 b! Y! D, [9 L
  1490.             $game_map.passable(point_x, point_y, 8)                #judge_end
    ; t/ u; h, _! E- T, r, {* @
  1491.         chase_path.push(8)+ v: m$ H- g6 {8 ?( P
  1492.         point_y = $game_map.round_y(point_y - 1)( g0 h1 ^4 O2 w% ^. F
  1493.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&
    # M' S, l, C3 k* C
  1494.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&# F% B4 N# H" T2 t$ i
  1495.             $game_map.passable(point_x, point_y, 4)                #judge_end1 l0 O6 v# N! b* b
  1496.         chase_path.push(4)
    ( S7 q6 A- h5 Y  ^) k! |0 |; _
  1497.         point_x = $game_map.round_x(point_x - 1): [6 r. Y  P; z1 m2 x
  1498.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    8 V: ^, O# A0 t( B0 i6 @% @- k
  1499.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&
    , q* O: `9 S# E! [5 T1 ^
  1500.             $game_map.passable(point_x, point_y, 6)                #judge_end! c+ J9 G$ z# J& q, h' a$ m
  1501.         chase_path.push(6)
    ( [" r0 R$ {/ Z
  1502.         point_x = $game_map.round_x(point_x + 1)
    2 \6 P; B6 n' `9 D3 B5 C4 f
  1503.       end
    7 ?' `) S+ D. B+ A
  1504.     else% |* }. e* V* C% l
  1505.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps         &&# `5 t* V, X3 P; C2 g0 n$ k) n
  1506.             $game_map.passable($game_map.round_x(point_x - 1), point_y, 6) &&3 M+ z$ t4 D( \/ z- h; {
  1507.             $game_map.passable(point_x, point_y, 4)                #judge_end
    ) a4 {$ z$ q6 m. v, D
  1508.         chase_path.push(4)- F" ]9 h  f5 l4 c
  1509.         point_x = $game_map.round_x(point_x - 1)
    * }2 b* j2 {7 t3 Q
  1510.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps         &&
    - N5 S  |6 D3 n' `( X) u
  1511.             $game_map.passable($game_map.round_x(point_x + 1), point_y, 4) &&( X9 K* M0 D% A' M  {  g
  1512.             $game_map.passable(point_x, point_y, 6)                #judge_end
    8 p# t$ U5 b! j9 N# F' F
  1513.         chase_path.push(6)
    ; u/ G" p: y, v2 W% `1 s
  1514.         point_x = $game_map.round_x(point_x + 1)7 V8 E. f( J- ?& @! ?9 c
  1515.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps         &&
    1 }. Z2 L8 L1 Q+ K3 v  M8 R+ W
  1516.             $game_map.passable(point_x, $game_map.round_y(point_y + 1), 8) &&
    - t7 m3 W+ i$ t% f' Y1 d' u- d
  1517.             $game_map.passable(point_x, point_y, 2)                #judge_end
    , R$ t0 b' @3 i5 Z4 @0 {! U9 x- A
  1518.         chase_path.push(2)4 e" E: E9 G: \8 G
  1519.         point_y = $game_map.round_y(point_y + 1)
    4 P3 ?- M* Z. J% ]6 t* T
  1520.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps         &&
    " P9 ~1 a  e# f1 K! g: d& h
  1521.             $game_map.passable(point_x, $game_map.round_y(point_y - 1), 2) &&
    9 b; c( u+ {* B; K& [# e7 j6 \
  1522.             $game_map.passable(point_x, point_y, 8)                #judge_end3 G5 n' p6 L" a& R" R, Y
  1523.         chase_path.push(8)
    ' e& {6 m- N. }" _* }: l) L4 M
  1524.         point_y = $game_map.round_y(point_y - 1)
    0 [, L5 ^8 R, C
  1525.       end
    7 C2 ~) F* k1 u6 \
  1526.     end2 s* P, D- I3 n8 b. {' @7 S
  1527.     end #endOfForLoop
    + W9 ^# z3 `. R, I! R  s% j8 E
  1528.     @mouse_move_path = reversed_chase_path.reverse + chase_path3 }+ h+ l: d' ]$ `+ R
  1529.   end#walk, Q; e2 ]3 Y+ P. m
  1530.   #--------------------------------------------------------------------------
    % R5 P$ M: d% {( P1 J4 g
  1531.   # ● 绘制boat的移动路径 @array[move_directions...]
    - j9 s- ~  h7 u; J, W, k$ c
  1532.   #--------------------------------------------------------------------------
    & D7 C' x/ o" P4 `6 |8 _7 I
  1533.   def draw_boat_path
    % k. b7 q- k% n1 z$ E
  1534.     # 准备绘制路径表格
      J0 E5 m1 R; M4 e7 `/ X8 f
  1535.     sheet = Table.new($game_map.width, $game_map.height)7 z6 g5 B  v* R1 ^* @
  1536.     reversed_chase_path  = []; chase_path  = []
    $ T) ^; ?6 H/ Z/ m
  1537.     reversed_chase_point = []; chase_point = []" I7 Q" S: Q: R1 ~( Y! U7 |
  1538.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]. Z, w# q8 j) X- f$ I/ n
  1539.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 2% N8 u5 n0 v9 x: U( X% v9 R
  1540.     reach_point = false! n. ^6 s1 @" V7 e3 T
  1541.     step = 3! j; a8 h' F! ^1 c$ B( z* y
  1542.     loop do #loop1 开始填充表格# f9 A$ y* q% X! \
  1543.      draw_path = false
    + Q3 X3 j, d4 ~- a
  1544.      check_points = new_start_points: w' ]2 Z8 c; w$ L8 N
  1545.      new_start_points = []
    - m* r5 M6 Y9 w# [* ]
  1546.       loop do #loop2 从起点开始正向填充. \7 J. {) Z" I, D1 Q
  1547.         point_x = check_points.shift# {0 j% e" U7 _6 x! @
  1548.         break if point_x == nil% P6 m; J4 e7 f! X! `& e, f
  1549.         point_y = check_points.shift
    - Y7 l9 ?* @/ D8 W& z$ I7 ^
  1550.         left_x  = $game_map.round_x(point_x - 1)8 V3 f% @6 v9 k0 {$ D6 H
  1551.         right_x = $game_map.round_x(point_x + 1)
    # w2 w, I, {- Z' v: ^
  1552.         up_y    = $game_map.round_y(point_y - 1)
    , `- B4 c7 R5 `9 N8 r
  1553.         down_y  = $game_map.round_y(point_y + 1). N6 i. M; j: ~9 N! t9 c  m
  1554.                     # 判断路径是否连通; @5 q. B) ]% X, r8 |+ H
  1555.         path_step = step - 1
    ' |1 J6 F$ v4 v! P6 V
  1556.         if sheet[left_x, point_y] == path_step+ c* V3 E" {3 e! _) s0 D
  1557.           chase_path.push(4)4 r$ T* B7 l- A
  1558.           chase_point = [left_x, point_y]0 L! @" v- r0 R: I
  1559.           reversed_chase_point = [point_x, point_y]
    $ k, p( _* x! j8 O: g" K
  1560.           reach_point = true; break
    3 U. H7 @% `# S! w3 l) L
  1561.         elsif sheet[right_x, point_y] == path_step  o0 k* g( N3 r. j5 i: k- E/ \8 O
  1562.             chase_path.push(6)
    - v  b1 j- ?' c% B4 q- ]/ l
  1563.             chase_point = [right_x, point_y]; e; x# F; d' o8 q( ~4 h& ?
  1564.             reversed_chase_point = [point_x, point_y]
    : r5 W" B' `5 J* [6 q" Y( y
  1565.             reach_point = true; break
    ) }& }  s( K$ F! j) a: A1 I% q* k
  1566.         elsif sheet[point_x, up_y] == path_step* {  q! G# y2 m* `- a- e; c3 R
  1567.             chase_path.push(8)+ Q- |* g, l2 Q% \% W. d- }: _/ v. N
  1568.             chase_point = [point_x, up_y]1 ^1 o% }- Z3 j4 C9 p$ O3 z
  1569.             reversed_chase_point = [point_x, point_y]: o: H7 ^1 k$ [9 u
  1570.             reach_point = true; break# v' o$ S2 f; G" d& b
  1571.         elsif sheet[point_x, down_y] == path_step& ^" V1 ]9 \* [6 T
  1572.             chase_path.push(2)
    " y% J0 Z- `% w
  1573.             chase_point = [point_x, down_y]% ]8 X- N# D, T8 g3 F5 \
  1574.             reversed_chase_point = [point_x, point_y]) k+ X) l0 N: N3 [7 d
  1575.             reach_point = true; break
    ( [. ~; M% K& Q- ^- m; p  ?3 x2 B% G3 k
  1576.         end
    % L8 o0 `% _& F( G7 I# P  i) b( z
  1577.         # 以需要抵达该点的步数填充路径表格 #
    4 o- E- K- l+ G
  1578.         if sheet[left_x, point_y] == 0                &&
    2 {7 \* B, l/ d3 j! Q
  1579.            $game_map.boat_passable(left_x, point_y)  &&& N( i8 \0 B$ Z2 [
  1580.            !collide_with_events(left_x, point_y)     &&
    7 F$ W! k4 M8 r, X, S' m
  1581.            !collide_with_vehicles(left_x, point_y)   #judge_end
    ' B. ~2 _) m3 E2 u1 r# P) X) {
  1582.           sheet[left_x, point_y] = step
    4 p  [( P& J8 _2 ^
  1583.           draw_path = true
    " d( J9 Y- n7 v1 ~, f- @) H5 N' I" x
  1584.           new_start_points.push(left_x, point_y)& u1 d* b6 P2 m- @
  1585.         end
    & q( M0 E  J& {
  1586.         if sheet[right_x, point_y] == 0               &&
    % V( w* t  {9 @
  1587.            $game_map.boat_passable(right_x, point_y) &&
    : E# D/ S# S) l
  1588.            !collide_with_events(right_x, point_y)    &&5 C: V$ }7 O/ N
  1589.            !collide_with_vehicles(right_x, point_y)  #judge_end
    4 O- Y) I. x1 Y" B8 }4 Y& k
  1590.           sheet[right_x, point_y] = step
    2 L) ~# E+ w0 B: s' j  L
  1591.           draw_path = true- p  \; `# x$ ~
  1592.           new_start_points.push(right_x, point_y)
    7 t' [" k0 w" |- M  o4 J) H9 m
  1593.         end/ ]; z0 [: w2 Q7 @+ [
  1594.         if sheet[point_x, up_y] == 0                  &&) K7 G4 i4 G' v0 C
  1595.            $game_map.boat_passable(point_x, up_y)    &&" G: C9 q- p9 O6 }
  1596.            !collide_with_events(point_x, up_y)       &&
    : v9 C$ U. J: M
  1597.            !collide_with_vehicles(point_x, up_y)     #judge_end
    + {1 d( D& J3 Q6 v; r
  1598.           sheet[point_x, up_y] = step
    , w4 A  t2 Y0 C- y. Q
  1599.           draw_path = true7 F1 d8 N5 ?/ d; z
  1600.           new_start_points.push(point_x, up_y)
      [1 @( o6 x" }
  1601.         end, p+ c: X) v! P- B9 H) v) y3 ^
  1602.         if sheet[point_x, down_y] == 0                &&. D) @$ v# N( d0 T
  1603.            $game_map.boat_passable(point_x, down_y)  &&0 B: Z, v' A" f3 Z
  1604.            !collide_with_events(point_x, down_y)     &&
    & E. s/ i9 ]% @9 _, f0 {* l0 F
  1605.            !collide_with_vehicles(point_x, down_y)   #judge_end
      }2 ?, p$ y8 r' r
  1606.           sheet[point_x, down_y] = step
    $ u: v' O+ ?4 a5 v6 x* [# @) Z) a
  1607.           draw_path = true
    3 u2 V0 z$ q# H! n
  1608.           new_start_points.push(point_x, down_y)
    ) D7 A% u: u8 z
  1609.         end/ X% b, W  u2 H; D2 `) ~! s
  1610.       end#endOfLoop2
    / K5 `3 ?8 @4 a$ y) I# ?6 U; i* O
  1611.       break if !draw_path  reach_point1 M. _0 e, ]0 A
  1612.       draw_path = false! d: b$ m" z! V% [
  1613.       check_points = new_end_points
    , v4 n$ ^- \  e) ^0 y
  1614.       new_end_points = []" x/ K% _1 ?# Q
  1615.       step += 1
    " U# f8 _/ R: l  ]" m
  1616.       break if step  KsOfSionBreak_Steps &&0 M+ \  y/ E/ F! a
  1617.                !Input.press(KsOfSionFind_Path_Key)
    ! _+ G+ s; i$ l+ E
  1618.       loop do #loop3 从终点开始反向填充
    $ E: H, c6 w& W7 d" V- }
  1619.         point_x = check_points.shift
    & U. w/ j( |; q' z
  1620.         break if point_x == nil* Z$ i2 e1 y/ h3 L- x5 |( C+ a
  1621.         point_y = check_points.shift/ U, h$ ^( y' J
  1622.         left_x  = $game_map.round_x(point_x - 1)
    " u' M8 t' o8 f& @1 t3 |
  1623.         right_x = $game_map.round_x(point_x + 1)
    7 a6 U7 {8 n# A% `- S! x
  1624.         up_y    = $game_map.round_y(point_y - 1)4 ]  l; Q" Y# X* i; E7 j- ~
  1625.         down_y  = $game_map.round_y(point_y + 1)
    - {1 T, V$ ?- K  f- j
  1626.         # 判断路径是否连通* x% N0 }, s" `" t9 }
  1627.         path_step = step - 1
    / ^! `5 R" K9 V6 [5 [2 {4 q) b2 Q
  1628.         if sheet[left_x, point_y] == path_step4 F. n' |$ n; \4 F; _% s: y! v
  1629.           chase_path.push(6)
    5 J/ J/ v  n$ M* _5 u. e3 t+ e
  1630.           chase_point = [point_x, point_y]) O( [( l- R: ~( J# r3 U
  1631.           reversed_chase_point = [left_x, point_y]3 M8 t" |6 O& v4 q- n
  1632.           reach_point = true; break
    - }7 p" _1 V2 I; V6 P
  1633.         elsif sheet[right_x, point_y] == path_step
    $ ^' B* D& O4 ~0 j, y" o( O
  1634.             chase_path.push(4): M$ a! b( p0 F0 l8 D( B) U
  1635.             chase_point = [point_x, point_y]
    ' k0 f  C0 f! t. p6 C
  1636.             reversed_chase_point = [right_x, point_y]
    $ ~( Q% Q* g3 O# D8 i2 u- Z7 ~6 J
  1637.             reach_point = true; break/ j( K" m1 _( r7 D
  1638.         elsif sheet[point_x, up_y] == path_step
    0 ?  \- s  D7 `/ D2 e0 a2 F5 W
  1639.             chase_path.push(2). y! H7 m9 `. c2 ~4 o( m# b
  1640.             chase_point = [point_x, point_y]
    7 {- _6 T, Q/ x" H
  1641.             reversed_chase_point = [point_x, up_y]
    # o8 L% |, T( |; i( y* G* ]% Y
  1642.             reach_point = true; break
    % D1 e, j5 S, Z: X: f+ A% B
  1643.         elsif sheet[point_x, down_y] == path_step
    3 b- S9 q2 o: @9 Z8 W
  1644.             chase_path.push(8)* P9 x5 W% n1 O- @* n: V
  1645.             chase_point = [point_x, point_y]8 H7 d- R( R9 G4 n; [; E9 e
  1646.             reversed_chase_point = [point_x, down_y]
    5 p8 g1 m2 ^& s! Z+ J8 ]
  1647.             reach_point = true; break
    5 w% b8 j/ d1 ~" V; `2 T
  1648.         end2 e! t" T6 B6 q5 G  r) a
  1649.         # 以需要抵达该点的步数填充路径表格 #( H, u, J$ D/ f% N8 J( e$ b
  1650.         if sheet[left_x, point_y] == 0                &&
    * C* P! Q; D2 ?
  1651.            $game_map.boat_passable(left_x, point_y)  &&2 U8 f/ u+ E9 k
  1652.            !collide_with_events(left_x, point_y)     &&
    . Q# b6 e, P  o; ^0 ~5 G3 w
  1653.            !collide_with_vehicles(left_x, point_y)   #judge_end! a6 ]/ Z( R5 k: @0 w
  1654.           sheet[left_x, point_y] = step
    - g9 O% |# P  a/ D1 `6 S* r7 N
  1655.           draw_path = true! w5 _- i7 {: S2 i0 ~" T8 g9 y
  1656.           new_end_points.push(left_x, point_y)! U. U3 J7 q, J$ u( N
  1657.         end
    4 v8 V; t4 X8 u9 P# g! \1 h* Q
  1658.         if sheet[right_x, point_y] == 0               &&) w: w: i5 ~' T; F: X6 N2 {
  1659.            $game_map.boat_passable(right_x, point_y) &&
    * H" h' g0 N9 N
  1660.            !collide_with_events(right_x, point_y)    &&
    0 ^# p/ A* i5 q$ l
  1661.            !collide_with_vehicles(right_x, point_y)  #judge_end
    3 H6 O9 ?, s& ?8 X* s; p
  1662.           sheet[right_x, point_y] = step- |/ O0 E& z( t4 C7 j$ e& P+ b1 y' \
  1663.           draw_path = true
    1 n3 U. T: {5 j
  1664.           new_end_points.push(right_x, point_y)
    8 h/ C3 ^- D7 c! B
  1665.         end
    / v$ h( p8 v) w( L
  1666.         if sheet[point_x, up_y] == 0                  &&
    8 K  l/ g% j3 a
  1667.            $game_map.boat_passable(point_x, up_y)    &&
    9 f/ a. P( R9 @# b( \) s: X
  1668.            !collide_with_events(point_x, up_y)       &&" m4 Y1 g, l; v/ d8 s+ I: o
  1669.            !collide_with_vehicles(point_x, up_y)     #judge_end$ Q: @1 |- U  Y. j/ `: K9 I, @
  1670.           sheet[point_x, up_y] = step
    + G' D9 k) i  ^1 P; Y: [
  1671.           draw_path = true" J+ ~/ ~/ _& I6 y8 l. e" ]
  1672.           new_end_points.push(point_x, up_y)$ q1 u8 X& @2 H2 G' X9 O
  1673.         end
    . e# r3 H, e6 k
  1674.         if sheet[point_x, down_y] == 0                &&, q0 \2 ]0 J9 j
  1675.            $game_map.boat_passable(point_x, down_y)  &&% D4 j- t$ c2 k' r. H6 @5 ?
  1676.            !collide_with_events(point_x, down_y)     &&
    . {, W# [$ }  ~. Z1 o9 p. I
  1677.            !collide_with_vehicles(point_x, down_y)   #judge_end
    : a1 u8 y/ E! M) E; c0 h$ z- [! P" b
  1678.           sheet[point_x, down_y] = step
    ! W& V- u, k# ~0 d/ ~8 P. |
  1679.           draw_path = true( J9 s: _) ~2 B3 ^" z; b
  1680.           new_end_points.push(point_x, down_y)9 z5 }, l2 U9 u# D* A! r
  1681.         end
    : O. }! O; z9 d5 ]' E) P: h/ X
  1682.       end#endOfLoop3
    + ~1 {6 o( J# }0 D
  1683.       break if !draw_path  reach_point1 }0 q: v9 A5 r
  1684.       step += 1- Z) [* U" I" I( R$ J) K0 j
  1685.     end #endOfLoop1 路径表格填充完毕
    7 q4 D1 U( o7 N& ?- _
  1686.     $mouse_move_sign.transparent = false$ _0 N5 h0 n- a# |* u! f  g' Z
  1687.     # 判断指定地点能否抵达7 E" a0 B1 j( N: n6 q9 [
  1688.     if reach_point3 S3 x+ @8 S# f
  1689.       $mouse_move_sign.direction = 2
    0 b5 z2 J, t, T" T0 f
  1690.     else. b5 u* T" n& O$ m0 g5 @+ w
  1691.       not_reach_point  V5 H6 E  i3 n& H: N
  1692.       return* \% p) Z! n8 t% ]: v
  1693.     end
    8 ^0 W2 Q" o4 R4 n" o- O% U
  1694.     # 根据路径表格绘制最短移动路径(正向)
    ' V4 Q9 E+ Z$ i) n
  1695.     steps = step  2  26 r* _6 s0 G2 |# S
  1696.     loop_times = step  2
    . O1 ?0 z, `) @. r: T/ e& [
  1697.     point_x, point_y = chase_point[0], chase_point[1]  r% w: ?/ ?6 B4 s3 y, P
  1698.     for i in 2..loop_times # forLoop
    / t! W$ M8 Q" ^
  1699.     steps -= 2
    ; u1 e  `" E& x+ A: d
  1700.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs0 @9 C5 B, P" `& u* K
  1701.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    4 q6 {8 ~5 M% J
  1702.         chase_path.push(2)$ y  }. V+ @9 L: i- }
  1703.         point_y = $game_map.round_y(point_y + 1)
    6 h0 s, @: u) }) y0 N( m3 c, M
  1704.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    # r3 s  Z8 `  C; D$ B1 d+ e
  1705.         chase_path.push(8)) h5 Z7 q7 B* n0 c; u% [
  1706.         point_y = $game_map.round_y(point_y - 1)
    - c6 ]1 a+ Q. i# ]6 F7 x4 B) u% q1 ?
  1707.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    6 R( x, c* c9 o: z9 w+ s4 j5 ]
  1708.         chase_path.push(4)% ?2 w6 \: K) [9 g# R* `3 Z
  1709.         point_x = $game_map.round_x(point_x - 1)
    ) X% Q: y% ?+ D) x! Z6 u0 S
  1710.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    + y3 L6 g3 n- R, F/ w7 `" I$ M
  1711.         chase_path.push(6)$ n! I. ]4 M, t7 I/ q$ }/ h- o5 }
  1712.         point_x = $game_map.round_x(point_x + 1)2 [7 V6 ~& [7 K& ~3 s
  1713.       end
    5 }$ R! Q! ^. v5 ^" m* x& z
  1714.     else
    + c9 w% O: h$ \4 J4 g/ t; R
  1715.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps3 J. ?4 `* l4 E! a) X% P8 s: N2 N
  1716.         chase_path.push(4)
    0 S, _, B6 R9 r! o' Q
  1717.         point_x = $game_map.round_x(point_x - 1)* P" e0 `# N: I3 z0 A' D7 i# \" _
  1718.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps/ {5 g; f) j4 J. H. P' C
  1719.         chase_path.push(6)
    # r, ^3 R# @6 j9 m& Z1 W. X5 }4 T
  1720.         point_x = $game_map.round_x(point_x + 1)
    5 f) B. D. ]% L, A& f1 J
  1721.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps+ Q3 ^. F2 l* m+ R
  1722.         chase_path.push(2)
    5 |% P7 Y6 C' u& \, m0 }
  1723.         point_y = $game_map.round_y(point_y + 1)1 x9 C4 T0 k0 T& E* e' @
  1724.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    + b! l4 ^) o& L8 }' \
  1725.         chase_path.push(8)
    2 h$ g8 g4 J9 Y9 C/ `5 E7 h
  1726.         point_y = $game_map.round_y(point_y - 1)
    4 I* q7 T; B4 F' V  N2 N
  1727.       end
    . z8 r# Y/ A5 v* f1 P5 A3 }
  1728.     end( K. }6 e- I4 H& P8 A
  1729.     end #endOfForLoop
    + h3 i$ k0 K7 W# q( \8 }
  1730.     # 如果指定点无法抵达或者登陆
    % Z+ B# k  n( f) b# Z& @
  1731.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)% b3 `8 I7 Y/ H* u
  1732.     # 根据路径表格绘制最短移动路径(反向)
    : K( k. J3 _' s/ k, t1 a
  1733.     steps = step  2  2 + 1
    & g# V! F; c! ]3 {
  1734.     loop_times = step  2
    ; p. H4 e" v$ L: p, S6 k+ N
  1735.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]! k5 y, U# h0 y; Z8 t5 W7 p
  1736.     for i in 1..loop_times # forLoop; u( g3 N, C  q2 v* o
  1737.     steps -= 2  ^: ~0 u) A: x- |/ y* \6 B
  1738.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    ' T- m$ T3 q* g( h
  1739.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    * D1 E: M* A( g# D) g1 ]
  1740.         reversed_chase_path.push(6)( r( X# b' C4 U
  1741.         point_x = $game_map.round_x(point_x - 1)6 a& U6 p7 ]! N" u- \8 U3 d. m
  1742.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps$ }( X6 U7 h" E! Q; A- ^
  1743.         reversed_chase_path.push(4)
    & }5 @/ h, b$ P
  1744.         point_x = $game_map.round_x(point_x + 1)
    . K7 y; f, R- u0 p
  1745.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    + C- K& W: X( }1 X( Y
  1746.         reversed_chase_path.push(8)
    3 ]+ X( Z/ S3 M2 h: h- l; r
  1747.         point_y = $game_map.round_y(point_y + 1)3 P' Z) F% {. O; u. B9 ]7 Q
  1748.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    & o. ^8 _# {) b/ u7 E' ?0 T
  1749.         reversed_chase_path.push(2)6 c" j0 U# v" L7 [; \& ]* H6 E3 Q
  1750.         point_y = $game_map.round_y(point_y - 1)3 Q. o( w) d1 Z' `: t1 `
  1751.       end2 z3 I3 \6 }. `& \7 J
  1752.     else
    ; @( i* L% Y6 s. Y4 ]: ~( e/ H
  1753.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps7 d( f1 t8 K5 e4 x
  1754.         reversed_chase_path.push(8)
    2 P8 r* A: Y( r7 s5 V
  1755.         point_y = $game_map.round_y(point_y + 1)
    * b1 s/ B9 d, b0 K: y
  1756.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
      J( a5 M5 {: b  }) O2 p5 y" D
  1757.         reversed_chase_path.push(2)
    % W8 L6 @' P# \9 Y
  1758.         point_y = $game_map.round_y(point_y - 1)
    % \" k' M; m: N
  1759.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    - a- r: i, {0 r$ F  g
  1760.         reversed_chase_path.push(6)
    5 r! _  [* g* o9 N, Z
  1761.         point_x = $game_map.round_x(point_x - 1)7 o0 j  r" Y1 C* z# o' p
  1762.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps0 ~# M6 C  _: X' c% b
  1763.         reversed_chase_path.push(4)
    ; ~7 O/ F. V1 T5 q& M6 Z2 }
  1764.         point_x = $game_map.round_x(point_x + 1)" H3 y( _' ~* E
  1765.       end
    % N3 X9 H$ z; G0 @
  1766.     end8 X3 D6 X) C, c9 G
  1767.     end #endOfForLoop# D" P& ?! c5 ]# N! J# l0 R" M
  1768.     @mouse_move_path = reversed_chase_path.reverse + chase_path! t' t& F. T" w* t
  1769.   end#boat! c# g  {8 M+ Z6 D. _
  1770.   #--------------------------------------------------------------------------
    ! d0 ^5 n; R- ]" m5 B
  1771.   # ● 绘制ship的移动路径 @array[move_directions...], x: J5 K6 I  X8 a) D
  1772.   #--------------------------------------------------------------------------/ ~! _+ s1 o& N" V  I3 k+ a* @
  1773.   def draw_ship_path+ E% n2 y. k1 [, I9 P1 h: O
  1774.     # 准备绘制路径表格! j7 R( o, Y2 z0 Z1 x
  1775.     sheet = Table.new($game_map.width, $game_map.height)
    ' _. d) o& ?: V; o: w/ c6 G
  1776.     reversed_chase_path  = []; chase_path  = []# N- y6 C! K5 o. B  m
  1777.     reversed_chase_point = []; chase_point = []. p( V$ X3 ~+ F
  1778.     new_start_points = [x, y]; new_end_points = [@moveto_x, @moveto_y]# c, W9 L4 r  Z& U" g
  1779.     sheet[x, y] = 1;           sheet[@moveto_x, @moveto_y] = 24 f( d2 g7 y, d$ ^+ r
  1780.     reach_point = false
    % ^+ f. R8 ~0 r& M/ C8 R1 m
  1781.     step = 3% r  z, s0 _. L4 O4 V% `
  1782.     loop do #loop1 开始填充表格
    + B4 X; |: {1 a8 R
  1783.      draw_path = false
    2 o) m4 w0 ~; c& n& T+ m
  1784.      check_points = new_start_points4 H2 j# A. \5 l
  1785.      new_start_points = []; [' G+ U+ g& D
  1786.       loop do #loop2 从起点开始正向填充
    4 o7 w+ z  E* @2 k$ ~& B8 D( S: U
  1787.         point_x = check_points.shift$ {2 w) i$ H: r  B
  1788.         break if point_x == nil
    . |! K7 J/ e8 q  l
  1789.         point_y = check_points.shift) |' a( ^; I4 ?% y, g( q; x. a# F
  1790.         left_x  = $game_map.round_x(point_x - 1)
    . U% H+ t# f% Y! K2 n
  1791.         right_x = $game_map.round_x(point_x + 1)
    6 k. L# R$ j- c6 ^( b0 w* [
  1792.         up_y    = $game_map.round_y(point_y - 1)
    ( t( {1 D( ^) _2 a$ W
  1793.         down_y  = $game_map.round_y(point_y + 1)
    8 ~0 P7 x5 k1 z. i; |
  1794.                     # 判断路径是否连通& S& K4 s& l8 Q, l: Z. f
  1795.         path_step = step - 1+ O+ I; X6 j# D7 g5 b
  1796.         if sheet[left_x, point_y] == path_step; W1 A1 X4 i! F7 z+ j# w0 t
  1797.           chase_path.push(4)
    3 L) g& d: d, \. t
  1798.           chase_point = [left_x, point_y]! e0 c: {1 m% w8 O' l" c
  1799.           reversed_chase_point = [point_x, point_y]" d! Z% A* L7 Y0 x8 ?2 M
  1800.           reach_point = true; break0 j) D* O* V; ?  Y
  1801.         elsif sheet[right_x, point_y] == path_step
    : }0 g# E9 @( ~. w# |1 b: h6 N
  1802.             chase_path.push(6)& Z, G. b: D& t
  1803.             chase_point = [right_x, point_y]
    6 t5 C, |" M0 c
  1804.             reversed_chase_point = [point_x, point_y]. N  z  m6 ]4 A
  1805.             reach_point = true; break
    1 p, F" |8 A! n4 [
  1806.         elsif sheet[point_x, up_y] == path_step
    8 z' w1 M% R0 X; P8 n
  1807.             chase_path.push(8)
    ' A/ L( n6 }- f% z0 x& t
  1808.             chase_point = [point_x, up_y]
    3 j. t$ {1 \0 A( u
  1809.             reversed_chase_point = [point_x, point_y]
    0 X6 y" w# Y' P9 l! B1 t& {
  1810.             reach_point = true; break
    # K, Q7 }! `& P( P& f$ b
  1811.         elsif sheet[point_x, down_y] == path_step; D0 c0 V) p0 D  l7 M
  1812.             chase_path.push(2)/ U+ r( _5 o0 m) r0 R6 @/ O& r
  1813.             chase_point = [point_x, down_y]
    3 g3 g. [2 W) L3 |
  1814.             reversed_chase_point = [point_x, point_y]
    % R* v# _+ w8 b+ a5 X
  1815.             reach_point = true; break6 i/ z& c. f* E6 G$ ]6 J
  1816.         end
    ) Q# I+ o0 \/ }. ^# ^5 \
  1817.         # 以需要抵达该点的步数填充路径表格 #
    4 n# `0 l# J  k, Q: \1 K
  1818.         if sheet[left_x, point_y] == 0                &&% q9 |* i( c! X8 J
  1819.            $game_map.ship_passable(left_x, point_y)  &&& s9 v0 u) F* A5 L" Q- A, L& {
  1820.            !collide_with_events(left_x, point_y)     &&$ e* v; V8 k$ {/ K/ d9 G
  1821.            !collide_with_vehicles(left_x, point_y)   #judge_end" u' \! _$ R; k0 u4 f& C5 a
  1822.           sheet[left_x, point_y] = step1 a5 Q3 u, V) @' B  K, e5 {+ h9 c
  1823.           draw_path = true4 Z$ b2 ^+ X5 q+ i
  1824.           new_start_points.push(left_x, point_y)+ D5 s8 S3 k# |% b6 J& k
  1825.         end" Y' u6 ~7 q0 j4 K, W
  1826.         if sheet[right_x, point_y] == 0               &&" \4 P% D+ c8 P9 c
  1827.            $game_map.ship_passable(right_x, point_y) &&
    $ k: x4 V' {7 N6 N
  1828.            !collide_with_events(right_x, point_y)    &&
    8 J- v0 K7 d5 _  E, Y+ ~
  1829.            !collide_with_vehicles(right_x, point_y)  #judge_end
    , w/ b. {& h( @
  1830.           sheet[right_x, point_y] = step
    / x' J" F! R4 z  B- B; @; }
  1831.           draw_path = true& K+ T' j0 ]! @  Y/ x
  1832.           new_start_points.push(right_x, point_y)
    % T8 G; Z: Y3 \. n: p4 X
  1833.         end* u+ x9 i  }) E6 ~8 V
  1834.         if sheet[point_x, up_y] == 0                  &&! g: d3 o3 B* s1 E: X4 d! R
  1835.            $game_map.ship_passable(point_x, up_y)    &&
    9 N* O' @( Y$ i
  1836.            !collide_with_events(point_x, up_y)       &&/ Y8 g6 G! D5 H$ H3 }( l1 J
  1837.            !collide_with_vehicles(point_x, up_y)     #judge_end0 k3 Z3 {$ s; Q. v; e: E
  1838.           sheet[point_x, up_y] = step
    2 D' W8 _1 @' X
  1839.           draw_path = true2 k" }% q3 \9 e) T# {, l/ f
  1840.           new_start_points.push(point_x, up_y)
    . c% |3 b4 U$ |: P  b5 M
  1841.         end
    5 I1 s9 ^) h) A
  1842.         if sheet[point_x, down_y] == 0                &&
    9 i9 |& U6 C( w$ ^$ b& x" W4 @
  1843.            $game_map.ship_passable(point_x, down_y)  &&- S# j1 f1 ?! Q* t& {
  1844.            !collide_with_events(point_x, down_y)     &&
    % H0 w" w  g4 N" W0 X2 b+ X
  1845.            !collide_with_vehicles(point_x, down_y)   #judge_end! f) l7 c9 @& Y- n1 W( @0 d
  1846.           sheet[point_x, down_y] = step
    * f  r% t) w- W; h
  1847.           draw_path = true
    * H, H$ [9 S" E, T& f- j( v- Q
  1848.           new_start_points.push(point_x, down_y)
    ) U5 T" ]9 ?/ t+ A8 Q
  1849.         end3 j" Z& w) Q, o: w& a; j& J
  1850.       end#endOfLoop20 r7 a  t: L% t& t& h- _0 M( S
  1851.       break if !draw_path  reach_point
    0 b1 i; S8 d# C4 L
  1852.       draw_path = false/ {, q, N8 Y. P1 R! o
  1853.       check_points = new_end_points) i" D6 h$ X# p1 y# @" k0 n3 n
  1854.       new_end_points = []
    5 G3 y8 b" x+ K  Z
  1855.       step += 1
    " I/ \3 c" x3 l$ ^% F
  1856.       break if step  KsOfSionBreak_Steps &&1 {% k/ E- i0 J* b3 G1 i/ C
  1857.                !Input.press(KsOfSionFind_Path_Key)# z7 W& b: U% {6 w3 N7 s% @
  1858.       loop do #loop3 从终点开始反向填充
    % {) n9 ]4 B2 j: D* Z
  1859.         point_x = check_points.shift  _7 D' A( [; P5 \. H5 a3 a0 c! g
  1860.         break if point_x == nil& V5 e7 R/ s- Z
  1861.         point_y = check_points.shift
    * B! Q+ {  S3 G2 o& r6 W
  1862.         left_x  = $game_map.round_x(point_x - 1)
    ( t* _- _% L: s7 D
  1863.         right_x = $game_map.round_x(point_x + 1)- G& V% J: }9 M% G4 Y) ^9 R
  1864.         up_y    = $game_map.round_y(point_y - 1), o  A& @$ @8 j* ~" N) s% i. U
  1865.         down_y  = $game_map.round_y(point_y + 1)$ j; s3 C, F3 J
  1866.         # 判断路径是否连通6 |6 R2 |' l9 v
  1867.         path_step = step - 1
      a" J5 D. ?5 ?0 D
  1868.         if sheet[left_x, point_y] == path_step
    8 x( d* @0 @2 y. H, k. c1 n
  1869.           chase_path.push(6)
    7 s" F. R) k6 L1 `; R
  1870.           chase_point = [point_x, point_y]2 B$ F9 ^* d6 k- E, y  U9 H4 U
  1871.           reversed_chase_point = [left_x, point_y]4 J* b/ H5 |  d7 |
  1872.           reach_point = true; break
    . P8 l+ t* T) i+ W  k6 ~0 C
  1873.         elsif sheet[right_x, point_y] == path_step7 [$ l( v* [5 z. s! n
  1874.             chase_path.push(4)
    ! G$ `- Y% y5 W( F( }2 P
  1875.             chase_point = [point_x, point_y]/ q: a9 R% Y1 u: j7 S2 P
  1876.             reversed_chase_point = [right_x, point_y]/ A7 X9 L# e- t
  1877.             reach_point = true; break' M, _7 k" L) k( ]2 [8 C
  1878.         elsif sheet[point_x, up_y] == path_step1 c! h5 d3 E# o$ H$ `' S" {- N$ G& y
  1879.             chase_path.push(2)
    . |6 I* r0 a0 ~% i
  1880.             chase_point = [point_x, point_y]$ e, J- s4 F: e
  1881.             reversed_chase_point = [point_x, up_y]+ v8 m; d; o) C2 N5 n. a8 }
  1882.             reach_point = true; break
    0 X4 |& ^: X! [' u+ C7 \/ c
  1883.         elsif sheet[point_x, down_y] == path_step" ^4 O) G' A; r
  1884.             chase_path.push(8)
    & P* _, ?$ u* s0 r
  1885.             chase_point = [point_x, point_y]6 G- b% u% T1 W
  1886.             reversed_chase_point = [point_x, down_y]
    * D8 g+ t2 G0 j1 L6 M0 H; x
  1887.             reach_point = true; break. o% ^+ T6 \1 V; m* j6 f) o
  1888.         end7 P4 j" }6 W3 o" z
  1889.         # 以需要抵达该点的步数填充路径表格 #
    " Y' @1 d7 F# k3 |
  1890.         if sheet[left_x, point_y] == 0                &&
    + g6 n  x+ m+ D6 N8 u
  1891.            $game_map.ship_passable(left_x, point_y)  &&
    2 M( q* M# @" E
  1892.            !collide_with_events(left_x, point_y)     &&/ D6 r( h" ]% d4 V# n
  1893.            !collide_with_vehicles(left_x, point_y)   #judge_end
    ; {1 D) i  m7 ?3 E
  1894.           sheet[left_x, point_y] = step
    1 p* C* s9 J8 C9 ]' ^0 d2 e9 p& M
  1895.           draw_path = true
    $ U0 l, A, X3 o5 B
  1896.           new_end_points.push(left_x, point_y)! E/ G. o5 V3 a2 y* P! N  M
  1897.         end
    & T/ }6 s- i0 {( x# U8 ^
  1898.         if sheet[right_x, point_y] == 0               &&
    * ~* V, d. @9 N$ H" Q/ O! v$ }
  1899.            $game_map.ship_passable(right_x, point_y) &&8 Z$ \; [, X% S) Q" t
  1900.            !collide_with_events(right_x, point_y)    &&
    ( x* o/ t* b0 p9 d" M) ?
  1901.            !collide_with_vehicles(right_x, point_y)  #judge_end
      Q; z7 n# \; g3 f0 {- o( `
  1902.           sheet[right_x, point_y] = step: L& A3 x* N; L3 |0 a- l! y
  1903.           draw_path = true
    4 B$ X5 B) Q4 t( \
  1904.           new_end_points.push(right_x, point_y)6 t! y" l+ {* Q. J: b& |! p
  1905.         end9 m& D' F7 F. m7 b4 Y. o6 s9 s
  1906.         if sheet[point_x, up_y] == 0                  &&
    ! U0 K0 E. g! l4 B( o: n
  1907.            $game_map.ship_passable(point_x, up_y)    &&
    $ m7 P  k  P; {# v, l
  1908.            !collide_with_events(point_x, up_y)       &&4 V1 \1 Y6 i. [7 f
  1909.            !collide_with_vehicles(point_x, up_y)     #judge_end
    5 L6 d  ?5 z( p; f( m7 E; L
  1910.           sheet[point_x, up_y] = step
    5 f  t! L2 Z9 I
  1911.           draw_path = true
    : ?: X7 Q; l% {  a4 ^
  1912.           new_end_points.push(point_x, up_y)2 i7 i1 N6 W- y3 l* i
  1913.         end
    6 i3 Q" Y$ _" G+ X" j% W
  1914.         if sheet[point_x, down_y] == 0                &&
    ) G; D8 k* m, X/ x# H, P& E
  1915.            $game_map.ship_passable(point_x, down_y)  &&
    & ]: i9 [: D$ |; p. z2 [- _  t
  1916.            !collide_with_events(point_x, down_y)     &&
      p3 S* X! a' {) u
  1917.            !collide_with_vehicles(point_x, down_y)   #judge_end  K" F$ d* z7 t' @6 u. ?  d
  1918.           sheet[point_x, down_y] = step
    0 l5 Q  }/ L5 [% B; Z/ k( B3 P
  1919.           draw_path = true, P( O* h9 B# X- I  L) \
  1920.           new_end_points.push(point_x, down_y)6 C+ N3 a& t( H$ h4 M4 ?$ K/ n8 f
  1921.         end
    : \& E3 ^: k3 w/ `# o3 p
  1922.       end#endOfLoop38 ^* c* G  _; L  i
  1923.       break if !draw_path  reach_point7 ~+ C  c# ^" }: f8 z) A) R+ r4 `
  1924.       step += 1
    . @& L9 k2 [( k
  1925.     end #endOfLoop1 路径表格填充完毕
    ! N% `( f4 G3 X" w- p
  1926.     $mouse_move_sign.transparent = false( E" J+ T; D0 L. n" R$ P
  1927.     # 判断指定地点能否抵达
    : b( g" x( R. S0 V1 Y
  1928.     if reach_point
    , Z- ~& n  b2 i# f  n' r
  1929.       $mouse_move_sign.direction = 2( D# _7 e$ e/ ^$ E) @
  1930.     else9 b) }% e) G0 j
  1931.       not_reach_point
    : s# I0 D+ P" q- {: ?6 j+ r& L
  1932.       return* h8 r' ?3 J# j* v% W6 q  d) P
  1933.     end
    : [8 W. K& |6 T# ]+ h8 ^
  1934.     # 根据路径表格绘制最短移动路径(正向)( H  k. E8 K  v5 ?, R4 q% d+ [, f
  1935.     steps = step  2  2* w. p# r) o5 p8 x
  1936.     loop_times = step  2
    ; M* X" p; L& ?
  1937.     point_x, point_y = chase_point[0], chase_point[1]) e& V* |( ]0 |8 t/ K1 H& ~
  1938.     for i in 2..loop_times # forLoop
    : ^! Q' Z/ S  n0 o- F. {1 j
  1939.     steps -= 2
    ; }7 J& V+ i$ e( `) p( _
  1940.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs2 E; b4 `1 ?( _" J
  1941.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps0 A  i, ]! N# g3 |8 Q2 ?
  1942.         chase_path.push(2)1 A+ v9 R, q9 @- Y' W, F
  1943.         point_y = $game_map.round_y(point_y + 1)
    ' C: u# f: W( ]( e- M
  1944.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    2 e' J- |, @7 d( u$ X
  1945.         chase_path.push(8)
    4 V# C. X6 {3 K$ [" [: B6 l
  1946.         point_y = $game_map.round_y(point_y - 1)
    * L- x% l: q5 I! D& I0 w" r
  1947.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps/ E6 }9 Y* G/ h* b$ U7 z
  1948.         chase_path.push(4)' ]! S% `2 v% }% K
  1949.         point_x = $game_map.round_x(point_x - 1)- M6 q$ F$ _9 P9 o+ s6 m
  1950.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    * h% s6 P3 D) s/ ]
  1951.         chase_path.push(6)$ `: E$ X& t/ K  z8 s
  1952.         point_x = $game_map.round_x(point_x + 1)0 h0 u. Q  N2 R2 O; \1 V
  1953.       end* j% B/ Y& `0 `# D7 ^
  1954.     else
    0 i, F1 \. d0 }; u6 p: [' a# l
  1955.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    $ b4 _' W1 f& m( G! U) ?
  1956.         chase_path.push(4)8 O+ b" F* m" L% m' R" g
  1957.         point_x = $game_map.round_x(point_x - 1)" s+ k7 c, L' W4 ]. F: q$ h
  1958.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    ( s- T+ Z8 A: f, X4 g3 [+ S
  1959.         chase_path.push(6)
    ' Q3 H8 t' U9 k, [/ x" v
  1960.         point_x = $game_map.round_x(point_x + 1)
    . f6 K% ^1 W5 H- h
  1961.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    2 J4 a/ D5 L- X- `; y
  1962.         chase_path.push(2)* Z2 p' R3 a3 U0 L
  1963.         point_y = $game_map.round_y(point_y + 1)
    ' P1 H) R8 N8 m! i8 [5 r  j
  1964.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps0 h! z+ I/ Q( @. r
  1965.         chase_path.push(8)
    7 P6 z7 a8 x8 s- A5 V* G
  1966.         point_y = $game_map.round_y(point_y - 1)* H2 ?: e6 U% _, [
  1967.       end9 {4 G) m7 k& h# L: N3 z( J' ]1 P
  1968.     end
    ! |2 ~" L7 Q, V& I
  1969.     end #endOfForLoop5 S, [: W8 o, {
  1970.     # 如果指定点无法抵达或者登陆4 L8 Q% I" \) g+ R& F1 t$ J9 ?
  1971.     return not_reach_point unless landable(@moveto_x, @moveto_y, chase_path)( u" O6 _. ?' A) F" V
  1972.     # 根据路径表格绘制最短移动路径(反向)
    0 \( |3 \. q: [# Q, T, }3 Z
  1973.     steps = step  2  2 + 1
    1 B0 D2 A3 V4 K. O
  1974.     loop_times = step  2
    ; ^/ f+ K# R. B6 \* P& ~; b
  1975.     point_x, point_y = reversed_chase_point[0], reversed_chase_point[1]
    * j( H8 S3 k. n3 |' i; W7 {
  1976.     for i in 1..loop_times # forLoop# D8 P% W3 g- ?0 D/ D4 f! i
  1977.     steps -= 2
    , I( o" A  r# x) e8 P. ~! ?9 o/ A& y/ S
  1978.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs+ f8 f( A" U! c% C
  1979.       if    sheet[$game_map.round_x(point_x - 1), point_y] == steps
    ) m5 A5 ^) R9 ]7 `9 G5 s3 G; Y0 [
  1980.         reversed_chase_path.push(6)
    * S# Y. y7 K0 c  _$ O
  1981.         point_x = $game_map.round_x(point_x - 1)
    $ [4 V( V2 }! x9 N5 U5 ~0 C
  1982.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps
    : ~5 C$ E. y( \- K) C
  1983.         reversed_chase_path.push(4)
    ( d0 }) W: p6 b% Y! R. f
  1984.         point_x = $game_map.round_x(point_x + 1)9 i/ C$ I$ L& e) m
  1985.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == steps
    . _% Y& T- _$ [7 {) K
  1986.         reversed_chase_path.push(8)5 [# ~3 Y  W0 C6 m4 R  t6 b5 Y
  1987.         point_y = $game_map.round_y(point_y + 1)# W' F: _! M8 t0 c7 ~
  1988.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps9 s0 k0 f! P9 j2 e
  1989.         reversed_chase_path.push(2)
    / ?9 D: a- j( \! g& R6 c! f4 W3 w
  1990.         point_y = $game_map.round_y(point_y - 1)
    + l% v. D: R# t6 t" `- j
  1991.       end
    # I% A8 y( B) S+ m
  1992.     else
    4 D9 \6 P, X6 g$ A& _8 U$ F
  1993.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == steps: E- L& G- F8 \! F9 P
  1994.         reversed_chase_path.push(8)6 W1 v5 m1 T# W+ k) S
  1995.         point_y = $game_map.round_y(point_y + 1)
    ' D9 A* {* u4 D* J1 s# ?! A
  1996.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == steps
    2 _+ F( f% a4 J( ?
  1997.         reversed_chase_path.push(2); w% R2 }- I  }
  1998.         point_y = $game_map.round_y(point_y - 1)
    0 e5 B& j! z0 @. m! C
  1999.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == steps
    $ x% A0 u  t) p6 G# G# Q
  2000.         reversed_chase_path.push(6)
    ( o1 j+ @  k/ f  [
  2001.         point_x = $game_map.round_x(point_x - 1)
    ; ?) \& @3 W* f
  2002.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == steps) }$ m! F7 }! h7 w* a; V
  2003.         reversed_chase_path.push(4)+ [' g7 U$ x' w4 c( _
  2004.         point_x = $game_map.round_x(point_x + 1)8 g6 Z. _; J4 N, `, e
  2005.       end7 p% X; U+ U4 z# S
  2006.     end1 F# ?; B6 H8 c9 A+ j
  2007.     end #endOfForLoop, \5 {# r2 E9 @
  2008.     @mouse_move_path = reversed_chase_path.reverse + chase_path; W: `! f! n; s5 A' C; y
  2009.   end#ship# v& c/ q1 M, f! u: `0 ^0 o+ ]
  2010.   #--------------------------------------------------------------------------0 {3 f3 l& [( F$ p( V7 J  r3 E6 ~  f
  2011.   # ● 绘制airship的移动路径 @array[move_directions...]
    7 s+ S; J+ _9 ]  u5 v
  2012.   #--------------------------------------------------------------------------
    & m# O; d3 I( Y
  2013.   def draw_air_path
    8 i( H3 R+ O2 Z4 s) m
  2014.     $mouse_move_sign.transparent = false: y4 e  r" Z8 K& R! a; Z# D. o- M5 I
  2015.     # 准备绘制路径表格
    $ w" H+ y) |1 x  X# Y
  2016.     sheet = Table.new($game_map.width, $game_map.height), n8 ?, H- j) }7 ~0 G+ v6 ~/ j
  2017.     new_check_point = [x, y]; sheet[x, y] = 1
    # l- ~. O2 M. e/ f5 H* H; G
  2018.     reach_point = false;      step = 2
    8 }6 h( c8 Z8 U8 i: t3 K6 V+ K& z
  2019.     loop do #loop1
    ) N8 x! R+ V7 s0 }
  2020.      check_point = new_check_point
    - k) v( G' k( o  x& F* H) \8 d
  2021.      new_check_point = []4 C8 h2 l- }0 e8 H; C# k
  2022.       loop do #loop2
    + N! a+ [( D+ l0 c  ^
  2023.         point_x = check_point.shift& n, k, ]# P9 k
  2024.         break if point_x == nil
    0 H8 {* C) G- S4 L7 j* o
  2025.         point_y = check_point.shift1 T; N3 ~2 O% C/ k  P9 T. `
  2026.         if point_x == @moveto_x && point_y == @moveto_y  H- _& ^& v, x0 w; X0 M
  2027.           reach_point = true; break# m3 e5 d" V3 {% \- y2 ~
  2028.         end
    0 O" v' @! {0 o
  2029.         left_x  = $game_map.round_x(point_x - 1)
    6 U6 n; z4 L8 G6 x
  2030.         right_x = $game_map.round_x(point_x + 1)% J& U8 l4 ~5 w- C9 l6 |3 N
  2031.         up_y    = $game_map.round_y(point_y - 1)
    ; l  x5 T, Z4 J2 b" |
  2032.         down_y  = $game_map.round_y(point_y + 1)
    5 o5 w; O: @; U5 @
  2033.         # 以需要抵达该点的步数填充路径表格 #; v. o! F. Z" x9 y( d
  2034.         if sheet[left_x, point_y] == 0
    . S+ Q7 \% [* ^# C6 `) d/ e1 A
  2035.           sheet[left_x, point_y] = step6 K) a2 i3 r9 `5 h# e$ O* L: H
  2036.           new_check_point.push(left_x, point_y)
    # l& n6 R/ v: U9 g9 z7 m& Z
  2037.         end
    4 R4 A) M# F. A; {
  2038.         if sheet[right_x, point_y] == 0  j& d" |# X& m3 y
  2039.           sheet[right_x, point_y] = step
    9 ^, C/ }' m4 }6 j) I
  2040.           new_check_point.push(right_x, point_y)5 y7 d5 Z: V& `
  2041.         end
    + @+ q% _: o9 k1 @( R
  2042.         if sheet[point_x, up_y] == 0
    ! J6 ^9 Z1 v/ u: D. \
  2043.           sheet[point_x, up_y] = step# r5 X& W0 ]- e) J
  2044.           new_check_point.push(point_x, up_y)
    7 U" ~4 \, G0 L6 a
  2045.         end9 o% P2 d7 e8 n, A% }0 o4 o* o
  2046.         if sheet[point_x, down_y] == 0" W; Z) q& N: d+ N2 K
  2047.           sheet[point_x, down_y] = step6 |$ }3 ?0 W) s; \& a
  2048.           new_check_point.push(point_x, down_y)
    . t* Q2 J) ]; i6 Q8 @* `3 x9 f
  2049.         end
    . K- [8 P' l2 Y3 s, v
  2050.       end#endOfLoop2, ~7 R, O) [5 f9 m
  2051.       break if reach_point
    2 n6 t& X4 U+ v2 w
  2052.       step += 1
    . h5 ]+ A6 K: w6 C2 `7 K& I. M6 F
  2053.     end #endOfLoop1. l2 n7 r( P8 I/ O9 x7 S/ _
  2054.     # 根据路径表格绘制最短移动路径 #6 U; x/ ]/ Y% D8 M8 z
  2055.     reversed_chase_path = []; step -= 1+ i& N. o9 k; E- g, U; [- S
  2056.     point_x, point_y = @moveto_x, @moveto_y6 \( O% \9 y+ Y+ i
  2057.     for i in 2..step
    ) _. V) T) p" b
  2058.     step -= 1+ {- h/ b  Z' J
  2059.     if (@moveto_x - point_x).abs  (@moveto_y - point_y).abs
    4 A& K8 a0 e/ l: n
  2060.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
    ( Z% G- l/ w$ ?0 F1 q& I- B
  2061.         reversed_chase_path.push(6)
    " K: P# H8 v' U$ k# T$ e( j
  2062.         point_x = $game_map.round_x(point_x - 1)" |( a1 x" o9 h$ Y& @5 A
  2063.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step0 N2 T. D6 O. ]8 J
  2064.         reversed_chase_path.push(4)7 v8 J/ }, h5 s- K
  2065.         point_x = $game_map.round_x(point_x + 1)
    / _1 ?% @4 E, v- ^
  2066.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
    " ]8 o" ?& L2 Q9 }0 Y7 M
  2067.         reversed_chase_path.push(8)
    ! @: j' \# e9 e0 q3 h
  2068.         point_y = $game_map.round_y(point_y + 1)
    . z2 |$ s/ s9 ?" F
  2069.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
    + g: _, I' s% [' t9 d' I8 _/ ^
  2070.         reversed_chase_path.push(2)  Y" X7 L; K+ K+ R" \' l
  2071.         point_y = $game_map.round_y(point_y - 1)
    1 e; X# r4 L' O) L9 d
  2072.       end
    $ @7 q; y! D. ?# y% i. l! {$ o3 S
  2073.     else
    # G  y: J- [% v+ _) M1 e
  2074.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step
      M) K8 R# z4 `9 F
  2075.         reversed_chase_path.push(8)
    / V" G! @$ v/ [8 J' ~) K
  2076.         point_y = $game_map.round_y(point_y + 1)8 U! Z/ ^5 [5 g7 f& u- T0 K* q* z
  2077.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
    ! T8 w: u5 t! z% a( n
  2078.         reversed_chase_path.push(2)
    1 a& U  \! W; p* |3 ]4 N" }/ |
  2079.         point_y = $game_map.round_y(point_y - 1)
    ; |* Z! x0 d' S& b
  2080.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step- k& V( k( c' b& L
  2081.         reversed_chase_path.push(6)
    2 W3 I) g2 Y5 o: T6 |
  2082.         point_x = $game_map.round_x(point_x - 1)
    # I7 |% d6 s" Q* T+ N- P" ^+ \
  2083.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step. u( n4 k4 K/ y: k' o/ Q
  2084.         reversed_chase_path.push(4)
    , Q7 A) E( D! |0 M8 [6 y
  2085.         point_x = $game_map.round_x(point_x + 1)# h& c. _0 s7 W- h0 \8 q, z
  2086.       end
    2 ~& x' c0 u, Y( n
  2087.     end% x7 }( |9 K$ w9 B; }; k5 F6 @5 G( [8 n
  2088.     end #endOfForLoop % K8 r: y' O+ b( K" O9 H
  2089.     @mouse_move_path = reversed_chase_path.reverse
      A8 K0 `  u- F% E
  2090.   end#airship
    + c0 g6 M4 _8 r4 F
  2091.   #--------------------------------------------------------------------------2 t/ _( N1 w1 O: G" M
  2092.   # ● 目标点无法抵达时的处理,用于各路径绘制方法内部7 }# I2 `: j3 @0 o3 W% C
  2093.   #--------------------------------------------------------------------------1 X) Q- t1 P8 k9 I6 ?2 V% k0 A
  2094.   def not_reach_point. {+ c& E5 N! J4 ^' W
  2095.     $mouse_move_sign.direction = 4
    % X9 j5 f- _) ~, e8 k) ]5 Z' s
  2096.     dx = 0; dy = 0; dir = 0
    ( p' b0 H- {; ?5 }, A( |
  2097.     if @moveto_x - x  0# p, q: }: M  E8 I8 n
  2098.       if @moveto_x - x  $game_map.width - @moveto_x + x &&( d; C& X% g  \& h' q
  2099.           $game_map.loop_vertical
    3 [7 \; Z  Z8 X4 k0 {% y
  2100.         dx = $game_map.width - @moveto_x + x; dir = 4$ W  X1 a  b% {4 S- d  \" n: E, O
  2101.       else, g* a+ a% X; n4 w$ F+ W
  2102.         dx = @moveto_x - x; dir = 62 z& O( r6 C0 X& U  r/ s
  2103.       end2 a5 j) K9 ^  K0 V4 w1 K
  2104.     else' R1 D; k1 U4 A
  2105.       if x - @moveto_x  $game_map.width - x + @moveto_x &&
    - n8 x% ]! r+ i& m
  2106.           $game_map.loop_vertical' t* f7 l  ~9 n) `. o( ^- v
  2107.         dx = $game_map.width - x + @moveto_x; dir = 6$ J* j, ]0 y, S9 Q3 V; _
  2108.       else
    & R, p# i( X: x1 b5 y+ J
  2109.         dx = x - @moveto_x; dir = 4: q( G! E- G6 O
  2110.       end5 A6 t8 Q4 S* Y/ E! ?
  2111.     end
    3 _6 s3 f3 \9 X, V. f; T
  2112.     if @moveto_y - y  0
    $ ]8 B& U! O% j5 @, d
  2113.       if @moveto_y - y  $game_map.height - @moveto_y + y &&
    7 J8 U9 F$ T( L0 O1 r
  2114.           $game_map.loop_horizontal& e) C3 b  W, ^0 j) c; f$ Y2 o
  2115.         dy = $game_map.height - @moveto_y + y
    - \; g3 h2 L# [" }- d1 k7 N. c
  2116.         dir = 8 if dy  dx
    * ~5 h* I9 W+ N6 r# w
  2117.       else
    ( y1 l$ ^. R2 Y3 b, V9 e+ k
  2118.         dy = @moveto_y - y( `3 o# D( s2 W: m
  2119.         dir = 2 if dy  dx: I" U. h6 }# J" c, A. Y
  2120.       end- k! q2 [( ^7 ?# o3 D
  2121.     else8 \  O, e' F' Z( ^
  2122.       if y - @moveto_y  $game_map.height - y + @moveto_y &&. g: l2 y* ~: P
  2123.           $game_map.loop_horizontal6 n5 f! v: B7 n7 o8 x
  2124.         dy = $game_map.height - y + @moveto_y
      K  e: x* Y+ [9 a6 O
  2125.         dir = 2 if dy  dx ) g; v5 B) k; h9 x# L
  2126.       else
    ; a: {/ ?4 @  d, W) x" s% j  _4 G
  2127.         dy = y - @moveto_y4 ^* c# W" N1 G; B" H; d7 R
  2128.         dir = 8 if dy  dx8 g$ J8 q' ^; U6 p) L! i8 h% r: N
  2129.       end! \+ B4 d, m  d5 l
  2130.     end+ P! U* q; e% K: M8 W
  2131.     @mouse_move_path = [dir, 0] # 0方向用于防止移动过程中触发事件1 {0 `3 \+ P- \3 b3 M  z( L& X
  2132.   end
    " |& X  T; p- V5 X
  2133.   #--------------------------------------------------------------------------0 c3 K0 [+ ]1 y$ N3 m4 u0 U& \, O
  2134.   # ● 判断目标点是否能抵达、登陆,用于船只路径绘制: ]# P  v9 G: r6 T2 N
  2135.   #--------------------------------------------------------------------------
    9 m( z: v1 ~0 U/ J. {% ~# U. ?( J
  2136.   def landable(x, y, path)1 I; ?- O- u. b! Y3 O; D
  2137.     case @vehicle_type! [- K  f$ B/ ?& r; d
  2138.       when ship; return $game_map.ship_passable(x, y)
    " g1 |- W6 n+ z3 G
  2139.         $game_map.passable(x, y, 10 - path[-1])
      B$ N' s; D( Q! p
  2140.       when boat; return $game_map.boat_passable(x, y)
    4 s" e" ?4 R5 J& |4 O$ T
  2141.         $game_map.passable(x, y, 10 - path[-1])
    " u$ A' s+ z  N2 A* R3 m9 Y
  2142.     end
    . d5 p! E$ q1 E; I9 T; r" j+ b
  2143.   end
    4 K4 {2 s* G, ^% D, `
  2144. end) n0 D- o) m) c% u7 z) D# N

  2145. $ N4 f/ q/ x* B8 Y7 M6 `
  2146. #==============================================================================
    9 J, G3 b7 y6 G8 J( ^8 r+ U
  2147. # ■ Game_Map' `2 t( q. {7 E, e4 G& ?  f* d
  2148. #------------------------------------------------------------------------------% H) J' x! s- a  e+ h! k# _) f
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。) l% Y2 s8 `1 t4 Y6 U0 W7 r
  2150. #   本类的实例请参考 $game_map 。
    2 A9 U6 L7 p% K1 r
  2151. #==============================================================================% o+ V# m! r5 Y' i+ U; w
  2152. class Game_Map8 m4 B5 `# |- a1 h3 `; O
  2153.   #--------------------------------------------------------------------------* z" Q* N4 `) I# C2 |. k
  2154.   # ● 定义实例变量# B1 B2 J# X' L6 Z$ Q) U
  2155.   #--------------------------------------------------------------------------
    9 U' Q! G6 d& o0 E
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据! e/ B6 C# k! x$ ^4 A; J- i
  2157.   attr_reader mouse_map_y # 同上. r: a$ o; ]2 ~1 ~; b6 w- s. @
  2158.   #--------------------------------------------------------------------------
    + N! D- K5 Y# |, h6 |" \: U4 `
  2159.   # ● 初始化对象9 N) @! x: X* g4 l7 y
  2160.   #--------------------------------------------------------------------------
    ! u5 S/ C# D5 v1 U6 P; X
  2161.   alias sion_mouse_initialize initialize
    , I0 D8 ?) Q: S2 r$ g1 v+ w; Y
  2162.   def initialize
    3 {/ |% e. F' L) c# c6 w" Z
  2163.     sion_mouse_initialize
    ) d, q; k& K- `, X  d% z
  2164.     creat_move_sign  ###5 d  u9 x7 u$ i9 l) W  O
  2165.     set_constants
    / w8 J) m+ q' K  f
  2166.   end
    + f% F# w" \9 ^% G" o
  2167.   #--------------------------------------------------------------------------
    " q/ K# }+ n0 {4 S* D$ k
  2168.   # ● 更新画面) O& p. L2 N  l* J! V4 z
  2169.   #     main  事件解释器更新的标志5 m1 U$ c/ H6 \/ S+ ?, L3 {
  2170.   #--------------------------------------------------------------------------) t* C! T6 l* S3 {8 p$ W/ Z
  2171.   alias sion_mouse_update update
    7 P; j, d/ r. |4 _: ]- k
  2172.   def update(main = false)3 O' p, X0 l0 a4 P5 b
  2173.     sion_mouse_update(main)
    8 X# E6 H: Z+ H5 t* U. D/ a
  2174.     update_move_sign0 w, E( @4 E3 V$ k8 g1 M1 |
  2175.   end+ R7 G3 |; g& S) A+ t3 v
  2176.   #--------------------------------------------------------------------------' M8 E( u* P- b3 N
  2177.   # ● 创建显示路径点的事件
    # ]1 K, ^- p% Q; s' w
  2178.   #--------------------------------------------------------------------------
    # H& i% ~( P  L. h6 o6 x
  2179.   def creat_move_sign
    1 q7 d7 |! Z9 [) _; L- m
  2180.     $mouse_move_sign = Move_Sign.new
    3 N3 Z% W! f/ u; a# `. _) e) X
  2181.   end# M: v8 |, S- l. \9 b
  2182.   #--------------------------------------------------------------------------
    2 h* Y, f7 i! E* s0 S9 }1 g4 Q
  2183.   # ● 更新显示路径点的事件
    $ ^4 z  q6 @: d  ?( S
  2184.   #--------------------------------------------------------------------------
    & _# q9 `3 ~2 V$ g
  2185.   def set_constants
    - ~1 o. z2 B! w$ x! ?5 ^6 G' b
  2186.     @mouse_pos_setted = true; `! a+ J8 `9 @
  2187.     @set_pos_prepared = false% D2 Y; Y$ }1 N5 p
  2188.     @mouse_old_x = 06 O' Q0 O0 B/ a: |% y8 a
  2189.     @mouse_old_y = 04 ^3 o* ~3 M; y- ~4 p* b# F  A
  2190.   end
    . \; |( t6 p. B& z9 Q2 t$ i
  2191.   #--------------------------------------------------------------------------0 f0 Q" x5 y# h0 g# Z5 C" b$ S0 ]
  2192.   # ● 更新显示路径点的事件# o% V/ ~4 [' P4 s* v' N* h. y
  2193.   #--------------------------------------------------------------------------+ c1 ?2 F. u$ C! y7 _# c
  2194.   def update_move_sign
    & |* C3 |4 k: L
  2195.     $mouse_move_sign.update
    2 T9 g* b% l/ J% ~, X/ R
  2196.   end
    - G: ^* X( S$ \
  2197.   #--------------------------------------------------------------------------7 y9 f! l5 S/ W- y9 V/ N7 ^
  2198.   # ● 获取鼠标位于的地图块的x、y坐标% f! ~/ f! R0 h& ^( b
  2199.   #--------------------------------------------------------------------------
    8 [& u; D7 l- m$ `1 }& Y; F0 g2 l
  2200.   def get_mouse_map_xy
    6 D9 V3 [" I" F% t; R9 Q7 u! q
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y7 B+ u0 L" Y$ f, ^/ i# q. d
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)1 o7 t6 e: l8 {( G; ^2 Y, \
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    0 @( H. F* r# ]
  2204.   end  |! k  J$ J7 s
  2205.   #--------------------------------------------------------------------------
    : D/ q5 y9 s& p. T4 T, d/ K! [4 A
  2206.   # ● 返回地图画面时重设鼠标坐标
    4 j: e- s; Z2 _
  2207.   #--------------------------------------------------------------------------  i2 P( S2 A/ B. F
  2208.   def reset_mouse_pos) ^8 Q, E/ _4 f- a6 n& A2 {
  2209.     return if @mouse_pos_setted7 u9 u' s. ^& O  C2 {
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)# E' D" a1 H/ L: `# t0 b
  2211.     @mouse_pos_setted = true
    5 G  \+ |# {8 Q6 m: }5 I. x, D' ~
  2212.     @set_pos_prepared = false% z0 Q+ q" d! t* N' s
  2213.   end
      m2 A: d! u) v* j; A/ b* [8 h
  2214.   #--------------------------------------------------------------------------/ {0 G. ]1 ?4 K: S) {1 m
  2215.   # ● 重设鼠标的坐标
    3 g9 p- \# Y/ b# Q
  2216.   #--------------------------------------------------------------------------
    / ?: o( u* z( L
  2217.   def prepare_reset_mouse_pos
    $ W  |9 n+ n! w# l3 o
  2218.     return if @set_pos_prepared
    8 o" I5 k+ n! z& L' R9 [5 c
  2219.     @mouse_pos_setted = false7 _3 T* _+ Q3 o5 N
  2220.     @mouse_old_x = Mouse.mouse_x
    . b* o2 d0 [% D! y# O. m8 M
  2221.     @mouse_old_y = Mouse.mouse_y
    + J& |- m8 i4 N( [& \( l" Z0 S' u
  2222.     @set_pos_prepared = true, b* |; {! s' Y, D
  2223.   end! I# I( D* G( E. m7 c# N- Y$ v( ]) \7 g
  2224. end
    1 k% q6 g" E/ C2 W- R3 R
  2225. / e  N# [, Z: y7 h: m
  2226. #==============================================================================1 a2 e) J% t4 v  [0 Z5 @
  2227. # ■ Spriteset_Map  i4 Z8 L9 w) ~7 g
  2228. #------------------------------------------------------------------------------
    3 P3 w0 n/ b+ ?
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    3 j( `0 `) }5 ?: r5 U
  2230. #==============================================================================
    . ?, y9 Y$ Q: \' k( ^% a4 S
  2231. class Spriteset_Map
    . w+ B; v4 j* i1 n
  2232.   #--------------------------------------------------------------------------
    / S9 _6 D1 ^' X0 A# j1 h# {
  2233.   # ● 生成路径点精灵" h+ y! A4 j' K& z
  2234.   #--------------------------------------------------------------------------
    4 w0 t, M0 m/ }
  2235.   alias sion_mouse_create_characters create_characters) C, h' P3 _/ ~( o
  2236.   def create_characters
    - n% u; z; Y2 l$ }! N! J2 q
  2237.     sion_mouse_create_characters( b" T# S' \4 ^2 \
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    / F9 u6 F' ?8 N6 u8 h; V, }
  2239.   end
    ! M, x. _+ S4 w" p+ R: \# @
  2240. end+ v+ Q; B+ m& c& O5 ^  @
  2241. 1 U- @! B* o& i4 l7 d* O* P
  2242. #==============================================================================2 e& f# y5 o: [. I. Z8 C
  2243. # ■ Scene_Map% J; t4 k1 G- D  |2 r& D; ]- i
  2244. #------------------------------------------------------------------------------, Y! f3 |0 s$ B. E; m
  2245. #  地图画面
      {0 Q4 r. ]: h1 W3 h( R, Q0 R
  2246. #==============================================================================
    ) ?# U# Y5 I9 `4 L# |. [
  2247. class Scene_Map  Scene_Base
    ) n" h0 U) c# A/ c
  2248.   #--------------------------------------------------------------------------
    0 P. K" q( w( ]; N% c
  2249.   # ● 画面更新
    # k0 L# }$ _6 y3 K: H( b" ^6 [2 z
  2250.   #--------------------------------------------------------------------------' N9 u! u. a3 B# ^  U
  2251.   alias sion_mouse_update_scene update_scene) b- Y7 E& h& z0 ^* R0 Q) y
  2252.   def update_scene# j3 \5 @- ~7 f" Y+ l& \2 T, G" S, E& f
  2253.     sion_mouse_update_scene) P! C; R& l! `; X
  2254.     update_mouse_action unless scene_changing4 [+ B3 v$ S7 B1 S$ w
  2255.   end
    7 D* h' [2 Y; z( G2 U8 h0 b
  2256.   #--------------------------------------------------------------------------
    % o5 o8 B# z2 N( G
  2257.   # ● 场所移动前的处理, p0 a3 G, O8 W, |( R0 H
  2258.   #--------------------------------------------------------------------------
    5 p5 V6 {. Z: n; r
  2259.   alias sion_mouse_pre_transfer pre_transfer
    , M+ I+ r+ v2 E, K5 H, n
  2260.   def pre_transfer
    & q( r/ w- Q9 ^
  2261.     $game_player.reset_move_path
    " N8 q# g: R" A3 s+ K
  2262.     sion_mouse_pre_transfer
    # M) E* |! X5 c* Y
  2263.   end9 g% T& J, b- \- n* ~
  2264.   #--------------------------------------------------------------------------
    1 ?& s7 S8 q+ w2 A. V
  2265.   # ● 监听鼠标左键的按下8 ^4 j# D) h* K  a4 w& \9 P
  2266.   #--------------------------------------------------------------------------
    . `0 E0 T# j- e  j# M+ |
  2267.   def update_mouse_action1 R3 W( l3 l  w# n
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    7 L8 K- P- `& l0 ]+ M. O/ {
  2269.   end
    ; k/ N6 _0 M8 N& S
  2270. end' p/ P" g& ]# y2 t

  2271. 4 I" k" {" ?1 h' t0 ~/ h6 j  `
  2272. #==============================================================================
    , N( j% g/ u& W
  2273. # ■ Scene_File9 K9 _/ @6 I; ^0 x6 T" g: a
  2274. #------------------------------------------------------------------------------+ u; Q( `% H* m
  2275. #  存档画面和读档画面共同的父类2 y7 E) D) O/ B. N1 {( ]
  2276. #==============================================================================
      m4 }5 `$ |# ^+ A6 B$ B; n% _
  2277. class Scene_File  Scene_MenuBase( ?: n# E- K# }
  2278.   #--------------------------------------------------------------------------+ O! |& L! @+ d: U, d& a  U
  2279.   # ● 开始处理
    ! j7 [* G0 b9 G0 Z8 c9 i
  2280.   #--------------------------------------------------------------------------) S6 `- M$ @' X! ^5 U7 p: H
  2281.   alias sion_mouse_start start
    5 v, t& G+ P* ?/ T
  2282.   def start  _; H2 y" z9 \1 N
  2283.     sion_mouse_start
    & P- d4 }; e1 S' V: u0 L. p
  2284.     @move_state = 0- w' w+ [9 {2 {. N& }
  2285.     set_mouse_pos
    0 Z2 N7 u, e, A4 t8 D: l& u
  2286.   end, j% ?: G% n3 k, c( I
  2287.   #--------------------------------------------------------------------------9 {8 X7 y# t; s2 `
  2288.   # ● 更新画面8 S4 v% g4 R. x& s* C
  2289.   #--------------------------------------------------------------------------- F  s: q" `, P# f
  2290.   alias sion_mouse_update update) `0 G0 `# [' G
  2291.   def update
    : V& R, I# E+ e; j3 h
  2292.     sion_mouse_update  J% m2 ?) `' N6 x
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos* J. X  ^9 @2 r+ I2 p# ~* u
  2294.   end$ g/ Z- T9 _% A! a
  2295.   #--------------------------------------------------------------------------
    : c$ b9 u( n' ?; v( z
  2296.   # ● 更新光标4 i. w5 l: @3 U  w9 d# C- i! V
  2297.   #--------------------------------------------------------------------------
    # O2 Q  G8 y4 H
  2298.   def set_cursor# g. V; n8 r6 b! ]# f; N
  2299.     @move_state += 1
    7 R6 E& X- ~0 y! W2 Y' b7 K
  2300.     last_index = @index  ~* A7 K+ @# [5 \; g$ \/ k
  2301.     if mouse_which_window == -2+ h) I* t) \) M; O
  2302.       if (@move_state - 1) % 6 == 09 G5 S% r: l. {/ S
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    4 S5 p6 J5 e4 P' x% Q3 j, _1 b
  2304.       end
    $ p1 |. j/ C5 S: j
  2305.     elsif mouse_which_window == -1
    7 \8 o+ N5 s0 Z
  2306.       if (@move_state - 1) % 6 == 0
    : b# b4 `- D( F. d# [$ i1 Q. m6 x$ @7 E
  2307.         @index = (@index - 1 + item_max) % item_max if @index  06 K5 T0 ]( |* Y3 e
  2308.       end. K. s" \; x* B  D9 u; q
  2309.     else( {5 }" i( M" S/ D
  2310.       @move_state = 0; K* R8 a. S- z! _; J6 W+ u
  2311.       @index = top_index + mouse_which_window5 m0 R7 u4 r" A+ i, |7 }, {
  2312.     end+ j( ]( \5 t& U; z5 }
  2313.     ensure_cursor_visible
    " |! }/ J/ N; E
  2314.     if @index != last_index
    ! }. e; {& z4 ]6 A0 y9 ~
  2315.       @savefile_windows[last_index].selected = false
      m- D3 `" U* ]) x" h
  2316.       @savefile_windows[@index].selected = true' o1 d% G$ T! S2 i+ R
  2317.     end
    2 C; g- ?8 |4 W! C, d0 J
  2318.   end6 c% t3 N2 z' a: g" Y0 ~0 a
  2319.   #--------------------------------------------------------------------------
    5 D2 X8 n5 W) P
  2320.   # ● 判断鼠标位于哪个窗口
    % S' x& h* t; f) Y+ u) E$ r
  2321.   #--------------------------------------------------------------------------. I! x3 t$ z, b) b
  2322.   def mouse_which_window
    ' {+ g; u& c1 H( [: E0 m
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y' l/ _0 ^" Y* c
  2324.     if mouse_y  @help_window.height + 14. u$ k9 i/ b# f( J0 a
  2325.       mouse_row = -1
    # R9 z% R9 b8 z9 n* \
  2326.     elsif mouse_y  Graphics.height - 14- e- A  ^5 `" u& s8 d( d" U' Q; O
  2327.       mouse_row = -2
    0 I, {9 ], O: ^9 _6 F- m9 h
  2328.     else* x2 N, i% H0 {3 \5 y; h
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 4 S6 C+ ~. ]- Y9 s/ x1 \
  2330.         (Graphics.height - @help_window.height). m- W9 a% U; A( I8 w, V7 e
  2331.     end
    2 M; c( V* n$ y0 z  A$ k5 c
  2332.     return mouse_row: c1 B/ l+ T7 w. a1 O" w" d
  2333.   end
    , a, q9 e6 E- Q2 B
  2334.   #--------------------------------------------------------------------------
      u* o7 _$ R- s0 s) O
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    : w2 K  {0 Q; f1 A) M
  2336.   #--------------------------------------------------------------------------
    * ^. L% X+ _0 b9 \1 W
  2337.   def set_mouse_pos
    - p$ r2 @7 Y3 M8 k, B3 L- \
  2338.     new_x = 40
    8 I, m2 Q* _) d
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 249 F5 f0 [6 r$ ~7 N8 A0 _
  2340.     Mouse.set_mouse_pos(new_x, new_y)( g- ~3 C/ k+ B, Z
  2341.   end2 m5 E; i# q9 i* i' G. Y- w! |
  2342. end* |5 j  K. V* L2 s
  2343. 9 q* z% E# K( b; s! G( u  Y
  2344. #==============================================================================( U3 |: J% D$ z- O+ C* b: Q
  2345. # ■ Game_Event
    / }5 P8 @" Y3 M) {
  2346. #------------------------------------------------------------------------------" L. O, x' u- P- v0 O3 i# X6 z! L
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    ! v- p0 s( l* ^: H; `4 s. R9 F
  2348. #   在 Game_Map 类的内部使用。) b7 A  W$ K7 V9 x
  2349. #==============================================================================
    ) ]+ @5 [0 T) m& _5 A- n
  2350. class Game_Event  Game_Character% \- |/ [5 S8 ~8 K7 L* ]8 N7 L0 w
  2351.   #--------------------------------------------------------------------------0 S  i, o0 s9 ?
  2352.   # ● 事件启动
    5 f4 D3 x. f- s# Y' u8 v$ y( y$ t
  2353.   #--------------------------------------------------------------------------5 ?4 n1 \' R) p9 z* D
  2354.   alias sion_mouse_start start3 o% {% b. G4 c. J" c7 g; m$ q  ^
  2355.   def start
    , v/ i6 B! p% ^8 l* S& ]- p- {2 j
  2356.     return if mouse_start && !Mouse.press(0x01)
    3 E( }% i+ R  [( Y
  2357.     sion_mouse_start
    ! ~% c8 Z& e- u- T; i) D
  2358.   end& Q+ V1 Y$ {- U) R
  2359.   #--------------------------------------------------------------------------. l0 S: L7 K7 b4 \3 L
  2360.   # ● 判断事件是否由鼠标启动* X; y# S- o! y" g. }( l3 m% }
  2361.   #--------------------------------------------------------------------------
    : i' Q1 ?3 A; W# L4 V2 `
  2362.   def mouse_start
    5 F6 B& o, R6 \8 w% t0 i$ ^( ]) N
  2363.     return false if empty/ C# h+ k  S# h! c2 F( S0 z
  2364.     @list.each do index  X8 B; O0 o$ n2 O. p! C
  2365.       return true if (index.code == 108  index.code == 408) &&
    9 b- }( L6 ]: ~0 S' n8 |
  2366.         index.parameters[0].include('鼠标启动')8 U# O4 j- v! Z9 J5 j% I+ Y
  2367.     end
    1 v- U+ [/ }$ M; d# @) U1 V/ G
  2368.     return false+ A4 ~! F! i' d) \
  2369.   end! P( E( i+ i" f! S8 W
  2370. end
    2 x# S  J4 \. E( w
  2371. $ y0 A* G3 L6 G
  2372. ####泥煤的height, o! b2 I2 D, Y5 |
  2373. # @height = height* E5 G, M- Q6 [) D& @
  2374. 8 [) R6 Y9 @, [
  2375. class Area_Response9 [5 n9 l0 C" Q- W; s' Z
  2376.   attr_accessor type
    . ]' d/ c9 _* e! G4 n
  2377.   attr_reader ox% r# c' j. k! L
  2378.   attr_reader oy: r3 w/ g* q5 j& S- f
  2379.   attr_reader width
    2 N* F7 ?9 r4 O5 ?$ ~. }1 C9 }
  2380.   attr_reader height
    : N- j0 P! N( z) E1 W; x/ ]1 T
  2381.   attr_reader switch_id
    , E. g! A7 L# r3 G1 z
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    " H( f0 w8 ^+ g4 \- h9 q/ |- M
  2383.     @type = type
    . y, m/ H* ]7 u
  2384.     @ox = ox
    3 H# b" V* C7 ], K' i
  2385.     @oy = oy4 A& Z) N) J( F# H: J8 B; J
  2386.     @width = width
    * W) u6 |! m6 L7 ?* p4 r" k
  2387.     @height = height
    4 K1 g6 s$ A$ W2 |  f
  2388.     @switch_id = switch_id& T, V8 B) I5 B% a, A* M4 {( T
  2389.   end3 ?8 k3 e" t( F
  2390. end
    4 F" q* p7 m8 p. \9 y! M
  2391. 2 ]) w& y+ L& w- L2 K( ~4 t$ J' p
  2392. $area_responses = []3 m" l8 n( P- V# h" L

  2393. 9 m( ]6 G( y/ `, w6 z
  2394. class Scene_Map
    ! N7 n$ z# C# H( U2 f
  2395.   alias update_mouse_2013421 update_mouse_action% G  j$ @# n6 u) O
  2396.   def update_mouse_action( Y: h4 j9 `' v0 K9 X2 C
  2397.     update_area_response
    ! T1 X" J  m& Q0 j
  2398.     update_mouse_2013421, S* p6 x. o2 V- Y
  2399.   end
    " Q5 h$ @, N' m# o& U! z+ X
  2400.   def update_area_response
    , [1 p& j: p( I9 S9 Z
  2401.     responses = $area_responses
    " E2 x% W) {% k: T: j( Z
  2402.     responses.each {response
    0 w& {) A# Q! [$ F4 B1 Q! k
  2403.       ox = response.ox
    ( s/ D  ]* N+ Z* x& X5 I7 ^
  2404.       oy = response.oy
    $ T( T6 A0 L% p2 p; s
  2405.       width = response.width0 |$ S- z. Q1 G) ]0 t0 y
  2406.       height = response.height$ _1 B* }7 L% R3 A# r
  2407.       switch_id = response.switch_id
    4 \/ j6 O) _; ]- l# O, v
  2408.       case response.type4 n* M1 p$ K4 p" W* u/ W
  2409.       when 0! I& q! E6 w1 e; Z' i5 O. [
  2410.         if mouse_in_area(ox, oy, width, height)
    + N" @, d! }) j- @( C7 g" V
  2411.           $game_switches[switch_id] = true
    , x7 L7 K$ ~5 b
  2412.           $area_responses.delete(response)( m, \% R; H& n. o
  2413.         end
    ; ~, n, N- o/ q: A$ l8 j+ o& g
  2414.       when 1
    ( Y& D! O. F/ ]" {' g: W
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)* I4 E9 s( w  N
  2416.           $game_switches[switch_id] = true
    ; Z& F: r/ R8 Y  d* e
  2417.           $area_responses.delete(response)
    8 r: A) R" c+ T. B# O
  2418.         end/ q) T6 f, W; ]" ^1 s6 j
  2419.       when 2
    9 v" w" n9 X! k. e! \6 g" Q: v
  2420.         if mouse_in_area(ox, oy, width, height)+ r: {" ~; i) R+ B
  2421.           $game_switches[switch_id] = true
    7 c: L8 V' |4 x
  2422.         else
    1 d$ h8 I, m- M, u6 X$ W9 b0 ?
  2423.           $game_switches[switch_id] = false
    2 Q6 t( s4 s' }* r& [( d
  2424.         end
    9 T; r4 j- b6 G4 D
  2425.       when 3- m8 w4 Q! T& M: s4 \, {
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,9 O# p1 Q: M6 H, m  w& s+ V
  2427.             (oy - $game_map.display_y)  32, width, height): l) H+ O8 C* ~+ e7 ^3 G* c: e
  2428.           $game_map.events_xy(ox, oy).each {event# V2 ?: q0 t* f% p' ~
  2429.           event.start/ F% e% n6 s: H  p6 J
  2430.           $area_responses.delete(response)0 c9 n# ~( e2 x- T
  2431.           return0 E1 r" Q7 o, H/ @. |
  2432.           } 6 Z$ l: N; m1 d
  2433.         end& U; L2 h1 m9 O5 M( x
  2434.       when 4
    * t+ K9 J) P/ g) f" [4 j
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,
    # @* k* F, _. x
  2436.             (oy - $game_map.display_y)  32, width, height)
    4 C& `* i3 S, V5 P
  2437.           $game_map.events_xy(ox, oy).each {event. o, K( P0 n4 X# z7 P/ p0 G7 r. E
  2438.             event.start: l6 w7 V, j/ y+ G4 \- p8 q
  2439.             return$ X& D5 c* M+ q* g; H
  2440.           } 5 X. ~, d) P9 [
  2441.         end
    7 \/ P# @5 @" @. S6 Z
  2442.       end
    . S1 R2 C* P4 W4 y
  2443.     }7 q. x' G. y& K% X' x
  2444.   end$ I. I( M8 o0 R& C6 p8 I5 y* v$ }
  2445.   def mouse_in_area(ox, oy, width, height)
    % Z8 v- J! \9 j; q
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    2 T% w0 g5 x$ ]! ]) ?
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height) @& Y1 ^, t( T  t+ Z
  2448.   end% h$ g) J1 _4 _( H1 O$ R" [3 q
  2449. end
    2 ]9 r' e& k, {% y6 C+ ]
  2450. class Game_Interpreter
    9 T7 f+ r$ e; h" X: S) H
  2451.   def area_response(arg)2 L! Q, i5 B3 U; p
  2452.     $area_responses.push(Area_Response.new(arg))! x7 D, n; d: Q1 L# Z
  2453.   end
    - M, Y# N7 [6 O; L7 Y
  2454. end
    3 e9 g9 y0 d; i. v% M  j
复制代码

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-13 12:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表