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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    2 ~0 i3 Y+ W4 j; v' Y1 g0 d

  2. $ p6 {, b3 \6 h1 I
  3.   Sion Mouse System v1.3e
    9 f) K8 N& W+ S; D" y9 x
  4.   $ C1 v0 G' ]9 G0 `1 J0 F
  5.   Changlog
      Z  U; y! o) j6 E' {+ i9 M% C5 T( _
  6.   ; f  I) o  @- f. ]0 e/ _% n
  7.   2013.4.21 v1.3f
    , a" ]2 t# l. S' f+ ]
  8.    
    & L' y, Z+ H8 g, S, t
  9.     1.3f 卷动地图 bug 修正
    ( z  P7 J7 D* ]4 {5 r; P* M
  10.     6 }3 p4 [3 _& x4 _
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口" @" M! A/ I8 Y( Y' z
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    ) t  Z9 w  }% l$ ]; X
  13.                               Mouse.unlock_mouse_in_screen 解除锁定! t+ L' |: i3 o+ H7 I; Z

  14. ) h1 ~+ f: F& z- L+ V' J2 b
  15.     1.3f bug修正, R* I+ d3 j7 n/ O, s4 {0 Y1 _
  16.   
    , |7 K, P: C) ?# e
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及
    3 ^9 d4 y* r! e) e! L
  18.           关闭菜单时,鼠标是否移动到原来的位置。
    7 a8 o# R5 Q$ P% E5 F

  19. # f- a( `, i3 ~0 P, V+ a$ V( i  E
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    - f" S% j/ Z4 B" O3 z; p. P! n

  21. , S. o. g; G3 e, [
  22.     1.3b 修正一些罕见的bug;
    - F+ |- S5 c0 b( v+ @+ d

  23. : h- t3 s6 J1 @0 l1 [& E
  24.     1.3a 代码小修改;& _' C; i% h% W' @, a6 i" k
  25.           加入了鼠标点击启动事件的功能,
    $ I4 h: r, ]& P
  26.           在事件中加入“注释”: 鼠标启动  ,
    % K6 Z3 x; U: H, r( N' q
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    8 [- Y. p  A6 a) W
  28.   " k( `* U8 ^. d
  29.   2013.2.12 v1.2/ E) j, b( ^. }% [7 _

  30. ! R9 a. A  y) n8 U/ o
  31.     寻路逻辑优化;  Q# S# Y  X+ ~' X& h
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    " K! s- ~" A! t: w, K6 i
  33.     现在支持用鼠标来操作载具了。
    9 e4 |6 O9 I; c) v# v% [" F# E$ n" M

  34. 8 c- O" b3 F* _8 A# v
  35.   2013.2.8 v1.1" M- U' [8 e+ m+ P" x
  36. ; A, ?2 P6 B& U4 r( T9 A* z
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    5 M4 d  W2 `  T/ H. K
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;% A/ X* C4 r1 P! P' h1 Y
  39.     移动时,路径指示点的绘制更加稳定;
    4 H( }  ?" q: U
  40.     现在支持默认存档画面的鼠标操作了。$ [2 B7 T' c$ ]% e% x

  41. 5 n  |; b+ I3 C/ z$ Q
  42. , i) N' C7 R" F
  43.   OrigenVersion: z9 H3 s; B5 R5 T9 c
  44.   
    ! S! a* ^6 [, F( Z/ z
  45.     2013.2.7 v1.0 , t2 h; i5 z5 R' `9 P3 A+ \

  46. , @/ J, {5 w5 s, e3 O- P
  47.   主要功能
    5 M4 i5 Y+ Q! p' g6 P

  48. . K4 S/ V2 ~( [! f
  49.       使用鼠标进行各种操作...
    ; F8 w( T! a+ i* ]% W0 p: v7 a
  50.       将鼠标锁定在游戏窗口内8 G2 }7 A. B* i7 f$ f
  51.       自动寻路,按住 D 键可以扩大寻路的范围& q: R3 M5 ~: h0 a7 a8 |3 }1 H
  52.       双击鼠标进行冲刺' q7 d0 i+ x0 j9 g! Q
  53.       更改地图卷动方式以适应鼠标移动9 q* ]1 [" P5 A9 }, \! v
  54.       变量输入框改良7 v6 l. r3 z$ e7 V4 z
  55. & p7 w  ?/ f9 Y. b0 Q
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    % J: X7 i# p% G3 j, c; M4 H
  57. . q  r/ C# T% c3 p
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    + m1 i6 W0 ~" h

  59. % r( \1 a4 r2 V
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭: e1 }3 a2 G5 E0 q
  61. 0 r* F( p7 P2 l8 I# W* R8 ?

  62. 1 f& O: |6 {) L/ ~! u
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    , x1 \* X( n# @2 F; t3 F+ ^2 P+ k
  64. ) a1 U) P0 b2 I

  65. 0 T  \6 d/ c! Q5 h8 o) y
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
    ' \. b8 j0 |2 z! o+ Z) v/ d

  67. 2 R% C% B4 Z$ I! M" Q
  68. #==============================================================================# N2 ~! M1 l5 D$ X5 F  q8 Q7 k( \! \
  69. # ■ 常数设置
    4 H- G% u1 _3 S$ z
  70. #==============================================================================7 p/ S& s" B- |2 Y4 `* C. Q
  71. module KsOfSion
    $ Z/ o! f4 ^' @! V
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false3 a" P: |6 B4 A& B. a, k; ?4 F
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    3 c6 c, t8 {1 w8 c
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false( O# y8 f' F" h. {
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量
    ; x6 C; R1 ]6 H( _) J! D7 B5 f
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处- o0 w; [' o2 e" q% f
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧$ L) A* X2 K  d' V# f& r
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)  Y% A6 q7 N# }' W8 j
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    7 _( @& O: w* S! R/ n# t& H6 G9 W( c+ C
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)! q. {* E, ?9 a) ], a& c* B
  81. end
    7 q) q* V: n2 w1 T4 H' r. g

  82. 4 v$ M% n3 }* V; H
  83. #==============================================================================
    & I8 V8 |& U% d6 V& G9 v4 S
  84. # ■ 用来显示路径点的类) Z) Z& ]4 x: N
  85. #==============================================================================) ^& r5 w, k$ v* v7 C2 m( e4 @! x
  86. class Move_Sign  Game_Character+ o& {3 `  }. M6 y  I" w7 A( p4 H) b
  87.   #--------------------------------------------------------------------------
    8 l) R( N! y$ p1 b! e0 {  b
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图2 _, H- J* d6 f& g1 j" Q0 o
  89.   #--------------------------------------------------------------------------
    2 A6 H3 u7 _0 \/ }; X, ^! G
  90.   def init_public_members
    - T7 @$ ]5 b7 p( S; S
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹" S3 [8 |$ Z+ {: y# ?5 E
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    & y4 o! ~5 \7 O9 P
  93.     @move_speed      = 5        # ★ 踏步速度
    4 |" H: ^7 j% P, j
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)9 `5 G6 T* p/ y1 f
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度8 l7 ]; V1 Q% J/ f5 ~
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    7 }" Y. o/ f) t. P2 U
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    + |. o+ c: h4 O! C5 V
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    . K: z1 @9 A2 s  V. Q) I

  99. . w& E) K8 Z$ h7 a, ?9 D9 {
  100. . J! t( x8 O  @" t: S
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    % v5 n6 x& c- E, q% q, }- R

  102. + e, [  y$ B7 h* m6 ^

  103. 0 x% c' T& r) E" z
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    4 \9 ^/ |4 X4 l; Z, }4 X
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    0 a  _  x. X1 d; Q2 e2 U0 g* M
  106. 1 D3 l" i. i4 R
  107.       if $no_arrowpic_warn5 b' f4 A( ~" N) K
  108.         MouseShow_Cursor.call(1): S* w! m- v* Y$ |% _) O/ F! C6 R
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    ! w# h7 J8 O% u$ }
  110. : C' X! r9 _* |5 R2 J0 X
  111. “路径指示点”将使用游戏自带图片6 `4 ]. I! c3 L5 c2 |
  112. 9 C" `; f- ^, E2 R0 N  Q
  113. 该提示可以在脚本内关闭'), E8 F9 ?; S$ j2 m4 r- V6 s( A
  114.         MouseShow_Cursor.call(0)
    ) b: E& G# F; ^8 m
  115.         $no_arrowpic_warn = false
    , t6 W: x4 H( G5 W0 [: a# F
  116.       end" O3 d4 T/ F9 j  h  J' k
  117.       @character_name  = '!Flame'9 J+ x* J$ L' m! ~  P
  118.       @character_index = 6
    4 T4 V' v( Z7 t1 H: a

  119. 6 ]6 a) m- j, B5 \. c
  120.     end
    1 w, t0 s& {! a8 {7 q" X9 e' x
  121.     @direction_fix = false  # 固定朝向
    7 ]  h4 C6 M3 d* p
  122.     @move_frequency = 6     # 移动频率
    " N. {4 U' [& O* b. L
  123.     @walk_anime = true      # 步行动画; |( C2 D+ N6 x# G1 b6 G/ ?
  124.     @pattern = 1            # 图案
      ^1 E3 l; j# e5 |3 L& w, ~
  125.     @through = true         # 穿透* \) ^. n, z3 i$ X& e1 _8 n
  126.     @bush_depth = 0         # 草木深度
    $ B7 h  S+ p% N! v; |
  127.     @animation_id = 0       # 动画 ID& \- T- `1 h3 z  g5 p
  128.     @balloon_id = 0         # 心情 ID1 x8 |: G; |- o7 M
  129.     @transparent = true     # 透明
    5 [% V" Y* G4 a* v
  130.     @id = 0
    / A6 r0 P/ S0 O3 b
  131.     @x = 0
    ' N: L. a; k" _
  132.     @y = 0
    3 s  Z4 x! j( d2 n
  133.     @real_x = 0
    0 Y1 D* a; s. x. r- Y5 |: R
  134.     @real_y = 0
    ' a9 ^5 X7 M7 J8 k0 {7 q0 X' C
  135.     @tile_id = 0$ q. _" D0 i9 l4 C
  136.   end
    - V% C) I1 k& y" w. r5 e
  137.   #--------------------------------------------------------------------------. a* V' V. h* r0 F# B4 O# U" t( l
  138.   # ● 定义实例变量
    3 Q8 d; a5 L2 ]
  139.   #--------------------------------------------------------------------------
    : H9 q/ Q5 g& R
  140.   attr_accessor direction* U; i" c7 f0 A% a% f( ~5 u
  141. end0 T2 ]. [4 {* {' B& l
  142. ! V, g% G0 ?- g3 v3 q! ?. p2 Q
  143. #==============================================================================+ g; m9 M' t" a; l9 N- y9 C% m! W2 U
  144. # ■ Module Mouse7 ~, V( o/ N( I  T4 U# M0 n
  145. #==============================================================================/ p% K& l, Q$ A+ j. H
  146. module Mouse
    . J9 o, P5 o1 a) N( `  f: m
  147.   #--------------------------------------------------------------------------
    % h: p# M; n1 u* S
  148.   # ● API( ?( J4 z  V  I8 F' K! @
  149.   #--------------------------------------------------------------------------' |: I5 [2 B# l" X
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
      {7 ~) `5 `! f9 L6 C6 e2 G- W& P
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    2 L; b5 f) v% _8 ?. S
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    6 R5 y1 K. _- J/ E8 r
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    / T- a0 Y0 ~/ l
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')/ _1 U% {1 x8 z& i; B8 ?( |
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')9 F  I# D7 h, d1 z! [" S
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')* L- A. ?" u9 Q: s9 |
  157.   Window_Hwnd       = Get_Active_Window.call- C3 p5 \) W  |# m' A# O9 o) _

  158. / }7 o  E; ]2 c- D  ]# k% y8 i* L
  159. class  self
    7 F! C, B& b: N6 l# o
  160.   #--------------------------------------------------------------------------- ?+ i( `; p( U  ~, R
  161.   # ● 初始化
    2 B3 D" j' l* J
  162.   #--------------------------------------------------------------------------+ w: L3 K* z5 u
  163.   def init5 [; @5 p! N0 F5 j' q
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor3 L. _3 p4 y9 H7 @
  165.     @left_state = 0
    ; ^  R0 E/ l! n  b' y+ ^( H' d
  166.     @right_state = 0$ z, \* V9 X. k; Z; D
  167.     @ck_count = 0 # 帧数计,单击以后从0开始5 H) _$ ~: N) Y# G5 c+ T* q( q) l
  168.     @dk_count = 0 # 用于双击的判定
    ! |! J* g0 Y# A7 l
  169.     @clicked = false
    * v8 m$ ?$ s  I/ |( p
  170.     creat_mouse_sprite4 R% G2 K4 B2 u4 F) a
  171.     update  v" J2 r$ E$ {3 H* f5 g. \
  172.   end  F! Y  h: X6 M6 m3 q
  173.   #--------------------------------------------------------------------------! |7 m1 L8 Y# |
  174.   # ● 鼠标指针精灵
    1 o, ^3 U$ Q" _* ^2 ^. b
  175.   #--------------------------------------------------------------------------( E# Q( m9 Q* f+ n
  176. #~   def creat_mouse_sprite
    % ?$ y# C  A2 l$ d& M
  177. #~     % K3 V, n) ~( M+ k1 I8 S8 q
  178. #~       @mouse_sprite = Sprite.new
    $ K' |/ z3 Z/ E9 e, {  `$ ^
  179. #~       panda = 2#rand(2)+1- V+ q. K+ B4 E' p1 {: r% ?

  180. 7 L+ ^8 }$ A( G. k. g3 ^: g, M/ x
  181. #~      if panda = 1% x, Q! C3 x1 k0 P* p* W$ A
  182. #~        if File.exist('GraphicsSystemCursor2.png')8 f; l( @5 y0 e, r3 K
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')3 b7 E9 G5 G. |4 L2 X, C0 p
  184. #~        end#with if File.exist) G; v& w: g3 c( o1 }6 F
  185. #~    % ?4 q# i5 P6 a* s& t% o
  186. #~     else if panda = 2 #with if panda=1) r4 j" ^2 y4 {" X: n1 ?3 @* W
  187. #~      5 E& X$ D) H- @  @
  188. #~      if File.exist('GraphicsSystemCursor2.png')- G# [% C5 G0 B7 m% g2 f
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
      M, o6 r% [9 n" C
  190. #~      end#with if File.exist8 d8 u# p6 W: `3 @4 g  X/ H
  191. #~       . F/ X2 l* o- S! D! q& q5 J9 L
  192. #~     else #with if panda=1  U/ T. U+ F$ g2 i5 e
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)  x( Q6 Q  l5 g. w- z
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    0 T  `5 O) X0 P, w$ U  i# e  ^& `' e% _
  195. #~       Rect.new(5  24, 24  24, 24, 24))# }- I: T% G: I" N8 V
  196. #~     end#with if panda=1
    : ^& L  e( W* K6 A7 r/ N* t
  197. #~     
    ) H# p+ E1 T* o
  198. #~     #with def( A1 O5 `: ~" X0 `1 j  L+ m
  199. #~   end
    ; g- |, L2 |6 Q4 h9 e
  200. def creat_mouse_sprite
    - p8 M  _" V, E! c) F
  201.     @mouse_sprite = Sprite.new
    * A: M% E  g* m2 z3 Y- B/ s+ I- e
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    " O) B$ h$ F' g/ u; Y
  203.     @mouse_sprite.z = 9999+ @( t1 D1 B" B$ W" B. M
  204.     Show_Cursor.call(0)
    + B8 ~. ^2 t. {1 d8 O0 ^" Z" \$ ]# y
  205. end
    ( V" ~2 ]# i# N" O& W, [
  206. . V- a& P' g9 {
  207.   #--------------------------------------------------------------------------
    ; i+ n, W+ M$ O/ a1 f3 W1 `4 N
  208.   # ● 更新' H/ G& m+ M+ \6 D
  209.   #--------------------------------------------------------------------------6 e; |9 E  T* U) j
  210.   def update/ P3 ^+ Y" s' g) k! x* W
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos4 L4 h' p7 N1 Y5 c4 b
  212.     left_state  = Get_Key_State.call(0x01)
    0 F" [, s# _7 ?0 C/ L' D) m
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    6 I; i# N  W8 r. `1 R6 ^& {
  214.     right_state = Get_Key_State.call(0x02)4 M/ }9 [5 w: ]
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0# S% P5 J+ w$ L
  216.     update_double_click
    / M! M# t1 B( ^! P: h+ K  D
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    3 \  a+ M% O* g6 s5 Q$ |
  218.   end  f3 r0 g+ q& v7 M: v
  219.   #--------------------------------------------------------------------------$ n5 O+ w* t& |
  220.   # ● 获取鼠标坐标
    , U/ a3 s4 m7 l! E; M2 p1 N
  221.   #--------------------------------------------------------------------------* G0 C. A# o8 |5 ^$ _" X* H0 @7 B# h
  222.   def get_mouse_pos) x: A' Y. }7 y- C+ M
  223.     arg = [0, 0].pack('ll')2 _9 J3 _+ ^+ k
  224.     Get_Cursor_Pos.call(arg)* E6 T& b  Q+ J1 x* z
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    ; d" {& F: |4 M
  226.     x, y = arg.unpack('ll')
    ! ]* Z7 z& i: G
  227.     return x, y
    4 O5 G  w; b1 }% o4 u6 X
  228.   end
    % h7 E0 z( Y' D7 S( t7 @
  229.   #--------------------------------------------------------------------------
    3 A( x. e$ {) ?; m; m
  230.   # ● 将鼠标固定在屏幕内  W" j$ U$ R4 C8 s% ]/ q
  231.   #--------------------------------------------------------------------------; z, A- z0 N! m3 w6 T" W
  232.   def lock_mouse_in_screen/ J9 A# l2 ?, b5 J. G8 X
  233.     arg = [0, 0].pack('ll')# [5 w& c7 q$ R$ O8 p9 U' b
  234.     Screen_To_Client.call(Window_Hwnd, arg)% Z- t2 K1 ?+ z- o
  235.     x, y  = arg.unpack('ll')
    ; w' z; u5 r' a. ]
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    ' a9 A8 Y7 |# r* w! l# s
  237.   end
    ( G9 ~  M8 k4 x' M  V
  238.   #--------------------------------------------------------------------------
    5 e' ~& _8 Q  E* w/ _
  239.   # ● 解除鼠标固定/ X; n! F! h; `2 H4 X+ }
  240.   #--------------------------------------------------------------------------
      F) j; \5 u/ I! ?6 Z! [
  241.   def unlock_mouse_in_screen3 H" J6 L$ g* c1 ]& T  P
  242.     Clip_Cursor.call(0)
    # E+ `8 j( M& U7 o
  243.   end1 l8 t4 N  p8 O3 p5 T. z0 ]
  244.   #--------------------------------------------------------------------------) J5 s9 i1 Z1 a
  245.   # ● 鼠标双击判定7 r& P% ^( C! s, m' [8 B
  246.   #--------------------------------------------------------------------------* b. i3 F3 q4 C5 h0 u
  247.   def update_double_click) P( f8 e! M* w6 A/ g, o( M6 u0 m
  248.     @clicked = true if @left_state == 1% @8 @  P* T5 d: v6 C, a
  249.     if @dk_count  0 && @left_state == 1  ~7 L1 l; d7 Z4 P6 Q$ @1 {# r
  250.       @dk_count = 0; @clicked = false9 f' k; n) i: w& s6 B, z2 n1 w7 \
  251.       return @double_click = true6 n+ P7 N- F; D$ f9 X* a' t
  252.     elsif @clicked
    " V/ b/ b+ X" b" T: b: |
  253.       if @dk_count  KsOfSionDbclick_Frame, s- ^% \9 i7 Y( Q9 T
  254.         @dk_count += 1# a) E6 ~, k3 K
  255.       else- M. ?3 W- R# `: p, A6 a) t
  256.         @dk_count = 0; @clicked = false6 N- V5 h( T& u' x
  257.       end
    ( _) k- _: B: K! z0 r" v
  258.     end
    & Q% C- X% j2 T
  259.     @double_click = false
      _$ [1 J$ J5 `9 D
  260.   end
    # N4 |( j& c$ T9 M( u# a! Q- V
  261.   #--------------------------------------------------------------------------
    & ~  Y5 t7 Y2 \0 Y1 B. }% o
  262.   # ● 按键被按下就返回true
    6 z7 i; y5 t9 v$ H9 ^+ {8 @& f
  263.   #--------------------------------------------------------------------------
    8 E9 K. G6 \$ m% u
  264.   def press(button)5 N& }6 p; s  B
  265.     case button, z. a/ m9 I5 d8 W: k
  266.       when 0x01; return !@left_state.zero7 e* w; e4 C/ z6 n8 q( X4 B: w
  267.       when 0x02; return !@right_state.zero4 b. ^- L; a( L  I2 ?1 ~* m2 B7 w
  268.     end; y. \3 ?: N) k- ?# V
  269.     return false
    2 ?* y8 Q- D6 s
  270.   end
    0 ~$ e4 \4 U  U5 y- y4 e$ q
  271.   #--------------------------------------------------------------------------& r/ y/ V: r& s5 }7 P' ?
  272.   # ● 按键刚被按下则返回true% `; f) G0 P, c4 L6 _
  273.   #--------------------------------------------------------------------------2 O, {3 ]6 K8 ?, K% ~
  274.   def trigger(button)
    5 E9 ]- |8 B9 p, M
  275.     case button8 ?6 j, W7 F* x- s: f4 a" u
  276.       when 0x01; return @left_state == 12 E" V! P8 \' V$ U# p9 |
  277.       when 0x02; return @right_state == 1" [$ e3 T2 E/ d# o! u+ k
  278.     end. J9 E, a9 x% S  W% h0 Y7 z
  279.     return false
    4 Y: e- ]* J7 P$ O/ q
  280.   end
    2 u/ \9 c. T  D& w5 ^
  281.   #--------------------------------------------------------------------------
    % ~2 I9 X3 E! U1 F6 q! o
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true( X* r8 p! S$ N) B  M% C" V& t
  283.   #--------------------------------------------------------------------------  I9 t, }. [/ a
  284.   def repeat(button)5 |$ P8 t& K* h" \8 h8 R6 _& l4 B; b
  285.     case button. Y: v) C6 _6 o1 l8 ]
  286.       when 0x01; return @left_state == 1 ; m" R1 c1 q7 F4 ]
  287.         (@left_state  22 && (@left_state % 6).zero)7 s& s# H7 E3 g* }. r( U9 P6 q6 ^
  288.       when 0x02; return @right_state == 1 9 w2 E9 y2 c3 |
  289.         (@right_state  22 && (@right_state % 6).zero)
    & r, @. L: @$ q: a2 T' o$ y4 P
  290.     end
    4 Z6 g3 `) e9 U: I' l; G5 c
  291.     return false2 p7 P% e4 v4 T( d4 g6 s5 m0 U
  292.   end
    9 i0 E3 b* u5 J3 a
  293.   #--------------------------------------------------------------------------
    , J2 l* R$ }7 A8 m
  294.   # ● 判断是否双击鼠标
    5 p1 u* _% n% `& w
  295.   #--------------------------------------------------------------------------
    : e: ?1 `' C" b2 d
  296.   def double_click
    ( }0 f  ~5 L6 J0 K& ]# n  k
  297.     @double_click1 K, i  ~! {/ b* F
  298.   end
    + Y! Z3 Z8 @2 F$ b: |3 ~
  299.   #--------------------------------------------------------------------------% Z7 y3 V3 c% a. m6 r9 D
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    " M- X- \" e. c* ]7 X; f7 p
  301.   #--------------------------------------------------------------------------8 o% K  I+ c  q: k. @; \
  302.   def click_count& `/ g  u9 F. l( L7 R, S) X
  303.     @ck_count
    5 l" H: `- a! \5 T7 s
  304.   end
    & I, D0 g& R9 j! i' ], ^# m+ ^
  305.   #--------------------------------------------------------------------------: _/ U0 D+ N4 X# y9 b* S
  306.   # ● 获取@left_state(按住左键每一帧+=1)1 x0 Q" S4 M* N8 }3 ^; Y! S
  307.   #--------------------------------------------------------------------------
    & P2 t# b9 B0 l. f! c6 I- |
  308.   def left_state
    * W2 `3 d4 a5 L" ^0 w+ H1 q
  309.     @left_state
    * Z, O+ s, s3 B/ T
  310.   end' w' y6 s, q# E0 y* E
  311.   #--------------------------------------------------------------------------1 S1 {. a4 C; [" g! L
  312.   # ● 获取鼠标的x坐标6 g& U- G7 F! B1 {0 H/ k
  313.   #--------------------------------------------------------------------------
    " ^) ]( h! Y0 F+ K$ k# z5 ~4 v
  314.   def mouse_x
    1 [+ w3 w7 _% M  ~3 J
  315.     @mouse_sprite.x
    ' r& k; F+ W1 S6 R0 X. j! i+ n
  316.   end  E' `5 O4 ^7 s' O0 ~7 y& N; O
  317.   #--------------------------------------------------------------------------- ^! k& x2 P! y
  318.   # ● 获取鼠标的y坐标" H# ?, |: Y0 u, E- D+ L
  319.   #--------------------------------------------------------------------------+ Q, n' l3 v$ s  e# o# z7 x
  320.   def mouse_y
    : M% M; s% i2 v7 N' I5 P: x# [
  321.     @mouse_sprite.y
    " ~- D$ g! K9 D1 V9 ?$ G4 A
  322.   end% K3 @6 X+ p- |* q
  323.   #--------------------------------------------------------------------------! m/ f2 g7 {9 ~1 J7 y8 q  q# S
  324.   # ● 设置鼠标坐标0 A+ H) c5 p* I4 ?5 b( X
  325.   #--------------------------------------------------------------------------$ ]! ~* e3 W, E, H0 n
  326.   def set_mouse_pos(new_x, new_y)  V/ v8 w2 n: I
  327.     arg = [0, 0].pack('ll')
    ! Y% Z0 N' `/ e+ F+ p$ n8 [
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    . e7 F9 b0 ~. g, O
  329.     x, y  = arg.unpack('ll')
    3 v  s" h- v% t6 v) `# K
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)
    / s. s4 Q& Z* K" `- H+ h5 ]2 d
  331.   end, W$ ~4 r2 ?8 `* }7 L
  332. end #end of class  self ( |" W; }7 C' K2 h6 `5 f
  333. + G4 J: q" g0 y, ^, f7 X
  334. end2 u2 r' l% p6 I+ u- n3 T
  335. * R& Z4 y8 T# @. _
  336. #==============================================================================
    - q  C* W6 ^* e) J0 M
  337. # ■ SceneManager- y2 n5 L- d% c: N9 c
  338. #==============================================================================7 Q3 G# O- B6 Q7 w) G7 P8 _
  339. class  SceneManager
    % ]" _) z* ~  Z* v0 O
  340.   #--------------------------------------------------------------------------
    : M1 K& _0 z* {- @. b5 R
  341.   # ● alias
    / ~+ K. m# {1 H
  342.   #--------------------------------------------------------------------------
    - h( \& h7 v2 u$ O
  343.   unless self.method_defined(sion_mouse_run)
    & n# u9 `1 o1 Y5 E8 P
  344.     alias_method sion_mouse_run, run
    1 O, k% }+ Z( D& K. k4 j
  345.     alias_method sion_mouse_call, call7 j9 O0 J# R/ i* B4 _, x
  346.     alias_method sion_mouse_return, return6 T5 I2 R" L) K
  347.   end
    0 b, P( t$ W3 `
  348.   #--------------------------------------------------------------------------3 Z# t$ s2 B/ ^& c% C+ v! c
  349.   # ● 运行
    ! e& R* F' a5 K
  350.   #--------------------------------------------------------------------------
    6 ]" @0 H! q$ w
  351.   def run
    % b7 m  x! D8 F, _0 ?6 \: i4 V+ D
  352.     Mouse.init
    6 I7 [$ s3 M4 n
  353.     sion_mouse_run
    3 u4 w8 c& n9 {8 \% x
  354.   end
    % `9 @% J% t1 L# F5 Y- Z
  355.   #--------------------------------------------------------------------------
    . O) T5 ^3 m/ E% j' M
  356.   # ● 切换
    ! D2 t: H- {% k
  357.   #--------------------------------------------------------------------------' U. S! t  e2 }, C
  358.   def call(scene_class), X+ A( t* s9 z6 Z8 M4 v$ _
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    , T. B  Y, B& ]0 g, w' T% v
  360.     sion_mouse_call(scene_class)) P3 i8 n; Z: v& n& n
  361.   end
    6 S, ]; g/ D% c( ^& V0 i/ Z
  362.   #--------------------------------------------------------------------------
    4 f6 n2 I% K- K+ k9 c: A
  363.   # ● 返回到上一个场景
    ) \, i/ }# G/ h4 ?! Q2 }; f
  364.   #--------------------------------------------------------------------------$ a; z1 V  [: d3 m; i, e& Q
  365.   def return, ^9 X2 t, e2 Z' v: h7 [; q
  366.     sion_mouse_return' t. i& Y0 b1 I/ |
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&* J0 V3 P1 O7 Q
  368.       @scene.instance_of(Scene_Map)
    ) o$ r: Z8 f) ]5 B4 b7 o
  369.   end
    7 E. i( f! v, S5 z" r! y  x% e. @! g
  370. end* |1 f8 [( i& ^$ p" |3 ?% |- m
  371. , K$ w2 p# {% p, a- q/ ^: f
  372. #==============================================================================
    # b+ p' z5 k2 t8 [
  373. # ■ Module Input# Z7 a4 q5 [/ j+ A3 q& w' c7 P9 S" ^
  374. #==============================================================================
    $ |- s) r: G- O2 F
  375. class  Input
    % O& |; `2 g. F3 h4 V
  376.   #--------------------------------------------------------------------------( n/ D; Y* o/ v3 M
  377.   # ● alias
    ( x% z- ]7 q/ \
  378.   #--------------------------------------------------------------------------  A) j  q! t7 v& ?) O, E( m
  379.   unless self.method_defined(sion_mouse_update)
      l8 o4 h* G4 x: y2 W7 T# T2 O
  380.     alias_method sion_mouse_update,   update
    4 {0 e% f+ J3 T5 x
  381.     alias_method sion_mouse_press,   press5 O) J" e2 T; Q
  382.     alias_method sion_mouse_trigger, trigger& r* O4 I( R" a8 G
  383.     alias_method sion_mouse_repeat,  repeat
    % x* s' w, a; q' u1 @8 ?7 s
  384.   end* \% J2 j! C6 p5 E
  385.   #--------------------------------------------------------------------------
    2 r. d  \4 `- }5 n* M# z5 ]
  386.   # ● 更新鼠标
    + j* o" y- w. V( E
  387.   #--------------------------------------------------------------------------
    " @. `* I9 T# K
  388.   def update
    4 B! q1 z. v3 |% P$ u6 {" Z
  389.     Mouse.update3 T& n0 X! f3 ~  ?: h. \# v
  390.     sion_mouse_update
    $ c) ^/ ]. q" N$ r1 j
  391.   end
    ) N3 i7 u. h/ J3 [
  392.   #--------------------------------------------------------------------------
    ' S0 M0 @  _0 ^
  393.   # ● 按键被按下就返回true, s( ]! m2 Y% ?9 {) `. e9 \
  394.   #--------------------------------------------------------------------------9 ]; Q) ]0 X% w! D# J
  395.   def press(key)' ?5 H. W8 E. s* r6 E5 E$ j& Z+ k
  396.     return true if sion_mouse_press(key)* _; q: N! {  [0 X  `, ]( A% ?
  397.     return Mouse.press(0x01) if key == C
    4 j# n9 r. @. |0 `" f
  398.     return Mouse.press(0x02) if key == B2 P+ _% g- s7 S# v
  399.     return false& @0 g  Z9 |- Z, d/ W
  400.   end
    ; j; c& S/ B: L* J5 m
  401.   #--------------------------------------------------------------------------
    2 ^& @4 ?: g4 C# \# N4 ?1 q: M
  402.   # ● 按键刚被按下则返回true5 c! d9 I3 ^$ p
  403.   #--------------------------------------------------------------------------5 C4 A' h# B  M3 h+ }) }
  404.   def trigger(key)" f/ Z) p9 _* g. i: L9 o/ G7 b
  405.     return true if sion_mouse_trigger(key)
    & a+ \. ?6 T: T5 h8 [" o
  406.     return Mouse.trigger(0x01) if key == C
    ! N. v. ?0 T5 c( p- d
  407.     return Mouse.trigger(0x02) if key == B  I  ?& c* W% M+ p' X
  408.     return false4 v) l; K% h5 h" j2 G+ ~
  409.   end4 H  G. S  I* Q
  410.   #--------------------------------------------------------------------------# b" ~; a4 X# A8 F
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    ( V& [$ A4 [: R
  412.   #--------------------------------------------------------------------------$ Z) m! z$ `7 f! j
  413.   def repeat(key)) `# W6 Y- n; ]9 o. [* x- Q$ h% x- O
  414.     return true if sion_mouse_repeat(key)4 O7 d. l) j/ @( M* x, ?* e0 K1 H- ^
  415.     return Mouse.repeat(0x01) if key == C
    6 |6 ?2 A3 O/ K& j5 m
  416.     return Mouse.repeat(0x02) if key == B' b: q& z- p" B( w: T1 t) T
  417.     return false
    1 c. L5 `( \. [" W
  418.   end
    4 D8 c& G; z/ ^
  419. end
    6 k& @1 q9 o4 ?% R& }, l/ P

  420. ; ]0 B7 G7 q; l! Q* E4 [
  421. " `1 p( L' ~9 T/ v! Z8 Q1 z$ J5 l
  422. #==============================================================================
    ( x7 Z# ], b4 N0 R
  423. # ■ Window_Selectable; \$ D+ c( {6 i! |$ J; N0 }
  424. #------------------------------------------------------------------------------- a6 A, q7 `0 A* s# O8 D) Z
  425. #  拥有光标移动、滚动功能的窗口
    & V- h0 n3 _+ S% z% R$ |; [
  426. #==============================================================================$ F- ~; t& A# x) }! B9 {+ n( X" _
  427. class Window_Selectable
    $ I, J) h7 T) L, S5 w
  428.   #--------------------------------------------------------------------------
    * U7 L3 p, z' T3 m9 i8 A* B
  429.   # ● 初始化, d# C) ?* ?; a( V5 @  V2 u% a
  430.   #--------------------------------------------------------------------------8 S$ B' \/ ?) ~) v3 n6 J! {' S
  431.   alias sion_mouse_initialize initialize
    ) f( ?; {' i$ d. \$ |2 }8 I- z
  432.   def initialize(x, y, width, height)2 w! B0 X% Q8 {9 g  T$ L
  433.     sion_mouse_initialize(x, y, width, height)
    $ W% N9 R9 }% o" ~/ ~9 a) e8 I
  434.     @move_state = 0
    " x" j- \/ X* g5 l  `+ r
  435.   end9 u: ~! Z: `7 w; ^; G4 z% [
  436.   #--------------------------------------------------------------------------
    & k- h( u2 e0 I5 v7 b0 f
  437.   # ● 更新
    0 [4 }9 A) {) G
  438.   #--------------------------------------------------------------------------% W" T9 a: H! V& F6 D& Q5 h
  439.   alias sion_mouse_update update
    - @: s8 P  h6 f0 @: Z
  440.   def update
    " X8 |! S  P, r1 }; @5 b' E# t7 H1 @
  441.     sion_mouse_update
    + _; o7 t  F3 C2 `$ y- K% T6 a
  442.     update_mouse_cursor
    4 C/ [" I& k% B1 b/ K& M8 T
  443.   end* i: g  H7 Y9 C+ U1 B
  444.   #--------------------------------------------------------------------------
    4 N" ]' l1 b% \2 {& w$ ~: J
  445.   # ● 启动后设置鼠标到index位置6 F1 W/ M0 n; n5 p2 I6 ~# b
  446.   #--------------------------------------------------------------------------
    , P% d) J& [* h" O2 q9 n, N
  447.   def activate0 {1 P, c9 @: Y! u' I  e
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    7 U8 Z# q: r' E5 J- F/ s. j
  449.     super7 E5 H& J0 k. R& l+ w
  450.   end
    # |, @) P, H" h2 e$ ]+ R: P: O
  451.   #--------------------------------------------------------------------------
    " b2 C+ g0 c! M
  452.   # ● 更新鼠标和光标的位置
    8 J9 K* D7 b. L
  453.   #--------------------------------------------------------------------------& }7 {/ X/ q  d4 L* i" t" E8 q
  454.   def update_mouse_cursor
    : b' S" b" y3 b9 D! _! Z
  455.     if active; U+ R: e4 @9 I5 c% J0 J
  456.       if @need_set_pos
    5 f' r4 A7 \1 Z( e" k. e1 c/ Z% c5 t( t
  457.         @need_set_pos = nil! u4 P6 w' ^" G  o! z  C
  458.         set_mouse_pos
    2 [8 P: V. b  f7 [
  459.       elsif cursor_movable
    / D% W* \3 P$ Q7 ^% u0 j9 h. w
  460.         Input.dir4.zero  set_cursor  set_mouse_pos- t# f4 c$ }. k( C  x: M
  461.       end% h) o; P, l/ M7 L. J( C. _/ F
  462.     end, r1 m- ?# I. J+ u  \7 u
  463.   end1 d% g* P$ x3 E: h5 Y" y9 ]
  464.   #--------------------------------------------------------------------------
    : m$ b/ S0 \3 K7 h6 z0 H0 W
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    7 O" d3 C% Y0 @+ j; a8 x
  466.   #--------------------------------------------------------------------------8 w2 y2 n0 H- C, j) i% |4 o" u/ V5 R; k
  467.   def set_cursor
    * P  t( i+ x1 l4 u: @
  468.     mouse_row, mouse_col = mouse_window_area
    - f: p. z. r: G3 H8 Z
  469.     if    mouse_row == -12 G; j% W- L) X) w( V
  470.       @move_state += 1 if need_scroll5 d; R' V/ f" q5 D3 n" Y
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand' b7 ^7 |" J9 e2 ^, i
  472.     elsif mouse_row == -2) L- p9 K5 U  p  @( E0 b* I3 E+ A
  473.       @move_state += 1 if need_scroll% e% |! q& ^" R& e6 G: w1 j
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    : Q! D) ?& J% E- F' O
  475.     elsif mouse_col == -1
    0 k8 v; _) J8 v4 f5 y
  476.       @move_state += 1 if need_scroll8 ]/ l8 x  m  z' z
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand) e& [9 ]- B' I, k9 C) v! g% W- ^
  478.     elsif mouse_col == -26 k4 D0 t6 f; B: D/ j+ w
  479.       @move_state += 1 if need_scroll# w; N) |- z/ a0 K! @
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand+ r0 p6 [% {  U) G9 p
  481.     else
    ! `  `1 ]2 [0 E( B( s; r
  482.       @move_state = 0
    $ `" C. A& ]1 U3 A* W. b, _, f
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    . n" P1 c6 V0 k0 m
  484.       select(new_index) if new_index  item_max && new_index != @index
    - d  [" `! I3 L
  485.     end
    - Z  V% u9 n0 d2 m9 b
  486.   end/ y4 {/ o7 g6 X9 K4 m8 j
  487.   #--------------------------------------------------------------------------
    7 E! {1 r8 o5 a+ L& {
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    5 c: G. H3 Y6 v3 g
  489.   #--------------------------------------------------------------------------) r* A0 G; C* B$ V) ~+ Z& M
  490.   def mouse_window_area( l( U' n3 u0 g) n$ y2 e+ t9 ]
  491.     if viewport.nil # necessary!
    7 R; \# C- ~1 j, `; E& M
  492.       vp_x, vp_y = 0, 0
    : ~2 O! e% R6 G7 u" F
  493.     else6 X2 ]/ R0 q9 r. [4 A) x. x
  494.       vp_x = viewport.rect.x - viewport.ox
    # l9 U) ~5 U9 ^: O2 \
  495.       vp_y = viewport.rect.y - viewport.oy2 d7 _  x5 H# G3 f
  496.     end
    0 P9 u( ]. D9 x2 v. \
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    * f" Z% `# Q/ p1 ^' H+ V
  498.     item_x1 = vp_x + x + standard_padding $ _, K  }' ?7 C% ~- _. }2 [7 {7 O2 T0 D" b
  499.     item_y1 = vp_y + y + standard_padding% s1 }! ?+ J* _3 r- w' t
  500.     item_x2 = vp_x + x - standard_padding + width
    . M4 S% g8 F6 X+ l% _0 n
  501.     item_y2 = vp_y + y - standard_padding + height9 ]* K% Y+ H6 r- H/ b
  502.     if mouse_x  item_x15 ^8 P$ X9 j5 I) {' [$ E3 I
  503.       mouse_col = -1' f, m4 g. Z% c( p, r
  504.     elsif mouse_x  item_x2
    2 u* e- D( L# A' T
  505.       mouse_col = -2
    ' x. i6 K: v: x
  506.     else
    : @# C# b& A, _) }1 }
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    $ B% \. l3 H8 P/ J5 f7 V
  508.     end
    9 E9 O. m7 u" p5 b( Y0 @0 U
  509.     if mouse_y  item_y1/ F; W4 A8 C! M* I# [& E3 X
  510.       mouse_row = -1% }5 A  l; v" F, Q7 u: [
  511.     elsif mouse_y  item_y2
    3 w6 l/ U/ x& Y
  512.       mouse_row = -2
    : R, r+ ~8 q% x, V- B
  513.     else
    % |& K8 T1 M5 Z- a  a% B7 w) G
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1), W2 H, L6 F4 S
  515.     end) _" \- q1 e: s  z; Y: B/ o
  516.     return mouse_row, mouse_col
    4 O6 h) F4 j* V4 s: f) M
  517.   end7 c% d) x! [! N& `2 X0 w
  518.   #--------------------------------------------------------------------------# W1 P8 ]& g: ~1 {$ ~+ n; e
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    8 E7 s" K# ?' b8 E) J* U, T) y
  520.   #--------------------------------------------------------------------------
      K4 E2 ?/ D4 y) Z6 r
  521.   def set_mouse_pos
    9 Z' _( V3 L9 a4 j1 X5 Q* ~
  522.     if viewport.nil # necessary!
    + T7 Z% j# Y* u- M6 ^
  523.       vp_x, vp_y = 0, 02 `, n* e  N) E
  524.     else8 H8 |( v9 Q2 R7 i  O
  525.       vp_x = viewport.rect.x - viewport.ox# H' B- L1 F7 r1 P& x7 n  I0 X
  526.       vp_y = viewport.rect.y - viewport.oy, n7 I$ a; o( x! x! Q# N& u
  527.     end
    7 u: ~& U* n) `+ Q8 q
  528.     item_x1 = vp_x + x + standard_padding   _% }5 G( `4 \" g
  529.     item_y1 = vp_y + y + standard_padding
    2 y+ R# m$ r4 t! U/ c8 I# j  V
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index , U  G# v, t* l& q
  531.     row = get_index  col_max - top_row. r1 a  p. I7 ~  v
  532.     col = get_index % col_max, n, t& B& V: V4 c
  533.     new_x = item_x1 + item_width  (col + 0.5)
    7 }; ?' G: Y3 {* I  g% r6 e
  534.     new_y = item_y1 + item_height  (row + 0.5)" M$ ^" i* q8 O/ K/ G0 ^: Q% y' O
  535.     Mouse.set_mouse_pos(new_x, new_y)1 x5 v4 j1 o  ]7 g$ \
  536.   end
    + O3 f: p; H4 U4 K/ u" P: ?7 I3 m5 I+ C
  537.   #--------------------------------------------------------------------------
    1 ?8 b7 e% L' V" i3 |5 d! X  B
  538.   # ● 判断菜单是否需要卷动) S- x: _1 E. u- l: N
  539.   #--------------------------------------------------------------------------& `6 g5 Y" ^' u. Z8 y
  540.   def need_scroll/ L& r9 a' F; N. A5 t* U$ s
  541.     item_max  col_max  page_row_max
    * Y7 ^; X3 P0 n5 J8 V
  542.   end8 e  V7 Y7 f3 U& X" `
  543.   #--------------------------------------------------------------------------
    - T( K. V3 {/ v
  544.   # ● 判断是否为水平卷动菜单
    2 K! T# b0 e: _  ^
  545.   #--------------------------------------------------------------------------3 U% {/ l0 ^% n; l: R) O/ z/ [" ?7 a
  546.   def is_horzcommand
    " O% l* F  R  ~+ `: S# Q! `- a' {
  547.     return false4 {+ i/ S, S& c( ^6 P
  548.   end& ?* _" w, @! D( p* {! A7 W
  549. end
    7 \+ A0 }3 ]6 u, d

  550.   b6 @/ n: R- f( u6 D5 |+ V  I
  551. class Window_HorzCommand
    8 @) L! {" w& Q" `) Q% b# U* b& E
  552.   #--------------------------------------------------------------------------+ I" ?& m, |  L% F  x
  553.   # ● 判断是否为水平卷动菜单: Y5 b0 [" W" x9 W3 B0 ~& a
  554.   #--------------------------------------------------------------------------
    & I. [* a8 ]4 v" L
  555.   def is_horzcommand# F" }) |: K$ c2 O" W  R4 K
  556.     return true" G# y: d( T5 V
  557.   end7 L$ n  X. E4 Y2 K! E
  558. end! f# f8 d! z" @8 i* V; \5 b
  559. 2 o8 O( t9 |! ^7 [; Q, V3 q
  560. #==============================================================================3 B- K5 j7 c! @/ I$ b0 U; N( ^; l2 I4 z
  561. # ■ Window_NameInput
    * K4 _2 P, A" S
  562. #------------------------------------------------------------------------------
    1 k2 y& \+ t# n% D6 F3 G" O& B8 W- R
  563. #  名字输入画面中,选择文字的窗口。
    ; o" l4 W' v& v* ^4 F* e+ V
  564. #==============================================================================
    " O7 O. I& @1 S: K# V! f
  565. class Window_NameInput4 K1 F+ z% H( x+ D- q! d
  566.   #--------------------------------------------------------------------------& I/ _( `2 e, g% ^, U2 C7 h
  567.   # ● 设置列数8 B! a' p+ @7 Z2 q; H
  568.   #--------------------------------------------------------------------------/ s# {5 X' V5 n- }: G
  569.   def col_max( ?& M  c7 A; O( X$ k
  570.     return 10
    # O2 m' |" f& q# I
  571.   end
    / N1 r: ^6 X- ^; @* k9 h
  572.   #--------------------------------------------------------------------------
    2 a. C' `  l) e& W$ B! {  i4 E
  573.   # ● 设置填充的Item个数
    5 t+ R0 S2 G5 Q8 u3 [
  574.   #--------------------------------------------------------------------------) \/ \/ D1 l4 c! t$ |. r
  575.   def item_max( X. H1 X1 V* R
  576.     return 90# `( a1 |* f8 Y1 a
  577.   end
    $ N# C# F8 E$ j: h% H- ?
  578.   #--------------------------------------------------------------------------
    % ]' A6 z: Q& h4 @; r
  579.   # ● 设置填充的Item个数8 j0 d7 z. Y$ f5 Y) T
  580.   #--------------------------------------------------------------------------
    6 e  K: w1 j4 p5 ?% s/ \& @
  581.   def item_width2 t( Q7 {( y' T$ @5 C0 M7 V. g
  582.     return 32
    ) k) M) }' f/ }& O% D
  583.   end
    - n8 ^( M& `% @0 I' r( d
  584.   #--------------------------------------------------------------------------
    ! X7 B3 f4 Z# F: m5 o
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    7 k5 z6 C0 \4 l  ^' s
  586.   #--------------------------------------------------------------------------6 Q. W( B2 U! ^# i2 M
  587.   def mouse_window_area1 O6 R" ]+ A9 d9 i# M! P; b
  588.     if viewport.nil
      F  x7 Q& y! D9 x  W
  589.       vp_x, vp_y = 0, 0  s* i# u1 }0 n4 Y/ f6 r: \* n
  590.     else2 r$ B' `% q% a* e$ s; x# z
  591.       vp_x = viewport.rect.x - viewport.ox2 @% u) m0 E/ e& D/ T! ^7 @) e
  592.       vp_y = viewport.rect.y - viewport.oy
    " S( w" R6 X) T5 g& P2 D$ d
  593.     end
    * |) N$ J: w- g; X6 W
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    % D0 l! i, u/ I
  595.     item_x1 = vp_x + x + standard_padding
    , T9 I9 L% a5 {; B1 D+ S; j
  596.     item_y1 = vp_y + y + standard_padding7 R( x7 _4 I5 X  Y1 A
  597.     item_x2 = vp_x + x - standard_padding + width
    % F, ^: m+ s4 x& ?- j
  598.     item_y2 = vp_y + y - standard_padding + height
    1 Z0 a! [2 W' n: T6 S& k& b
  599.     if mouse_x  item_x1
    7 r' m0 x0 h  Z
  600.       mouse_col = -1
    5 I, R8 m+ S4 F3 A+ v4 c
  601.     elsif mouse_x  item_x2
    0 R" m: N: s: T$ Y" u- {
  602.       mouse_col = -26 R. v; j7 E! E. \4 e; R
  603.     elsif mouse_x  item_x1 + 160
    * ?  y3 q  U8 a! f  j! S
  604.       mouse_col = (mouse_x - item_x1)328 i: }9 R% R5 F
  605.     elsif mouse_x  item_x2 - 160
    / L  U% K8 ~0 l( \! g  S2 O3 Y5 Q
  606.       mouse_col = 9 - (item_x2 - mouse_x)320 j# r% B/ H+ y9 o& s( R, M) O
  607.     else
    7 L" z) p2 m: i+ n/ G
  608.       mouse_col = mouse_x  x + width2  5  4, A5 ?! E, ]! h4 M- e" ]5 ]- S2 X8 }
  609.     end
    ( y8 D. |2 [* {5 g) F4 S
  610.     if mouse_y  item_y1
    ) k  K! G( ?2 o6 u
  611.       mouse_row = -1
    8 a. k. K2 X8 B( V6 T
  612.     elsif mouse_y  item_y26 m6 N; A' c3 [$ C+ b  w8 [, b
  613.       mouse_row = -2
    6 }' S0 O% y: Z' L4 u* ]
  614.     else
    0 z1 ~$ b, z% [# b7 ?+ L% j
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)/ X- E  N& n% X
  616.     end
    1 t! a2 {+ u2 f0 ~4 n/ Q' {
  617.     return mouse_row, mouse_col
    & e1 _4 s7 B- I0 s6 u7 x, `1 I% a
  618.   end
    9 v) d6 s. E% l" q! w4 x9 j  A
  619.   #--------------------------------------------------------------------------
    , y8 M4 P; s9 O, h
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
      P: E/ c3 F6 W0 c  b' H
  621.   #--------------------------------------------------------------------------/ T0 R8 M/ W8 W4 [, v
  622.   def set_mouse_pos% f* L% Z$ e3 E# j( T4 F
  623.     if viewport.nil # necessary!1 Y( E) ]  G# F
  624.       vp_x, vp_y = 0, 0
    ( E; b3 U6 \: C  D# G: K
  625.     else
    ( R" ]. c4 q7 H  ?0 A4 h+ [6 L
  626.       vp_x = viewport.rect.x - viewport.ox
    % k5 f" I5 a4 j9 H3 W% s
  627.       vp_y = viewport.rect.y - viewport.oy9 k; y4 H5 ]. _
  628.     end
    0 E& p9 K4 t9 N. ]+ N
  629.     item_x1 = vp_x + x + standard_padding # r/ R; r, y6 v
  630.     item_y1 = vp_y + y + standard_padding
    8 j! C7 y2 x  [! U% B
  631.     get_index = @index  0  0  @index ) ?) K7 l$ n3 T$ F
  632.     row = get_index  col_max - top_row
    # |; Z) `$ D; H2 H. y+ m
  633.     col = get_index % col_max# z9 H$ c/ Y% m/ |0 [
  634.     new_x = item_x1 + item_width  (col + 0.5)
    ' w* T, |$ i0 _4 E: I$ @
  635.     new_y = item_y1 + item_height  (row + 0.5)$ a5 y* ^) X3 o) h# F
  636.     new_x += 14 if col  4
    : g  e  {( U" `; [9 b4 z7 R* l
  637.     Mouse.set_mouse_pos(new_x, new_y)9 ~& ]' t5 W1 x' k0 V7 G* |
  638.   end
    # U0 H1 G: L4 p0 h5 ~+ |) i
  639. end
    " ~/ k: N, x% U! i* k, Z; b) s0 H
  640. - R2 L4 p9 o% M  ~
  641. #==============================================================================
    4 V; ^2 J, @! \% o: q' G! j" O
  642. # ■ Window_NumberInput
    3 ]' b, K+ ?- y6 y- D- T% S( Y2 X+ H
  643. #------------------------------------------------------------------------------
    $ t) n: \+ W% R6 j/ W8 f! |
  644. #  重写了数值输入的方法以适应鼠标
    3 p2 ?  ?5 F' h# S
  645. #==============================================================================
    9 B9 e3 ]2 E5 O7 U- y' U/ ~' {3 G
  646. class Window_NumberInput  Window_Base1 _7 H* h* a1 W. [. P
  647.   #--------------------------------------------------------------------------
    1 Z- T3 c; Q' g/ f0 q* r. }1 q
  648.   # ● 定义实例变量$ T( L8 B/ E9 B
  649.   #--------------------------------------------------------------------------
    * t( h7 p6 J4 V* _
  650.   attr_reader extra_window* ~1 K$ W0 V0 o+ b# G6 V8 G
  651.   #--------------------------------------------------------------------------! N8 H2 W7 F4 Z" D9 d5 N
  652.   # ● 初始化& F6 b9 y1 J$ |0 A2 P/ j3 C0 g
  653.   #--------------------------------------------------------------------------  [/ b: |! Q  }( L
  654.   alias sion_mouse_initialize initialize
    % y4 R  J, t/ u' X) `2 ]5 q
  655.   def initialize(arg)# u% s% D- j. R
  656.     sion_mouse_initialize(arg)
    4 u4 G/ N& A( }# |, S* b8 @  x6 e
  657.     create_extra_window5 r. \+ C: F9 ?! c
  658.   end
    7 B9 i3 b% c+ Y1 w) C: D0 e
  659.   #--------------------------------------------------------------------------8 s+ r- B2 e6 A0 b# k* S& e
  660.   # ● 启动
    7 S: [" V* d3 d
  661.   #--------------------------------------------------------------------------& U; \2 C% Y2 p! `1 X
  662.   alias sion_mouse_start start
    8 O# [) ]  J; F
  663.   def start' S. L' e& W( d  ?2 P
  664.     sion_mouse_start
    * ^# R; s/ D! e: Z' P
  665.     deactivate+ E6 \& G: g9 H; d" f2 c0 A5 q- f& J
  666.     extra_start2 W% Y- O2 |7 V
  667.   end! @; p" ~9 G$ g# C/ {5 W2 z, |1 P
  668.   #--------------------------------------------------------------------------
    7 O4 @5 F5 \+ l. r' G9 b9 ?9 C6 U: W
  669.   # ● 创建新的数值输入窗口
    " i. d7 E7 |+ Z4 X0 ?2 h$ J9 e7 c
  670.   #--------------------------------------------------------------------------( A; R4 o* w1 ~( r; \% }
  671.   def create_extra_window9 A6 M! q4 h3 l$ O
  672.     @extra_window = Window_NumberInput_Ex.new
    ( [6 _" A; Y0 v/ d% S9 j' m
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    * V! X3 |9 d+ U0 b
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    3 W4 K% a/ q# v* j4 I* p
  675.     @extra_window.index_proc   = Proc.new {n @index = n }9 r. b! L' t0 Z( |# `0 ~) Y
  676.     @extra_window.close_proc   = Proc.new { close }
      n3 D, s5 d0 c3 U8 U
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    ) l( y; J6 y' W8 |- J
  678.   end1 @; `; d; @$ Q5 w4 p0 w
  679.   #--------------------------------------------------------------------------
    3 O) r; R' t& K/ U9 e
  680.   # ● 激活新窗口" z6 B7 ^% n& \1 h) ~/ U
  681.   #--------------------------------------------------------------------------
    4 f1 L- u; f" H# p7 j" \. b
  682.   def extra_start
    $ J/ N0 C1 Y& X; u+ V
  683.     case $game_message.position
    , I; w# {% z$ w8 o. R8 i- Z! y
  684.       when 0; @extra_window.y = y + height + 4' N  C7 s; T' F, j& I
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    9 E# y" Z. a- k
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    + r+ n1 g/ e" V& U
  687.       else  ; @extra_window.y = 8
    # m0 Q; ~7 r7 P
  688.     end$ x, f7 j: }3 t# X
  689.     @extra_window.variable_id = $game_message.num_input_variable_id, H% x# p  x, r, L' t, ^
  690.     @extra_window.digits_max  = @digits_max
    ! ~5 s- ~; {. v, Y. b1 r1 `- V
  691.     @extra_window.number      = @number
    7 n5 `( u- d) A) f) O# E
  692.     @extra_window.open' Q/ K( Q6 ^) o
  693.     @extra_window.activate
    1 I' @/ K$ E( Y0 W: k8 c
  694.   end
    : D/ }  {6 r4 O# W( M0 l
  695.   #--------------------------------------------------------------------------% \5 b, r' I" E" E6 x' N
  696.   # ● 更新
    * V3 _+ a3 w' k& s$ J- m; V
  697.   #--------------------------------------------------------------------------% \6 B' @: W  f- Q4 O
  698.   def update
    / T9 }& d- A- q9 m* S* @
  699.     super; q6 N, j/ |) n
  700.     @extra_window.update
    & R+ m8 f; t2 |5 O+ k
  701.     update_cursor7 S, b9 e: C. E0 Y8 @
  702.   end
    , ~8 A/ v$ ^: t9 q2 m% S7 ^1 V1 A
  703.   #--------------------------------------------------------------------------6 n* z6 ~$ B5 Z
  704.   # ● 关闭窗口) v+ L0 ^. x; k. d0 X# u; |
  705.   #--------------------------------------------------------------------------( i" Q8 |% s: f- R
  706.   def close" r) ~/ c; @% _/ c5 i* c  r5 I, P3 ~
  707.     super8 }% o! g+ n# A' s
  708.     @extra_window.close$ u; b8 E9 D9 W. v8 j( H7 O, N
  709.     @extra_window.deactivate
    ( y& T7 V9 _0 I* A/ |
  710.   end
    + e$ }0 j, Y& l3 G
  711. end
      h& _3 {; K0 z6 h8 I' k( Z
  712. 5 X2 h0 v( H5 J; F/ o- O
  713. #==============================================================================, i5 j, P" }: K% |
  714. # ■ Window_NumberInput_Ex
    - U1 `" d7 c  n" L! Z0 h( {( I
  715. #------------------------------------------------------------------------------4 [+ o" C7 k0 q8 A1 c6 I
  716. #  新的数值输入窗口(NewClass)
    3 K$ @" S% r% {1 X8 s
  717. #==============================================================================
    & U0 [' W. c! |5 E
  718. class Window_NumberInput_Ex  Window_Selectable
    " A$ d4 T' r4 F5 X
  719.   #--------------------------------------------------------------------------2 g6 n6 R& _' D* P
  720.   # ● 定义实例变量
    $ b' n3 _, I" G6 K
  721.   #--------------------------------------------------------------------------
    8 [1 M8 g% G  n0 M) s
  722.   attr_accessor number_proc9 T* y0 q4 g7 m# @9 e
  723.   attr_accessor index_proc! n5 B2 G' K' z) I  e7 u) N. Y
  724.   attr_accessor close_proc" c" w: F% B2 j) |5 W
  725.   attr_accessor refresh_proc
    3 X" L* a( g8 Z: {
  726.   attr_accessor number
    ! K& ^% l$ y+ q" D
  727.   attr_accessor digits_max
    ! s% b% a$ ]& G* {; w/ }% c' V4 |
  728.   attr_accessor variable_id
    8 M* F) f5 l/ @, K  d( i5 A8 N
  729.   #--------------------------------------------------------------------------
    4 q( e2 K5 \! M' a
  730.   # ● 数字表; h8 G# o) _" K
  731.   #--------------------------------------------------------------------------
      }, ~2 Q! t( D
  732.   TABLE = [  7,  8,  9,
    8 `7 M4 l5 e% p0 ~' O. j
  733.              4,  5,  6,! b9 ]0 T  H9 A7 M8 @
  734.              1,  2,  3," P9 u0 W0 r3 P
  735.             '←',0,'确定',]
    ! P" j: q6 ]' W2 O. o% ]5 \
  736.   #--------------------------------------------------------------------------$ o% q; O. \! A/ R0 `& o/ D, a: ?
  737.   # ● 初始化对象8 e& i1 I; [% e0 F  ]
  738.   #--------------------------------------------------------------------------
    - s9 q/ D" s8 n, R0 W
  739.   def initialize
    6 j8 a# i/ Y: h8 x2 g: H2 m' J
  740.     super(0, 0, 120, fitting_height(4))
    . T5 `' V  P4 K3 _# K+ i
  741.     self.openness = 0( w2 K( t5 L8 X
  742.     @index = 0
    6 A1 i& G+ F1 I0 D4 X+ |/ D  i
  743.     @number = 0
    ( Y- N  d# E# n, H5 Z& Y$ H: u- ?
  744.     @old_window_index = 0, z5 Z& q8 ^* I$ E: Z
  745.     @digits_max = 0
    & `$ g+ o3 V, L4 e; C
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }& Q& z% i, s. }# U( m; a
  747.   end
    3 K# \. H# m" O$ t. P2 O" h
  748.   #--------------------------------------------------------------------------
    + ]+ c+ T" B3 `" i* R
  749.   # ● 获取项目的绘制矩形
    : I# y5 z8 v7 q( f: E" y
  750.   #--------------------------------------------------------------------------) m% f6 R- ^( Z& n$ n% _1 t) d/ `
  751.   def item_rect(index)
    & S: Y& o+ G+ p, i( c+ v
  752.     rect = Rect.new# A. B% D& |: y8 S- |% @* G  o2 u
  753.     rect.x = index % 3  323 e/ l) ?6 I3 |% x
  754.     rect.y = index  3  line_height
    . m0 g; \; l% ]8 T+ j- q
  755.     rect.width = 320 P: A# {+ Q, j: ]4 e
  756.     rect.height = line_height
    & ]9 j2 ^; d( [) ?9 }$ i
  757.     return rect" e+ V0 w! g* W) A" I
  758.   end' U- p+ {# Z# a4 y5 g1 P" x8 K
  759.   #--------------------------------------------------------------------------& s# P0 Q% \# x7 ]) n/ w8 [6 ?4 {
  760.   # ● 将光标设置到鼠标所在的位置
    " a2 w7 Q0 |0 p/ c- E
  761.   #--------------------------------------------------------------------------8 t$ m6 c. M2 j; S
  762.   def set_cursor% i8 r" ~) h2 W. y2 h# ^" o/ b
  763.     mouse_row, mouse_col = mouse_window_area4 B  K  k9 \' W6 \8 @" z$ J, q
  764.     if mouse_row = 0 && mouse_col = 03 N4 m% z- p) E# T9 T( d
  765.       new_index = mouse_row  3 + mouse_col! L, |( m  s. K. l4 g+ y$ |9 t
  766.       select(new_index) if new_index = 11
    ; \: O, k8 f6 @4 |
  767.     end' {7 ]: W1 w$ L; }) u
  768.   end
    / w2 c5 y# ~% [! \' P- ~
  769.   #--------------------------------------------------------------------------1 _) R* F3 p& X/ b& k7 g+ p* a( \
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列$ j0 R1 {1 U/ c4 ^- X7 T3 V1 N
  771.   #--------------------------------------------------------------------------( m' ~$ {- S- ~! \' Z# `3 e$ x
  772.   def mouse_window_area
    9 V: t  }& \% R6 Y& M8 h. x% Z
  773.     if viewport.nil
    * G$ t3 d. v9 M9 A/ T
  774.       vp_x, vp_y = 0, 0
    0 D1 c. Z6 D, ?/ ~: o4 d" Q
  775.     else; u) |. L+ R3 v3 F5 x% o, S3 P) I4 Y
  776.       vp_x = viewport.rect.x - viewport.ox
    8 q2 n5 V( t$ G. W; Q; @
  777.       vp_y = viewport.rect.y - viewport.oy
    0 M7 S% A5 r  d, w9 v
  778.     end
    6 V$ z. L8 x3 M
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    7 M! c" Z( i7 N: \
  780.     item_x1 = vp_x + x + standard_padding
    4 c, I% L9 _: F: B4 J2 Z6 W6 z; n
  781.     item_y1 = vp_y + y + standard_padding
    1 h0 }) N( h0 p. k: t
  782.     item_x2 = vp_x + x - standard_padding + width
    ( N8 F0 B! o% a, I# d, \
  783.     item_y2 = vp_y + y - standard_padding + height
    . S: S* o; F, O4 X
  784.     if mouse_x  item_x1
    # J! j* y! ^+ `( V/ @' w7 H
  785.       mouse_col = -1, A% I" t1 ~' A3 S  J/ l' @. b
  786.     elsif mouse_x  item_x2
    & f) D. u7 M+ ]# B; S
  787.       mouse_col = -2
    9 u6 ?# G( p8 H0 [
  788.     else7 P% c5 M; j9 @& d- M0 W1 a
  789.       mouse_col = (mouse_x - item_x1)  320 ?6 \4 D3 Q' [
  790.     end/ ^" g6 w, m5 Y
  791.     if mouse_y  item_y1+ ]2 B& L$ T4 Z4 e" }; |
  792.       mouse_row = -1$ w# {- K0 B- v" y. \8 k; c
  793.     elsif mouse_y  item_y2
    # y0 T+ Q, p9 U9 J: @/ B5 V* D0 w
  794.       mouse_row = -2
    7 {  T* v9 h+ z  m# s- ~9 ?
  795.     else
    8 v! y- ^5 G/ r2 g9 b% \( Q( a
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    ; n' Y4 E- ]& S1 J
  797.     end
    - c1 f/ v6 u2 i
  798.     return mouse_row, mouse_col" P: ?) o  `7 G- P0 L6 d, X+ \' y
  799.   end6 o% v! Y$ E: g! e! g4 A
  800.   #--------------------------------------------------------------------------1 O7 b& z% E: Z6 ]
  801.   # ● 获取文字* E: ~/ a2 x( F7 R  C( y  }
  802.   #--------------------------------------------------------------------------
    1 ?: x( m% S4 J0 ~; F4 h3 T! l- a2 E, c
  803.   def get_number, o- p* Z& S! k; ~
  804.     return false if @index == 9  @index == 11
    , q: ^) S2 C6 ~
  805.     return TABLE[@index]
    4 L! C" _9 i* l8 B( Z
  806.   end; l- s- W; i8 H' D9 A' V
  807.   #--------------------------------------------------------------------------
    3 j: ~2 K* C, S) s/ s6 v3 r# w
  808.   # ● 判定光标位置是否在“退格”上
    ( S9 |9 B/ U! u3 ?5 b
  809.   #--------------------------------------------------------------------------
    # m, H* }- ^: \1 j
  810.   def is_delete) V* R+ A# y( x$ D, c
  811.     @index == 9
    & S. N7 H$ v, s$ V# n. f6 l
  812.   end, l. q% P2 u, o! y
  813.   #--------------------------------------------------------------------------' }' A5 D% M1 A1 e3 {' j
  814.   # ● 判定光标位置是否在“确定”上
    7 s  U. B# n! [& N
  815.   #--------------------------------------------------------------------------5 U+ Z$ I, Q  J; o
  816.   def is_ok
    7 m4 C2 @" M  I5 T' K7 z" N' C( @
  817.     @index == 11
    8 R2 v4 c; w- _& S. t
  818.   end
    + Z) D. H3 L% T" |
  819.   #--------------------------------------------------------------------------
    # t1 G" J% v" w& g, K  W
  820.   # ● 更新光标
    ( ]. J$ j8 w+ Z7 v
  821.   #--------------------------------------------------------------------------7 F) Q# }' k- j0 e; h. o4 k
  822.   def update_cursor4 e6 z" _0 ~% l  m, f7 v4 d
  823.     cursor_rect.set(item_rect(@index))6 M$ x$ Y( i2 M' H$ [
  824.   end6 J* n5 h# N/ ~3 y/ M
  825.   #--------------------------------------------------------------------------1 h+ x- }7 A# x& J/ k
  826.   # ● 判定光标是否可以移动5 L2 t1 c" H" Q
  827.   #--------------------------------------------------------------------------7 ~" L/ X( A: X: B  S
  828.   def cursor_movable
      C. ?% \. a/ k8 o; f9 F( P+ C# L
  829.     active
    * [$ K) B7 S& Y. k8 n
  830.   end1 F' r7 @8 i) _" X& R, n; e# `! [/ g
  831.   #--------------------------------------------------------------------------- X0 K* q7 G- [' B" ]! a! r
  832.   # ● 光标向下移动; h1 O# o/ T" N  O
  833.   #     wrap  允许循环
    " o/ V1 R4 ?$ g$ H6 c4 w& H
  834.   #--------------------------------------------------------------------------4 D' n5 x+ ~/ F; J. A
  835.   def cursor_down(wrap)
    1 U) d, `# `/ v) q$ S  e6 d
  836.     if @index  9 or wrap  _. {4 I# c" V
  837.       @index = (index + 3) % 12
    + g* x+ G8 A7 u& N1 T
  838.     end
    9 ^" ?: n: w5 I" V# J/ [
  839.   end9 F* T, ~( h: V# l- E$ b  g" I8 H
  840.   #--------------------------------------------------------------------------
    ) T& h: J) U9 x! W; r+ O, Z
  841.   # ● 光标向上移动) E% b0 B, g7 h# p1 s/ z' Q, ]' V" l8 V
  842.   #     wrap  允许循环
    7 r5 ]5 I# n% D9 w" R" V2 N
  843.   #--------------------------------------------------------------------------! `- n* X" U# A9 z% f" w; L' w0 S# G8 q3 O
  844.   def cursor_up(wrap)5 W2 A& C0 p1 q& m
  845.     if @index = 3 or wrap8 M% n7 C- }5 m& u. G7 E; d
  846.       @index = (index + 9) % 12
    ) b$ P% V4 N2 Y8 z0 g/ m: L
  847.     end
    . [6 Q5 O  [, Z! L# W2 C  ^
  848.   end* @! w& h# x* W# r: s
  849.   #--------------------------------------------------------------------------" v. Y2 v/ }/ @
  850.   # ● 光标向右移动
    : e; `: C6 u, h
  851.   #     wrap  允许循环8 J9 s* ^8 H. |- L& Q# ?
  852.   #--------------------------------------------------------------------------1 i* Y* K% P9 k
  853.   def cursor_right(wrap)
    - ?5 n) M; X/ @% s
  854.     if @index % 3  2
    " C2 ~# e& m. n; V6 v  c
  855.       @index += 1
    2 ~) P; f" ~+ K8 K
  856.     elsif wrap; t' C/ R$ X% E2 q  w4 Y
  857.       @index -= 2
    ! \+ y* i! Z5 M8 {0 y1 K
  858.     end  R  G. Y, K8 U2 O4 R
  859.   end
    - N9 d( y# K' }% P& P
  860.   #--------------------------------------------------------------------------
    6 _/ e0 q8 W$ d( a
  861.   # ● 光标向左移动0 |/ M$ a) m8 s, y
  862.   #     wrap  允许循环: L% c, P& w# G5 b' F; F' _
  863.   #--------------------------------------------------------------------------
    ) l, h8 o2 m: E  C/ f# B) d
  864.   def cursor_left(wrap)
    ( n9 d! E+ O/ i$ P# M. K7 }
  865.     if @index % 3  0
    8 [6 x9 T$ D- \8 }% F
  866.       @index -= 14 z( O. m* r/ d6 n# G9 l
  867.     elsif wrap
    & ^$ `) [) p' s" m
  868.       @index += 2) f2 }3 d0 o7 G
  869.     end
    ) v/ B* P- b" q- T* P& U) ?
  870.   end
      O" c; {/ ~6 }$ a1 u- ]; x% A& d1 O
  871.   #--------------------------------------------------------------------------; f/ ^- ]7 @( K% _- B1 j
  872.   # ● 处理光标的移动9 D1 Y1 l% D3 J3 j
  873.   #--------------------------------------------------------------------------
    : r! S1 [0 P0 s
  874.   def process_cursor_move
    4 l9 p/ T+ u' T5 p  o
  875.     super( c" `+ z2 w$ G9 ^7 x. `
  876.     update_cursor
    9 Z& E" L6 E; I) _
  877.   end$ a# D9 `7 b, g5 A# y3 `8 m! p
  878.   #--------------------------------------------------------------------------
    3 P, c6 `! b3 U* {1 m7 P: {( s/ G1 ^
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    ' Z! T  g) [# ?
  880.   #--------------------------------------------------------------------------  z' B4 ?/ Y, j1 U9 q: X1 S
  881.   def process_handling6 U: f& |* c' \
  882.     return unless open && active
    4 N6 k0 }7 \; }
  883.     process_jump if Input.trigger(A)* p' z6 a: f! E$ S
  884.     process_back if Input.repeat(B)( f# R% g, G# l$ h% p
  885.     process_ok   if Input.trigger(C)4 L' v6 B  y( V; ~/ Q, e' ?
  886.   end; m1 ?3 c% J6 Y6 Y( e7 W' w7 l
  887.   #--------------------------------------------------------------------------
    * o# o6 C$ w$ I
  888.   # ● 跳转“确定”7 ?5 N2 ]7 d9 T$ x0 @
  889.   #--------------------------------------------------------------------------
    / F6 W) Z/ e2 U1 A5 _+ a& b
  890.   def process_jump
    3 Q7 r) U2 o+ A
  891.     if @index != 11
    1 `( U! }) y7 c( F1 ]
  892.       @index = 11
    4 t  U9 K4 ]# E: o# T& W- T
  893.       Sound.play_cursor5 K; ?$ j, {/ h/ v2 n+ m
  894.     end5 q) y$ ?# F7 L0 d8 {/ f
  895.   end% y( A# `' R! S: c$ z0 z
  896.   #--------------------------------------------------------------------------7 }, y8 _; y1 ~* o7 f
  897.   # ● 后退一个字符
    , B  U7 @( S, t  S: _' E! ^
  898.   #--------------------------------------------------------------------------
    0 ]6 Y4 S7 ^% N" E. e- w: z" O
  899.   def process_back
    $ a5 ]( w! c, O. Y! u7 l+ T
  900.     Sound.play_cancel  {7 r) f/ a- Y1 T# W
  901.     place = 10  (@digits_max - 1 - @old_window_index)0 E( L; d( ?& h  K4 }
  902.     n = (@number  place) % 10
    - |: g4 W/ \$ `$ `( d) i0 a" i
  903.     @number -= n  place; |( z1 C" |% b% `  f
  904.     @number_proc.call(@number)/ i/ X1 |( {% f/ Q
  905.     @old_window_index -= 1 if @old_window_index  0
      Z2 C& B. }# L7 g. m
  906.     @index_proc.call(@old_window_index)1 Y9 p# b8 Y5 M  n. ~$ N: l4 q
  907.     @refresh_proc.call! U& [7 B5 [6 K
  908.   end9 X$ D- l3 Q( Y/ g5 U& F
  909.   #--------------------------------------------------------------------------  ~* X( o/ l3 |2 x1 Y" P
  910.   # ● 按下确定键时的处理* h) j" |0 F+ ~$ L0 g, a& l
  911.   #--------------------------------------------------------------------------
    * Y9 Z& v! O6 ^0 O% U
  912.   def process_ok
    * s0 S$ e# m! k* b8 x
  913.     if get_number
    3 \% u1 \* ~4 r) c2 A1 \. D' @# E8 L& h
  914.       Sound.play_cursor
    2 p: k( Z9 Z" t! g" M
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    8 N" B- j) r# {% i+ M7 T* t) Y
  916.       n = get_number - (@number  place) % 10: \2 R1 y+ |: D0 w$ O! y' C# _
  917.       @number += n  place
    & k( a5 A- {* ]( G7 ]0 T
  918.       @number_proc.call(@number)
    8 ~4 H% K# w3 x) l
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1/ n- a. p) h" C- X: |2 W7 s
  920.       @index_proc.call(@old_window_index)  a: e( y; W* o0 P* f
  921.       @refresh_proc.call
      X' C. T# p+ t3 Y
  922.     elsif is_delete3 e$ M1 l$ G* z" @1 ~" D
  923.       process_back" s* `0 y4 I( r" w! ?5 b
  924.     elsif is_ok
    3 m9 K( I3 @+ k$ M1 U
  925.       on_input_ok5 B: k8 d5 \& \8 z/ [
  926.     end
    3 I0 v2 Z. K' a, L! K
  927.   end
    2 ?+ ~5 I. u$ z% f5 v2 p
  928.   #--------------------------------------------------------------------------
    ; H2 ]* p! K: b
  929.   # ● 确定# J( \+ E5 ^6 u! K' u
  930.   #--------------------------------------------------------------------------, X. I6 A! M" N/ _) F# `! e1 B
  931.   def on_input_ok
    & i! i" x4 Y  ^9 I& e
  932.     @index = 0& i5 F( I+ ?8 G
  933.     @old_window_index = 0
    # P1 C7 n5 W6 y5 A* Y: r1 j+ ]" v
  934.     $game_variables[@variable_id] = @number
    - t1 \& W0 R9 c
  935.     Sound.play_ok% e6 X- K) X0 L7 s% Q
  936.     @close_proc.call
    8 m2 s- R* F6 ~1 O6 Q/ U" f
  937.   end
    ' r$ F8 s. c0 f+ q4 y# ~& |  u9 B
  938.   #--------------------------------------------------------------------------
    % J) T8 ~1 [2 b0 i- ^5 x+ q7 |
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置9 L: n$ a% a* @$ E* g+ d) r
  940.   #--------------------------------------------------------------------------) w8 {) y7 ?. t: ^( O
  941.   def set_mouse_pos; n. O4 M3 ]# Z6 D3 `2 y6 d. j
  942.     if viewport.nil # necessary!" @" K8 b' M/ q; e& e& Q
  943.       vp_x, vp_y = 0, 0
    ) y" l6 _- C0 G1 y6 t6 r
  944.     else8 M" r0 e2 q; P* E- V
  945.       vp_x = viewport.rect.x - viewport.ox
    ) X+ C+ J4 o/ ^! l- i
  946.       vp_y = viewport.rect.y - viewport.oy
    4 v' e; `  E) n/ u8 t: z+ V( a) c
  947.     end# E+ i' ^; g6 o0 ~+ r0 P
  948.     item_x1 = vp_x + x + standard_padding * I; p0 L5 y6 S3 N0 V4 z1 E! m
  949.     item_y1 = vp_y + y + standard_padding
    6 a5 G) z% V1 G8 p9 b
  950.     get_index = @index  0  0  @index 3 h! N2 `% V& E; c( t
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)5 _; Y  `  f, ]% T. }: w
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    7 Q% |, W9 H" [# d
  953.     Mouse.set_mouse_pos(new_x, new_y)
    # [! C* t" ^9 `2 Y5 E7 q3 }' \
  954.   end2 o: T! N$ P6 s& v7 t6 Y
  955. end& h6 r$ P7 n& C3 p: u) @

  956. : V: H1 N& y! t  v6 `9 N, b
  957. #==============================================================================; m: _' ]1 Z" \+ S0 T$ z
  958. # ■ Window_Message
    ' ]' [( d: H7 m; M# p* o" [
  959. #------------------------------------------------------------------------------
    6 {" i' q% U. S; M; {/ J" G
  960. #  显示文字信息的窗口。
    " @" S6 a+ z+ T5 F+ B; Y" l
  961. #==============================================================================
    ! @. T3 s  B' t4 ?
  962. class Window_Message  Window_Base" [7 J/ v  T6 N* F/ X3 n
  963.   #--------------------------------------------------------------------------2 q/ k& K$ p5 t9 ^. J3 x( s0 m% P0 F
  964.   # ● 处理数值的输入(覆盖原方法)
    . Y7 [# g/ S- q4 q$ ^. L
  965.   #--------------------------------------------------------------------------. \; D' P; @4 y5 R+ n# M2 S1 U2 l. R/ g
  966.   def input_number9 [2 Z3 D& G! F1 R. U0 E
  967.     @number_window.start
    0 f7 H$ o' V6 \, |3 m9 h& c
  968.     Fiber.yield while @number_window.extra_window.active
    9 |7 `3 Q5 @( Y" J0 x
  969.   end% ^1 T8 i2 X$ R1 P4 l! N/ X
  970. end
    ' `$ V8 e7 }2 X  b; s$ q
  971.   _3 ]$ j. Y, ?
  972. #==============================================================================
    % W9 K7 I  |- U7 @6 b' J
  973. # ■ Window_PartyCommand2 G& t+ g5 O( M! m$ p
  974. #------------------------------------------------------------------------------# h# A, M( R/ x; j. O
  975. #  战斗画面中,选择“战斗/撤退”的窗口。- s# w, ?5 S9 R, t& @" V; p; L3 n
  976. #==============================================================================3 q9 D0 [2 f8 h
  977. class Window_PartyCommand  Window_Command
    7 }" `" D& {5 p
  978.   #--------------------------------------------------------------------------
    + W& y& P0 F" T. ~) ~: m
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置$ E1 n3 ^& \/ u2 y2 K$ q0 M' _
  980.   #--------------------------------------------------------------------------
      O. ^' G1 D3 [1 o
  981.   def set_mouse_pos
    . c& X( ]$ _9 p; L0 p" E
  982.     if viewport.nil
    % n; N' d1 A+ j& t; w
  983.       vp_x, vp_y = 0, 0
    3 O4 E' e6 O  I! D
  984.     else
    - `1 ~" y9 `+ |  V" c. L
  985.       #vp_x = viewport.rect.x - viewport.ox! Z: q* e  B9 y* o
  986.       vp_y = viewport.rect.y - viewport.oy
    * Q0 n) o+ L9 H* C0 R" z4 C
  987.     end
    5 K& X9 A6 f/ T$ M& X
  988.     item_x1 = x + standard_padding
    1 N  g; d6 H# m. W; B9 W
  989.     item_y1 = vp_y + y + standard_padding
    2 n( c0 }( M  P3 g4 R0 `% k
  990.     get_index = @index  0  0  @index 7 I( `: @+ I2 O( J  }
  991.     row = get_index  col_max - top_row6 f" T1 I7 N* F  Q* B
  992.     col = get_index % col_max+ U6 ?3 y9 y& |5 H6 j
  993.     new_x = item_x1 + item_width  (col + 0.5)( {$ I( e, S2 A) a" \# `
  994.     new_y = item_y1 + item_height  (row + 0.5)% @  M8 @, G3 M1 _
  995.     Mouse.set_mouse_pos(new_x, new_y)
    4 Y9 a" M3 L  }/ e5 \4 c! X/ H
  996.   end2 ?) Z- z. m/ i+ R4 ^/ h  Z
  997. end
    2 X% @- O) Q/ i

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

  2145. . }+ w" c2 o2 e
  2146. #==============================================================================0 l+ h% [0 L+ s$ M9 }0 I5 P% J
  2147. # ■ Game_Map
      O) d/ h$ [7 Z1 X
  2148. #------------------------------------------------------------------------------
    3 C9 ]- Q, h) F. u. A* O
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。' \& p( L  ?$ i  J8 H+ i" ^
  2150. #   本类的实例请参考 $game_map 。
    , d6 `8 N; f! K& j3 i
  2151. #==============================================================================
      Q& Y# J& _' H4 ?7 Y7 w* ~0 m$ ]
  2152. class Game_Map
    : y! E  |( z: G  j
  2153.   #--------------------------------------------------------------------------
    , |' c/ ~, q0 z3 ~: O7 o" E
  2154.   # ● 定义实例变量
    ' V1 t/ I) b5 ?- C
  2155.   #--------------------------------------------------------------------------3 T7 N; f6 v' b/ H" h( {2 B# Z9 R
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据6 P8 p4 h. a) ?! |7 b. x
  2157.   attr_reader mouse_map_y # 同上; N. W7 j3 z+ g0 I& A
  2158.   #--------------------------------------------------------------------------( r# Y0 E8 M. f5 r! P
  2159.   # ● 初始化对象
    ; Z+ j( X" y  v% ~1 s) m
  2160.   #--------------------------------------------------------------------------
    * a& M+ Y) X  Y8 I* [
  2161.   alias sion_mouse_initialize initialize" y& B3 U* h& V3 }
  2162.   def initialize$ l6 l: T! m0 r
  2163.     sion_mouse_initialize8 u$ m' r) Y* {. v2 [& F
  2164.     creat_move_sign  ###4 E8 R& ~* B, R! R3 v
  2165.     set_constants
    5 B, ^( }1 x) y$ u3 ~, a
  2166.   end
    % U5 m7 y2 L$ E8 e4 Q0 k# ?
  2167.   #--------------------------------------------------------------------------* m4 U# n% A/ k; o0 E: `6 E
  2168.   # ● 更新画面
    % J6 [, ]1 B) x5 e# ?
  2169.   #     main  事件解释器更新的标志, G4 @0 w+ u; R9 Z
  2170.   #--------------------------------------------------------------------------
    ' I. b% t. N% o8 A: F' P
  2171.   alias sion_mouse_update update
    , W: Y( ], R- }. B
  2172.   def update(main = false)
    * k4 A  }. H) T7 ]1 x5 V
  2173.     sion_mouse_update(main)" P1 v2 b$ _( M
  2174.     update_move_sign
    % p$ c9 h% u# z' ?3 L) B+ w
  2175.   end' R* [% O  C- n" x' G, K
  2176.   #--------------------------------------------------------------------------) h; S" h- t. t7 y. H
  2177.   # ● 创建显示路径点的事件7 P" J$ D' H/ R# t, D' Z2 L
  2178.   #--------------------------------------------------------------------------6 a0 V9 A7 T, G( d: k
  2179.   def creat_move_sign
    & L' j7 f3 e2 M. _7 V! ^6 h. C
  2180.     $mouse_move_sign = Move_Sign.new
    , g  @; M" m6 e- r5 G
  2181.   end
    + M0 O  H0 E$ w% U; v2 {
  2182.   #--------------------------------------------------------------------------
    ; q9 h6 X5 Y: E. f0 A* r5 f' |! c
  2183.   # ● 更新显示路径点的事件' T) J; ?/ a( C8 {& g5 ?
  2184.   #--------------------------------------------------------------------------
    ) ?( Q! B! V& d+ p# D
  2185.   def set_constants' X7 Q5 }& P. n: n! Q
  2186.     @mouse_pos_setted = true
    9 W+ q( ^8 b7 m  L  I8 O8 {
  2187.     @set_pos_prepared = false
    7 G) U+ n0 `- l0 K5 o
  2188.     @mouse_old_x = 0
    % }' _6 y* a! g$ n
  2189.     @mouse_old_y = 0" F! _7 U5 p  o" e& D
  2190.   end
    2 g# \9 W# l) O* }
  2191.   #--------------------------------------------------------------------------9 F2 F3 e0 |8 V
  2192.   # ● 更新显示路径点的事件8 B8 V2 d' U$ c9 [& n0 Z3 @+ T& K
  2193.   #--------------------------------------------------------------------------
    1 z# F; i% \$ k6 Y6 ^
  2194.   def update_move_sign1 V. |8 a! E3 x# V" m& _6 O$ C) _( b
  2195.     $mouse_move_sign.update% E! h6 C, _. W# W6 h
  2196.   end
    8 ^5 p4 A8 h! o! t' m+ j7 e  I
  2197.   #--------------------------------------------------------------------------
    - O  U2 L6 M, u3 q) Z
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    3 Q, n9 u5 T5 K; q/ L! }
  2199.   #--------------------------------------------------------------------------' d& |3 m4 Z& |$ j& _3 F- |
  2200.   def get_mouse_map_xy) T  j2 q( l5 ]% @) ^' }8 Q7 W
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y0 t/ f! a' n0 p4 P
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    ( {. r. _/ z  ?$ j  @
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    ) j& p. j8 r4 [- e0 H
  2204.   end
    % C+ F$ H; ?! h2 A( B
  2205.   #--------------------------------------------------------------------------
    1 e9 G2 r1 }# c( F+ l$ c
  2206.   # ● 返回地图画面时重设鼠标坐标
    % C  ~- p3 b. E9 A( J0 G* N; h2 g
  2207.   #--------------------------------------------------------------------------
    : C4 c1 w- g1 B6 @
  2208.   def reset_mouse_pos0 p8 X- D* o4 d+ W8 W7 T5 A
  2209.     return if @mouse_pos_setted2 h- Z# X3 w6 n/ z1 b. R( H
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    + Y& D6 u! s* E1 Q$ `
  2211.     @mouse_pos_setted = true
    9 `7 Z, h: [4 I& u
  2212.     @set_pos_prepared = false7 ~; K( U9 E4 Q5 o( D
  2213.   end. d( Q/ Q7 @6 d3 L# m# R# x$ d
  2214.   #--------------------------------------------------------------------------
    " V( e: I4 A, b7 x- y1 O
  2215.   # ● 重设鼠标的坐标
    , Z2 n- Y0 E( G1 Q
  2216.   #--------------------------------------------------------------------------
    ( @& s) n+ S- w3 Q- r
  2217.   def prepare_reset_mouse_pos
    # _; \1 _* E; k/ r" f
  2218.     return if @set_pos_prepared/ i3 j1 ?% K' Y+ @4 Q9 ^& E0 S
  2219.     @mouse_pos_setted = false3 L3 |) K% X; a* \
  2220.     @mouse_old_x = Mouse.mouse_x* k9 j1 X! F- h+ |5 l: p
  2221.     @mouse_old_y = Mouse.mouse_y
    % {! Q4 @! y( `
  2222.     @set_pos_prepared = true3 @- M) Q# C# l. u
  2223.   end! z# @, {2 {2 I) |1 P6 A& r8 K
  2224. end
    # l: f6 \  ^# `/ B

  2225. " V; Y6 M1 w4 x& H% ?2 V4 \
  2226. #==============================================================================% ~# y7 u1 z! k. {1 I6 ~
  2227. # ■ Spriteset_Map1 @7 G6 H# l5 i4 F
  2228. #------------------------------------------------------------------------------8 {/ l' I# Q4 u( f/ {3 P' M
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    : L5 Y# g/ N! H4 P3 |4 t
  2230. #==============================================================================
    # Y- ]8 Q* t1 O0 Q; I
  2231. class Spriteset_Map6 M. `9 f0 _5 _6 Y! }
  2232.   #--------------------------------------------------------------------------  c2 H. v8 c4 T6 f$ |
  2233.   # ● 生成路径点精灵
    " i$ Q3 B& }0 L0 v, F6 e2 ^
  2234.   #--------------------------------------------------------------------------4 h0 ~; C. X$ I# G7 D5 _0 |: ~
  2235.   alias sion_mouse_create_characters create_characters
    ' K7 y# Q8 ?1 P2 ^& z
  2236.   def create_characters% q( F. P9 `- i. s, Z) E: Q0 d
  2237.     sion_mouse_create_characters
    ; n3 I, l4 M/ A# o1 m3 s) [# r
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))$ y8 y$ a" t# R1 a7 N+ V$ C4 Q
  2239.   end+ Q3 o: C# A5 b3 z( B/ W
  2240. end
    ' L, ]% V. g" p
  2241. & Q+ @- j& G' z5 h- G8 n# ]
  2242. #==============================================================================
    % A# S$ w4 B8 h: W# F  I
  2243. # ■ Scene_Map
    9 v8 @6 _: G# [& D5 }0 g
  2244. #------------------------------------------------------------------------------
    : d5 [* q9 q9 t/ h( p
  2245. #  地图画面! r* h; f) T; }
  2246. #==============================================================================
    ( p. X: l" b& Q7 ^: i" |5 R
  2247. class Scene_Map  Scene_Base: T$ ?$ X7 x9 h7 X- L% {" |7 j
  2248.   #--------------------------------------------------------------------------
    ) z3 ^  n7 d3 b' `
  2249.   # ● 画面更新) g3 b" w8 H/ H0 O" i* J
  2250.   #--------------------------------------------------------------------------& _! W8 e% [; c+ k4 }
  2251.   alias sion_mouse_update_scene update_scene* |! W! r5 y" ^. r
  2252.   def update_scene
    0 }3 a$ G4 F4 `  Q9 w, P6 ]
  2253.     sion_mouse_update_scene
    2 @6 |+ W+ o& @2 D, x2 T: F* `
  2254.     update_mouse_action unless scene_changing
    ' p; l( {  i. L; F$ \- ?: q, r7 m
  2255.   end
    6 T* u; x: B. t- {
  2256.   #--------------------------------------------------------------------------% F* f. d, R' w$ }- [& S
  2257.   # ● 场所移动前的处理
    6 s/ z9 C+ H: d0 C0 t& i8 K
  2258.   #--------------------------------------------------------------------------. h6 Z# I* d# {0 r" b. \
  2259.   alias sion_mouse_pre_transfer pre_transfer% N8 c0 H& b! n1 d+ Z: K
  2260.   def pre_transfer) m. l* Q% `; P
  2261.     $game_player.reset_move_path
    $ Y/ ]. A3 v+ u1 d/ @+ c$ i  p
  2262.     sion_mouse_pre_transfer
    " i8 j0 ?5 D6 F1 z8 T! f" N% o& N
  2263.   end2 m" f5 V. H0 i4 s8 S% n% \
  2264.   #--------------------------------------------------------------------------- [7 ]  m3 U3 S" K  @
  2265.   # ● 监听鼠标左键的按下
    6 w# s" L6 q' o: |% V4 M
  2266.   #--------------------------------------------------------------------------
    $ g$ J' ?( u! ]- F9 I2 {0 }
  2267.   def update_mouse_action0 a8 c; q) R8 \$ o0 c' s8 l
  2268.     $game_player.left_button_action if Mouse.press(0x01). d3 ~7 P, b' H$ M' j+ B, ^
  2269.   end2 R/ O% c+ F: Y2 ~9 n5 Z. Z7 k
  2270. end3 k' b/ O  G* U/ c  |/ t
  2271. 7 J. I3 H) Z! K
  2272. #==============================================================================! M# u# a$ ^, J- J
  2273. # ■ Scene_File
    # y3 I8 g2 F( d& H4 `, P9 J* K! n+ r
  2274. #------------------------------------------------------------------------------
    ' k4 q4 r8 I& S* i- q* h' A7 b/ p
  2275. #  存档画面和读档画面共同的父类
    ( Y, J5 E/ O5 N# ^& q# Y4 `0 ^
  2276. #==============================================================================# ~9 X9 Y6 D! i6 c1 Z
  2277. class Scene_File  Scene_MenuBase
    ) ?8 ]3 O5 s6 {  A
  2278.   #--------------------------------------------------------------------------
    - {" K9 J; }$ _: f
  2279.   # ● 开始处理
    " h" c6 E! d9 @4 S, ?1 Y1 r( G
  2280.   #--------------------------------------------------------------------------$ z7 s- ?  i$ C7 W  T+ [9 I
  2281.   alias sion_mouse_start start( J" ]! x2 b0 p$ x2 t- {
  2282.   def start
    9 n6 ^4 T# o+ B
  2283.     sion_mouse_start4 Y5 t5 }- W6 p$ ~4 E
  2284.     @move_state = 0
    * }. ^5 }: C/ V5 C
  2285.     set_mouse_pos
    $ B7 o/ e- j2 r  r8 g" n, \
  2286.   end
    ( X, q) f: a2 @/ V& C5 _* U
  2287.   #--------------------------------------------------------------------------# H9 m7 \1 _8 l: U4 ]; B) P* Y0 y
  2288.   # ● 更新画面
    ) Y# n9 W' @" M
  2289.   #--------------------------------------------------------------------------# Z  {- W8 h( S
  2290.   alias sion_mouse_update update' O2 z3 D9 G% t8 P2 n
  2291.   def update
    # r, c  n+ l1 Z  Q( s. S
  2292.     sion_mouse_update
    ) G& o+ K2 j/ N8 I; W
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos/ }8 I7 T: s/ I9 q4 \
  2294.   end
    0 K. U1 h$ Q! k1 A' @. D
  2295.   #--------------------------------------------------------------------------
    1 D6 E1 i6 r2 {' a1 j: Y3 ^& {
  2296.   # ● 更新光标/ X! E7 x! Q  h; Z
  2297.   #--------------------------------------------------------------------------
    ; l, v% u; a' M% {
  2298.   def set_cursor+ y# `& w' S. z/ o. a
  2299.     @move_state += 1
    0 N0 a: r4 F* D( e( W( m. j" R5 t% m4 i
  2300.     last_index = @index1 v% ~% S; K2 u, O( P1 V& j' k
  2301.     if mouse_which_window == -25 P3 y$ J. E) f
  2302.       if (@move_state - 1) % 6 == 0
    / p, V1 p6 R4 N0 |7 e6 v
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    % w2 F9 i+ K" o% m
  2304.       end8 o% W$ j7 ]; C) c- }% P
  2305.     elsif mouse_which_window == -1
    7 i& L5 ~2 [1 y7 l4 T' U# ~" E
  2306.       if (@move_state - 1) % 6 == 0
    8 z  B2 ]8 _( _
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    2 B7 Y  v; [2 a" a. j3 w7 r6 O
  2308.       end: ?; u) S9 O8 H; ^! o. \
  2309.     else3 c% z1 A' e0 s; K  e/ g! P. |
  2310.       @move_state = 0
    9 \, N, K# c" h( m  e$ i
  2311.       @index = top_index + mouse_which_window
    ! G# a& D/ A! J& h
  2312.     end
    ' s& j. ~- _% H1 U4 X
  2313.     ensure_cursor_visible
    + w  \1 |1 ~$ Z; Y2 b& h
  2314.     if @index != last_index
    5 d+ ~* M& f9 P" x4 r- Z/ v
  2315.       @savefile_windows[last_index].selected = false
    ; @0 M  w0 e5 }3 @& X
  2316.       @savefile_windows[@index].selected = true1 ]8 U7 C& |. l6 A! c' q9 U
  2317.     end  n+ |+ |2 [: W5 f' i
  2318.   end
    ) y& c5 [9 n6 m# t
  2319.   #--------------------------------------------------------------------------
    $ M. L3 ^" G* t( L9 ?
  2320.   # ● 判断鼠标位于哪个窗口
    - \, _# N  u+ \  F7 J# v0 t
  2321.   #--------------------------------------------------------------------------* U3 y* A9 ~0 }, [4 r8 X$ ?/ x
  2322.   def mouse_which_window
    3 s% J/ K. Z: d' T% H
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y5 i! E9 t  k+ }' C$ f
  2324.     if mouse_y  @help_window.height + 14
    6 u5 t) }' k7 R$ ^% v2 |
  2325.       mouse_row = -1
    1 d( p+ i' ^3 L: v) @
  2326.     elsif mouse_y  Graphics.height - 14
    ! c; b6 l& h# J2 J- r# L% B
  2327.       mouse_row = -2' L. A5 u1 n3 d- B$ f
  2328.     else
    1 d% S! c& f( K# M7 t( O' O5 ~' r  K( p
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 4 R! a2 z6 U) k, U5 o! g, g0 K
  2330.         (Graphics.height - @help_window.height)
    " H5 Z% J; k7 i' y
  2331.     end
    $ V5 G1 y+ }8 X5 |1 v9 h# r7 o
  2332.     return mouse_row
    ( s7 V6 T# ~8 ~/ L' I' {: x6 b
  2333.   end1 B) [6 P1 A3 x' F  W% [( ^
  2334.   #--------------------------------------------------------------------------8 I- I1 K  x7 X& b7 q
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置9 g# T: F/ b- U
  2336.   #--------------------------------------------------------------------------- `+ ~$ |5 a" [. y0 ]! A% v$ C
  2337.   def set_mouse_pos
    3 K/ n9 v* i$ D; e* K! H( E/ @
  2338.     new_x = 402 \- S' Q+ w5 ]2 N
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    ! w5 V! O9 D  v# ^" W/ J
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    - W! v: S9 f4 x( a
  2341.   end* [0 X+ Z4 G$ ^# K
  2342. end
    1 g9 ^# ~/ \" v# a2 G
  2343. 7 J  s* `% J- o: I& \1 s
  2344. #==============================================================================
    9 S9 Q2 D1 u( v& |" d$ p
  2345. # ■ Game_Event
    - N. j- `" |+ ]
  2346. #------------------------------------------------------------------------------
    ! a3 G# H. r% D  N
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。* p3 E5 W3 g7 V2 j
  2348. #   在 Game_Map 类的内部使用。, r0 z2 ]+ z% {( M% e' ~! z6 I
  2349. #==============================================================================6 Z3 g: x: E( e& a' g/ l9 g3 g
  2350. class Game_Event  Game_Character# Q9 s/ v9 _8 s. h
  2351.   #--------------------------------------------------------------------------
    + L2 [+ z3 F5 u5 b/ \' G0 I+ A
  2352.   # ● 事件启动
    5 D0 S# Z# L, E3 X
  2353.   #--------------------------------------------------------------------------
    3 i% O$ E% D& L9 k- J& C+ \
  2354.   alias sion_mouse_start start
    4 i1 \- D2 o# N4 J
  2355.   def start/ G  u& [8 ]9 g  a8 D& S: L! C
  2356.     return if mouse_start && !Mouse.press(0x01)
    4 g/ k9 @9 L" ^# W* H3 a1 v
  2357.     sion_mouse_start
    + _4 u& Y3 E6 R' I; ]* |
  2358.   end
    ( E  w/ i% Z9 E% y; ?( }, z7 \
  2359.   #--------------------------------------------------------------------------, x' G& s( T$ @/ A: u
  2360.   # ● 判断事件是否由鼠标启动
    % k+ X5 @8 W& ], A6 m
  2361.   #--------------------------------------------------------------------------
    2 ~% v% s6 Q4 w2 V9 B$ x* y
  2362.   def mouse_start
    ( e) H, c, g9 d; D
  2363.     return false if empty! C' J: ]6 z4 v: {6 I( h7 m" o
  2364.     @list.each do index
    ; K. w) g; b* B; B& G( J/ W3 i
  2365.       return true if (index.code == 108  index.code == 408) &&: {( ?) U, j% M9 w/ w' l
  2366.         index.parameters[0].include('鼠标启动')
    ( P) e6 B8 y' U# N/ b5 P
  2367.     end
    - Y1 Y4 [: c$ q% M- _8 w4 {8 \; G
  2368.     return false
    / B0 o# d, @, h8 c0 \# R
  2369.   end
    $ P6 l* U8 L0 x& @0 o0 S
  2370. end9 u  _3 D2 i4 O

  2371. * L+ l: Y( \- T2 N
  2372. ####泥煤的height7 r  n' U4 m7 x3 y7 m
  2373. # @height = height7 G7 [) ^* ^; W  H

  2374. : _2 s+ K% s/ j7 R6 r# D' w
  2375. class Area_Response
    ; n! s; B8 X# Y! K4 s
  2376.   attr_accessor type9 m/ `! r( \& x% q9 z4 d
  2377.   attr_reader ox* Q. [1 l" x9 @& c
  2378.   attr_reader oy
    - z5 l( u  c. t9 e( E
  2379.   attr_reader width7 p' U1 h. C5 Q6 Q5 l' o
  2380.   attr_reader height
    " v5 i* S7 _8 u7 P/ S
  2381.   attr_reader switch_id* @; `, e+ ~+ F* ^! Z
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)& u' P' k/ v& N8 k7 h1 E3 L
  2383.     @type = type
    7 R0 k2 ~- A( W) e  S$ V) S3 T
  2384.     @ox = ox1 D" t1 r8 [) {7 j+ k1 }1 v. x
  2385.     @oy = oy; ]8 ?. j; g; {, Q& T8 E# t  n
  2386.     @width = width6 s3 m5 C2 q8 |. A
  2387.     @height = height# v1 j* h$ t$ ^  m( w6 {
  2388.     @switch_id = switch_id8 q5 I4 f0 ]. K. ~4 c
  2389.   end6 I' W7 |5 W+ l1 l
  2390. end
    6 }7 q  f. ]9 b. N6 F% s. n

  2391. % o4 E3 r1 `, U$ `, J
  2392. $area_responses = []2 b: D: U- _  C1 i: @3 o! J5 i8 ?% o

  2393. ) T' r1 L. L! ]7 y& A
  2394. class Scene_Map( Z* D7 n. t) d2 l! X
  2395.   alias update_mouse_2013421 update_mouse_action
    / [7 P( V$ e  n; Y, l% D- O' X: H
  2396.   def update_mouse_action
    ( r- L. W2 T. ^2 U5 J
  2397.     update_area_response
    6 f; h4 d3 S6 U6 u8 q
  2398.     update_mouse_2013421
    0 e/ c, s4 I" Q, K1 i
  2399.   end3 S4 t) K2 O) g/ y. S; X
  2400.   def update_area_response
    % z8 k0 R4 a6 J
  2401.     responses = $area_responses/ z: y& C  O8 D/ k6 S
  2402.     responses.each {response) e( q. V, ]0 {7 y
  2403.       ox = response.ox# S1 i2 x/ V$ Y+ [
  2404.       oy = response.oy
    ' x$ J2 y# v6 u/ r
  2405.       width = response.width$ F/ H  @6 G1 Q/ N1 Q7 [+ r# u
  2406.       height = response.height
    ' e' ?8 ]4 Z4 X' x
  2407.       switch_id = response.switch_id5 D6 P( A7 c$ B, h
  2408.       case response.type# A" \; W. l; S
  2409.       when 04 j$ Q/ r: E7 }9 J
  2410.         if mouse_in_area(ox, oy, width, height): W; S( T: h6 C: d5 {
  2411.           $game_switches[switch_id] = true' P: Y: v4 V! S  F9 a( P# \3 \
  2412.           $area_responses.delete(response)
    0 e: j& \$ H6 p1 s
  2413.         end  `5 P1 Q3 t% B3 F* }" l9 F9 W3 [
  2414.       when 1
    ) s1 v" G( X0 @5 V" K$ r- \/ m
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)% P) P3 D( A9 G$ U. T' l0 v
  2416.           $game_switches[switch_id] = true$ ?% ^7 j/ r/ E8 W+ ?
  2417.           $area_responses.delete(response)8 ~; T4 h4 t4 d1 m: x$ t
  2418.         end3 F+ e7 d  G1 c
  2419.       when 2
    4 M! D5 h, ]9 E+ b
  2420.         if mouse_in_area(ox, oy, width, height)1 R9 @5 P+ ?8 k* B- k
  2421.           $game_switches[switch_id] = true  x- u* |3 V6 q$ z3 r) _
  2422.         else
    + A- m- N/ _" {$ ?# x( s, E9 i
  2423.           $game_switches[switch_id] = false" @, m# j/ j+ ~5 N5 Z2 E
  2424.         end
    4 Q' c1 O+ K/ e: q1 H( w
  2425.       when 3
      V2 B# b, W# k/ X9 d# X* x9 E, X1 ]
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    % f; ~8 b, O( {7 y
  2427.             (oy - $game_map.display_y)  32, width, height); Z% u- D7 H8 T; \( N
  2428.           $game_map.events_xy(ox, oy).each {event: |0 w. R& ^( D
  2429.           event.start
    # h; s, r5 E3 B- z0 E
  2430.           $area_responses.delete(response)
    ; l8 d( ^! I& g
  2431.           return
    ) q% |+ u. a& M1 k) T
  2432.           }
    0 K/ b0 Z, p$ `, Z5 Q
  2433.         end
    8 G" ~& U% v7 o4 Y/ W
  2434.       when 4
    4 g, w/ n* W; I$ }
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,5 ^0 v6 g, o! F5 l: B% Y$ y
  2436.             (oy - $game_map.display_y)  32, width, height)8 a! E- G9 b, J  }
  2437.           $game_map.events_xy(ox, oy).each {event
    8 q5 p1 v; j% m0 m% ~- w% Z$ [6 d0 W
  2438.             event.start# c/ i5 D( w6 `2 a# c0 a! L" k
  2439.             return% M4 P  N  T+ V, k
  2440.           } $ F4 F' d; B3 H+ j4 b7 S9 l
  2441.         end
    ( c6 Q5 c# R4 C+ N8 D+ A" |
  2442.       end% Z# z: \2 a/ K3 [
  2443.     }
    " {4 O0 A3 E! a6 [" l( o, u9 R
  2444.   end/ a+ F, l) L3 x! A
  2445.   def mouse_in_area(ox, oy, width, height)
    3 B/ T0 {: ^. U/ E6 Z
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    " P6 w) |9 ^4 B
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height4 l: `1 `+ H, d
  2448.   end. [7 Y6 W8 L  a6 M- T
  2449. end+ f" d  x$ l) o' o! f/ L! \
  2450. class Game_Interpreter
    / B* G9 d& s& _0 [4 Z* M3 {9 l
  2451.   def area_response(arg). t9 j; w0 V% M. N
  2452.     $area_responses.push(Area_Response.new(arg))6 {, }" L$ A# j) b
  2453.   end
    * y) [7 H$ C* }9 N
  2454. end# E9 P) a: {5 ^8 z7 C$ s8 _
复制代码

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

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

GMT+8, 2025-5-12 15:00

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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