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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================: V' y2 o, c* x+ i  `
  2. ) y: f9 v4 D. m$ ^" s( a" K
  3.   Sion Mouse System v1.3e
    " A% B" }! Z3 S  m  G  J( r
  4.   ! }+ z# `) C- Q* z
  5.   Changlog
    ) D/ w0 y* Q, L4 W) t( N3 a, A
  6.   
    9 y) |8 t* O2 P' b6 R7 h
  7.   2013.4.21 v1.3f
    ) N# P- z$ o3 r) H  E' `& m
  8.    
    $ K8 O9 f) C; o2 U0 M
  9.     1.3f 卷动地图 bug 修正
      F+ Y! z: o+ [: Y
  10.     5 r7 D: T4 ]2 S7 r7 a; m: \
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    1 g( {. N, B0 w" d7 t
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内* k- k2 D4 ^% o: j& |% |
  13.                               Mouse.unlock_mouse_in_screen 解除锁定  V  h( m2 m# S. t" ^- c
  14. - z! k  g) x9 T
  15.     1.3f bug修正
    ! Z7 j) i. O& D$ `
  16.   ) t  g+ O" z4 `% e$ w$ [
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及/ h$ {: l8 W0 J4 k  e, _
  18.           关闭菜单时,鼠标是否移动到原来的位置。0 U, Q: _. J) s
  19. ! a$ T8 {; S/ {' M1 a
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处- P/ H, X7 y6 u: S: `2 ~: `
  21. : _6 J7 w1 ~0 f
  22.     1.3b 修正一些罕见的bug;
    # w) \: L" f7 F; o

  23. $ J/ K" n7 W9 A+ S1 P' M
  24.     1.3a 代码小修改;2 C7 V- R5 I/ s7 p5 }" j" ^
  25.           加入了鼠标点击启动事件的功能,( `9 P- k) }0 z, p
  26.           在事件中加入“注释”: 鼠标启动  ,6 e" M0 ~; r$ Y0 x: @9 W
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。
    . J' }' M& G! U* _/ a8 a
  28.   " g4 S: n) C1 \: z- e4 o. c+ f
  29.   2013.2.12 v1.2
    9 g5 n' M% d5 n
  30. 6 O& k: F7 K7 P8 d2 U
  31.     寻路逻辑优化;4 Q: X: a( c% P- ^, N4 c
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    4 M$ a& G  I1 L3 g8 K) F' \2 r9 i
  33.     现在支持用鼠标来操作载具了。) F9 w9 B; Q0 ^8 P! Q. @' t* A
  34. , t4 {# `% T; ^! N3 B$ [
  35.   2013.2.8 v1.1
    # `5 ?' F9 o& U* A6 ]; O+ k

  36. , k  y  T5 b) g* A5 o; `
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    1 h( [7 z( h6 G" m- g
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;
    & d7 f5 }+ m& I* |
  39.     移动时,路径指示点的绘制更加稳定;
    3 W2 f+ T! N9 j# Y2 G
  40.     现在支持默认存档画面的鼠标操作了。/ Q0 T+ u5 {- W& V- e9 s

  41. : c7 C5 d9 X6 ]( {" F# j

  42. 3 Q6 L5 e5 A- Z: H
  43.   OrigenVersion5 k: a; ]8 Y" M
  44.   # K- n# V; _. r; h+ t+ }- v2 {# Q
  45.     2013.2.7 v1.0
    6 J9 `9 E: p/ o% u8 R& e
  46. - r8 ^$ B% k1 n% j% m+ n! {( R
  47.   主要功能  h& v$ J0 @6 O( R& D8 x; i
  48. 5 {' [$ g6 U* _$ c/ K% k0 O
  49.       使用鼠标进行各种操作...+ p* o3 ^* U% q% }4 r9 G, e
  50.       将鼠标锁定在游戏窗口内
    ' Y. O' s/ d( ?' R
  51.       自动寻路,按住 D 键可以扩大寻路的范围* Q- ]' x, ?" L' r
  52.       双击鼠标进行冲刺
      G9 Q2 Z0 N. @# C5 P8 [6 ~
  53.       更改地图卷动方式以适应鼠标移动
    + m  h( K+ x* M7 M3 W
  54.       变量输入框改良5 ]5 P6 W) n6 O# `. L. I

  55. + G6 H! _9 B8 B' K  Q' U+ C
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    2 ~  u4 ~# ^& p) Y5 {) v

  57. 4 [4 t9 M0 f! U3 k+ a" N$ ~' ~
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹/ z2 i! Z% z8 a5 ^* b7 `
  59. . N+ S* l! C  j/ v9 e4 f/ I( _
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭
    - P, B# g" `5 G4 l7 c; l
  61. " h6 G" ^4 x, I9 |- x6 I
  62. & |3 t: B& S$ ~5 p
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★
    # H2 s* t1 Z! j0 [7 j
  64. " v4 U# o3 g( d+ I4 H

  65. 3 y, P3 v7 G' I! ?9 Z* D
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示/ U) j7 \$ h: q5 r6 U) o
  67. 7 X, W# H# _: K$ X- K
  68. #==============================================================================# H* _' \+ g8 Y* a; h; m* L2 v; K
  69. # ■ 常数设置 ) _$ x% s" R% S
  70. #==============================================================================! R( _  F4 D1 p7 Q; A
  71. module KsOfSion1 g& p0 ^: H- a2 R0 {2 N
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false6 R' T) @* ~! q! d$ ]/ V1 n
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    ! _  Y+ u" i. x8 @: K
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false2 B# i# G0 r5 r7 A  e' Q
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量5 }: c4 Q: i) x2 ^
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    4 M  Q4 l5 D1 i( U8 ^# e
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧6 M; g& e1 A4 _( ?( p1 q; B
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    " \* V" a  x+ Z- s
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键" q8 T+ O# u9 m8 T
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    8 Z7 \0 f% O, l% q& |) x
  81. end
    . q& d8 r$ t  V! A' [6 c

  82. $ K$ D4 d0 t$ V( `, x  ?9 F8 k
  83. #==============================================================================, q3 u. }/ {5 v
  84. # ■ 用来显示路径点的类) Z& p" U$ n# I0 x4 X
  85. #==============================================================================& g0 h/ w) N4 ]7 f% \% f
  86. class Move_Sign  Game_Character: s% g! W3 [# ?" k# A* u
  87.   #--------------------------------------------------------------------------
    ) s4 W& _" P/ S" H& x6 M1 T
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图  {4 g* j3 W- R; @2 H& t
  89.   #--------------------------------------------------------------------------
    * B' J2 ^8 ?: M. V" p" p. E$ X6 V' |
  90.   def init_public_members! F  F( ^6 @: B: |4 {! r6 e  D
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹
    7 F; B" l% Y3 l% Z( c2 }  W+ D
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0& |1 \% J" s; R4 n) P3 @
  93.     @move_speed      = 5        # ★ 踏步速度6 Y( U! i: \0 m( Q
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)2 d! T2 A8 w/ \% G
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    ! |" h4 [  @/ @9 e5 [
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    : c% i7 }* L3 e2 E! w
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列0 K+ {8 c/ j2 u; Q4 L/ U/ @
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1); L& X2 n# _9 O/ I; k) b# H1 h

  99. 7 S. i5 R4 R4 G( t2 z
  100. 5 Q2 }" ?; y, ^. J
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    / x6 o0 [- ?4 B& M, C$ q% J  P

  102. 9 y9 D& I) h; v- Y% z  L

  103. 0 o6 _$ t9 L/ r
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图
    6 O. |- X# M+ b4 f: V4 K
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')- z  T' J' {* ~! q8 [/ K7 m
  106. ! Z0 b4 q- O0 l: ^% _+ Y$ m
  107.       if $no_arrowpic_warn2 V# s  c. n. I: E
  108.         MouseShow_Cursor.call(1)) T7 m. U4 w7 i$ y2 U" _
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    ( a* k- r, ]! o3 s. B

  110. , n" y: c0 [; R& L
  111. “路径指示点”将使用游戏自带图片! Z  @6 Z8 [/ y; p3 r5 [; v' U
  112. : a  r- f. u! t/ g6 U3 X
  113. 该提示可以在脚本内关闭')5 p& s" I7 C( _- C; H
  114.         MouseShow_Cursor.call(0)& J# j6 w+ r! X0 F4 J! C
  115.         $no_arrowpic_warn = false% K  u# ?* P& s  C/ u9 f; N' S
  116.       end6 _; ^1 o& e1 E
  117.       @character_name  = '!Flame'
    5 c0 _$ f! j9 l- O! l  i" d+ S
  118.       @character_index = 66 @* _  {8 w8 b2 U; s
  119. ) L: r- S; B& W* N7 f3 N/ Z- |
  120.     end
    & ~& H7 b6 O; A
  121.     @direction_fix = false  # 固定朝向5 u( C) w9 T8 V/ `& l! G
  122.     @move_frequency = 6     # 移动频率( q; A, P2 }! C, b
  123.     @walk_anime = true      # 步行动画
    : k. p* M+ h! I  \
  124.     @pattern = 1            # 图案" h1 t: p9 y/ V* G0 F" v6 Q5 b
  125.     @through = true         # 穿透2 Y/ f; T% p9 Z5 b3 r: B
  126.     @bush_depth = 0         # 草木深度; w1 D$ [1 d" N/ U2 B- m. S$ |
  127.     @animation_id = 0       # 动画 ID2 r5 z( c" S8 V. O7 J
  128.     @balloon_id = 0         # 心情 ID
    $ Z* }3 S2 o3 z
  129.     @transparent = true     # 透明
    5 x7 n, \% r$ v
  130.     @id = 01 F9 S% s* \9 D7 V! g5 I
  131.     @x = 0
    ) X. }; y/ I2 q$ q& S# r
  132.     @y = 0( D, t3 O& q' d3 ]
  133.     @real_x = 0
    ; n$ a7 M* i7 J; h. F
  134.     @real_y = 02 }' N9 e/ `; D' p0 Q
  135.     @tile_id = 0
    , g: l  c, A+ h  ], }  }8 _. I' W( @
  136.   end) y" u9 r) `% A  a
  137.   #--------------------------------------------------------------------------
    - l7 f2 O6 c/ u) Z
  138.   # ● 定义实例变量) K. Y1 k9 s: Y! [1 B+ v
  139.   #--------------------------------------------------------------------------8 N1 ?' j1 W. i
  140.   attr_accessor direction6 Q) M7 v9 Z! }! i$ e$ g" @
  141. end: D3 }& e1 c$ D8 F% n

  142. 1 x5 q, M8 m; X2 t% Q$ v# \6 _
  143. #==============================================================================
    # X% f- s7 ^! Q9 l; z$ Q5 R) s, t
  144. # ■ Module Mouse5 h4 V& B3 N0 Q4 w: W
  145. #==============================================================================2 a7 s  a$ }- _* o8 x
  146. module Mouse- R$ S7 k/ Q9 w4 L
  147.   #--------------------------------------------------------------------------
    % }2 |3 S$ @3 g7 \) H, d
  148.   # ● API
    ' m* q( \6 N3 p1 {- G" t! C5 d
  149.   #--------------------------------------------------------------------------
    % j. p  W" K" @; u" F4 G5 U' L
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')6 L' A+ C# I! {: h
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    ; ^! l6 p% n0 X1 k
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')9 O; N( S0 ~0 [# F* }3 K
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')4 m  M, h. o! V; O& I
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    1 U) S$ l! Q3 ]" B
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')3 Q5 V) K9 I  _% r( \+ N
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')
    7 F$ W6 l" q6 j" ?" p! t
  157.   Window_Hwnd       = Get_Active_Window.call
    , \* S( m% E3 Q1 s
  158. $ Y4 A8 S5 T# t% p3 c" y
  159. class  self
    : ~4 K( W$ I1 r  w: ?% n: s
  160.   #--------------------------------------------------------------------------9 @, O/ j% Y5 {
  161.   # ● 初始化
    9 r" W* B; u1 i( t7 `
  162.   #--------------------------------------------------------------------------2 s7 H' D$ H8 k6 ~, _' O* [' q# A
  163.   def init
    $ c2 f. z8 \% X1 k1 S( I; }; {
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    % m* V: m0 Z& p" I
  165.     @left_state = 0
    2 A# N! x: y- C+ N; H" q
  166.     @right_state = 0$ u9 \: ]! X. T
  167.     @ck_count = 0 # 帧数计,单击以后从0开始7 f* X# m$ F( q: {. O9 B  `+ M
  168.     @dk_count = 0 # 用于双击的判定
    ! [+ l0 t+ m9 k+ B) ]
  169.     @clicked = false
    " a) Z" t/ U6 ?. W. ?1 Z
  170.     creat_mouse_sprite
    " i/ E0 a( r6 p
  171.     update
    / {& m+ R% a; D* Y4 n* ]4 s. {
  172.   end) `% n" \- z) U
  173.   #--------------------------------------------------------------------------
    + k: L$ C/ t. t' ]2 z. J# B
  174.   # ● 鼠标指针精灵
    ' C: ?+ l& |! e- L4 I) ~4 c2 ^
  175.   #--------------------------------------------------------------------------
    9 Z# f6 f' F: ^- o# o! j4 L( J8 B
  176. #~   def creat_mouse_sprite
    ) x% |; [. T% s1 ?. i
  177. #~     2 _$ D8 z3 T3 V, p
  178. #~       @mouse_sprite = Sprite.new% G+ L+ `5 n* I& i! j1 y4 O
  179. #~       panda = 2#rand(2)+1. f/ M2 j7 `1 I" j
  180. ; S2 v$ I+ J, f# T
  181. #~      if panda = 1
    + O) N  M# B: p0 P: d! M- ^
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    ' ~! S% \7 D8 \% t+ C# s
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')6 w+ {0 u8 q% }% K. G) w8 i
  184. #~        end#with if File.exist+ t6 y; c8 M. j5 ?
  185. #~   
    ; Z2 Y0 i) ^6 g4 X* B
  186. #~     else if panda = 2 #with if panda=15 Q; R. l& y# F0 k2 M+ l; \
  187. #~      3 x. _" I" I2 ]8 \
  188. #~      if File.exist('GraphicsSystemCursor2.png')2 Z" S+ o( R$ N7 L$ w5 U( J" i/ ]
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')
    * k- n3 b, }) S( W1 M
  190. #~      end#with if File.exist' j0 g! |/ D8 P3 t+ y1 `# ~
  191. #~       4 M6 [# O  E2 v
  192. #~     else #with if panda=1# U6 z5 t" p; _) T
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)2 N5 C5 Q4 q5 c4 Q
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),( V0 z. r, c+ p/ D$ A) V. l2 i
  195. #~       Rect.new(5  24, 24  24, 24, 24))1 l  r5 O, @3 l7 e
  196. #~     end#with if panda=1
    7 R$ m3 V+ t2 I: h$ Z5 j
  197. #~     
    , F* j9 m# k- P7 G, g0 W% E1 Z
  198. #~     #with def
    8 y4 N6 A2 f; h$ w
  199. #~   end
    ! X/ ?5 p$ K1 h# W9 I: i
  200. def creat_mouse_sprite. O! }8 r0 h! w8 v0 f0 B6 w5 ^
  201.     @mouse_sprite = Sprite.new8 o7 s- e3 A- f" u2 z
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    . W' ?* q" L! X9 k0 O
  203.     @mouse_sprite.z = 9999! W( `1 ~8 x" H! D, Y/ {
  204.     Show_Cursor.call(0)
    ' O- _5 g4 S" `& w4 [, v# z, j; W
  205. end
    - @9 e. Z5 Q) t9 z( u) C5 B

  206. " A" W/ H8 N. N) F
  207.   #--------------------------------------------------------------------------' y6 z+ F' d+ I1 }% z
  208.   # ● 更新
      j" z5 k( X1 h) L
  209.   #--------------------------------------------------------------------------; J! |4 Y- Y8 ]- r; v, K, m9 V
  210.   def update
    * d' d! L2 R3 S2 I8 N; C* K7 P
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos  [- Q  {3 k+ ?0 q+ L2 A
  212.     left_state  = Get_Key_State.call(0x01)) f8 ~# `" ~0 _2 q9 X* x8 T
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    5 Y( D) i$ F  M- |3 x8 |0 X8 ?
  214.     right_state = Get_Key_State.call(0x02)
    * q0 D' g- m+ u; b/ D% \
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0* L+ e" b  B3 j# }% R
  216.     update_double_click
    + |0 Q" I, n: X* z- |8 _2 S
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1) b4 _; `2 `1 Z
  218.   end
    $ ]/ N' U/ r2 B; i8 V+ I, C
  219.   #--------------------------------------------------------------------------* r1 `: t2 \, R4 |3 Z' t
  220.   # ● 获取鼠标坐标5 C8 n* i* g: Z. e6 n' w
  221.   #--------------------------------------------------------------------------
    % h2 s0 N( e+ j1 x1 w4 N
  222.   def get_mouse_pos
    # X# S' V. P2 u% T0 }$ H& O
  223.     arg = [0, 0].pack('ll')5 K' j2 G2 b4 W' L: ?' k/ l
  224.     Get_Cursor_Pos.call(arg)' a; e) w  |: l1 {+ E
  225.     Screen_To_Client.call(Window_Hwnd, arg)
    ; H* n3 O: l- J; Z; N9 K1 M- _: P
  226.     x, y = arg.unpack('ll')
    ! q/ y  x1 s- g
  227.     return x, y& h1 m5 C8 S! D
  228.   end5 i! g0 N8 L: r% I
  229.   #--------------------------------------------------------------------------
    * T8 z4 ~& s% b7 W* g; l
  230.   # ● 将鼠标固定在屏幕内
    . H  U+ v) s1 Z
  231.   #--------------------------------------------------------------------------
    4 y5 D; l& `  h$ W
  232.   def lock_mouse_in_screen
    9 X5 X6 z/ w( j7 Z3 r4 T( r
  233.     arg = [0, 0].pack('ll')) Q* X  r% e. |9 {$ n
  234.     Screen_To_Client.call(Window_Hwnd, arg)
      h  |. T" u1 t1 ~
  235.     x, y  = arg.unpack('ll')+ Y( P8 _5 a/ }- E8 x2 S; d& a
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    + y/ K! h' J8 ?) ?
  237.   end
    - A( [+ v1 W& |, B' P& D; Y
  238.   #--------------------------------------------------------------------------# c$ G; o9 d- R8 _" Y6 B
  239.   # ● 解除鼠标固定4 u  R+ ]7 T; x/ r+ d, x4 i
  240.   #--------------------------------------------------------------------------
    9 Y' L: q5 O% \$ B& V' G
  241.   def unlock_mouse_in_screen
    1 b3 T' y# ]9 I* C' I$ x
  242.     Clip_Cursor.call(0)
    9 E; M5 t" m1 l; `7 i: ^3 w
  243.   end
    / F' U0 w3 @. U9 B- d5 k- p# B( }
  244.   #--------------------------------------------------------------------------4 v& B+ m# }, c( O" N3 o2 P/ J" c
  245.   # ● 鼠标双击判定; M6 I3 {* `+ s7 O: d3 T( E
  246.   #--------------------------------------------------------------------------0 k2 r4 G* y7 r
  247.   def update_double_click
    1 G" T3 ?3 D7 O9 ?1 T
  248.     @clicked = true if @left_state == 1  b' B1 {/ o' k9 P) t! I1 \
  249.     if @dk_count  0 && @left_state == 1& \* j1 W" l1 D* l2 x/ e# Z2 X
  250.       @dk_count = 0; @clicked = false
    6 N# T: e! E: \; c7 H# N& k* s
  251.       return @double_click = true; E# d( ~9 I( G; V" a
  252.     elsif @clicked
    7 m2 t, [' _0 q
  253.       if @dk_count  KsOfSionDbclick_Frame( E1 S, b' \9 O* J# ^$ T- r
  254.         @dk_count += 1
    % T8 V8 Z2 K% g3 ^% ~, n( f
  255.       else
      H+ X/ R" r; I# `6 f; C; x
  256.         @dk_count = 0; @clicked = false
    5 g; Q# D4 b8 Q' B2 t
  257.       end
    ' o+ q" A! M  H2 b% U
  258.     end
    5 R. d9 H) \) `, j6 k7 c8 }6 u
  259.     @double_click = false
    2 P8 p. u1 A  H" o  W7 T
  260.   end/ U7 n5 p9 o8 t3 P
  261.   #--------------------------------------------------------------------------
    0 V" T. p, Z& W# I
  262.   # ● 按键被按下就返回true
    - [1 |% _6 z5 O1 X' w
  263.   #--------------------------------------------------------------------------
    % q5 W1 j4 t$ [
  264.   def press(button); _- L. B+ |9 n) u& h4 E
  265.     case button
    5 H* [; z$ }* N
  266.       when 0x01; return !@left_state.zero
    / I6 P0 ?7 t: H2 i9 O7 T
  267.       when 0x02; return !@right_state.zero5 e+ E8 B% I1 y/ o  G
  268.     end
    , l, N  F+ N9 ]8 c. a% a0 C, ]
  269.     return false
    & F. U, R; s3 S0 {! `
  270.   end" C$ ~2 \. P4 g6 m) N
  271.   #--------------------------------------------------------------------------5 v& I8 B* T' F; U- f0 K3 ^
  272.   # ● 按键刚被按下则返回true/ y! j! E1 j  A* n4 Z! h' e
  273.   #--------------------------------------------------------------------------7 i3 x- a2 O9 r1 ?+ U
  274.   def trigger(button)
    : D$ c% D6 l# Y4 T6 t
  275.     case button
    ) h# L* n# H( o. g4 o( a4 o
  276.       when 0x01; return @left_state == 14 V8 |' K0 u2 C3 j
  277.       when 0x02; return @right_state == 1
    ; e7 T7 ^, U2 u( A  R
  278.     end; V' H1 T" R: I# o- Z" Y3 k
  279.     return false
    ; U) t4 h/ V7 E0 O% v
  280.   end
    ! f- Z- k7 Q  Z! @( x" J0 d
  281.   #--------------------------------------------------------------------------% s2 ^( j1 ~, `; X, r
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true  j0 k6 U; i' g8 i. V! b
  283.   #--------------------------------------------------------------------------
    6 \& T9 W" Z0 C: y2 j
  284.   def repeat(button)
    6 S/ ~( k1 z1 f! o
  285.     case button
    9 o; N* n) Z7 Z7 _
  286.       when 0x01; return @left_state == 1 ! A- j- D- ~. _& \8 S, q
  287.         (@left_state  22 && (@left_state % 6).zero)+ r# c+ K' J7 {8 g- T* s. n; T
  288.       when 0x02; return @right_state == 1 9 k! r8 B6 y% \/ x9 M- D5 ]7 A  N
  289.         (@right_state  22 && (@right_state % 6).zero)
    , e/ S. R" |# E6 k! O
  290.     end
    ; M% U7 b6 o( J
  291.     return false
    * \, J/ U. I2 e7 y) n
  292.   end
    ! p  l8 y! S! Q) t7 W/ V
  293.   #--------------------------------------------------------------------------
    % C8 e  ~7 Z- d; I1 u+ O5 w
  294.   # ● 判断是否双击鼠标
    ; r2 W; N! q* S% j
  295.   #--------------------------------------------------------------------------4 e/ |! A2 U% _" g7 e9 ~7 V
  296.   def double_click
    0 i& i5 `4 q9 I9 I
  297.     @double_click7 N+ v; F) F, l/ C6 @
  298.   end! |4 i! F' L: @7 p
  299.   #--------------------------------------------------------------------------" J' O7 E, B% c( S* R# |
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    : z( b! L3 z% @8 ]
  301.   #--------------------------------------------------------------------------4 h6 W) O' b9 H" E* E
  302.   def click_count5 y$ p9 a6 ~. S" v7 r7 M8 k
  303.     @ck_count
    0 v' W  u; z; s- T
  304.   end
    . E5 h% Q2 M0 A" [
  305.   #--------------------------------------------------------------------------
    + R3 T  i& l7 J. H: V2 c0 a
  306.   # ● 获取@left_state(按住左键每一帧+=1)5 ^/ u, C% @  @5 F/ o$ I7 G
  307.   #--------------------------------------------------------------------------
    ' d5 h( T  R" k  ]' q- C
  308.   def left_state; R/ }7 p2 H* c4 g& e6 @
  309.     @left_state
    5 l. K$ A' a) B7 p+ n4 r% ^
  310.   end
    1 u0 ]) C( O# Z3 f
  311.   #--------------------------------------------------------------------------7 O* M, Q+ f# A- i
  312.   # ● 获取鼠标的x坐标
    ) ]  _6 }6 d5 B, U" }% D: y) O+ n
  313.   #--------------------------------------------------------------------------
    6 z3 O9 i* |, t5 ~. B$ E
  314.   def mouse_x
    3 Q/ i, A& \: @: K8 i3 q
  315.     @mouse_sprite.x( v7 |) e9 H+ V+ @1 a
  316.   end
    $ c! x6 p$ T& a6 T: Q8 `& l* \
  317.   #--------------------------------------------------------------------------
    : g  L6 L! B& u. E' q
  318.   # ● 获取鼠标的y坐标7 J% A" U1 [% o
  319.   #--------------------------------------------------------------------------
    . u# A* Q" V) _- f8 _: Y2 t
  320.   def mouse_y
    & o' G; u% k$ k0 K8 I* W, G
  321.     @mouse_sprite.y" ]7 {  w3 a9 B2 T% v
  322.   end0 {7 X8 h! C9 T8 S/ g, g6 C! R) r4 `
  323.   #--------------------------------------------------------------------------
      }6 _6 H% x! H: ?. r- ~( D
  324.   # ● 设置鼠标坐标; Z8 b& P# s0 S5 C7 J
  325.   #--------------------------------------------------------------------------9 S& I% [5 J4 L  W* s: Q
  326.   def set_mouse_pos(new_x, new_y)
    ) A6 |% U+ ?3 q; @! @
  327.     arg = [0, 0].pack('ll')
    9 g( g0 W% O' E' o
  328.     Screen_To_Client.call(Window_Hwnd, arg)
    ! T) |! X/ i# P& X
  329.     x, y  = arg.unpack('ll')
    ' c0 L$ }" S$ I
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)" n0 {6 @' F$ U' C
  331.   end/ s2 P$ s/ A& c' ~4 H9 J3 U
  332. end #end of class  self " y7 s# S- u5 J4 d% E+ P
  333. # k+ f: J; z4 ^
  334. end/ w# P) x5 z/ \" n5 B

  335. 2 E+ w( U" o( P% m6 x  t% [
  336. #==============================================================================
    * ]/ s/ a$ T# {- `! q* ~6 s" H9 [, `
  337. # ■ SceneManager
    2 o4 Z7 b+ x2 R% z6 q( O7 u
  338. #==============================================================================
    2 G" h1 f" Q3 I$ ?
  339. class  SceneManager1 |+ p' Y" f! O5 K3 ~
  340.   #--------------------------------------------------------------------------
    8 x4 _3 d6 m0 i. I
  341.   # ● alias
    2 G# o" j' V$ V/ @' H
  342.   #--------------------------------------------------------------------------6 ?+ v; g1 h  N, J2 r
  343.   unless self.method_defined(sion_mouse_run)
    : k$ }+ t9 C+ E* M8 F" \
  344.     alias_method sion_mouse_run, run
    & R, i2 V! K2 `5 A& M4 q
  345.     alias_method sion_mouse_call, call
    7 Y+ i* r. R, l: o: N6 m/ K
  346.     alias_method sion_mouse_return, return9 c3 M$ ~6 q4 |9 o% c6 a
  347.   end
    0 S( m" i3 m) C, p- |- F
  348.   #--------------------------------------------------------------------------" a3 w+ F6 S1 z2 r  S7 O
  349.   # ● 运行
    2 a9 A- ^& f: Y
  350.   #--------------------------------------------------------------------------5 p3 r. j$ ^# a/ \
  351.   def run
    + z3 h' C( D$ I  \; m* q. F
  352.     Mouse.init
    # A4 W7 |% i$ H! n
  353.     sion_mouse_run  X! C4 x! B, y
  354.   end6 z9 I! l! y/ l" x3 R
  355.   #--------------------------------------------------------------------------
    + R. A1 a$ a- }  h
  356.   # ● 切换
    7 O# |1 s; @$ o( _6 E, r' M
  357.   #--------------------------------------------------------------------------. E! O4 E% j$ a2 I9 R3 j
  358.   def call(scene_class)) P6 l6 c% ?  ~* q" c
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)* j# d% h1 u, j/ L/ M2 Y
  360.     sion_mouse_call(scene_class); B5 ^+ v7 A) r+ ~4 V
  361.   end
    * R5 Q' Z1 T0 c. R8 z
  362.   #--------------------------------------------------------------------------
    & w+ m' R6 }$ T$ g4 F" n2 G+ Y! Y
  363.   # ● 返回到上一个场景4 K" `% v3 H; H* X
  364.   #--------------------------------------------------------------------------. H& b( V. a) r( G
  365.   def return
    ; I' Q- a$ v3 }# ^. O" R" N
  366.     sion_mouse_return; z* i( U) [8 F$ h
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&# h" S2 D9 Z3 w" v3 A. o0 r
  368.       @scene.instance_of(Scene_Map)' R3 g$ ^+ E: `& _0 c6 Z4 j
  369.   end: W& x5 e" n" L- H. Z& T
  370. end
    4 W3 M4 ~% t' U+ f- G( g

  371. . I) e: }: ^# [& [/ z( y
  372. #==============================================================================1 ~1 Y) ?2 @1 M7 {' b* M3 _0 W
  373. # ■ Module Input
    2 e& ^! b9 x) U; l8 f
  374. #==============================================================================
    6 D! T. q, f( }' T
  375. class  Input* K  b- C% S" \8 a- C0 J4 m2 ?* [
  376.   #--------------------------------------------------------------------------) q) _* z; s3 x  I2 q
  377.   # ● alias3 r) h* b6 l2 s/ M0 o; T7 }$ c  ~
  378.   #--------------------------------------------------------------------------
    ; w, I( x+ d- m. u) a4 G1 c
  379.   unless self.method_defined(sion_mouse_update)
    2 N! c7 k; O& I. |6 K. ?" v5 A
  380.     alias_method sion_mouse_update,   update# F9 @1 X0 _, j
  381.     alias_method sion_mouse_press,   press
    + }5 O7 O2 Z- d+ e1 r8 u8 F
  382.     alias_method sion_mouse_trigger, trigger% v: T2 x# I% V, c) y6 V
  383.     alias_method sion_mouse_repeat,  repeat, ]1 U0 {( }5 }5 g1 y0 {+ o% d
  384.   end
    9 F& X+ G. w; b
  385.   #--------------------------------------------------------------------------
    0 ], X: P5 u/ W" @/ ?7 U, w9 d2 o7 l
  386.   # ● 更新鼠标& M2 B, X; C" U; J
  387.   #--------------------------------------------------------------------------
    2 j8 b4 L/ r- V6 f3 i5 E5 v9 A
  388.   def update; B) k* M5 J7 T; D0 l; l2 Z
  389.     Mouse.update4 }3 Q2 U% X6 ?( o  [
  390.     sion_mouse_update- A# Q: F/ o! \% b  R
  391.   end
    + Q+ L2 h+ E6 a* k) I% Z
  392.   #--------------------------------------------------------------------------
    ' k# C. A7 H( k' Z! r4 A. o* Z
  393.   # ● 按键被按下就返回true1 f/ K: f4 Y( v! A# T
  394.   #--------------------------------------------------------------------------
    . o6 l. S1 y' X
  395.   def press(key)8 w/ s1 _% a- x! _" p& C1 o. `
  396.     return true if sion_mouse_press(key)
    4 b, r' D$ W- A1 [* d: z
  397.     return Mouse.press(0x01) if key == C
    - k$ a. h7 w  v: k. N
  398.     return Mouse.press(0x02) if key == B, U; L  M  H4 a$ n
  399.     return false9 h- a7 k7 Y2 v% y) A6 D
  400.   end
    # o. ?3 m# r5 e! S" s1 p
  401.   #--------------------------------------------------------------------------
    ) x7 Z3 A. ]0 v& d1 r3 z; d1 @+ c6 J
  402.   # ● 按键刚被按下则返回true3 K7 F4 m8 L$ v/ M
  403.   #--------------------------------------------------------------------------# o/ d) P/ m5 q& A% x+ m! K
  404.   def trigger(key)0 h) f" N7 [- a! \7 u3 E$ A& t" m- n
  405.     return true if sion_mouse_trigger(key)
    7 E0 ]  Y4 g: Z: N! @7 N9 g; t6 B, `
  406.     return Mouse.trigger(0x01) if key == C
    0 H/ }+ J' `& b7 A4 r- ~
  407.     return Mouse.trigger(0x02) if key == B
    4 N4 E5 n/ p/ T5 D/ |' E* H
  408.     return false5 [2 G) o$ }( Y5 p
  409.   end
    , g% k" N. `. I! X
  410.   #--------------------------------------------------------------------------3 w" ?6 V' P6 t4 v+ Z
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true% y8 D& h2 I/ g. v, r
  412.   #--------------------------------------------------------------------------) T( n4 N- q. h9 b8 }3 ~* m3 |
  413.   def repeat(key)
    / }) y) q0 J: M- a8 b
  414.     return true if sion_mouse_repeat(key)* w- t7 w! }! ?
  415.     return Mouse.repeat(0x01) if key == C
    7 ?6 s/ `2 `; l, e+ p
  416.     return Mouse.repeat(0x02) if key == B
    9 n( ~% h3 u$ p
  417.     return false
    8 @8 G6 U& R  ]6 \, [
  418.   end
    * D9 j8 v% A( k2 q; x, q! i( p
  419. end, C) P2 @& p) K7 C, v$ q! S

  420. ; h* i% Q+ ~5 M; J3 g
  421. 9 @, X4 E5 I6 }3 W4 h4 W" ^1 R
  422. #==============================================================================5 k. f1 x* ]; r! O
  423. # ■ Window_Selectable
    4 O, R6 y/ R' K8 |" ?' E0 P
  424. #------------------------------------------------------------------------------) o$ ~# c4 a3 W, \2 }: V
  425. #  拥有光标移动、滚动功能的窗口9 K5 L$ ~: \# F) \! n) n3 k+ f
  426. #==============================================================================
    . _4 V2 ]  l7 M: @3 [% A
  427. class Window_Selectable
    $ o  `7 {/ |: j( c1 I% }6 D
  428.   #--------------------------------------------------------------------------
    . J2 \0 O+ ~2 S& t: a
  429.   # ● 初始化$ Y) d# Y3 S+ H& g
  430.   #--------------------------------------------------------------------------/ O2 e4 m( B* j! ^; v: R
  431.   alias sion_mouse_initialize initialize
    6 I' K# g4 B6 Z$ t3 l
  432.   def initialize(x, y, width, height)4 {- n/ X8 U: a0 N! t
  433.     sion_mouse_initialize(x, y, width, height)
    ) A! T4 x; ]5 i2 `' d+ [, I+ P* P+ Y
  434.     @move_state = 08 B( _- p9 v& l! X) m! Q/ u
  435.   end
    + c4 _  w! l. G" T1 \& h; T6 J8 m5 E* ]
  436.   #--------------------------------------------------------------------------
    ) u, l5 r8 {% C/ a. E
  437.   # ● 更新
    ( x+ S" i* S/ y# S/ }
  438.   #--------------------------------------------------------------------------
    % u' u4 C0 G" L  _3 j
  439.   alias sion_mouse_update update' c) @6 w7 T, V0 g5 f% f
  440.   def update; i8 n. C) h- y* D
  441.     sion_mouse_update
    + r% Z% i  L7 c+ E' j. G6 j
  442.     update_mouse_cursor" W$ o7 F: ~. G, L0 `0 Q0 J
  443.   end  k- S+ E; D" B5 o
  444.   #--------------------------------------------------------------------------: I! ?6 A* u1 g) U- L7 H7 l
  445.   # ● 启动后设置鼠标到index位置
    % O% o/ m0 f/ q/ l* m/ b
  446.   #--------------------------------------------------------------------------3 m! v6 Z$ v6 h0 D
  447.   def activate- C; A, W$ E$ G* g! r
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos. Q  s- g" P) S
  449.     super6 \; d3 K* M( \. b% e
  450.   end
    & q5 \+ j' {3 }5 X/ M# |& z9 i
  451.   #--------------------------------------------------------------------------
    ; v% @* \& [+ }( |7 x2 a0 M
  452.   # ● 更新鼠标和光标的位置
    : M+ H4 y: H& w. e6 Z6 K$ Y& G
  453.   #--------------------------------------------------------------------------
    : Y3 k& ]0 s7 `: G% V$ n
  454.   def update_mouse_cursor* x3 i1 X; f8 k4 F6 X: r
  455.     if active7 C, q8 L4 `6 P6 w
  456.       if @need_set_pos
    ) t" U2 O$ m/ N3 a% K" r
  457.         @need_set_pos = nil, f) U- O7 t: K! u* i! F
  458.         set_mouse_pos
    8 u$ ~7 w; m  p) Q# p/ s3 L* {
  459.       elsif cursor_movable
    6 Y; E" u7 N4 f4 M7 m1 r* Y) v
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    ' I* d& x" L9 R
  461.       end) u' V* O* M9 g9 k6 U
  462.     end
    ) \9 f4 ~* ^! @" O  A
  463.   end
    : ]' y8 Q* k" G: p
  464.   #--------------------------------------------------------------------------( u( V3 B9 p4 \' k
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    * h" h# ]& |1 f
  466.   #--------------------------------------------------------------------------
    1 ?( U( K7 X% Z, X- p
  467.   def set_cursor4 l. l) L2 m( ~: M
  468.     mouse_row, mouse_col = mouse_window_area5 J/ K) Z- R% c6 v( @7 I
  469.     if    mouse_row == -1
    & C5 m% o' y/ m2 m  C  L) u" [
  470.       @move_state += 1 if need_scroll
    4 B/ q0 v8 s( n/ V( ]" A
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    $ N2 [; H+ {7 e" d2 G7 c
  472.     elsif mouse_row == -29 c  z$ K. H- t4 E$ I  W
  473.       @move_state += 1 if need_scroll: s, p; k4 o  K) W: @0 P
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand! z  G# F4 e* ~
  475.     elsif mouse_col == -1* M# p6 Q* z; t
  476.       @move_state += 1 if need_scroll' `: {4 W. Z; p
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand; w( e* I2 J3 r/ B' x7 m3 B
  478.     elsif mouse_col == -2# O1 S5 U8 e3 u7 A& E
  479.       @move_state += 1 if need_scroll
    7 N! t" C( D8 z6 F( q8 V2 g1 d8 f
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand% b+ M. n7 P' Z7 B/ F" j
  481.     else
    * K/ S4 a* U* X* I
  482.       @move_state = 07 B7 F' `6 x" {, J* s$ s
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    , C! C7 X7 F" x, [) M, K
  484.       select(new_index) if new_index  item_max && new_index != @index
    / n: |) }+ Y  A8 r7 T8 v( V) P& [! M
  485.     end5 E8 D+ L* L* n+ K' C2 h
  486.   end) X, x9 P/ k9 j
  487.   #--------------------------------------------------------------------------
    & o. H4 X* P: _" ~  e3 |* `
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    ; z6 x/ M5 }% [1 ~% a0 ]) e
  489.   #--------------------------------------------------------------------------+ S3 M! J( i5 i  b  r( M
  490.   def mouse_window_area
    6 D  g& g" x9 V
  491.     if viewport.nil # necessary!
    $ p3 q: v4 s6 g! |! J7 Y0 x6 i
  492.       vp_x, vp_y = 0, 0/ C+ G( D1 v7 Y/ d3 m$ U+ u
  493.     else( N& ^, @, G$ m
  494.       vp_x = viewport.rect.x - viewport.ox, q& u9 V# Z2 ]. I+ t' e
  495.       vp_y = viewport.rect.y - viewport.oy% |% D9 K) `! W' o$ @- s: ]5 O
  496.     end
    4 W$ K- e5 j: v$ ~
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y8 ^* x8 h, ?# G/ g% k# h) Z4 k
  498.     item_x1 = vp_x + x + standard_padding 8 n: p. O, _* M9 I/ R
  499.     item_y1 = vp_y + y + standard_padding
    ; l$ q6 [+ T! H% Y7 W8 r
  500.     item_x2 = vp_x + x - standard_padding + width
    * h; _  K' e3 B
  501.     item_y2 = vp_y + y - standard_padding + height
      P# q, r$ v9 X  L+ v6 P  \
  502.     if mouse_x  item_x13 ?+ t/ Z1 @0 B3 m
  503.       mouse_col = -1
    ) H/ o8 A, f, B; }. {6 O2 H0 Y& a
  504.     elsif mouse_x  item_x23 ~* Z& G/ ?! c& t6 |, B$ Z
  505.       mouse_col = -2
    8 Y( I3 j* m$ Q
  506.     else
    1 j' y3 P/ Q; k" o2 g% d0 ]' c
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    " W" U1 R/ M3 j) e- n7 N
  508.     end
    ' ^5 W* f; M7 L: [2 G
  509.     if mouse_y  item_y10 R6 {/ k2 \) s. n/ k) ^$ O! h
  510.       mouse_row = -10 ^. ?: H# T; Z. j( |7 M5 y
  511.     elsif mouse_y  item_y2
      ^% `  T2 x/ J. d
  512.       mouse_row = -2
    ) q' V! F, a- J( N, D5 F, s
  513.     else9 O8 ~' U, Y) _( h9 \$ t, |' p
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    ( K+ x, T% u# y$ Z, E% H3 p! Y5 ~
  515.     end' \4 q$ b' D* h6 i
  516.     return mouse_row, mouse_col
    # o, }4 |4 n$ A2 T3 L2 ^# q  V/ @
  517.   end
    7 u3 I) z% i: h  X
  518.   #--------------------------------------------------------------------------2 M1 G, s. z. E! u; W: m8 k
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ; D1 K' M0 T0 F+ f4 G( f" d
  520.   #--------------------------------------------------------------------------
    . A! X. `+ i, M5 k+ s
  521.   def set_mouse_pos
    . I+ K. }$ V9 |, J, z
  522.     if viewport.nil # necessary!+ G0 l  b, Z# G$ [9 m
  523.       vp_x, vp_y = 0, 0
    8 A( u% r8 v& q0 e/ v
  524.     else
    8 ]0 q* i# K3 v3 E
  525.       vp_x = viewport.rect.x - viewport.ox
    + s2 s7 H* q5 j9 A
  526.       vp_y = viewport.rect.y - viewport.oy
    6 ~, L$ Q6 Z6 j/ g8 j' G
  527.     end
    5 N. b0 u/ G+ h1 N
  528.     item_x1 = vp_x + x + standard_padding
    / }. j2 e% J+ p. p/ l
  529.     item_y1 = vp_y + y + standard_padding
    4 Q, d' h/ A, |# |
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    ) }. \+ ]8 |5 U8 z
  531.     row = get_index  col_max - top_row5 A6 n7 E: j$ O8 l! B' M. A7 r
  532.     col = get_index % col_max3 u  F( |2 I: g0 _! w+ n! E9 k
  533.     new_x = item_x1 + item_width  (col + 0.5)
    3 r& W# A# H$ r, M+ [
  534.     new_y = item_y1 + item_height  (row + 0.5)
      ~2 y0 ~8 z8 T
  535.     Mouse.set_mouse_pos(new_x, new_y)* B4 E5 t  `" z. X+ K2 ~
  536.   end
    3 T+ k0 a  C0 x+ E( t
  537.   #--------------------------------------------------------------------------
    / S3 P# @6 y) j. ~  ]& |
  538.   # ● 判断菜单是否需要卷动
    % G$ f# t2 i" C% F% _1 g% U" w
  539.   #--------------------------------------------------------------------------
    9 w0 q+ L) m' q8 @$ }; Z
  540.   def need_scroll
    ! T7 N) T) s7 z4 _
  541.     item_max  col_max  page_row_max
    - _- q0 {( w8 q  p  t
  542.   end
    % F6 j$ g( |0 J' w( r$ f
  543.   #--------------------------------------------------------------------------
    4 o, f" o  r! U1 T2 h8 Q
  544.   # ● 判断是否为水平卷动菜单
    3 X5 j/ d" j6 {+ U& B2 U. D* [: G
  545.   #--------------------------------------------------------------------------9 p/ K" a0 m. b( p1 e, X  d( l
  546.   def is_horzcommand
    " L  T5 y) d! |, w! C7 x
  547.     return false' K/ f0 x& e8 p: R# H$ n% F  L+ r% h
  548.   end% [. p# N) k$ X$ [7 ~9 V. s
  549. end
    % K& l+ o. i; L+ \3 F

  550. & }: t9 z* V  V0 O! [& V; g# c8 u
  551. class Window_HorzCommand- z. \3 b7 a. _  y. a
  552.   #--------------------------------------------------------------------------
    7 j/ D7 U( B- d
  553.   # ● 判断是否为水平卷动菜单
    ( `5 X: c9 t8 @) ^8 o- O
  554.   #--------------------------------------------------------------------------
    9 v4 t/ X/ q) S$ K  q4 k- x
  555.   def is_horzcommand
    . F) D2 p% O8 A! L
  556.     return true
      h2 g/ \6 x- [2 x$ g
  557.   end" i1 G/ W% D( B9 F
  558. end
    . @3 k2 |& J% {. J2 l8 k

  559. ! R5 A' z  h" m1 L7 |, n2 z  ^
  560. #==============================================================================% p, e% G: H; _- b% p6 y
  561. # ■ Window_NameInput
    1 `. d9 I7 a. h4 i5 v# L$ ?
  562. #------------------------------------------------------------------------------0 M+ T3 ]( l2 l* ?& J1 V, e
  563. #  名字输入画面中,选择文字的窗口。
    % U/ I0 A- U! q% g/ E9 q( y( A
  564. #==============================================================================
    / V2 r0 P/ e8 w- v
  565. class Window_NameInput
    0 m7 u5 P/ N2 D# Y( q' J
  566.   #--------------------------------------------------------------------------' ]0 {" e( ~2 y2 ^# {9 p9 ~
  567.   # ● 设置列数
    : c: j& o' L6 y# A, l6 n
  568.   #--------------------------------------------------------------------------) q2 f& H2 ^$ i" h7 C0 `) H" g
  569.   def col_max
    . z" e$ f# `, `2 @, a& \) [
  570.     return 10# y! e0 K8 y" G9 ]
  571.   end7 e# R+ e7 E0 ^. o1 K0 g1 J
  572.   #--------------------------------------------------------------------------
    7 W; y! @4 j1 }4 k" u
  573.   # ● 设置填充的Item个数
    / o: r! `5 E) S. ^, |5 g
  574.   #--------------------------------------------------------------------------
    2 c6 z0 b' T4 a1 a$ t/ l! _, A5 U" R
  575.   def item_max1 i: ]0 x$ J" L
  576.     return 90
    0 n, |/ L6 A" Y& k# g7 t  ^: Z- H! @
  577.   end0 J: E7 z& J) {/ Y) g' w# t
  578.   #--------------------------------------------------------------------------* U# N0 ?/ a4 ^
  579.   # ● 设置填充的Item个数" y/ J. Z7 `8 F
  580.   #--------------------------------------------------------------------------8 R8 q# ~% C' C3 g
  581.   def item_width  c, K% D( Z  X3 O( B: ?  P
  582.     return 323 ~5 l6 j4 T  M6 l* Q  F- V
  583.   end
    6 ?9 d$ d/ k, E# X8 ~
  584.   #--------------------------------------------------------------------------! A) e' P2 L4 L! B; Q
  585.   # ● 判断鼠标位于菜单的第几行、第几列1 s% |4 s& c/ X' D6 \+ ~
  586.   #--------------------------------------------------------------------------, \! l" \# U/ O8 ~
  587.   def mouse_window_area1 D6 T# s# I$ y& o7 ~: n1 S
  588.     if viewport.nil, j# S2 P4 U- P$ l1 M5 K
  589.       vp_x, vp_y = 0, 0# u9 o0 N0 X  w. c1 j+ T4 z; s
  590.     else% `+ N& w7 J* y7 M" _8 T. M: R
  591.       vp_x = viewport.rect.x - viewport.ox
    ) F  Z3 W: g: N+ K8 e
  592.       vp_y = viewport.rect.y - viewport.oy+ m# ?& |- p# A# K2 U( F. n
  593.     end. e" P0 k5 K# }) X
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    1 S( V4 v; {- L3 N6 B
  595.     item_x1 = vp_x + x + standard_padding % d; j4 z9 f/ `) O+ s' a
  596.     item_y1 = vp_y + y + standard_padding6 l$ d: N& s! p& ]; V3 d+ H4 g8 D
  597.     item_x2 = vp_x + x - standard_padding + width7 @/ i, z+ j0 O1 L* Z! K8 Q! `: `
  598.     item_y2 = vp_y + y - standard_padding + height
    9 d( }6 G  D7 N7 X/ s& p5 S
  599.     if mouse_x  item_x1- t* g. y5 @" J: R2 |
  600.       mouse_col = -1( X" V  [# O4 N5 L; v/ Z
  601.     elsif mouse_x  item_x2
    % d/ O/ H: _. D
  602.       mouse_col = -2; k- F! X1 ~2 U, a* h
  603.     elsif mouse_x  item_x1 + 160, _6 N2 L% _. n& ]- Z* O0 P% X6 x  k
  604.       mouse_col = (mouse_x - item_x1)32
    8 E) L: x6 F( b+ J
  605.     elsif mouse_x  item_x2 - 160& A0 f3 I8 h+ ?+ I4 S8 W1 @3 |3 o
  606.       mouse_col = 9 - (item_x2 - mouse_x)32( W9 j( U; T7 W. A
  607.     else: Z6 x( l4 \* M+ b. T+ J% n
  608.       mouse_col = mouse_x  x + width2  5  4) G4 b: C* h% ~2 C
  609.     end+ k3 ?) Q3 w$ Z( K  ]7 U
  610.     if mouse_y  item_y1, f+ {9 c* c6 W/ a0 d
  611.       mouse_row = -1
    , v& J+ W' [- ]& W
  612.     elsif mouse_y  item_y2
    " d* P' Y5 G. I+ E$ V7 p  P
  613.       mouse_row = -2
    , D* i0 g+ \9 {8 `+ a# Z+ ~
  614.     else) B" r- B/ V1 _( H3 d% s
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    4 r' R; i4 F( S' {
  616.     end
    ; v$ c+ f) d) S" n
  617.     return mouse_row, mouse_col
    ! ]. h! [( U8 A" `2 F
  618.   end
      u2 |/ V5 l0 Z2 q+ S
  619.   #--------------------------------------------------------------------------
    ; E1 w' D' Q& k1 q# J1 b
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置3 x& q# @7 B: j/ J+ _" u' N
  621.   #--------------------------------------------------------------------------2 d% `" f3 z' X: h
  622.   def set_mouse_pos5 B; I# F& T1 b& _) W5 \. N
  623.     if viewport.nil # necessary!
    0 L" }: E5 f& h& Q$ o2 H
  624.       vp_x, vp_y = 0, 0
    & ~0 q2 }. X3 u7 r0 e! L4 y1 f
  625.     else$ u4 K& l' Z! k# y
  626.       vp_x = viewport.rect.x - viewport.ox
    ) d5 G1 r2 r! G0 L7 |
  627.       vp_y = viewport.rect.y - viewport.oy
    ( U' z# |, B( ^) f3 M; `/ U$ }+ T3 R
  628.     end" ~& _* F7 P2 p* t
  629.     item_x1 = vp_x + x + standard_padding
    7 R9 \. A7 A0 H, p$ c" B
  630.     item_y1 = vp_y + y + standard_padding- N9 c4 W; a0 O; r% x: B
  631.     get_index = @index  0  0  @index
    ; x8 @. y6 L7 l2 ?0 a
  632.     row = get_index  col_max - top_row
    ! q" \0 P8 S2 D2 H- d6 O
  633.     col = get_index % col_max
    * e/ ~* b" d7 [: S& c* y
  634.     new_x = item_x1 + item_width  (col + 0.5)1 u+ T8 E* {2 H6 Q; v
  635.     new_y = item_y1 + item_height  (row + 0.5)& I5 K- P; c3 w2 V# b: g6 f
  636.     new_x += 14 if col  4
    : `) G7 i$ G3 P; b
  637.     Mouse.set_mouse_pos(new_x, new_y)( g# `" u3 d# ^; G; S
  638.   end
    4 q3 J$ t; {5 A; B( W3 G  n* J' u
  639. end* S# ]  q: y' J3 g+ V

  640. & @5 z" L  U: W- P9 W4 k1 C/ j
  641. #==============================================================================- {. \6 U1 c# v) S
  642. # ■ Window_NumberInput8 G, b9 b2 O4 Y  ~/ j
  643. #------------------------------------------------------------------------------1 D5 [' v$ g6 O5 C' y! }" ~
  644. #  重写了数值输入的方法以适应鼠标- d# f! S# d( N: M
  645. #==============================================================================
    2 O& G, H  N+ d5 C5 b  }4 P0 ^
  646. class Window_NumberInput  Window_Base& \; p: H  o/ f& W
  647.   #--------------------------------------------------------------------------
    & f9 b; ]. G' W; [' u- k6 b2 ]# A
  648.   # ● 定义实例变量0 j7 [* C) u! {! y
  649.   #--------------------------------------------------------------------------
    % s5 p' |& C7 l! s$ j
  650.   attr_reader extra_window
    " F- `2 @9 R/ }1 S% C
  651.   #--------------------------------------------------------------------------4 e9 w, ]; E% r" n# }
  652.   # ● 初始化) c; c' j9 m( I9 k4 {; N8 ~
  653.   #--------------------------------------------------------------------------
    ) b: r8 D( ]2 _( u7 m& E, z3 C; M
  654.   alias sion_mouse_initialize initialize" H  a: T$ M( W. Q! d* t6 }
  655.   def initialize(arg)
    3 m5 L2 M: {4 b3 c) X% o  L
  656.     sion_mouse_initialize(arg): r% f% B: E/ ?
  657.     create_extra_window
    1 t+ c! g4 }- c' z; j
  658.   end
    - k$ h- r; D4 |. n0 }
  659.   #--------------------------------------------------------------------------
    * \0 G. _" G0 T1 Z' g: k  s
  660.   # ● 启动& `7 X" \* f7 {
  661.   #--------------------------------------------------------------------------
    8 }5 Z; S: V0 g" G, S1 t
  662.   alias sion_mouse_start start
    - p5 [5 p0 h8 q+ W: J- x( h6 S
  663.   def start
    ! E' F( U' F: x. Y
  664.     sion_mouse_start+ s5 ^/ N4 J; e. ]
  665.     deactivate
    8 S7 Y# e) [  F
  666.     extra_start
    / ?( I+ P! C) k1 @! d) |
  667.   end( a' G  H- t3 l5 {9 N3 d3 r8 ?
  668.   #--------------------------------------------------------------------------
      Y: K# N- Y7 C
  669.   # ● 创建新的数值输入窗口
    $ \4 d. O( h! T. [6 B; _
  670.   #--------------------------------------------------------------------------( p& Y1 L& o/ s' `/ R# H
  671.   def create_extra_window
    ' v: F( Z5 V, N, @8 H+ t5 U+ g
  672.     @extra_window = Window_NumberInput_Ex.new
      L0 U+ h0 G. w% a
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    & \! z8 e7 Y# P% b% D
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }: k9 T" r0 K8 t2 n) ~8 V
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    $ s- `$ q/ u% L& g" E
  676.     @extra_window.close_proc   = Proc.new { close }' x4 B* D/ Z( c3 b4 e
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    7 v& g1 N7 J& `& _8 n
  678.   end
    % K& @) {0 b) }4 t* u0 }& o
  679.   #--------------------------------------------------------------------------
    " E5 {# n. m" V/ e
  680.   # ● 激活新窗口
    " X$ X5 X' s  v) P! |0 S5 @6 g
  681.   #--------------------------------------------------------------------------5 U$ h$ M* X3 @  T, B
  682.   def extra_start2 d* z$ z/ C9 K
  683.     case $game_message.position
    & Z, Z$ c2 k5 K) r+ F" f
  684.       when 0; @extra_window.y = y + height + 4
    % G: ~: s" I  k6 R2 {5 ?
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 81 ~# p& ]# g& E: m+ }3 T
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    5 ?' n# S6 s3 g0 E+ J
  687.       else  ; @extra_window.y = 86 P" p2 [/ [2 X4 [8 L$ O) X3 c
  688.     end
    5 l& F* n& e0 z4 z' i% M
  689.     @extra_window.variable_id = $game_message.num_input_variable_id. e) x, L) E- n
  690.     @extra_window.digits_max  = @digits_max
    ' Y4 r8 j+ A% _3 H
  691.     @extra_window.number      = @number& }. ]' j1 H/ ]) `; P( {( f
  692.     @extra_window.open
    ; I2 U8 g  z" ]* y; Q" }) G+ \7 B
  693.     @extra_window.activate
    2 {" {4 x: M7 ?) e  F% n
  694.   end% s8 G7 q4 e' t  s  t0 {/ s/ }
  695.   #--------------------------------------------------------------------------
    + L, y$ T1 z  f$ q  q! i0 U% N
  696.   # ● 更新
    * y' x+ u0 f% X) K+ I9 O
  697.   #--------------------------------------------------------------------------
    , I0 U! `) H! {2 t# L8 V
  698.   def update
    4 m) B0 ~6 d' ^7 V( Q  d
  699.     super0 _$ X8 E9 D! w- |1 F' z* s
  700.     @extra_window.update
    ! ?" @' N! B0 a! W6 a0 V
  701.     update_cursor+ F) J" B$ q) _* U1 @
  702.   end9 K; ~8 W  ?$ }
  703.   #--------------------------------------------------------------------------% e, t0 j$ G3 p5 I9 ?- Z$ o. [) k
  704.   # ● 关闭窗口
    - v% V% d: @6 l6 l* o
  705.   #--------------------------------------------------------------------------
    # N. v1 V5 J# s3 ]' T- C
  706.   def close; N) @/ \" _) y2 R1 Y
  707.     super
    / S1 ~- a1 G, l' C5 g% a# J8 [5 m
  708.     @extra_window.close
    % b& J5 F" E/ F5 p7 R
  709.     @extra_window.deactivate
    % p7 ^- S0 f% A) ~7 T) P
  710.   end3 X$ t; d. y4 j  e( k
  711. end2 f! l3 m9 Z7 u

  712. ' K' A5 V5 g+ c2 y* u, y
  713. #==============================================================================
    0 w% L: p/ B! X' r3 Z( ]
  714. # ■ Window_NumberInput_Ex
    ( B* E! `- d# I) V
  715. #------------------------------------------------------------------------------
    $ w. |0 b  V' K% L
  716. #  新的数值输入窗口(NewClass)
    $ F% Q- H3 \, }9 H2 {! J& L
  717. #==============================================================================
    3 ~- H3 H; R  _* I1 T2 i# N# E/ O
  718. class Window_NumberInput_Ex  Window_Selectable9 S8 m) F, L3 `! K0 P5 ^+ K# R( t
  719.   #--------------------------------------------------------------------------3 o) l, }+ K. R! d
  720.   # ● 定义实例变量
    ) u1 E! T2 f) l
  721.   #--------------------------------------------------------------------------0 s9 F. E# N/ K7 f
  722.   attr_accessor number_proc' E6 b8 T/ m) Y* x* K# O
  723.   attr_accessor index_proc# j  D5 E% x' {% D
  724.   attr_accessor close_proc3 o" G6 e. X' d5 F* w/ l1 {( p
  725.   attr_accessor refresh_proc
    5 S( R+ l; X' b5 L1 K0 ?9 H, G) P
  726.   attr_accessor number: n# T9 b) B/ ~/ l0 n5 A; M& p
  727.   attr_accessor digits_max! e) g8 Y1 {* V: P! n
  728.   attr_accessor variable_id3 h3 d. N. b! l+ x( e' E5 g; U( C
  729.   #--------------------------------------------------------------------------
    4 H* l  G. \' A
  730.   # ● 数字表
    + L, t7 }' S  D  s0 O2 d; `
  731.   #--------------------------------------------------------------------------" J3 w; r$ y1 Y  B8 n
  732.   TABLE = [  7,  8,  9,9 H# q+ D  D) j- ?% P
  733.              4,  5,  6,
    . f3 U$ D, M( }( v6 c/ ~2 `: m
  734.              1,  2,  3,
    & j! J8 A5 e% B; q  _, @
  735.             '←',0,'确定',]
    + r4 {- q& S+ }4 y
  736.   #--------------------------------------------------------------------------5 s# o) P. w7 X$ S: q$ C& g
  737.   # ● 初始化对象
    ! v6 g' K; p' ~2 Y% G- `  o
  738.   #--------------------------------------------------------------------------
    * W, [2 `# e: a% x- r+ x$ R! w
  739.   def initialize
      |  W* Z: z  }0 I/ w+ U. w
  740.     super(0, 0, 120, fitting_height(4))& h$ c7 }2 \1 c. g  L# s- m; R
  741.     self.openness = 00 ~$ J$ E2 D1 s) p: J) L
  742.     @index = 0. l! b/ `4 C) }3 K: I: E* s
  743.     @number = 0
      w# p5 C1 [# L- f
  744.     @old_window_index = 0, k. H$ p, w$ l3 D- b6 y
  745.     @digits_max = 0
    ; J: F6 A" D+ W0 v; z" O
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }' t% W+ Y! I) {% l6 e7 ^
  747.   end! i" [; j3 ~4 ^2 U, \& @
  748.   #--------------------------------------------------------------------------3 A* l. ~6 H6 Q
  749.   # ● 获取项目的绘制矩形3 G, y; [, q2 ]" {" x/ y; Q7 h6 `
  750.   #--------------------------------------------------------------------------
    2 R: v0 ]4 T7 P" ]# p
  751.   def item_rect(index). Y- D: V& @5 o1 v3 J- w/ _. g) B! o
  752.     rect = Rect.new
    1 |' m% X0 F5 j* o3 ~
  753.     rect.x = index % 3  325 Z  I- i; f8 k. Y+ B1 ]6 S- P
  754.     rect.y = index  3  line_height
    + E5 j3 c4 T/ k& s' u0 J
  755.     rect.width = 32
      i7 a: ?' n) y" c) ~
  756.     rect.height = line_height  G- K& P+ S$ ^
  757.     return rect
    ! f" @: m  v% p/ P  |
  758.   end
    " @  ]  I& t6 o5 @
  759.   #--------------------------------------------------------------------------
    ) S- E8 s( D9 d4 H0 W! w5 D, l
  760.   # ● 将光标设置到鼠标所在的位置
    . |8 a% g! O+ P4 k4 a/ t. o
  761.   #--------------------------------------------------------------------------( }: c, K* O2 J& b; W$ {
  762.   def set_cursor
    0 O2 l2 V' c; @; \+ s8 i
  763.     mouse_row, mouse_col = mouse_window_area5 H3 n: R; Q6 \3 e5 H( u: A
  764.     if mouse_row = 0 && mouse_col = 0
    + u8 c! C9 O3 O% j6 B; j$ \
  765.       new_index = mouse_row  3 + mouse_col
    ! `+ f5 f8 ]( C
  766.       select(new_index) if new_index = 11
    ( d3 d8 v' S6 {5 a9 t) T
  767.     end
    ! G1 f+ B4 e& N, L
  768.   end
    * t  e$ ~! x5 ~( J6 |/ t5 j$ R
  769.   #--------------------------------------------------------------------------
    * i. K% l7 R7 |
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列; |: @3 t% L, d
  771.   #--------------------------------------------------------------------------% ^' N5 Q& u, k* j) R! T
  772.   def mouse_window_area
    ; `, H4 Z0 g  \% I0 r) B
  773.     if viewport.nil6 z% y6 P  s2 W9 Q  v
  774.       vp_x, vp_y = 0, 0
      [& r: w9 @# ]: e8 u  x
  775.     else
    : t$ }, C6 o( A% ]0 P
  776.       vp_x = viewport.rect.x - viewport.ox
    6 B$ f0 p0 j" [/ o  W
  777.       vp_y = viewport.rect.y - viewport.oy
    % S5 G' _, B8 Y+ h/ U( |
  778.     end
    . @0 T2 I# q( v% y
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y4 U8 O% J, c! A- n. r8 u, P
  780.     item_x1 = vp_x + x + standard_padding
    . F. C9 q& `! e9 m1 @# p
  781.     item_y1 = vp_y + y + standard_padding/ u9 }& d5 c& j( j0 o8 \. q6 N$ ]
  782.     item_x2 = vp_x + x - standard_padding + width3 D$ `" a- X. z! O8 E
  783.     item_y2 = vp_y + y - standard_padding + height/ N% A/ E/ E$ O4 U" W' T/ c3 s
  784.     if mouse_x  item_x1
    + A0 C3 h  v! q
  785.       mouse_col = -1" o# H' r2 W1 W7 z) l* ^
  786.     elsif mouse_x  item_x2! q! s0 g" l1 O0 C3 f. L  Z' v2 U, h. y
  787.       mouse_col = -2
    7 k, [2 |) o) m7 I% j, C6 K
  788.     else0 h2 O0 l; H4 A" Z) o
  789.       mouse_col = (mouse_x - item_x1)  326 J* A; ~# w0 F1 p. C/ _
  790.     end
    1 n# g3 E1 `/ r* s
  791.     if mouse_y  item_y1
    ! Z6 s2 X- T) `6 E0 S! J( @* O2 T  _
  792.       mouse_row = -1
    * u% q2 Z* m: y. w4 P0 c
  793.     elsif mouse_y  item_y2
    + m, N+ [% Q5 {7 p+ u1 R& n- u
  794.       mouse_row = -2
    8 U; }% i; z* F  d9 V4 c
  795.     else& G  M+ M: E' G" K
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)( Z4 l1 e- {+ E9 g1 I* m  p
  797.     end
    " v0 P( c% q. z1 b9 W2 Z) z! y$ s
  798.     return mouse_row, mouse_col% V2 _* D, s3 `: f7 i
  799.   end
    " ]5 h* p3 g: y$ C
  800.   #--------------------------------------------------------------------------
    : x: ~: O& }7 _: i6 z0 A; g  _7 v
  801.   # ● 获取文字
    7 U) p/ V3 q$ w4 m( S+ |
  802.   #--------------------------------------------------------------------------
    3 ~0 G$ n# g* c0 N  e6 M7 p  L
  803.   def get_number
    ' O6 `) [0 d) `% w  Z5 c: N2 H
  804.     return false if @index == 9  @index == 118 h* f7 ^* E  ?( p, w% Z4 V. ^9 |* |
  805.     return TABLE[@index]
    8 H5 D) w8 \" P; e7 j; M# N1 q% _
  806.   end3 I+ }% s0 l+ T
  807.   #--------------------------------------------------------------------------% v0 J# e/ K: R1 g! `
  808.   # ● 判定光标位置是否在“退格”上
    4 `, f% _# L, m
  809.   #--------------------------------------------------------------------------. ]% r" b3 i2 [) C
  810.   def is_delete
    / D! y$ ^1 F1 q$ d
  811.     @index == 9
    ) I- ^. f3 R$ q+ Z. S3 B5 q+ W
  812.   end
    3 s4 n$ L: k6 U; J
  813.   #--------------------------------------------------------------------------* _7 j  Z( i5 a
  814.   # ● 判定光标位置是否在“确定”上) |4 Y7 d: t( S; f3 y8 N
  815.   #--------------------------------------------------------------------------
    ' U3 ?2 w6 F, V: Q1 e& P
  816.   def is_ok+ t. K# L0 l+ H2 J" m
  817.     @index == 110 Y9 ~) _. [7 }2 r2 P- A5 E
  818.   end) j  K3 A/ i% Q% U5 v
  819.   #--------------------------------------------------------------------------
    4 I8 t( [/ s4 y) L  d/ z8 p
  820.   # ● 更新光标) y  @6 }2 ]1 v& E. c
  821.   #--------------------------------------------------------------------------
    ) R; |+ N; V/ F) {) y1 U2 Q
  822.   def update_cursor
    + W/ q& \. F6 \* k1 v2 x; e; @
  823.     cursor_rect.set(item_rect(@index))5 l6 i; T7 o5 }, p' V& G
  824.   end
    ( x4 B5 Z  G2 X
  825.   #--------------------------------------------------------------------------
    ! y1 s; W8 m, {: p1 p3 D$ v
  826.   # ● 判定光标是否可以移动
      N( [' R* z9 W7 p0 Q8 I
  827.   #--------------------------------------------------------------------------4 O: N& z% B& q* Y
  828.   def cursor_movable
    + b6 w( a  U) `2 E/ W
  829.     active
    7 \; h0 ~6 F6 y* f* g% c% r
  830.   end- z/ V+ I9 ]0 r' {9 u' k# x
  831.   #--------------------------------------------------------------------------2 l3 J+ v5 ]0 D
  832.   # ● 光标向下移动
    - z* s; m/ @" P
  833.   #     wrap  允许循环8 q1 m1 c; P# n0 a
  834.   #--------------------------------------------------------------------------
    5 m% k: T) t& F7 Z7 D4 i6 _
  835.   def cursor_down(wrap)
    ) x" X% N7 b; i8 n- j0 W: r/ B
  836.     if @index  9 or wrap
    , N& ]7 d* A( i. p5 @
  837.       @index = (index + 3) % 12
    ! Y$ n4 {7 O  W" a- q0 ^
  838.     end0 |: r; g6 @% N& F" ^- f
  839.   end% y! U' k- c6 M. c5 ?+ v- a
  840.   #--------------------------------------------------------------------------
    9 N  v* j. @4 s4 t
  841.   # ● 光标向上移动
    ! O2 q% n2 O) D3 p& |
  842.   #     wrap  允许循环
    * l, C/ I: k; h7 ~; ~5 P
  843.   #--------------------------------------------------------------------------
    ' f/ Y" @$ Z- h) {5 V9 w( O
  844.   def cursor_up(wrap)
    & N1 q$ u) h2 B6 ]
  845.     if @index = 3 or wrap% D! y+ f, V% W  u' k9 x7 ]
  846.       @index = (index + 9) % 12
    , [( E+ \. o7 r- H1 u& l0 j
  847.     end
    5 ]& U/ M, q- v2 e% j7 |
  848.   end
    ; z* q  M& t! @3 J
  849.   #--------------------------------------------------------------------------( Y2 l* @0 ]+ y: `9 G5 P
  850.   # ● 光标向右移动7 L. ?. v8 K8 N3 V: ^( {  k$ \" j6 `0 |
  851.   #     wrap  允许循环
    . s8 K4 r+ W' q3 A4 x( L9 D# j
  852.   #--------------------------------------------------------------------------. h3 m" J2 \2 _2 h3 \6 O
  853.   def cursor_right(wrap)
    : K3 M, A7 H- }: P' L8 `9 C2 K: {
  854.     if @index % 3  2
    8 c. f" {: Y' g. W
  855.       @index += 1. o- h$ }: Q5 t- w3 L$ c" _
  856.     elsif wrap
    1 e0 Z5 m* h% P0 Y. M
  857.       @index -= 2
    % l3 m' J2 }+ J
  858.     end
    : ~% E- B  \  v% J, r# m& d0 i" a- `
  859.   end
    # K1 c5 S  j5 D9 H
  860.   #--------------------------------------------------------------------------" t/ t. t! v* H9 U% H0 e8 x
  861.   # ● 光标向左移动
    - d; R0 g1 F( _* V; }% N+ B
  862.   #     wrap  允许循环
    , ]$ V; A& O6 I: N) \5 O
  863.   #--------------------------------------------------------------------------
    ' Q6 e% {+ U. \# M: {' D9 s
  864.   def cursor_left(wrap)
    * ]' \" f4 m3 }0 j7 p
  865.     if @index % 3  0
    " [' i- N% N1 P1 |9 X: D$ b( D
  866.       @index -= 1
    9 ?% H3 `" @" C+ S  c) J
  867.     elsif wrap
    & b: z5 \! M) ^
  868.       @index += 2
    * c/ R' y: @. Z; L/ a9 e
  869.     end* B3 q- {% Z* F. U( {4 M8 d
  870.   end9 n) `5 ?8 [' X2 u5 U, C5 `
  871.   #--------------------------------------------------------------------------7 F8 D/ V$ ~0 a( y6 Z9 w
  872.   # ● 处理光标的移动6 G+ J8 G* t3 X; n  N5 `
  873.   #--------------------------------------------------------------------------
    ; v% L$ @2 Q6 T  a
  874.   def process_cursor_move& w8 q" p1 |0 q& r0 O2 X8 i0 q
  875.     super$ B7 J4 _3 Z! H9 h
  876.     update_cursor
    6 h2 V$ O7 }9 g
  877.   end
    & E  M) B; o1 N" y9 d& S
  878.   #--------------------------------------------------------------------------
    ( }6 W# q! C5 L) K" S# W
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    6 D" v& M( G" X: y. j+ _4 a
  880.   #--------------------------------------------------------------------------8 s2 y7 c! v  b- o- ^
  881.   def process_handling* w( U& x# q1 L. N* z+ D0 Y
  882.     return unless open && active: g4 L" u" c( U, Z' e2 S3 v. F
  883.     process_jump if Input.trigger(A)" |" l& V  L) j3 R/ q4 K
  884.     process_back if Input.repeat(B)/ s$ C! k6 p* C* ^& S( H
  885.     process_ok   if Input.trigger(C)8 x$ m% |- B$ {8 Z7 ^
  886.   end- f9 J2 N9 l, {  {0 p
  887.   #--------------------------------------------------------------------------& D( ]  Q5 y# Q2 p" T1 p
  888.   # ● 跳转“确定”9 |- ]* x* B  ^- x
  889.   #--------------------------------------------------------------------------
    7 y5 \9 @. C( Q+ c0 [: L) i* @, @( `5 i
  890.   def process_jump
    4 [6 |% i+ K2 [" [1 `8 l9 e  c
  891.     if @index != 116 ~& h2 E, @. N  l# ~( W
  892.       @index = 11/ v$ b2 V; E1 t, u% f$ B
  893.       Sound.play_cursor9 x6 W- Z. ^$ Z2 ?! O; L
  894.     end
    6 K: ]$ ?6 F) T2 A: Z4 M
  895.   end
    ; D! n, }) R. g% J
  896.   #--------------------------------------------------------------------------: @) R$ L$ B- x3 h3 s
  897.   # ● 后退一个字符
    & q+ [* n  t1 E; [- ^# X
  898.   #--------------------------------------------------------------------------" Y- R  c" c+ @+ k8 `6 F7 G
  899.   def process_back" [$ q5 O; ^$ \. f4 q5 X8 J
  900.     Sound.play_cancel- q6 s- y7 O9 y# N8 U- D
  901.     place = 10  (@digits_max - 1 - @old_window_index)* _. R, i, O* R  y4 ~2 `0 b
  902.     n = (@number  place) % 10
    0 _4 R" {0 W$ [$ J0 V" k, c% |% i
  903.     @number -= n  place
      y1 U# e; Q- Y7 q- g; L
  904.     @number_proc.call(@number)
    3 d) }% {, |9 q8 s' e8 d
  905.     @old_window_index -= 1 if @old_window_index  0
    # c( c# _7 C9 {7 t+ E
  906.     @index_proc.call(@old_window_index)% T9 u3 U1 j4 ~) m, b! ]
  907.     @refresh_proc.call( ~0 |% v; H3 m. |) z1 }9 T
  908.   end
    5 [8 p1 i# d: w6 Y) B4 `9 z
  909.   #--------------------------------------------------------------------------
    ( f+ E) ]$ Z6 [' \& }% c8 @
  910.   # ● 按下确定键时的处理
    3 L2 x) ?7 N9 f! n" V2 L
  911.   #--------------------------------------------------------------------------
    , G8 p" N4 I2 e7 ]
  912.   def process_ok
    3 \6 _! D2 _1 N( ]( Y
  913.     if get_number2 {4 [. e7 c# }+ x
  914.       Sound.play_cursor) S2 y' i. U; w4 X$ g7 ^
  915.       place = 10  (@digits_max - 1 - @old_window_index)/ l5 j  n' A4 j: b' s2 R- O6 y
  916.       n = get_number - (@number  place) % 105 `+ A! t' p: G4 [  P) f" e
  917.       @number += n  place. G5 h) L1 a. ^7 K+ E5 N
  918.       @number_proc.call(@number)
    . F  \5 L1 U& R% k+ N2 d" F
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1$ }9 V9 M( R+ G; o" r7 {9 D
  920.       @index_proc.call(@old_window_index)2 u, `1 v6 }4 C5 ~! m3 m8 i8 @
  921.       @refresh_proc.call
    - s5 s; t' j$ T# d' Y; r" I
  922.     elsif is_delete+ \! i$ _# H& q  D* I) R0 o* x
  923.       process_back# I3 T$ f6 ~$ H7 O0 l6 o6 ]
  924.     elsif is_ok
    . _6 w* q( l3 |+ {
  925.       on_input_ok
    9 E3 J7 Q1 Y0 h- [0 O7 J
  926.     end
    3 \) x2 [$ \7 x
  927.   end
    8 ?0 y  q" X3 K! x- j! b- p7 [8 C& c3 i
  928.   #--------------------------------------------------------------------------
    . N4 H) Q3 i: }8 w
  929.   # ● 确定
    5 H4 o4 a$ s# B. f
  930.   #--------------------------------------------------------------------------9 H. [6 b2 w4 h0 Z  z+ M
  931.   def on_input_ok7 _1 m2 @0 [' \4 s) S
  932.     @index = 0
    - Q8 A0 r/ ?" `( o
  933.     @old_window_index = 0, g; W/ c; n0 Z! u8 l8 b; J
  934.     $game_variables[@variable_id] = @number
    + ^, O/ s' y3 {/ S' _2 L8 ?9 A' K
  935.     Sound.play_ok
    4 q1 ?; C! ]. n$ i
  936.     @close_proc.call% ~, d' _6 ^9 P8 o  i3 h3 i
  937.   end
    " ]4 g. W( |  T, X/ b: T3 O
  938.   #--------------------------------------------------------------------------# D& P: Q  l) Z6 [; L2 ~( D
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置7 X, d% k1 n8 V" t7 i) H& t7 e
  940.   #--------------------------------------------------------------------------/ K+ I- h: b5 B& q1 y6 b. r
  941.   def set_mouse_pos
    8 ]/ N& h4 `5 ~4 C5 F2 w' a
  942.     if viewport.nil # necessary!: i1 Z' D) S& O8 g: p
  943.       vp_x, vp_y = 0, 0. E1 V2 N% R: R2 w' ~
  944.     else
    ! E; n8 j* J/ P0 T- H
  945.       vp_x = viewport.rect.x - viewport.ox1 ]+ T. _5 }4 E5 _9 f
  946.       vp_y = viewport.rect.y - viewport.oy  D/ \9 y# N( ~8 b7 K6 G
  947.     end
    % I* t& r/ U# l( Z3 ?9 U& r, C
  948.     item_x1 = vp_x + x + standard_padding
    8 B" \9 W' G; i" k
  949.     item_y1 = vp_y + y + standard_padding. a6 k' n7 O2 a! C! ?% b' d2 F
  950.     get_index = @index  0  0  @index
    ! V( Y! R4 Z8 [# H
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    + o$ F  J- Q, P
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    1 w5 f, c' t# u- X1 c# \# b
  953.     Mouse.set_mouse_pos(new_x, new_y)2 o* G5 W- I* Z& e) b8 C& ]
  954.   end
    3 U: z2 F3 g( H/ u- I
  955. end
      r% u/ F1 M* A5 @) r
  956. - j& W/ B# B/ I: x7 u. Y2 z& ?- @6 Z
  957. #==============================================================================* ]" }" Z& s4 ?$ d
  958. # ■ Window_Message
    % i* z7 N8 r3 I& Q! E+ }
  959. #------------------------------------------------------------------------------; p7 b! e. x  P# J: y. \+ j
  960. #  显示文字信息的窗口。' t: t7 G2 q+ ~/ ~( n) ^2 ]
  961. #==============================================================================
    " l( Q# O* i% N! N
  962. class Window_Message  Window_Base
    0 p1 J5 L" X" k, l5 Q
  963.   #--------------------------------------------------------------------------
    5 W7 p9 w9 e+ q0 j7 m1 C5 }
  964.   # ● 处理数值的输入(覆盖原方法)0 C/ H3 p, u/ W& n* t
  965.   #--------------------------------------------------------------------------) Z6 p- J5 b6 Y1 ]- h
  966.   def input_number
    : v: m( k/ {0 Y( \' p
  967.     @number_window.start" e$ |- E& n% `/ T
  968.     Fiber.yield while @number_window.extra_window.active* A9 E( S% r3 G6 j  A$ U) v( `: Y
  969.   end/ T5 H7 B- I- z& ]
  970. end
    $ V6 p- T! i5 o

  971. ) A1 [% l, [; J0 Y+ }' Q
  972. #==============================================================================) N5 ?; r  F1 {0 D5 x8 @1 M
  973. # ■ Window_PartyCommand
    - `3 n( \0 {; G  d9 j2 b$ ?" |9 p
  974. #------------------------------------------------------------------------------4 l6 D$ U# V! Q* A6 l: b6 F
  975. #  战斗画面中,选择“战斗/撤退”的窗口。
    $ z% E, h/ T. Z& Z
  976. #==============================================================================
    % Z  j+ \8 I; s
  977. class Window_PartyCommand  Window_Command
    5 y8 v: A$ Z/ {1 B! T1 q& [0 |
  978.   #--------------------------------------------------------------------------& z' b: `/ X8 j% I% H
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    5 J! A4 h0 [# N8 n7 H2 x; P
  980.   #--------------------------------------------------------------------------
    3 u+ n( A4 \9 [( B7 \' t" Q8 k7 R
  981.   def set_mouse_pos5 w. N- g  `* o( T
  982.     if viewport.nil3 X8 N: e/ X  J
  983.       vp_x, vp_y = 0, 0
    # k/ D, }" w: M% u0 p. {7 F
  984.     else+ F/ S! e6 O# x1 Z1 s! d8 @% ^
  985.       #vp_x = viewport.rect.x - viewport.ox0 N& S& S8 y: K2 X" E' R( U
  986.       vp_y = viewport.rect.y - viewport.oy- [1 }7 F0 Z* ~0 ?9 g
  987.     end
    / w+ N7 |, E+ w. o- p7 ~
  988.     item_x1 = x + standard_padding & ^- f: G) `& @
  989.     item_y1 = vp_y + y + standard_padding/ D( n5 v6 q& ^& u, I
  990.     get_index = @index  0  0  @index 7 G1 M# m5 p$ ^* q( r0 h- M. N
  991.     row = get_index  col_max - top_row6 p. D3 `1 z4 i  ]; |) Q2 }2 M
  992.     col = get_index % col_max* g2 w& F# f( P  y& r/ |
  993.     new_x = item_x1 + item_width  (col + 0.5)
    ! B- A2 {4 }' Q9 L6 f
  994.     new_y = item_y1 + item_height  (row + 0.5)" S& j1 J) ]4 }: F) _3 `
  995.     Mouse.set_mouse_pos(new_x, new_y)
    " ]' Q8 F- h6 d/ I
  996.   end
    6 N$ t7 q' P5 W7 W
  997. end+ F& F( n! t  e$ B

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

  2225. 2 X, w3 ]) Z+ g" \
  2226. #==============================================================================+ F: w$ b2 P; J
  2227. # ■ Spriteset_Map+ f1 S5 n" s4 x( x
  2228. #------------------------------------------------------------------------------
    8 R) ]- y% V! f4 ?
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。& o- B0 {; w. c( s: S# r; s$ k
  2230. #==============================================================================& x4 o- b/ q9 ?) x! w
  2231. class Spriteset_Map
    ! r6 o, y  N" R0 A/ @0 I4 I
  2232.   #--------------------------------------------------------------------------
    2 |9 R+ }! F7 p
  2233.   # ● 生成路径点精灵! Z* X' h8 g/ U; |) J9 X2 S* Q
  2234.   #--------------------------------------------------------------------------
    % `: A3 |5 J" ?6 N; o" Q0 p
  2235.   alias sion_mouse_create_characters create_characters
    8 N' l/ }: K, u! m
  2236.   def create_characters8 X' |, Z4 v( _- ^
  2237.     sion_mouse_create_characters& x. ], E  ^* x* M3 }, K. i; ^9 w
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    5 D, N% ]3 A3 P, A" a8 M
  2239.   end
    ; J# J. J2 I- I, n( S
  2240. end
    % W% X4 h' _9 Y
  2241. 4 a2 R2 R% x% k* c( K. M/ j$ R
  2242. #==============================================================================
      v3 C1 E# N9 |
  2243. # ■ Scene_Map+ E& u% f4 g% M' U6 u) B
  2244. #------------------------------------------------------------------------------
    * \4 c5 L3 C: b5 E
  2245. #  地图画面
    : t( k9 h+ D; Q
  2246. #==============================================================================( s! _5 m- ^& h2 x( }  F
  2247. class Scene_Map  Scene_Base
    ( [+ `3 W/ z  b7 _
  2248.   #--------------------------------------------------------------------------1 H5 l$ h! o. E$ q! _, r
  2249.   # ● 画面更新% p+ P& C1 T& f
  2250.   #--------------------------------------------------------------------------+ ?& Q" ?% y; ~6 {5 O/ f
  2251.   alias sion_mouse_update_scene update_scene# x/ F3 p; u, A$ c
  2252.   def update_scene
    ; G- m9 a0 a3 f& _. t. `
  2253.     sion_mouse_update_scene
    3 l- o/ Y# Z1 g, Q9 n6 j0 L3 k
  2254.     update_mouse_action unless scene_changing
    ; T, c  v) E" L9 H
  2255.   end+ K" d( H: T$ V; X/ b
  2256.   #--------------------------------------------------------------------------, X% Y9 u7 _/ O5 {
  2257.   # ● 场所移动前的处理
    3 f5 e/ N' k# R
  2258.   #--------------------------------------------------------------------------: \/ g1 d- `( j. N; N3 |" T
  2259.   alias sion_mouse_pre_transfer pre_transfer6 @( ?% o: V) R. H9 x
  2260.   def pre_transfer
    3 A5 b0 T" l# v3 [, l# U3 `9 C7 U
  2261.     $game_player.reset_move_path! g3 d, F6 O- E1 A/ o
  2262.     sion_mouse_pre_transfer3 }" q8 C. V2 k% `6 I
  2263.   end
    / {* g0 _5 B0 P! l
  2264.   #--------------------------------------------------------------------------
    2 c. ^2 l" e6 G8 O
  2265.   # ● 监听鼠标左键的按下
    ( Y% P9 k) k! T+ b# w7 h
  2266.   #--------------------------------------------------------------------------
    $ z6 N& ?' H3 |( f4 X* F2 i$ @  d) E
  2267.   def update_mouse_action
    ! v4 }* `; D1 o: a: _1 f
  2268.     $game_player.left_button_action if Mouse.press(0x01)
    ' ]/ x% ]  o$ I' o
  2269.   end
    4 g* ]4 p2 D8 N
  2270. end9 G* h+ {8 }9 z$ }. f5 A1 i

  2271. $ G  o, d  r/ e* N7 j
  2272. #==============================================================================; P4 {! G; ~! m2 ^: {7 D; q! r
  2273. # ■ Scene_File7 g3 O- `' Z3 ~1 g1 q2 y7 @5 T
  2274. #------------------------------------------------------------------------------8 Q3 ]. T! D+ `5 G& o
  2275. #  存档画面和读档画面共同的父类
    ! e0 q8 D, h$ T! H
  2276. #==============================================================================3 Q- ^, }8 L: h
  2277. class Scene_File  Scene_MenuBase- `1 y8 X6 @, A/ T; o
  2278.   #--------------------------------------------------------------------------$ e- r, z9 d! a. {) t) w
  2279.   # ● 开始处理; B" I4 b$ |* w5 j5 G  b* x( @. y
  2280.   #--------------------------------------------------------------------------9 u( w4 p( C0 F9 d: W* ?* V7 F. c
  2281.   alias sion_mouse_start start
    , A5 @& T' }; s
  2282.   def start
    0 z- b% I; x8 q
  2283.     sion_mouse_start
    2 H" v0 w2 l+ F: p% P0 s: A
  2284.     @move_state = 0
    3 Q( j) k+ j: t/ r
  2285.     set_mouse_pos
    ! R; E/ q3 n- h8 Z4 c
  2286.   end
    ( g% P) ?1 c3 n! y9 t
  2287.   #--------------------------------------------------------------------------3 E5 T& m) W  w4 g
  2288.   # ● 更新画面) v, G* T  x0 A6 a- n  a) v" k
  2289.   #--------------------------------------------------------------------------
    % J0 i; q5 {* i1 W& J) h% d
  2290.   alias sion_mouse_update update
    9 K$ y# J$ u3 I, ~
  2291.   def update
    9 a5 x6 ^% d6 i4 s' x6 N/ w
  2292.     sion_mouse_update3 F" L" {( b9 O2 m1 v
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    0 `3 ~: i2 C( Y
  2294.   end5 C! x( o  b$ G. t: j4 n. V
  2295.   #--------------------------------------------------------------------------1 O5 `2 C2 T( }& Y- b
  2296.   # ● 更新光标1 J! V! ~; d  q7 M# ~2 l7 |
  2297.   #--------------------------------------------------------------------------+ k2 G6 Z: J9 I/ r3 `4 B
  2298.   def set_cursor9 B# U! _3 [; }  i9 L
  2299.     @move_state += 1
    2 n8 f7 Q, Z1 V
  2300.     last_index = @index
    ) h* W" f/ Y2 y& x  S  Y5 _+ J* q
  2301.     if mouse_which_window == -20 |/ x- e& L' ^" C: T
  2302.       if (@move_state - 1) % 6 == 0
    & Y9 C' e9 H8 w3 u6 h. N  O5 J
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1( ]4 ~# [0 N$ ^. w. X
  2304.       end
    , n" J" S( U, F# U
  2305.     elsif mouse_which_window == -1
    $ E) S# }) H8 F9 C* }, i% n
  2306.       if (@move_state - 1) % 6 == 0
    : m; d# \# }9 e' n, i. B
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    9 q9 `7 j4 n+ D$ r/ d
  2308.       end
    1 X, I. E; h9 R+ n
  2309.     else
    3 j+ r) L& i  `& m* r! s
  2310.       @move_state = 0
    + O  B! e+ l; U9 F0 S
  2311.       @index = top_index + mouse_which_window
    6 w9 Y5 W8 e* i: M
  2312.     end
    % B5 A0 d( @, ~: d% \
  2313.     ensure_cursor_visible
    . }# a; m0 u# f" S
  2314.     if @index != last_index% O) ?3 ?5 `/ E
  2315.       @savefile_windows[last_index].selected = false
    ( i% t7 H. G  F% Z2 ~1 {
  2316.       @savefile_windows[@index].selected = true
    # _; @& s8 y8 U4 N  c" M
  2317.     end
    % G0 p' g$ J. s( w
  2318.   end
    4 a7 k2 H/ A8 X* X' S" D3 \+ M
  2319.   #--------------------------------------------------------------------------
    6 L9 \' K+ V, P5 x, b
  2320.   # ● 判断鼠标位于哪个窗口
    1 Z9 K( ?3 E; s- N: ]& H8 X( T/ k6 d
  2321.   #--------------------------------------------------------------------------
    2 ~& E, g, P$ m6 x
  2322.   def mouse_which_window/ ^/ g) `& H: {
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y; m' U, J5 r2 n* t! V: _; j
  2324.     if mouse_y  @help_window.height + 14
    2 o8 v# e9 D' i7 T9 j
  2325.       mouse_row = -14 l' R% [3 r' d4 C, K1 B5 h4 H
  2326.     elsif mouse_y  Graphics.height - 14) S$ Q$ ?" u1 y6 @1 b' z0 A! k
  2327.       mouse_row = -23 E; m, V. N( G7 |
  2328.     else, s8 l4 C1 D6 I& u3 N2 v9 k( @
  2329.       mouse_row = 4  (mouse_y - @help_window.height) * }1 \, P3 M# p* u0 A. F/ S' J
  2330.         (Graphics.height - @help_window.height)
    9 h9 \" p  ]% v0 M
  2331.     end
    : t0 \: V7 i+ Z) f1 N
  2332.     return mouse_row
    3 @( x4 ~. }! o
  2333.   end7 |* r) {: z; _
  2334.   #--------------------------------------------------------------------------
    2 ]  W: H3 u/ z5 z& v% H) a8 i
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    - E. x; t( i6 I6 ]" x9 p
  2336.   #--------------------------------------------------------------------------' [0 y4 D& P3 s7 M
  2337.   def set_mouse_pos
    9 D: O, O* p) ]; Y4 @9 b1 ^* X
  2338.     new_x = 405 l% ~6 d: W: ]% d. R! I2 @
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    5 [7 E' z$ h( ~8 {
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    % y9 E+ ]1 i* j2 K
  2341.   end
    ' y: B; U% w: X( V2 Z6 P% c
  2342. end
    * V1 Q# {% U! {$ ^( C

  2343.   h2 L# }: G" @6 D
  2344. #==============================================================================
    4 y% q  {* p1 o$ [7 o3 j0 t3 Q: {2 K
  2345. # ■ Game_Event
    / t3 [  L+ v5 b  N7 b% F% m
  2346. #------------------------------------------------------------------------------
    & o: S$ W$ D1 ]$ x! n7 T3 M
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。- E+ Q) _9 F- ?  g1 U; Q
  2348. #   在 Game_Map 类的内部使用。  H( B' D! k/ F7 H* u
  2349. #==============================================================================" y# T7 p7 Z9 n7 Y
  2350. class Game_Event  Game_Character
    $ U0 n3 b' z- J$ s$ l
  2351.   #--------------------------------------------------------------------------
    2 C4 x9 `# {* I. w$ `2 w8 A
  2352.   # ● 事件启动, Q6 t4 j5 B9 t. u' w" b
  2353.   #--------------------------------------------------------------------------! o) q6 h, d4 K( n' e% Z
  2354.   alias sion_mouse_start start
    1 C0 s. `# }; z: U9 m- h& G1 b" T$ l
  2355.   def start( r) a7 G1 J3 _( _) s' ~
  2356.     return if mouse_start && !Mouse.press(0x01)
    / S( {* I  O1 H$ G" ^: {
  2357.     sion_mouse_start: f7 a" g" O: n" F# w( L2 o- w% k8 M
  2358.   end. O, |- ^; s! j) l& p
  2359.   #--------------------------------------------------------------------------0 q/ Y3 e+ G& X2 c$ t
  2360.   # ● 判断事件是否由鼠标启动
    5 X* Z2 l& _/ m: r7 n( S6 s
  2361.   #--------------------------------------------------------------------------( r0 N$ D" h7 ^( d; ^
  2362.   def mouse_start
    8 j3 d+ u# `" ]: D' D9 `
  2363.     return false if empty
    , u1 p, b: `% ?0 Y
  2364.     @list.each do index
    - T  z( t6 A5 p/ z7 \: m
  2365.       return true if (index.code == 108  index.code == 408) &&6 w, p) \5 }1 ?& I5 x
  2366.         index.parameters[0].include('鼠标启动')
    - j, x) m% ?* k% p6 v
  2367.     end1 _/ ^6 E' c  E" P6 i# C' F
  2368.     return false; ~/ z0 ~! q6 t
  2369.   end
    . O0 |* d8 l0 `
  2370. end3 S$ v; p- Y0 W9 A" j

  2371. 1 A% d+ C- I+ [3 a% z) R+ y
  2372. ####泥煤的height" ]9 O2 W' e4 j# g+ [- M9 A
  2373. # @height = height7 A; c7 N) t4 k* h5 R4 m

  2374. 1 I8 s9 j# m- b
  2375. class Area_Response# t" v* u0 [0 m2 n% P* ~+ Y2 d5 y
  2376.   attr_accessor type0 {4 [3 T; s' j' q
  2377.   attr_reader ox0 g1 R. P( [* n( f: P8 J
  2378.   attr_reader oy& }% h0 B3 C* P$ w. i
  2379.   attr_reader width* }7 I: Q$ l# j$ x. p- k3 L
  2380.   attr_reader height2 R' q1 k% y$ ~$ g9 u
  2381.   attr_reader switch_id7 d: T' `. L3 {7 M" S. n
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    % p$ v, Y% ~! G2 b
  2383.     @type = type
    ! w" m% g8 k5 h8 U8 [' X
  2384.     @ox = ox7 F0 o9 g. L) g4 D1 y1 A
  2385.     @oy = oy2 ?$ ^7 x8 l' `+ _4 D
  2386.     @width = width
    2 _# [. z# W$ q8 }$ M2 R5 Z
  2387.     @height = height
    # W& ]9 h' |9 U, [0 P
  2388.     @switch_id = switch_id, q* E8 e% c" i( E, }  k
  2389.   end
    % q$ y; |& d% f) }+ B. p8 }% G
  2390. end5 N- g. L6 d8 O) _2 z, u! ^

  2391. % E% Z' U( J, Q( F& G: K
  2392. $area_responses = []
    ' Q: R6 \) K) _3 L. J3 u: y

  2393. % o% v$ ]3 n+ A# B7 X: N, ^5 z/ l
  2394. class Scene_Map
    , A/ d$ I- T( Q. u1 r
  2395.   alias update_mouse_2013421 update_mouse_action7 Y5 V& c: U/ B0 B) Q2 _! Z
  2396.   def update_mouse_action
    0 M3 R6 ~6 A( B) L7 e
  2397.     update_area_response! B5 H, E# J3 w- Z! w& W
  2398.     update_mouse_2013421
    - y. _3 C5 k- \
  2399.   end  _" j6 J/ G) S; G6 B% e" y
  2400.   def update_area_response9 U# k! {" {' z) ~6 w' i4 i, p) a# |2 o
  2401.     responses = $area_responses
    ! ^7 s$ m8 l" D& f! s6 w+ u
  2402.     responses.each {response2 h/ X; M" Z" d; ^( |' K
  2403.       ox = response.ox# m* g* u9 _3 _- v7 A4 L
  2404.       oy = response.oy
    8 F! O2 ]' G7 J; w( p
  2405.       width = response.width
    ! R/ J7 a/ D6 s, D, A( O
  2406.       height = response.height
    7 b2 z9 j$ z2 |. k: o% Y; S
  2407.       switch_id = response.switch_id: D/ ^% y9 K1 r# @8 h% f
  2408.       case response.type& ]) V( C- [6 s+ A, `
  2409.       when 0/ g8 A# g$ r9 }5 i  M; S! K( v
  2410.         if mouse_in_area(ox, oy, width, height)
    & L3 ?; q# ~( I- z
  2411.           $game_switches[switch_id] = true% l( u; M1 n6 y# x' r7 \' K6 A
  2412.           $area_responses.delete(response)
    $ f( n- [2 i" F- c3 t9 H! R
  2413.         end6 C( s5 h* [4 ]0 i
  2414.       when 1
    ; O1 I5 s# K* \! O0 @- y2 k
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)) P$ T, Y/ k' [* K& F5 E
  2416.           $game_switches[switch_id] = true
    ; D4 T" s8 g; s2 K. Q  q
  2417.           $area_responses.delete(response)
    $ L% i( P) w" S/ e
  2418.         end- y; w: b/ Y# p. I* h/ x' p
  2419.       when 2
    8 e2 K6 Q) D5 x; \
  2420.         if mouse_in_area(ox, oy, width, height)
    9 O" [6 c* R$ ]- j  A, w
  2421.           $game_switches[switch_id] = true
    , P* [* I8 W3 t9 G, f9 _  l! a
  2422.         else# W2 J0 M5 `- \/ M( N/ p; \
  2423.           $game_switches[switch_id] = false
    3 i" X9 s2 k1 _; X
  2424.         end( l) _- F( s% t, X; f/ n* o
  2425.       when 35 P# s1 u) N, N- B- D, s8 @% U
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    $ f+ O: A' b0 B( Z/ w( L* D( K
  2427.             (oy - $game_map.display_y)  32, width, height); f. D7 e2 k" h
  2428.           $game_map.events_xy(ox, oy).each {event$ U& x4 j8 t' |' I- ^
  2429.           event.start
    - Z& D6 ]# U+ H- q1 `
  2430.           $area_responses.delete(response)
    . K. y. H& q0 e+ p5 k8 D
  2431.           return
    5 J* I5 W) x5 ?3 K" y9 h% K
  2432.           }
    / J+ W# K  ^. z8 H$ R+ ?( Y
  2433.         end$ x, G+ a1 j1 d+ |
  2434.       when 4
    . U3 v, z. {6 T+ B: }
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,% u/ Y5 \4 k! p- u8 J& [
  2436.             (oy - $game_map.display_y)  32, width, height)( E: q0 T& i; W: i
  2437.           $game_map.events_xy(ox, oy).each {event
    6 C; T3 v3 }2 B6 h7 Y
  2438.             event.start0 W6 R% @* e7 H5 M( ~8 ^  L
  2439.             return$ o1 U' B4 Q4 N: j- M4 g
  2440.           }
    . M+ t' Q! `, u3 f) g6 B6 v
  2441.         end5 U; `/ q% L2 _6 t  k: y
  2442.       end
    . y/ Q0 x! ?; _, ^, j% F
  2443.     }& {% X  S8 [. a; |4 Y  R$ @
  2444.   end9 Y+ j4 K+ ]; k, J" a
  2445.   def mouse_in_area(ox, oy, width, height)
    - T4 a2 P! o# X' r4 w
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    0 n$ d: I: e0 K( n5 z
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    ! d: @! @. p/ [
  2448.   end
    ; R/ C, J/ E" P# g
  2449. end* W9 g: l' U* Y1 u: F
  2450. class Game_Interpreter8 t; r+ c! @" A
  2451.   def area_response(arg)4 i3 g* F; F! h% ^) P6 `' k
  2452.     $area_responses.push(Area_Response.new(arg))/ d6 W" \5 y0 K; q4 f0 `7 P! i
  2453.   end
    ( A/ C1 A: C" c/ z) P
  2454. end
    ' A5 [; j6 o6 k" F
复制代码

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

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

GMT+8, 2026-7-23 21:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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