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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================: W+ A7 b9 c# M; `& i# O
  2. * g1 q1 H. D* l( \) H. `! y
  3.   Sion Mouse System v1.3e; a- N" h. x& w
  4.   + Q# l' e+ s% _" F, ^
  5.   Changlog
    ) ], l' V8 M6 B  x& O: {
  6.   ) u4 v- D0 D# V
  7.   2013.4.21 v1.3f
    - f4 R& ?( i7 H! f1 F3 }; |
  8.     ) ^0 V# `% ~! @' o
  9.     1.3f 卷动地图 bug 修正- i& O* r7 [- k1 m2 O6 t
  10.     ; N$ h% U( ~% ]9 y. M0 }
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    8 w. O, E+ M/ s& d8 U) ]
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内- e0 {: ]4 |$ ~
  13.                               Mouse.unlock_mouse_in_screen 解除锁定* \) t0 R* M, D4 ?
  14. ; Q6 e/ P  N: P. }& B, z) d# p8 D
  15.     1.3f bug修正
    8 {3 g& I4 t! t( I
  16.   
    / v) M# M. s5 N/ ^: p) x( j
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及. b5 s4 l+ G9 I* M
  18.           关闭菜单时,鼠标是否移动到原来的位置。( J/ i( S& H) F6 E

  19. 6 q6 U5 g1 x7 r8 r. w* l
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处! ]& E( w! ^. w$ d3 S3 A
  21. 3 \: m% V. ]2 e3 e2 Q( o' C
  22.     1.3b 修正一些罕见的bug;
    . `" d1 l! F, y7 @: B& X4 j5 Y2 O
  23. $ O1 y5 P3 B0 r0 Y- C6 D+ N
  24.     1.3a 代码小修改;! s0 i- c- J( e9 i2 r% X
  25.           加入了鼠标点击启动事件的功能,1 U( z7 T' c( Y) i- w! x. m
  26.           在事件中加入“注释”: 鼠标启动  ,$ V1 E8 @& Z' N& M$ `# e( k7 B
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。5 W2 ~3 u$ J, q8 G/ u# ^
  28.   
    # s+ i! p0 c7 A# K( V; p) D
  29.   2013.2.12 v1.2! r& u5 o1 V7 k( u8 o
  30. ) s% L  ?3 V2 p# o2 a6 L: D" d! x; l
  31.     寻路逻辑优化;
    # Q& K% T! @' [0 s* r: J7 Q8 k
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;$ X# N$ F$ g# e2 u0 _% j* \
  33.     现在支持用鼠标来操作载具了。: r  F$ Y, M5 e2 z4 b; T: o
  34. / n9 H9 z0 x3 D6 T. \6 `8 T
  35.   2013.2.8 v1.1- C9 d$ k$ b/ a, K

  36. ! {' G  \/ V8 i" c
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    , ~" `! f. k; M8 ~8 m3 F( \, i& m
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;2 I# [) o( h( J% ~5 e
  39.     移动时,路径指示点的绘制更加稳定;
    1 j/ g* r- J9 w% M, L6 {
  40.     现在支持默认存档画面的鼠标操作了。+ k, X- b# A8 N9 j

  41. ' O3 L- j: b' x  x

  42. % i) Z6 H! |+ H) W  U6 G2 l
  43.   OrigenVersion' C' W( m7 u+ F, a2 p
  44.   + R4 J6 t) J; X
  45.     2013.2.7 v1.0
    & w) Y) R- ^7 k$ D7 ]8 H
  46. % I+ d* x% o" l( C, P$ c
  47.   主要功能
    8 ~1 y! B7 `7 T8 H3 a% ?& L9 \3 G

  48. 3 Q% d: f' O. F7 H( Q6 k7 K! Y2 b
  49.       使用鼠标进行各种操作...& S6 n9 x1 I, m# N, e2 O4 N
  50.       将鼠标锁定在游戏窗口内5 \8 O  R% x# `) E
  51.       自动寻路,按住 D 键可以扩大寻路的范围# e4 H! V3 }% g5 A. N* t% `. h
  52.       双击鼠标进行冲刺
    # f& W" T: Y* T1 h, T/ L; n
  53.       更改地图卷动方式以适应鼠标移动
    4 g- O$ k. k/ ~/ f5 F) s
  54.       变量输入框改良
    - T( b4 n; V6 h. m- Q
  55. 8 f3 V8 z0 f# p% m7 w4 K- |# @
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹8 e# l1 g- l! ^

  57.   {' Q2 s  y( @; d; t1 ^
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹) w/ X- ~; @# r' R4 v
  59. 1 {; X% y5 ~- ~- s8 d
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭8 U' u1 x, U8 m" d5 a
  61. 0 X. z% M0 ~6 _. _* b2 T3 S
  62. # O: J1 P) ^9 M1 ^# |. A* x' n- Z  I6 c
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★+ D" [/ |. P  H6 C. [! o1 N; C

  64. & S, ?  M9 d6 B& i3 p+ k; e8 [

  65. 8 F" m8 C  ~( Y9 M. }+ w, t, ~
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示/ U( ^: b2 [4 R$ i' M# K. q

  67. / C- W2 ~6 ~" h4 V* t8 E
  68. #==============================================================================
    % ^! ?! i$ Z: S6 P/ P
  69. # ■ 常数设置
    6 v- m" R4 u3 ]$ ]5 k
  70. #==============================================================================6 e, M' M7 C% h( J" v; E
  71. module KsOfSion# W4 E4 N" R, g- J( e
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false9 v2 K# p8 k- r6 Y
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑( H& q( H. g8 Y# W, S. _
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    1 \' c9 i% P  H# }' c) P, e9 V- f
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量% o5 a; u' h3 Y1 E$ d
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处
    " Y+ f; c) q8 W8 `5 y: l# f
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧9 w# B+ Q/ F5 Y, A+ x& o
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)6 |  x, c* E- j* x
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    / a8 N' g; y: X8 q/ [) z
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    ' p% }/ \3 S( ~% O
  81. end  `# `$ Y# N" E4 ]) z# z

  82. ( b% v# x* o. v2 P4 u: S, I
  83. #==============================================================================$ Y! D6 y; l  g
  84. # ■ 用来显示路径点的类4 d' N2 z( i/ C% T$ |* I3 y; t9 G
  85. #==============================================================================- v  n( N& ?- Q" F2 P8 O
  86. class Move_Sign  Game_Character
    # F+ r7 q- O. ~( u+ H
  87.   #--------------------------------------------------------------------------
    5 m8 n. a$ y0 H$ q& X+ t4 `6 u  }
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图
    7 G' c8 ^* f9 f) ^( I, X' X
  89.   #--------------------------------------------------------------------------# g9 p( j7 y% U6 x4 |
  90.   def init_public_members" L) e4 |" z; j6 w2 q/ `
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹8 d. p. K' F8 u! q. L' t
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    0 y4 W& z" f5 l7 }/ s0 W
  93.     @move_speed      = 5        # ★ 踏步速度) B) z- w$ m, p9 r4 |1 I; ]8 g; t
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)% P3 K" x! f& w. \6 X, e
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度
    9 H& Y% o3 i4 }/ z$ f- i
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    ' ?& F1 f9 S: B& ~1 ^' H! a" k4 [
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列* f" B8 f7 h- w
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    ( q  j% B+ }$ }1 y" |# Q' v: ~# Q/ S

  99. & z4 z6 e% g# K7 [$ g

  100. $ c+ g  F8 W! u$ n$ y
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    $ H$ o7 I6 E  ]" g; t2 I. Q/ A

  102. ; R$ A9 U. _0 o2 m* C# E* o! I
  103. 8 p" N  p4 Q' Q* S. `/ @
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图: R1 `! l  ^6 R  {& o! A
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    - B% ]3 a8 w- A6 M/ M0 j
  106. ( c3 _, s% \8 n" v# L0 d: C
  107.       if $no_arrowpic_warn
    $ {. j9 n) R4 m4 l
  108.         MouseShow_Cursor.call(1)
    ! R* W' [7 w* W
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png0 k1 e. c* ~" |% V5 u
  110. 7 t8 F. N$ w4 l: ^7 y
  111. “路径指示点”将使用游戏自带图片
    9 O/ n' o5 g8 K' @

  112. % k6 ~( H; i$ z- F$ Q; S
  113. 该提示可以在脚本内关闭')
    ; {  Y6 t: A, g) r; f+ \
  114.         MouseShow_Cursor.call(0)
    & x' W0 Y$ P2 i' p7 L6 M
  115.         $no_arrowpic_warn = false
    * l, O. r6 _/ z- u
  116.       end. m  @1 y2 J* F9 H3 ~% M% o( _
  117.       @character_name  = '!Flame'# V+ W5 D# e% D2 a( ?& n3 i
  118.       @character_index = 6
    , M( K! y9 R3 G4 t8 Y/ G: G
  119. . K$ H4 L# {$ W" P" Y' y. W
  120.     end
    8 a& z% ^! o1 i. f* P6 p
  121.     @direction_fix = false  # 固定朝向
    & s0 S4 c  r5 A9 N% u& B9 r
  122.     @move_frequency = 6     # 移动频率
    ; ^& F8 \0 o$ S- ?7 ~' N, S
  123.     @walk_anime = true      # 步行动画: _2 ~+ t/ a" G- n( G' {% V+ M7 Q
  124.     @pattern = 1            # 图案
    ) I' {8 H  n  c/ X/ a
  125.     @through = true         # 穿透, D: [6 V4 V8 p+ g9 p/ ?
  126.     @bush_depth = 0         # 草木深度' R5 {5 u1 {! g, d. T; I
  127.     @animation_id = 0       # 动画 ID
      G8 |. {& O/ z4 ~
  128.     @balloon_id = 0         # 心情 ID
    7 i9 G1 Y; H- L5 n3 B
  129.     @transparent = true     # 透明5 k- `4 H( x2 t
  130.     @id = 01 K$ Z6 l! ?% U$ s
  131.     @x = 0) E. Y+ S2 R; F( ^5 i
  132.     @y = 0
    5 z' Z/ h6 C& I" M) M: H4 T
  133.     @real_x = 0
    ; E. @% ]& w% d0 A& X
  134.     @real_y = 03 ]- m/ F# D' G  f1 U: b
  135.     @tile_id = 0
      K: v" r5 y( j2 A
  136.   end
    5 y% x8 F5 u, {! ^; s4 a
  137.   #--------------------------------------------------------------------------% N! `' {; {/ l1 [. z
  138.   # ● 定义实例变量+ ^$ s. w, C/ i3 q2 r' ~6 V4 R
  139.   #--------------------------------------------------------------------------
    + D8 [( z, h6 x1 Y* Z8 Y) {
  140.   attr_accessor direction1 J! [# R7 ]) q, {
  141. end
    # D, T6 H' H" s  z; u  ?& A
  142.   O# u" E/ T1 W" E( C# I7 F
  143. #==============================================================================
    2 [: v2 f/ s/ y, i7 H/ o8 @
  144. # ■ Module Mouse
    * e: i- b( z( [1 \/ d2 r1 u
  145. #==============================================================================- n3 a3 g. ?7 ?6 L5 V
  146. module Mouse0 h) T) B7 ]5 `$ t
  147.   #--------------------------------------------------------------------------. d% o$ Q0 V3 Z& n; Z
  148.   # ● API
    ) @* [2 X" ?7 N) N! e
  149.   #--------------------------------------------------------------------------: {$ Y4 r9 S6 m- R& G
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    * T3 `$ Y4 Q9 d1 w: |
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    3 q* N9 {: X7 {. |6 W
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')
    , @+ @/ B# p! a& E: [8 O$ {
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')9 c- |. L2 y( O2 h
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    : K9 G$ L2 z' J6 Q( W& J
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')
    : y1 \9 p8 G1 t1 i2 s5 F( N
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')& [! i7 d9 }4 T# N/ v+ v
  157.   Window_Hwnd       = Get_Active_Window.call! u4 U: Y# I) f; m
  158. . m% g* R1 x( ^8 B5 Z
  159. class  self' T1 W. W4 ]! h1 D  T" V
  160.   #--------------------------------------------------------------------------
    " W! N' ]9 D% B4 Q
  161.   # ● 初始化& t. F6 ]  L2 e8 a" Q" Z/ v! u; L/ o+ i
  162.   #--------------------------------------------------------------------------
    / R  }+ K2 V+ q4 c5 d# \
  163.   def init
    4 D) H9 R2 e4 J: l' C
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    - o7 B7 h8 R, Y  Q
  165.     @left_state = 0+ u3 }7 S; E% }1 r  e
  166.     @right_state = 0
    ! Z2 F0 t4 b/ j1 @& B
  167.     @ck_count = 0 # 帧数计,单击以后从0开始: @' h% \6 C$ {
  168.     @dk_count = 0 # 用于双击的判定( b  V( C7 N) F- j) I
  169.     @clicked = false
    / Q# ^1 T+ R7 Q6 O+ G4 G
  170.     creat_mouse_sprite* N+ V, A0 _, D
  171.     update
    & c" e2 l; W& }" ?6 `3 j
  172.   end
    , U. J; H1 L) r% u+ u! q. n/ R8 k
  173.   #--------------------------------------------------------------------------
    : o  L6 c6 Z9 G3 p" n' i1 v7 c
  174.   # ● 鼠标指针精灵; W! B  H7 M2 u% V  m
  175.   #--------------------------------------------------------------------------5 Z0 P# _/ J2 R' ^* ?  z
  176. #~   def creat_mouse_sprite$ [' N0 \' y1 Q* S- v& d" t1 g8 K
  177. #~     
    . h3 ~, W5 i& K4 }; ~1 u
  178. #~       @mouse_sprite = Sprite.new
    4 A: G* k! t. I8 d3 n% w
  179. #~       panda = 2#rand(2)+1
    5 A) a9 ~( D8 e+ u
  180. 8 l3 Y% @( e7 t3 e% k1 I1 X
  181. #~      if panda = 1& M0 j+ G+ m7 O; V
  182. #~        if File.exist('GraphicsSystemCursor2.png')
      x1 {0 ^8 @+ a$ ]
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')7 x0 w0 G/ |5 \/ K
  184. #~        end#with if File.exist4 r7 K0 T* ^% p" R1 w; \
  185. #~    8 [& g7 B  Z3 z
  186. #~     else if panda = 2 #with if panda=1
    , ~& f$ x; {3 b  Y  o* u
  187. #~      ! `: |' l& ?' R% d3 X# i2 X
  188. #~      if File.exist('GraphicsSystemCursor2.png')6 g( A' Q/ k9 F5 {, Z. z% I2 y" f
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')3 ?2 K' V) {0 B) O5 e% q5 C- k* K5 E: |
  190. #~      end#with if File.exist1 x  U. d8 ]  p3 l
  191. #~      
    , f7 n+ A1 A6 Q/ d& E
  192. #~     else #with if panda=1
    ! \1 J& L8 X" M6 P+ v% u8 F  y
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    $ k; C; h8 S# j! ]  u' I4 R5 U+ Y
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),( R; I, y. _0 d/ c( S, R- f
  195. #~       Rect.new(5  24, 24  24, 24, 24))
    * x$ Y* T1 f; G! p' E
  196. #~     end#with if panda=14 b" l, `  \# F; z
  197. #~     / }5 ^9 T7 @- P! [
  198. #~     #with def2 J& {% \) z( d7 {/ v+ V; i+ p
  199. #~   end
    & \% j+ S& C( h2 q, @
  200. def creat_mouse_sprite3 w! Y( E6 H: D. R2 i; q
  201.     @mouse_sprite = Sprite.new2 B3 W2 q$ s# M" \1 S% }& M
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    , m' K6 A3 ]% e' k; D; ~
  203.     @mouse_sprite.z = 99996 A. [0 l+ C( ?7 N% A# y/ {8 [
  204.     Show_Cursor.call(0)% D5 L) z9 R- F0 T- R
  205. end2 u: o2 X" Y: Z+ F9 F. ]& R
  206. 9 I' H& F& m+ J3 o
  207.   #--------------------------------------------------------------------------' y, x: p; U; `4 A* g, U: L
  208.   # ● 更新8 [) r; H+ k5 y- e/ m- M
  209.   #--------------------------------------------------------------------------
    9 J9 u: u/ G$ {: N" {( ~
  210.   def update/ W2 J& X) {7 x: H8 u3 W  D
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    ( ]' a% v! P9 X) `4 G
  212.     left_state  = Get_Key_State.call(0x01)  D: O% b8 p- ~: {
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0: M, C0 ^0 d' z8 V: Z
  214.     right_state = Get_Key_State.call(0x02)
    / U) k" L1 n9 b
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0: N# K1 g2 P+ P; v) B: o0 Q- m
  216.     update_double_click
    8 f# T. E- P: J5 f" P* b. \. O
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    ; Y* `" h2 k- \  w' v, m* f
  218.   end
    9 E) f5 S" p$ W4 ]$ O: ]
  219.   #--------------------------------------------------------------------------
    - }: I- R; y7 y/ u8 f' z
  220.   # ● 获取鼠标坐标
      Z- n$ e9 n  ^! u! V1 k3 m
  221.   #--------------------------------------------------------------------------
    0 W9 r6 t  m0 D5 A0 k6 T* c- z
  222.   def get_mouse_pos
    " F- m' _1 {- M
  223.     arg = [0, 0].pack('ll')1 w& ]* j6 ]  o  g
  224.     Get_Cursor_Pos.call(arg)
    2 o% h0 r+ A. O, T
  225.     Screen_To_Client.call(Window_Hwnd, arg)' M7 u- O1 G5 Q2 x( ~  B. E
  226.     x, y = arg.unpack('ll')
    / b$ U8 E0 |- Z& i1 ]
  227.     return x, y
    , e! k! J. M- G0 @! x8 }8 g$ W$ U
  228.   end
    3 w3 V  A5 u9 z! p3 T+ C' X2 c) s
  229.   #--------------------------------------------------------------------------
    4 ^$ Q, @) w+ r6 d' K4 @8 y
  230.   # ● 将鼠标固定在屏幕内
    & A$ f. _  _/ Z
  231.   #--------------------------------------------------------------------------
    9 ^% n- T1 I) y
  232.   def lock_mouse_in_screen% R6 Q% v, r' }3 z9 T! {2 C# w
  233.     arg = [0, 0].pack('ll')
    , {. }) W/ G: [: F
  234.     Screen_To_Client.call(Window_Hwnd, arg)
    - r: p- s2 R- v8 ^7 P
  235.     x, y  = arg.unpack('ll')1 Y1 E& z& F7 V3 w
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))6 a/ D) B. o$ q3 o8 d; _
  237.   end
    - L8 i, W! h5 I9 g4 [
  238.   #--------------------------------------------------------------------------, V6 Y$ \6 s% b# f
  239.   # ● 解除鼠标固定
    / f4 ?! K" i3 ?3 Y0 c  }
  240.   #--------------------------------------------------------------------------4 E. N) @, L( Y. u: c$ Q/ I* p* {
  241.   def unlock_mouse_in_screen
    # V. e. n, W- A" @
  242.     Clip_Cursor.call(0)0 W# M5 A" l' T* F: F/ [5 D
  243.   end) Q: ?" t: s3 |, F) |
  244.   #--------------------------------------------------------------------------
    8 x2 J. W* [0 q; |: b, w* Q! E
  245.   # ● 鼠标双击判定+ j* _, ~: ?. Y2 f+ a, s
  246.   #--------------------------------------------------------------------------
    4 a5 [5 B" y( D9 h& `
  247.   def update_double_click
    ; G6 b7 i( t: k. Y" s/ X9 ]% s  `* x0 K
  248.     @clicked = true if @left_state == 10 `" G1 [9 C5 _
  249.     if @dk_count  0 && @left_state == 1  Z4 s& T& E) L5 R) e
  250.       @dk_count = 0; @clicked = false  l# j3 m& X2 b' |& F3 P& s
  251.       return @double_click = true
    0 `. h; g# v7 X3 O; ?
  252.     elsif @clicked
    ! ]% t9 ~1 T+ H8 J
  253.       if @dk_count  KsOfSionDbclick_Frame& B2 i" Q; l2 a8 ~) }. S
  254.         @dk_count += 1. X7 {+ Z# v: l  I: H' `' i
  255.       else- O8 S( W0 @: H. f; N$ s
  256.         @dk_count = 0; @clicked = false
      C+ U: ?# S9 F' S2 `  a
  257.       end
    2 D0 j7 W/ w" E1 N8 o
  258.     end" u, S- K0 H2 E  n
  259.     @double_click = false9 i3 s  H' b+ c
  260.   end" [9 J. I; v; _  P
  261.   #--------------------------------------------------------------------------, H& i! U2 G+ ~; l
  262.   # ● 按键被按下就返回true) y$ C- M' }' G( p5 W# B
  263.   #--------------------------------------------------------------------------# Z8 e/ Q* a8 O6 j! d% Z4 B8 O
  264.   def press(button)
    , j' y+ {$ g0 T4 `% o
  265.     case button1 q! J' f& E  u  \- W
  266.       when 0x01; return !@left_state.zero" T1 R% C2 W  D* v3 `: {4 `
  267.       when 0x02; return !@right_state.zero
    1 C1 d1 w0 ^1 O" Q3 s
  268.     end3 }, z& r/ s1 _4 ]  f! }$ B
  269.     return false
      f/ ^0 f4 `/ c- q  ?( C
  270.   end+ Q# @- r3 f: T& z0 f; Z
  271.   #--------------------------------------------------------------------------
    . A8 i* U4 x  }0 L2 G) M* g
  272.   # ● 按键刚被按下则返回true
      N% c' l* G9 u2 [/ g! \, J
  273.   #--------------------------------------------------------------------------
    $ d$ A- X) }4 Z2 x! X
  274.   def trigger(button)" A2 r4 X" K/ N: w
  275.     case button5 P) n* @/ }- s8 Q
  276.       when 0x01; return @left_state == 1* J, V1 k$ \9 W# \9 K
  277.       when 0x02; return @right_state == 1
    ; D) |) V2 s. y7 b6 d
  278.     end; w2 @; W" L" D
  279.     return false0 j5 f# i' K  J2 h( V+ S4 C+ F
  280.   end
    2 O% t- \" Q( m
  281.   #--------------------------------------------------------------------------
    ) y% g+ Z1 _9 k3 `" i5 P
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    5 I2 h" t( {5 W" u5 b2 h2 }
  283.   #--------------------------------------------------------------------------
    8 q2 y, u( i  U( N( R) X2 \- B& y
  284.   def repeat(button)
    % X1 F" E, m3 n
  285.     case button1 Z% }9 h7 m, E( ~1 s, @- S
  286.       when 0x01; return @left_state == 1
    5 p+ G1 D5 i; \" K% P1 `
  287.         (@left_state  22 && (@left_state % 6).zero)8 s% n( Q5 p7 ?% g  r
  288.       when 0x02; return @right_state == 1
    " ?8 v9 G4 g! a; B
  289.         (@right_state  22 && (@right_state % 6).zero)
    4 V' t% F) ^8 A5 @6 [$ @( v
  290.     end
    / a5 h! I4 I8 {3 z. K5 |
  291.     return false. c1 G+ x3 S5 ?" f2 ]/ ^
  292.   end. y; T3 I' }+ o  e5 x
  293.   #--------------------------------------------------------------------------/ y. h. X/ R, F) C6 I6 Z& n
  294.   # ● 判断是否双击鼠标
    # Z+ o6 x; ~" O5 ?. ~$ Y  {1 F" i
  295.   #--------------------------------------------------------------------------
    : p' l$ b' V. k. m( ~8 E0 L  J+ N& J
  296.   def double_click  O  v5 \) W4 W' J( ^+ m2 ^- g
  297.     @double_click
    % Y& q6 u  X+ O8 o7 E
  298.   end
    ) M' l7 ?% {' S& v" E, z8 M
  299.   #--------------------------------------------------------------------------1 p; c( q+ ?9 Z3 B1 m3 d+ p% y
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0): e- U' f$ \) ^' O' p
  301.   #--------------------------------------------------------------------------
    # D1 G+ I7 l: N% \3 n1 O) {/ |) l
  302.   def click_count. u8 H1 q1 D( m# H( q# B3 \" v
  303.     @ck_count
    $ L3 E, F$ k( w* Z- i' j. R- W# p
  304.   end0 }: M3 h8 c3 d' M& L
  305.   #--------------------------------------------------------------------------
    ) f2 X/ Q  j3 V7 `
  306.   # ● 获取@left_state(按住左键每一帧+=1)
    2 E" M& l4 N$ ^, b; H; C" @0 d
  307.   #--------------------------------------------------------------------------' r* }% y7 A* W& j4 Q* G" P
  308.   def left_state% F# `6 f1 X; ]/ o
  309.     @left_state
    ; e8 g1 }- f( A0 T
  310.   end
    + {  t/ J1 l& c6 a. {6 J
  311.   #--------------------------------------------------------------------------
    ) t/ I: T7 h1 x! v& |
  312.   # ● 获取鼠标的x坐标
    ; x( e7 `2 `7 w3 }: p& u
  313.   #--------------------------------------------------------------------------
    0 ^" M1 X, d; D2 v& K8 k
  314.   def mouse_x
    0 e$ Z7 l% e4 d% i* M4 e" j
  315.     @mouse_sprite.x
    * Z9 c" G$ G& A+ A
  316.   end
    5 J, _! v* H  i- u" {
  317.   #--------------------------------------------------------------------------
    ! j1 ]" Y" }1 r4 j! A: u4 \
  318.   # ● 获取鼠标的y坐标' f; c0 H9 o* |! M/ O
  319.   #--------------------------------------------------------------------------
    * X. j" G( P! j
  320.   def mouse_y. I5 ^" i7 j; c4 v2 ^8 `3 \0 {: R% j
  321.     @mouse_sprite.y
    ' n% p3 K6 P. z. E8 s: _3 q
  322.   end
    " r( t/ e. K/ e% N5 ^2 l9 r* ]
  323.   #--------------------------------------------------------------------------  R* @* s& ~0 i0 X' T
  324.   # ● 设置鼠标坐标
    : [1 s4 a: X  n$ U6 C
  325.   #--------------------------------------------------------------------------
    & y$ N* G6 v% K; G1 e9 L' O% L
  326.   def set_mouse_pos(new_x, new_y)
    / N' D/ |  Z. T) Q
  327.     arg = [0, 0].pack('ll'): p2 d. b6 K5 Y( V- I
  328.     Screen_To_Client.call(Window_Hwnd, arg)" G2 d  U) t5 a1 b
  329.     x, y  = arg.unpack('ll')
    9 m. m* Q8 K0 D9 t4 C; j
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)" D6 \$ S. d! j6 k3 b  E& D
  331.   end& R" O; v! l* \9 B1 k3 t
  332. end #end of class  self 3 |: S6 Y4 ?9 b  k( T) ^
  333. / R3 ^9 T, E: T- z. r: l! u7 A
  334. end
    . }% n6 A+ n& i9 X9 `
  335. : }$ J: \0 D) L
  336. #==============================================================================
    $ K: s* @, I4 t9 J
  337. # ■ SceneManager8 \5 w; T" i* @! Q$ ^; X! X* p
  338. #==============================================================================+ @; b3 [0 \0 q2 f6 I- q
  339. class  SceneManager
    ! f. M. V* J2 K; ]5 I
  340.   #--------------------------------------------------------------------------+ r& ~; d# b$ E! _% a6 H
  341.   # ● alias8 o: X3 e5 K# v! `/ B+ D' d
  342.   #--------------------------------------------------------------------------! e$ ?, l% L7 p# m3 k# ]
  343.   unless self.method_defined(sion_mouse_run)
    ) ]+ ~% `2 H9 p0 `9 `  U1 Q
  344.     alias_method sion_mouse_run, run
    * _1 r4 L% \, ?6 K2 ?5 N3 S
  345.     alias_method sion_mouse_call, call( Y+ q8 A0 U% w; |8 \$ ^+ ]
  346.     alias_method sion_mouse_return, return- `% ]  B6 L( g, m6 ^6 K: u$ _6 D
  347.   end# X3 f5 b  `! [1 J) e# @3 x( k+ x
  348.   #--------------------------------------------------------------------------" L% d; i4 z4 o+ T: N3 @4 n
  349.   # ● 运行2 r  W5 Y# g: W& }: B( J
  350.   #--------------------------------------------------------------------------
    ) m" w5 L- L$ v% Y- R7 Y- h
  351.   def run
    # p* {. c3 w" c. C: \; F! ^/ C
  352.     Mouse.init* [4 B. ~5 Y: l; z1 ]* S6 T; I6 g
  353.     sion_mouse_run( \# `; S+ k3 o6 s3 ~, V  b
  354.   end& N) \# w- Y. z: f4 q. ]# k1 C+ Z
  355.   #--------------------------------------------------------------------------
    8 P/ D3 p  R! i& o8 n% [8 `, n, M
  356.   # ● 切换
    4 x7 F# _. r" f$ Z7 j5 F: n/ @
  357.   #--------------------------------------------------------------------------
    ) G& U) A3 T9 M- `) j1 V
  358.   def call(scene_class)
    2 u* t. v8 K+ B" H
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    7 _3 J* t8 S2 a( u; ?1 u! Q3 g: K5 L
  360.     sion_mouse_call(scene_class)
    8 `, F/ i, D) N( e6 l( h
  361.   end6 W$ C1 ?7 M- l' b! r* K
  362.   #--------------------------------------------------------------------------
    , ~" J' L! |% D, r1 ~* s
  363.   # ● 返回到上一个场景0 D) p- r+ ?* |( s: O2 k
  364.   #--------------------------------------------------------------------------* l6 h& e  p- g/ r
  365.   def return
    * z% U3 ?, J3 x0 M
  366.     sion_mouse_return
    0 j: ^: K! M0 _1 \" l5 d
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&
    5 X$ C4 m  \: ~* D& @  C, u
  368.       @scene.instance_of(Scene_Map)1 O8 K- P: l4 ?+ e
  369.   end) G2 ]+ u# v- ]9 @
  370. end
    4 q, F# \4 \& ^, Z

  371. 1 T0 ]: E7 {  t6 Y: G
  372. #==============================================================================
      c  v: l' ?3 J$ w* m
  373. # ■ Module Input
    0 `: y# q+ g7 b
  374. #==============================================================================: H5 h0 v& N/ L9 Z! y+ p4 B3 h
  375. class  Input
      e5 I' Y: j; T, i" b
  376.   #--------------------------------------------------------------------------
    0 E& X- _3 [2 U+ U* x, j; y/ m
  377.   # ● alias& z3 ]1 x/ {9 E' S) x
  378.   #--------------------------------------------------------------------------: e1 T- p! J% P3 R$ v1 ]
  379.   unless self.method_defined(sion_mouse_update)  E  z# a6 a/ w
  380.     alias_method sion_mouse_update,   update
    " F. n- Y. e& I4 H0 n! b1 _: ~4 j9 ?
  381.     alias_method sion_mouse_press,   press
    5 p& X" }9 C- R4 K) W, o2 D
  382.     alias_method sion_mouse_trigger, trigger
    4 H( P6 b* V( `% O) n
  383.     alias_method sion_mouse_repeat,  repeat
    / u. N7 ~, A+ ^
  384.   end
    / i2 T( W. P  O( @
  385.   #--------------------------------------------------------------------------
      C7 Y/ X* `! w( Q1 b! _' r3 i
  386.   # ● 更新鼠标
    0 m, C( k% L* [. V
  387.   #--------------------------------------------------------------------------: ?9 N# R( q7 w  i
  388.   def update
    1 f6 O' i' T8 @9 Y9 U# F% I; C
  389.     Mouse.update& ]0 R! v4 d0 X9 l  T7 o3 z4 c
  390.     sion_mouse_update" Y$ `* T' Z9 A2 {
  391.   end( L1 C& O1 T0 h! @2 P
  392.   #--------------------------------------------------------------------------
    : a) L( i( |4 o* b
  393.   # ● 按键被按下就返回true4 c9 {4 L- b% G: O; j
  394.   #--------------------------------------------------------------------------
    0 b9 @# s" E' K1 r
  395.   def press(key)' F8 W: U. c7 B9 {
  396.     return true if sion_mouse_press(key); p$ U- {2 _2 }
  397.     return Mouse.press(0x01) if key == C
    * c6 [7 n: h' o8 J4 ^3 }" ~
  398.     return Mouse.press(0x02) if key == B! N. r! O% R8 F( `7 z9 ^
  399.     return false6 g4 c- v0 e8 V; q: p4 e( x
  400.   end! k: E1 G4 v  _& w
  401.   #--------------------------------------------------------------------------, x* @" J6 _" S9 Z4 j
  402.   # ● 按键刚被按下则返回true2 T& l/ Q+ W2 f, M% D6 A7 j
  403.   #--------------------------------------------------------------------------- x  c$ G3 d3 o
  404.   def trigger(key)3 ?7 H8 ]8 D2 j
  405.     return true if sion_mouse_trigger(key)! k4 {8 z# [1 R, S3 P4 D
  406.     return Mouse.trigger(0x01) if key == C
    & a, I; g4 B; c! p" {/ l
  407.     return Mouse.trigger(0x02) if key == B# F' f8 A* G; k- P
  408.     return false
    2 F9 d; B5 |& E7 E) ^
  409.   end+ b8 c, w3 n+ ?0 t
  410.   #--------------------------------------------------------------------------
    ! @& Y0 q  Z1 H* }0 [
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true/ I8 `/ j3 G7 r) b* V
  412.   #--------------------------------------------------------------------------
    / w6 U8 J5 s- a$ V9 D; e
  413.   def repeat(key)
    8 _( z) W' w6 ?' J) x
  414.     return true if sion_mouse_repeat(key)4 c6 @: B' z! {3 B
  415.     return Mouse.repeat(0x01) if key == C9 S" r; j7 P" M0 v; \$ s8 `9 {
  416.     return Mouse.repeat(0x02) if key == B; v5 ?/ v0 z9 U2 g# W, C  c
  417.     return false: r" W5 N+ L: W+ n
  418.   end
    ( w' n) H0 X7 D9 ?( o8 A' @  s
  419. end" C9 g7 [! w6 p) R: w  S
  420. $ k; o$ W- w& O2 s, n
  421. , \3 f- v2 T! R$ o
  422. #==============================================================================# Y' s$ v! [0 d& ~( u" D2 Z
  423. # ■ Window_Selectable
    3 T$ S# [5 A* n: g/ q
  424. #------------------------------------------------------------------------------
    , w6 B/ V  P# o; ?7 \
  425. #  拥有光标移动、滚动功能的窗口1 a  \0 f/ Q$ F1 s. u
  426. #==============================================================================0 z% {  l. }. z# n
  427. class Window_Selectable
    5 S! H3 A, }  H
  428.   #--------------------------------------------------------------------------
    3 O: L( `# L$ W6 F/ h- y" R
  429.   # ● 初始化
    % R; w0 z" J6 x8 D2 Y' C
  430.   #--------------------------------------------------------------------------
    . b( _2 M  ]$ `- ^5 w1 h! B+ F
  431.   alias sion_mouse_initialize initialize
    & M$ `, |6 d+ X- K8 K
  432.   def initialize(x, y, width, height)
    : u' e0 K1 ^' j) x
  433.     sion_mouse_initialize(x, y, width, height)0 A6 F* B; ~1 i3 E
  434.     @move_state = 03 H* Y+ }4 p# Z( z
  435.   end" P4 E- G' o! w, W2 ~: S! g! O
  436.   #--------------------------------------------------------------------------  Y0 M( f8 c. Y, d& T; m2 r" \# @) ^
  437.   # ● 更新
    ' E  A  Y/ a6 _+ q3 |
  438.   #--------------------------------------------------------------------------+ _" H# t1 z. M" L# k
  439.   alias sion_mouse_update update; {: q  R3 N$ A$ k9 J
  440.   def update% m- U- |) T5 ^2 m0 ^
  441.     sion_mouse_update
    8 I* p# ^: E+ }) N, x: N/ R# l7 Y
  442.     update_mouse_cursor
    7 P7 e5 s$ F4 `3 b1 x# |. _
  443.   end+ i* ?# H2 h- Z% z
  444.   #--------------------------------------------------------------------------
    4 I0 y) |8 l# r& [# f( e
  445.   # ● 启动后设置鼠标到index位置0 ~% U0 \" i. p3 S% X! U& x
  446.   #--------------------------------------------------------------------------
    ( I# Z# `/ Q$ L) P- B& ^
  447.   def activate: D" o* z1 i- v' B4 s
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos+ |) _' Z" W3 d; G; R8 b* J, s
  449.     super4 W  R2 }0 K5 J* r3 k, u: M" K0 c. [
  450.   end
    , C7 Z; F5 N% F! r( X  d: f) l: A% g
  451.   #--------------------------------------------------------------------------
    8 u9 }5 F/ v/ J" ~7 S
  452.   # ● 更新鼠标和光标的位置7 K6 [" q/ ?. ~% K4 d
  453.   #--------------------------------------------------------------------------2 i8 O0 ~7 D, O$ f1 n$ Y, @
  454.   def update_mouse_cursor3 X6 G/ v' ?; F+ w
  455.     if active
    ; I( i& B3 v# X" x# Y4 n; r
  456.       if @need_set_pos
    8 }  v. {8 q) q
  457.         @need_set_pos = nil
    ! K' {& T; z; |7 }6 T
  458.         set_mouse_pos+ h# M3 H- k) `
  459.       elsif cursor_movable2 E' k% e$ b$ X2 d5 X& K, z4 @
  460.         Input.dir4.zero  set_cursor  set_mouse_pos- E$ q5 ]# C1 h2 g& U% q
  461.       end3 E3 O8 b7 q! ?" d
  462.     end# l( F9 }, D6 k2 p
  463.   end* Y! a! c: ~# R8 u4 q
  464.   #--------------------------------------------------------------------------
    . S/ c! U" Z* o( C: m3 [
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能( s) `: \9 O( A: g+ k( o
  466.   #--------------------------------------------------------------------------( `5 \4 f0 y3 Q  `2 z2 B
  467.   def set_cursor# f! v' c) |7 S, S9 {- M( C+ s* b& P
  468.     mouse_row, mouse_col = mouse_window_area
    ) u9 R! g0 t, d% s! Y
  469.     if    mouse_row == -1
    5 T; o6 p$ X3 f, k$ r% z
  470.       @move_state += 1 if need_scroll
    / Z/ K  {! y2 R
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand% Q) F% [( D) A
  472.     elsif mouse_row == -2
    3 n( Y8 q, w7 y' L
  473.       @move_state += 1 if need_scroll  _3 M% V, Q+ Y) e' r" M$ i
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand/ E! \# S* K+ h2 Y& [9 T- y
  475.     elsif mouse_col == -1
    " p3 T% f  b) W# B( @- m
  476.       @move_state += 1 if need_scroll
    - x$ c" U7 I( t5 i
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    : z3 w. `+ ~0 [" B1 a# i4 y0 l& H
  478.     elsif mouse_col == -2* _. p  S7 x7 {2 J- Z/ W+ k
  479.       @move_state += 1 if need_scroll6 w+ ^+ n8 H8 O5 D7 P$ {( K
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    3 g! J7 r' L* z7 n( u/ M
  481.     else
    & x5 v8 Q1 O# H: r& D; `" \
  482.       @move_state = 06 t8 j& [* M0 E0 E& j0 P+ @4 K. @- s8 f
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    5 @: U; p9 v* V( {) g
  484.       select(new_index) if new_index  item_max && new_index != @index
    & |$ ~  I7 D$ {- r+ q, I  }
  485.     end
    5 \0 w: u$ R8 B7 }
  486.   end7 m. l1 ^2 \9 l6 l' u3 q9 S9 \
  487.   #--------------------------------------------------------------------------
    / J' E- o% e# K5 A% a) k) y4 d/ H' N
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    0 @! g3 q/ ^8 Z; U/ D5 b
  489.   #--------------------------------------------------------------------------9 u2 J' \9 M6 e' j
  490.   def mouse_window_area
    6 t# x2 O0 e; m; C& P- s
  491.     if viewport.nil # necessary!6 A% s7 W2 R1 l4 x, ]0 J
  492.       vp_x, vp_y = 0, 03 h! |+ V, K* v/ x. T  u+ s, n: T" K
  493.     else6 t- l2 d; `( ~5 I% @& d& E
  494.       vp_x = viewport.rect.x - viewport.ox% |* w9 ^: p( ^% }, z
  495.       vp_y = viewport.rect.y - viewport.oy
    9 |) @3 W9 U- U+ D! e4 i
  496.     end
    6 {! U  o5 L' U2 Z/ N: G' ?
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y/ P+ F2 F. ~- e4 v7 m
  498.     item_x1 = vp_x + x + standard_padding
    ( C9 k* }# u/ v% P& z, h0 z
  499.     item_y1 = vp_y + y + standard_padding3 O+ Y8 y; [' q+ F1 m, @  E9 B
  500.     item_x2 = vp_x + x - standard_padding + width
    ) t1 r2 u3 S8 V
  501.     item_y2 = vp_y + y - standard_padding + height
    6 V0 W* _% M( U# e5 s. h
  502.     if mouse_x  item_x1
    + ^8 j3 Q. g9 {; K& I
  503.       mouse_col = -1
    , P5 h0 T% z5 ?# [* q, H' U9 E3 {1 |
  504.     elsif mouse_x  item_x22 t5 T# c. j$ l2 k8 g" G( x" P
  505.       mouse_col = -29 F; [& R5 w5 j% c, S
  506.     else: K) H; S: s% A4 w% s6 h% P
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)& w0 Y8 u0 r& N
  508.     end+ a- H, h! r$ [. F; W
  509.     if mouse_y  item_y1: n6 J) I6 T: k+ q
  510.       mouse_row = -1
    7 l/ Y- ~, F6 a( i8 E& w
  511.     elsif mouse_y  item_y2
    ! H! ]. f% P  C6 W( O  i' n' j
  512.       mouse_row = -2  r& Q: X/ c* p% I( q$ E/ m2 g
  513.     else' L" k( X5 M- e  r5 c# K# W
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)" C$ k4 ?5 S+ N$ k* P
  515.     end
    . p/ ^# F' x6 h0 d2 }) ]
  516.     return mouse_row, mouse_col
    1 S6 ^1 Q& a: b5 t6 ]
  517.   end# w: u' M3 m# d, S# F
  518.   #--------------------------------------------------------------------------
    . d) G4 _2 d& K# f  P. u: I# ^
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置$ ^* v* p' l6 k
  520.   #--------------------------------------------------------------------------
    ) F& z9 e  K" m0 c/ w& w5 v$ J
  521.   def set_mouse_pos
    / m' Y. J* T0 q9 [% B; i- V
  522.     if viewport.nil # necessary!' A, |, q7 g+ [; v2 c# l
  523.       vp_x, vp_y = 0, 0
    ; r6 Z: a% @* U+ k
  524.     else
    4 ?1 j3 {) [3 R" h% E2 D
  525.       vp_x = viewport.rect.x - viewport.ox
    ) ~; C6 `) e% R: u
  526.       vp_y = viewport.rect.y - viewport.oy3 @# h! k" S" Z! Y' t' F% J
  527.     end
    7 ^+ H3 @! b# r3 P6 C" W- Z# Q
  528.     item_x1 = vp_x + x + standard_padding
    + K" O$ f, {/ t4 g
  529.     item_y1 = vp_y + y + standard_padding' d# Q( ], y4 t9 \) D  k) t) o1 r
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index + f# b8 E. L6 n
  531.     row = get_index  col_max - top_row
    - G. d7 S3 @8 S9 S( s/ ]
  532.     col = get_index % col_max
    % n& `/ w5 V7 ~9 o% B& N! g& A
  533.     new_x = item_x1 + item_width  (col + 0.5)4 K2 b6 \( x6 t% ^/ {( U
  534.     new_y = item_y1 + item_height  (row + 0.5)" ~& h' Y6 X( r1 z7 l& c8 v
  535.     Mouse.set_mouse_pos(new_x, new_y)/ R" k: ?) s* `/ D9 D
  536.   end
    6 j7 S5 b% \2 d0 |( O7 S
  537.   #--------------------------------------------------------------------------
    8 v* J+ ^& t# Q% z8 A" V% d
  538.   # ● 判断菜单是否需要卷动
    ; y( ?  b! p/ h  V* A/ x5 @1 x4 {
  539.   #--------------------------------------------------------------------------
    7 @. V% j* n# {4 A
  540.   def need_scroll
    0 W* W3 {3 F7 e  N
  541.     item_max  col_max  page_row_max
    % }+ [9 U2 L' L7 p, Q
  542.   end
    6 |2 x/ v8 f& Y% L8 R/ k# Z% H$ {
  543.   #--------------------------------------------------------------------------
    / t5 T, M# d; ~3 v% B, p9 W
  544.   # ● 判断是否为水平卷动菜单5 U3 H0 {( }1 ~3 A6 x0 Q
  545.   #--------------------------------------------------------------------------3 d, h3 e5 g# \& Q6 p
  546.   def is_horzcommand
    3 r  J1 z9 J& r0 M
  547.     return false
    - {. l6 t. M. X5 ]9 M+ |! a# A
  548.   end
    1 b$ U/ _9 x  g
  549. end
    ( f8 a* @: S! z: D' F- w8 A
  550. ) G/ x9 E: b9 M; F
  551. class Window_HorzCommand
      h  p; v. A0 w# \' L# ?- u
  552.   #--------------------------------------------------------------------------7 y" p& S/ a5 O' n, t
  553.   # ● 判断是否为水平卷动菜单9 j# v( _& Z0 @0 F1 F! u7 p6 g
  554.   #--------------------------------------------------------------------------8 G5 g. T: R) I
  555.   def is_horzcommand
    - a$ |! D! B  }& _! F5 Y! A
  556.     return true( l* `) S: A6 C
  557.   end- r) E) G3 C5 s, P- h% W
  558. end% I: S  k4 K0 l4 ]4 X
  559. & P2 Z' S3 O! W  b8 s9 e
  560. #==============================================================================. y# \$ V5 j6 z2 b) j
  561. # ■ Window_NameInput
    ! n4 G. K4 J! }5 L
  562. #------------------------------------------------------------------------------1 o: C+ [% M3 L  w# G. f9 r
  563. #  名字输入画面中,选择文字的窗口。
    ! T, _4 _  {3 A6 J" B1 Q3 C
  564. #==============================================================================6 |* ~7 F! h- R, @: C* z
  565. class Window_NameInput% t# D4 V- Z$ U* w* C" O
  566.   #--------------------------------------------------------------------------
    7 m8 y" q( a! a* C+ R1 B% Z
  567.   # ● 设置列数
    8 P& z6 i- X0 g5 f2 T6 X* X
  568.   #--------------------------------------------------------------------------, a0 k3 ?: c5 [: R+ z
  569.   def col_max( t* B/ P/ n' ]1 a0 Y8 f
  570.     return 10
    " ~% W# Q# X( \6 V% v
  571.   end+ E% ~1 k) p" T% {" }. u* P
  572.   #--------------------------------------------------------------------------! Y. }' `# |0 ]: j
  573.   # ● 设置填充的Item个数
    ) p3 ]6 f5 U; T7 m
  574.   #--------------------------------------------------------------------------
    2 x( u+ \' P% e: i4 h+ ^# k
  575.   def item_max
    7 m9 j+ v0 }- D. h
  576.     return 90
    : o, P' N3 _' U( _" M) a# j  C
  577.   end
    6 w- H) v- G' t& V* {# F
  578.   #--------------------------------------------------------------------------
    6 ^4 h+ E& p% `8 d3 h% p4 F3 K
  579.   # ● 设置填充的Item个数
    2 t, x+ [  B3 D/ `  P, L
  580.   #--------------------------------------------------------------------------8 B/ T: C- l- J0 m5 t
  581.   def item_width
    + g1 b5 Q: v8 ^" Y. a" ?
  582.     return 32; ?8 p. f" `% h2 k1 Z
  583.   end0 \& G9 X- J6 e6 M
  584.   #--------------------------------------------------------------------------
    7 s5 h6 }4 Y, B7 P
  585.   # ● 判断鼠标位于菜单的第几行、第几列# _( c) S3 h" Q3 N) k
  586.   #--------------------------------------------------------------------------
    " P1 ]/ a. u- e6 G
  587.   def mouse_window_area
    % p. M( n" @7 f- H1 G8 N
  588.     if viewport.nil: p  b; A, O+ V
  589.       vp_x, vp_y = 0, 0" Q0 K. C4 d: X8 q
  590.     else
    ) v0 i' ]4 E- H9 P+ S% B
  591.       vp_x = viewport.rect.x - viewport.ox
    9 F1 a' g1 A0 a
  592.       vp_y = viewport.rect.y - viewport.oy
    - b3 z2 N( C8 S; {5 D) T) d
  593.     end5 ^6 ]2 ?1 L8 o/ T+ {+ F
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    . G3 X) ?- T: {' U
  595.     item_x1 = vp_x + x + standard_padding
    % Y5 B7 |5 s$ O4 J
  596.     item_y1 = vp_y + y + standard_padding4 m! F* I, R& C# v
  597.     item_x2 = vp_x + x - standard_padding + width
    . R- D3 }1 t# w: C8 P
  598.     item_y2 = vp_y + y - standard_padding + height5 J5 i, d" c* Q
  599.     if mouse_x  item_x1
    2 G: j' s2 |1 g5 R2 h( T4 e
  600.       mouse_col = -1/ C1 `8 b2 o# u* R
  601.     elsif mouse_x  item_x2
    8 I0 @4 H) _9 i, j8 Z. a% X
  602.       mouse_col = -2, Y$ W: {! R' ]; \. m* S7 x' I6 F3 ?
  603.     elsif mouse_x  item_x1 + 1608 J2 h. _0 d7 r* i
  604.       mouse_col = (mouse_x - item_x1)324 n1 ]5 L6 q) A; X8 w$ w  l
  605.     elsif mouse_x  item_x2 - 160
    ! b$ X& D/ b: k+ e7 z2 [+ S: v; J
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    ( k/ p: Y0 p0 d9 `1 w# ]
  607.     else
    2 k: {9 v- f% l6 o7 v5 x- i
  608.       mouse_col = mouse_x  x + width2  5  4
    - m- I# n9 Y# W" g# K
  609.     end
    % }9 M# L& Y. i& Z/ d6 j# R: z
  610.     if mouse_y  item_y1
    # y5 S( ~" ]7 ]. ~
  611.       mouse_row = -1  B8 |6 y, {' X7 ^
  612.     elsif mouse_y  item_y2
    ! M8 d. ]2 |6 A4 G8 ?9 l' E5 ~/ M
  613.       mouse_row = -2
    4 e6 [' H6 Z  n% y' v" @- ?4 y
  614.     else
    ) S$ c% Z1 w! t5 r7 W1 @, X
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    & K9 E3 V' a5 O9 H. o) d) l  ?
  616.     end
    " e% b  O6 w1 P0 C1 v
  617.     return mouse_row, mouse_col7 U2 e# H8 Z* a( w2 k/ P
  618.   end
      ?) _8 Z0 e8 h- T) o. t
  619.   #--------------------------------------------------------------------------% a1 D/ Y) I- T4 W% f
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    8 j/ r+ \# _1 h& M
  621.   #--------------------------------------------------------------------------; w+ [9 J! R2 Y+ g* Y+ V
  622.   def set_mouse_pos
    4 A; `. S7 \$ s7 {3 A
  623.     if viewport.nil # necessary!  E; x9 h& m; v' O4 r8 H0 {1 I
  624.       vp_x, vp_y = 0, 0; X9 e1 ~- G# q) I1 k
  625.     else
    & B# Q# Z( |* Y9 G( N( D- X* f
  626.       vp_x = viewport.rect.x - viewport.ox8 V% h8 _$ U# F. S1 o
  627.       vp_y = viewport.rect.y - viewport.oy) V$ F* i! V! J) B
  628.     end
      A8 v  a  v* F: K
  629.     item_x1 = vp_x + x + standard_padding
    : R& W% d+ s. I8 g5 f, S
  630.     item_y1 = vp_y + y + standard_padding7 F5 z. L  m& H9 Z% x! }' r
  631.     get_index = @index  0  0  @index
    % ]5 [: g4 [$ z( d; |& c+ Q  m9 K
  632.     row = get_index  col_max - top_row
    ; I8 k9 a/ _( W
  633.     col = get_index % col_max! s3 o" N# k  I/ q# i' {7 [+ j
  634.     new_x = item_x1 + item_width  (col + 0.5)" E4 Y% V$ M; D# f3 a2 F) o/ ^
  635.     new_y = item_y1 + item_height  (row + 0.5)
    1 M% s5 a' A* s/ c
  636.     new_x += 14 if col  4% x, t3 d7 p5 y1 e
  637.     Mouse.set_mouse_pos(new_x, new_y)
    , d) V/ e3 w+ @2 H  C  i
  638.   end
    2 h, o& f' v0 |# U7 S' A2 v
  639. end
    " u- e# H7 P5 ?; o) m# ~

  640. 8 e- m; r$ I& N8 S! v+ x
  641. #==============================================================================
    # H+ |3 f) ?) f5 ^9 u! X& o
  642. # ■ Window_NumberInput4 a  ^- ]( G1 D' Z8 o2 R
  643. #------------------------------------------------------------------------------! {6 E; x* T8 C) v
  644. #  重写了数值输入的方法以适应鼠标
    ! A) `* m% s% O  S+ \4 O
  645. #==============================================================================
    3 C2 q0 M& H; ?) A
  646. class Window_NumberInput  Window_Base, C7 S8 D! {: e8 v$ b
  647.   #--------------------------------------------------------------------------
    0 z/ K8 m- {* y0 z& p, ?. `
  648.   # ● 定义实例变量/ Q4 w) ?# n" F$ `8 H, e$ w& S
  649.   #--------------------------------------------------------------------------
    4 Z: J- I7 l: M9 f9 V
  650.   attr_reader extra_window" ~/ x" E0 N% A
  651.   #--------------------------------------------------------------------------9 a1 Y4 S0 g" @+ q+ j2 D# i
  652.   # ● 初始化& G! o1 ]5 R- A
  653.   #--------------------------------------------------------------------------
    , v2 a% A6 D- @- b2 g
  654.   alias sion_mouse_initialize initialize' d+ }0 j$ d  R& \7 B
  655.   def initialize(arg)! s& N# X% a1 D( h9 S
  656.     sion_mouse_initialize(arg)
    8 e3 y3 B7 v+ _( n! F$ `6 x- J
  657.     create_extra_window
    3 k6 }5 M  k/ X$ j$ g
  658.   end* y. k* S( O1 B  i( D
  659.   #--------------------------------------------------------------------------
    3 P1 m# M* d6 v* _/ t5 D. Y
  660.   # ● 启动
    ! R5 Y+ O- h4 x
  661.   #--------------------------------------------------------------------------& c/ X  f0 e* W9 z1 ?$ ]4 z5 r  ^
  662.   alias sion_mouse_start start# ^7 w- U- O' ^  q
  663.   def start) i8 K; ~: x  w2 R0 S) i2 ^  C8 H4 {
  664.     sion_mouse_start
    " _/ d) B! H. d: D2 F& ?" L$ g
  665.     deactivate
    * Z9 D& T) ?7 C- f/ D8 L0 D
  666.     extra_start* |# F. L& i9 y, y5 u* B; D
  667.   end1 E: W9 q9 P. b+ A0 R4 y
  668.   #--------------------------------------------------------------------------
    8 }! N/ |; \# F  h) y
  669.   # ● 创建新的数值输入窗口
    4 \9 c+ K+ w  U( ]  y
  670.   #--------------------------------------------------------------------------
    , _/ K$ N' m5 n  a! V# Y0 }& o; M
  671.   def create_extra_window* w% u8 [1 s' ?/ O# _- P
  672.     @extra_window = Window_NumberInput_Ex.new) a5 @& W+ a- q3 p/ \
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    7 l  H7 o: N" G' J8 Q) N9 Y
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    & t- \; v1 i( P& N; {+ W
  675.     @extra_window.index_proc   = Proc.new {n @index = n }& K& }8 _. m( G+ S
  676.     @extra_window.close_proc   = Proc.new { close }
    - `: R. ]' a& K3 O1 I6 {
  677.     @extra_window.refresh_proc = Proc.new { refresh }
      H2 H3 D1 E/ \  r" A0 J/ T1 v
  678.   end! V& J4 B4 w% B. P7 m* x. f4 S5 j5 ?
  679.   #--------------------------------------------------------------------------
    & k+ h, D$ K. W- ^6 l. R
  680.   # ● 激活新窗口
    . `. W8 n2 \! [7 R
  681.   #--------------------------------------------------------------------------
    , r0 l5 T, n. m! ?9 V0 E8 z
  682.   def extra_start
    4 D+ u5 ]" G) z% f
  683.     case $game_message.position
    " g' ?% n% w* P" ?
  684.       when 0; @extra_window.y = y + height + 4
    , ?8 Q) A$ @! x# \# t7 V
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    / O5 \# X) [, M# F) ?
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    ! h2 O' e6 W& T5 p, \9 m0 B
  687.       else  ; @extra_window.y = 8( P6 Y8 P4 W; W0 _! a
  688.     end
    . a0 Y8 E4 B! E$ f* v
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    , n1 K/ I* v+ m9 n; [/ s$ d
  690.     @extra_window.digits_max  = @digits_max4 w  p( K& K# ?$ Q, x! O
  691.     @extra_window.number      = @number
    ' @) K4 B$ s6 R; V) ~" s' o. S8 f3 T9 Y4 Q
  692.     @extra_window.open
    5 m6 _, x" ~- H2 C* A2 s  [
  693.     @extra_window.activate
    5 N+ Y. o) S# V! _1 O
  694.   end5 k# ^3 E  e& ^% J* Y
  695.   #--------------------------------------------------------------------------
    ' F! p# i$ T6 `7 x* e
  696.   # ● 更新$ n* e, [) ^; O$ s9 |! P
  697.   #--------------------------------------------------------------------------. [  a3 o! u% G1 `$ ]% k, O
  698.   def update
      X7 ^8 V6 l3 K4 g: s, Z
  699.     super
    + Y1 m& n' F1 B- O0 U* h
  700.     @extra_window.update( Y5 I8 A& o! N- f% m: `
  701.     update_cursor
    ) t' c' v' s  U
  702.   end7 R/ t5 I" h# c& ]/ p2 s
  703.   #--------------------------------------------------------------------------
    , n0 O" r6 ~" H% o8 `! t5 t+ A; f
  704.   # ● 关闭窗口
    / m0 b; X  i8 m5 R6 R( a7 g* [
  705.   #--------------------------------------------------------------------------
    & G! R" S  Z1 B8 y% x
  706.   def close
    / S* Q; e+ \$ q0 R5 @+ t- u
  707.     super2 C- d& m: F" c$ C
  708.     @extra_window.close" a( w, a# g+ b1 A! `
  709.     @extra_window.deactivate
    5 A9 L) W8 g  ^% ~+ u
  710.   end
    7 Q  o3 D9 b( Z7 ^) L
  711. end( D+ ~) S8 R7 @: |
  712. / v9 ]1 E/ r8 U8 l) C& D- s5 [
  713. #==============================================================================
    $ V: `+ c# v% p5 n9 t# L
  714. # ■ Window_NumberInput_Ex: ]0 Z- M/ x) f" l. C
  715. #------------------------------------------------------------------------------# Q& q3 R( q" z0 G, V: u
  716. #  新的数值输入窗口(NewClass)
    . j- g# c4 C9 N) v& I8 A
  717. #==============================================================================6 p/ G9 N8 \% h3 q, p* Y
  718. class Window_NumberInput_Ex  Window_Selectable
    4 O, _, q: q+ _
  719.   #--------------------------------------------------------------------------- N" \: U4 c/ j2 J/ |4 }
  720.   # ● 定义实例变量
    ' T* l- k/ w3 V5 f4 ?% `: O
  721.   #--------------------------------------------------------------------------
    * b( [$ R. E* }8 c  d- O3 l0 x9 B( U
  722.   attr_accessor number_proc
    5 n; E2 }' |: h' @" p# ]
  723.   attr_accessor index_proc2 m% ?, v7 E" u+ f
  724.   attr_accessor close_proc
    ; [  J1 k: R: u1 a* f4 ^* ^3 H2 z, R
  725.   attr_accessor refresh_proc8 ?% J" }. F9 P' k" O; `& x  W0 d
  726.   attr_accessor number
    ' O+ ]& s0 K! R3 ?6 `2 N
  727.   attr_accessor digits_max
    ; b( {( b7 ?6 ^; b3 B# \
  728.   attr_accessor variable_id
    ; e. c1 C( \" w& K. r
  729.   #--------------------------------------------------------------------------
    ! `- A$ ^9 N0 O0 _/ h: @( D. J# O* t; G
  730.   # ● 数字表
    * h# G+ n0 G; \$ y3 K# Q
  731.   #--------------------------------------------------------------------------
    8 [, [% v  I  g' y( ^! [- V+ n
  732.   TABLE = [  7,  8,  9,
    ! J0 y+ V: C' p; s
  733.              4,  5,  6,6 h" ?9 S% |! W1 \9 k0 `4 t% x1 X- M
  734.              1,  2,  3,
    ) o) X3 F3 ?/ q( t4 J5 T0 U; [( L9 G
  735.             '←',0,'确定',]* v+ K$ K& |4 Y, j
  736.   #--------------------------------------------------------------------------
    , E: |0 J- e: A9 t8 r1 O- F  s6 O
  737.   # ● 初始化对象
    ( V9 S4 F3 O8 b) Y% F' c
  738.   #--------------------------------------------------------------------------
    5 \$ S; e7 j# ~4 u. @# F  }8 H
  739.   def initialize
    2 ^, m! m# A) z8 l* F6 R) f7 x
  740.     super(0, 0, 120, fitting_height(4))6 u6 u4 p# _& f. l
  741.     self.openness = 09 u' v2 {/ d" C, S
  742.     @index = 0
    5 y6 h9 n- B3 h
  743.     @number = 0
    1 ]- z, r$ Z' q& \
  744.     @old_window_index = 07 H  o8 {9 m+ u- R
  745.     @digits_max = 0
    - j+ i4 H; c5 N5 [5 \0 j; H
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }: ]! X+ D4 s. F" w$ Q
  747.   end, B: V: w8 c5 r5 B
  748.   #--------------------------------------------------------------------------
      V$ A, {- [4 F- d& G' D7 c
  749.   # ● 获取项目的绘制矩形
    # i4 b0 e; C6 `. G
  750.   #--------------------------------------------------------------------------
    5 ~2 U# {- U- c" q, N& _) r
  751.   def item_rect(index)
    & c# A' |; k0 X- u
  752.     rect = Rect.new9 ]2 A0 c: }, J' }: N1 R1 j9 X1 i
  753.     rect.x = index % 3  32$ G+ n+ Z& p/ n0 k/ @# ^$ u
  754.     rect.y = index  3  line_height
    9 R% g7 J+ H, e
  755.     rect.width = 320 `. a7 L4 T8 |6 k6 }' o0 R% @
  756.     rect.height = line_height, x' j6 s- S. I4 l0 j$ U: X
  757.     return rect
    1 I7 a# w4 D  J6 F8 O$ R4 R
  758.   end
    0 l+ L3 G7 J8 E; g/ |& d4 w. k
  759.   #--------------------------------------------------------------------------
    ; n, q5 [- Y/ C+ z1 f7 X
  760.   # ● 将光标设置到鼠标所在的位置
    5 ~# K1 T& T9 c$ C9 h2 [
  761.   #--------------------------------------------------------------------------6 P. H, ?; ?3 p  f1 M
  762.   def set_cursor
    3 I1 j2 ~. I1 t; }" y4 G/ \
  763.     mouse_row, mouse_col = mouse_window_area
    6 G5 \, x, B  S5 X
  764.     if mouse_row = 0 && mouse_col = 0
    ) c' Y8 i3 K. l
  765.       new_index = mouse_row  3 + mouse_col* d5 T2 @1 g" n+ e0 a$ {5 N" Y$ g- {
  766.       select(new_index) if new_index = 11
    / N( r4 c6 g% k8 B0 d
  767.     end
    , R. X  B! M6 W7 h4 l. z: B8 R
  768.   end
    ( {6 f) u$ B. I- P& T- Q
  769.   #--------------------------------------------------------------------------
    8 e& G! }6 J/ @0 o- ~) d4 X, i8 O
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    5 ~1 W& Q* C! T9 j- `+ ^4 Z
  771.   #--------------------------------------------------------------------------$ `$ ^: Y- a! q" L
  772.   def mouse_window_area- I2 [5 ~( g1 }5 n
  773.     if viewport.nil. k/ L4 V5 `$ }) s: I
  774.       vp_x, vp_y = 0, 0" d) X3 I2 y% X* m( g9 e# N
  775.     else5 U+ g; g# j: k, ]% L1 i: T
  776.       vp_x = viewport.rect.x - viewport.ox4 L* u1 z$ V' x# t/ p
  777.       vp_y = viewport.rect.y - viewport.oy
    . Y' a( j+ R" C" k3 Q# z1 @
  778.     end
    ( ^; B: ?5 h5 j, o/ P% h
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y1 k/ U1 g- J0 Z  q1 K+ O
  780.     item_x1 = vp_x + x + standard_padding ( K1 i/ S! o4 ?' R3 R9 l! ?7 p
  781.     item_y1 = vp_y + y + standard_padding6 W0 ?" C8 d8 r( U, ^
  782.     item_x2 = vp_x + x - standard_padding + width* X% e6 J' E: V7 {
  783.     item_y2 = vp_y + y - standard_padding + height
    . [  Q* L6 R0 {$ V; ~
  784.     if mouse_x  item_x1
      B# L9 X# M% [6 I4 ^
  785.       mouse_col = -11 f1 h  v% g' M) V# B6 q& P& z: \
  786.     elsif mouse_x  item_x21 S+ |- `$ y' T! U  V
  787.       mouse_col = -2
    + A* |, ?3 f  ]: m  {
  788.     else6 k" s4 n' q; I3 E" B. [- ^7 M
  789.       mouse_col = (mouse_x - item_x1)  32
    + h- k4 G0 K- N' j& y) `% z
  790.     end
    4 k' Q1 O7 ?* K/ C5 H* u+ Y% K
  791.     if mouse_y  item_y1
    7 A  Q/ q8 h  n% `
  792.       mouse_row = -1
    5 g6 ]" F' D7 h1 c1 K
  793.     elsif mouse_y  item_y2, s0 X0 y! k6 m) x2 S  b
  794.       mouse_row = -27 |/ Z+ E3 M2 L( w
  795.     else/ d# Y  {+ J( |( W! ?9 s
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1); p! q2 B8 I* L2 f5 h) K. q6 c# f* @
  797.     end# C& K& b8 x5 B, n$ p* C) f* A7 N1 N
  798.     return mouse_row, mouse_col$ k, @  H) O& }$ K7 l
  799.   end
    4 g" `  ?; Z* h& p; P3 d
  800.   #--------------------------------------------------------------------------
    + [& G; @2 V5 v; ~, I
  801.   # ● 获取文字
    ; L3 @" y- ~9 e
  802.   #--------------------------------------------------------------------------5 q# F& r3 v' K3 ?- `1 c
  803.   def get_number
    6 l. ]1 |3 O4 e+ u
  804.     return false if @index == 9  @index == 11
    & W- p' b' n% P& c& P9 |  R8 K1 q
  805.     return TABLE[@index]
    3 e" h% L# r1 Q) U% M
  806.   end+ ?+ ?4 P: H9 V1 ^; p
  807.   #--------------------------------------------------------------------------% R$ Z5 ]3 m3 k- w) Q4 Z
  808.   # ● 判定光标位置是否在“退格”上( `6 X7 ?* l5 q+ R
  809.   #--------------------------------------------------------------------------
    4 E1 @" A0 m; L. L- A+ r4 o3 _
  810.   def is_delete
    % R' f3 K+ D: x$ j9 M4 o% t  `( E
  811.     @index == 9& F& Y4 |- Q/ H* K) W
  812.   end
    . k+ i5 ?6 s% p0 ]# B1 T
  813.   #--------------------------------------------------------------------------1 E; B. m2 M- j$ C  R# B) p
  814.   # ● 判定光标位置是否在“确定”上) O& @" v1 y: R9 @) P% a
  815.   #--------------------------------------------------------------------------7 }+ {3 j0 i4 S2 z& d. T% j. ~
  816.   def is_ok: S* d2 N# a. @
  817.     @index == 11
    3 b  h% e; r5 f3 l# `- G4 r6 A
  818.   end" @5 ~% h5 y" A
  819.   #--------------------------------------------------------------------------$ @8 p' f% J! G! p
  820.   # ● 更新光标
    + @+ h( c9 f! v
  821.   #--------------------------------------------------------------------------
    / ]+ @, v0 A! R; E0 Y
  822.   def update_cursor$ j; \& X0 D0 n) @7 h) x- h& S
  823.     cursor_rect.set(item_rect(@index))2 A! }/ {/ ?; r4 z4 e4 u7 d
  824.   end. R/ s5 z# Q- R" _
  825.   #--------------------------------------------------------------------------
    3 e, V. m/ w: g+ N9 T
  826.   # ● 判定光标是否可以移动/ j$ r% t- D) z: F( V
  827.   #--------------------------------------------------------------------------2 S- t9 ^9 o' H0 @, N
  828.   def cursor_movable7 ?! q# g; ?$ o7 j" t: D
  829.     active7 C) V1 J% s: f8 ~
  830.   end8 P: {& J0 G- S
  831.   #--------------------------------------------------------------------------+ L  p# ]5 b8 ~" L
  832.   # ● 光标向下移动
    3 C; |2 n, b4 e/ C$ p
  833.   #     wrap  允许循环7 J: r+ ]2 Y) @5 F6 }0 S6 `8 U
  834.   #--------------------------------------------------------------------------
    ( M6 x5 A7 f) U, X4 \
  835.   def cursor_down(wrap)
    - P* i0 w7 ?( g: h1 w6 C' Z
  836.     if @index  9 or wrap
    , w. x4 L$ H% |3 L; y# q
  837.       @index = (index + 3) % 12( F7 U, |' b7 Y4 V
  838.     end
    1 k2 U' F+ t; W  d, s2 s
  839.   end2 O* }9 L( \* y. S
  840.   #--------------------------------------------------------------------------7 }" r! ], A' n; ?3 J: q* q
  841.   # ● 光标向上移动
    0 }3 `4 z0 }5 w) x
  842.   #     wrap  允许循环
    6 E) s# G  r4 [5 `) ~4 ?* N$ I
  843.   #--------------------------------------------------------------------------4 ]' ~6 ]' X) w. c' {: D9 I
  844.   def cursor_up(wrap)9 ~7 O  z0 M, p* i4 n  d# A
  845.     if @index = 3 or wrap
    6 J; L' f$ X6 }+ E& I0 p
  846.       @index = (index + 9) % 122 w! y6 C* I) I/ ?
  847.     end
    9 H1 X  }* @* m; C  u9 E) @7 L$ ?
  848.   end
    ( K! V: W9 j5 M0 ?
  849.   #--------------------------------------------------------------------------
    - N/ G3 n$ Z9 Y& w7 g5 ?/ x
  850.   # ● 光标向右移动# v8 M/ {  z) n# a
  851.   #     wrap  允许循环
    * _) e& }& I# ~* t8 _
  852.   #--------------------------------------------------------------------------; }  n6 Q. b  ^2 f( @) z' _
  853.   def cursor_right(wrap)8 H" q* U- a8 m; ]2 D% w6 G
  854.     if @index % 3  2
    $ H9 x# t6 H# l) V' n7 k8 D
  855.       @index += 1
    0 G: S1 V4 k2 M) V/ x' ]
  856.     elsif wrap
    6 t/ ^3 G9 y) r4 Y  U
  857.       @index -= 2) h$ r  J* M+ g/ b6 N
  858.     end; Z$ g( b. s0 h* [$ m, T
  859.   end
    ; G6 a# V4 C. `, L) u1 T  K8 y/ J
  860.   #--------------------------------------------------------------------------
    ; D, l5 b, q. R, \9 G8 {
  861.   # ● 光标向左移动3 p8 F( }4 a& u2 j# f4 {$ W
  862.   #     wrap  允许循环5 B2 O3 K2 \8 Q3 L2 a
  863.   #--------------------------------------------------------------------------
    8 y7 K; ~6 s8 X9 ]) K: z- w
  864.   def cursor_left(wrap)
    5 |4 n! A" Y) @- ^
  865.     if @index % 3  0
    1 B* X9 o/ R' b1 N* ~
  866.       @index -= 1+ E+ [# q  B) C2 h0 F
  867.     elsif wrap% Q# o! B) T) }, U, d
  868.       @index += 2
    ) a% A+ N- H% p3 E
  869.     end
    " a( O( J' w: f3 {  l& K
  870.   end6 M. W$ s2 C7 T' |7 E
  871.   #--------------------------------------------------------------------------7 R6 L/ g0 z$ s/ L$ g3 b
  872.   # ● 处理光标的移动3 U$ ?& P3 E0 y  T( L. T
  873.   #--------------------------------------------------------------------------, i! j. D3 c) M8 `. M
  874.   def process_cursor_move
    $ }6 O3 S' _; u* J6 e
  875.     super* S# O& o1 Z, N: S' P5 |* X3 y9 j/ @& g
  876.     update_cursor
    - L" W1 \; N; v& L, q  t' F  n
  877.   end
    9 m' A8 f+ V) ]! P  u/ M0 ?
  878.   #--------------------------------------------------------------------------5 d/ r+ X& |$ V+ r1 t. D  S
  879.   # ● “确定”、“删除字符”和“取消输入”的处理( ]5 ^. d) S7 T) z; y
  880.   #--------------------------------------------------------------------------! {3 Y) U/ \8 _% ~; u
  881.   def process_handling
    , @9 J' s! w0 s( C$ r. M& y
  882.     return unless open && active3 W, s3 v8 C3 I/ z% H
  883.     process_jump if Input.trigger(A)( K/ A+ E. H% M6 a' L5 h
  884.     process_back if Input.repeat(B)
    ( [. \% ~& n! E
  885.     process_ok   if Input.trigger(C)
    * f: O5 T7 P7 t& [
  886.   end
    3 P0 F  q1 g! P3 d* n+ d
  887.   #--------------------------------------------------------------------------
    - a9 F; M* Y8 T( c1 q2 Q- V
  888.   # ● 跳转“确定”& O; L5 A$ P- ~) e; c  Y  w
  889.   #--------------------------------------------------------------------------
    - Y- t, j" @- w" P- \
  890.   def process_jump
    8 d/ \( l* b: G2 v) {; r+ d
  891.     if @index != 11
    ' j. u; [, D! J7 v
  892.       @index = 11
    5 r6 e( F$ H9 K" \- g+ ^
  893.       Sound.play_cursor
    8 B" O/ ?# W. h/ H2 m0 s$ r
  894.     end) W1 o3 T2 t; \6 M
  895.   end5 O1 o  t8 e5 L4 o7 j* ]3 }) ~7 J
  896.   #--------------------------------------------------------------------------+ z  L  |# s+ z$ u8 O! a
  897.   # ● 后退一个字符7 H' b+ r. S8 j
  898.   #--------------------------------------------------------------------------& J. a3 x  G: ~5 [
  899.   def process_back
    : _" X4 `- Z2 ?, g1 V% a
  900.     Sound.play_cancel" {- D/ o/ {! H, W$ b4 l& c4 M
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    5 e9 H" r: e+ Z1 D
  902.     n = (@number  place) % 100 p4 a! d# G. X
  903.     @number -= n  place
    + {1 |) s# a3 W$ F7 O) s
  904.     @number_proc.call(@number)
    + P+ Q' ]) \' e& K
  905.     @old_window_index -= 1 if @old_window_index  0
    ) V' t7 N5 p' g$ @+ e% Q
  906.     @index_proc.call(@old_window_index)
    : M: y5 @3 z3 X- f; A' l/ O
  907.     @refresh_proc.call
    8 H7 M  v7 K* X3 M
  908.   end
    ) Y# X$ u# W. {' Z8 a/ @
  909.   #--------------------------------------------------------------------------
    % _7 L& n1 Z* ^: k$ ?
  910.   # ● 按下确定键时的处理0 R+ A$ g5 {, [  o: w
  911.   #--------------------------------------------------------------------------
    ( B# r( K# z( }$ F  [
  912.   def process_ok
    6 g4 i  ?0 v& s3 ?& x% y
  913.     if get_number4 e7 _1 w* e/ Q$ j6 E1 B) V; ]# x7 m
  914.       Sound.play_cursor
    + {% ~5 c! q# ^1 R
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    * Q8 }( h8 ~3 _
  916.       n = get_number - (@number  place) % 10: N$ e9 V& {5 w4 `
  917.       @number += n  place7 _* `. I# i: `  |( K% {* G
  918.       @number_proc.call(@number)
    $ x( H, r2 @! R  `" q0 X
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 16 x  K. [# N; e0 d5 |
  920.       @index_proc.call(@old_window_index)
    0 B  {* k, H3 h, ?9 B
  921.       @refresh_proc.call' z$ ~: D! i8 z; K/ M
  922.     elsif is_delete
    4 g6 X8 A" ], e6 z5 j0 C
  923.       process_back
    $ C/ U. [, J9 Z
  924.     elsif is_ok
      @. j8 _/ ^+ w, G' e) ^
  925.       on_input_ok
    4 h" r4 W* A! |/ C4 Y3 F
  926.     end2 K2 D2 k$ _& M) i7 L
  927.   end
    , r- E. W7 i: {8 u* u
  928.   #--------------------------------------------------------------------------
      D& d3 H8 j6 e
  929.   # ● 确定
      ~/ W; R) S) V$ P4 B
  930.   #--------------------------------------------------------------------------
    4 t& Y2 V& i0 ~& _0 Z
  931.   def on_input_ok9 B6 C' D& R. [' h0 [
  932.     @index = 0
    6 m. K. ~. I+ \# g
  933.     @old_window_index = 0) x2 L6 D+ ?  L1 i3 V% G: V
  934.     $game_variables[@variable_id] = @number# x0 F: s+ \4 e& J& }7 C
  935.     Sound.play_ok
    , M3 k/ ]# Z* B& M" t
  936.     @close_proc.call: L8 `6 b) E+ S3 W# h" G
  937.   end1 v5 W+ Z( o2 g) g+ W! _' O4 o% |
  938.   #--------------------------------------------------------------------------7 x; X2 [) I6 v  B$ Q3 w5 d: s
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    # O, W, W: Y, V
  940.   #--------------------------------------------------------------------------/ ^$ z" M  x2 _, ?) U9 j
  941.   def set_mouse_pos
    % w" ^) n4 O6 y) v
  942.     if viewport.nil # necessary!5 C8 Q# {& c' }- G/ N+ W
  943.       vp_x, vp_y = 0, 0
    " ], x; S, t0 F/ A$ s; s; L1 ~  o
  944.     else2 e% ^& z' U4 l$ M/ u$ B) P
  945.       vp_x = viewport.rect.x - viewport.ox* l) Y) s5 i) J/ b$ O
  946.       vp_y = viewport.rect.y - viewport.oy
    # v. j4 Z4 t% E. w0 U
  947.     end& i. C' Q" g. n: c! ^7 p# {/ Z
  948.     item_x1 = vp_x + x + standard_padding ; J7 F; C  }3 j/ n% d- M7 t$ C: P
  949.     item_y1 = vp_y + y + standard_padding
    8 u: ]1 l, G0 [; l
  950.     get_index = @index  0  0  @index - U0 y0 _9 W0 E3 q; j1 O5 _
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    8 y8 R8 X' \6 N% Y- T, q& X
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5): S' e6 d6 h) _9 _0 J6 H2 |+ y) @$ A
  953.     Mouse.set_mouse_pos(new_x, new_y)
    7 r# B6 Z5 `: F9 S
  954.   end5 S( ~( W% o7 S) c! u
  955. end
    , `& R1 _7 X2 h  c) f2 A" y
  956. ( l3 s/ W/ y; f2 n" E8 [/ V: _% e3 \
  957. #==============================================================================+ G: ?& I( ?- l
  958. # ■ Window_Message
    + J- Y- q. V* M; y& |
  959. #------------------------------------------------------------------------------. D* c, u! w2 ^5 {! x7 o0 V
  960. #  显示文字信息的窗口。
    ( x. K/ G5 y9 e+ f9 P
  961. #==============================================================================
    0 }1 C0 U5 w! l+ X
  962. class Window_Message  Window_Base8 X1 C& R& L8 y2 s: o
  963.   #--------------------------------------------------------------------------) u1 B% r% f, _0 r
  964.   # ● 处理数值的输入(覆盖原方法)
      J" T+ b0 Y3 G: `9 R
  965.   #--------------------------------------------------------------------------
    ) A! H. O6 j8 T+ f* T5 J
  966.   def input_number
    - d; S( o) R. J; V! I& b) U
  967.     @number_window.start
    6 z  ?  A! a" m0 w( b
  968.     Fiber.yield while @number_window.extra_window.active
    / B- T" L: z) w0 U: H' w9 e
  969.   end
    8 M8 ?* S- `/ G; I3 g5 p
  970. end
    6 B8 @+ k& v) n

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

  2225. " r. |9 y3 |+ j2 K: z/ c
  2226. #==============================================================================
    " b6 X! b; F3 O& P  M) m
  2227. # ■ Spriteset_Map- [- H8 }8 s1 p: U/ R% A
  2228. #------------------------------------------------------------------------------
    , q4 }& Y7 s* @$ Y
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。' H: e3 F! f* K# K/ |7 }$ w
  2230. #==============================================================================) v4 x! D# Z2 E7 j- c2 l* p
  2231. class Spriteset_Map% G: |$ a1 X# y9 {
  2232.   #--------------------------------------------------------------------------
    0 k, h: e9 P& s
  2233.   # ● 生成路径点精灵. h7 B; n" ~: x$ ~+ L
  2234.   #--------------------------------------------------------------------------
    / k# q# f; N- B
  2235.   alias sion_mouse_create_characters create_characters
    $ R1 Q5 |) f& g# w" Z" u0 }
  2236.   def create_characters* `, T9 p. t' m7 v
  2237.     sion_mouse_create_characters0 a+ r" X& X. Y$ A' |; r, S( ~
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
      t4 T1 v$ w) \# k1 p
  2239.   end0 o9 i: B1 {1 k9 K+ l/ w
  2240. end
    % K& p' A4 F- t9 e
  2241. + _8 }8 q, t1 d, b4 P
  2242. #==============================================================================
    6 b  Y( {; y5 `$ z* e: j
  2243. # ■ Scene_Map7 n1 y/ Q( w  a3 N& @" I
  2244. #------------------------------------------------------------------------------
    ; V2 @/ `8 G7 ~9 W
  2245. #  地图画面
      R5 J! l/ p, V9 i
  2246. #==============================================================================- G4 g! Q& L, m- [
  2247. class Scene_Map  Scene_Base
    8 H4 b" d& g+ E& S
  2248.   #--------------------------------------------------------------------------3 x1 s: c7 X3 u: }  O; _. y
  2249.   # ● 画面更新3 j. g  c% |+ U7 L. V
  2250.   #--------------------------------------------------------------------------# X! h3 p% G1 y1 h/ B! d
  2251.   alias sion_mouse_update_scene update_scene( I6 d$ d2 N- _2 @7 H# X. j1 J
  2252.   def update_scene% Q! r4 M; p7 p2 Y: ~% ^
  2253.     sion_mouse_update_scene) g0 a9 s# ^& R" _( I
  2254.     update_mouse_action unless scene_changing
    & c$ A2 W1 O% g1 c5 ]
  2255.   end
    & d8 ]9 j- @9 j) u9 v
  2256.   #--------------------------------------------------------------------------* j8 _0 R) g- g( A/ x* _
  2257.   # ● 场所移动前的处理
    1 d* m3 g& `' `* e' n: t" D
  2258.   #--------------------------------------------------------------------------& }" U3 {$ ?( }- s  j3 g4 Z# ~
  2259.   alias sion_mouse_pre_transfer pre_transfer
    ; p5 Z) |0 h/ p2 f& D
  2260.   def pre_transfer
    9 v6 f. g5 a" {0 i9 r4 d
  2261.     $game_player.reset_move_path
    ! x' ~7 T( }5 r% S: o( A1 t5 g6 o
  2262.     sion_mouse_pre_transfer
    * F6 n6 Z& z* X
  2263.   end) b$ Z. X2 {" |2 J' u* q0 q7 Q
  2264.   #--------------------------------------------------------------------------! a, u) n2 w  Y1 G3 u( n/ N/ ?6 {
  2265.   # ● 监听鼠标左键的按下- K; ~3 Q2 n+ H- A
  2266.   #--------------------------------------------------------------------------$ H* `* C% G* L! |1 _" k5 m+ f
  2267.   def update_mouse_action
    : U) \! f+ [; x. V
  2268.     $game_player.left_button_action if Mouse.press(0x01)- A6 k/ X2 K4 ~& y2 S- `9 F4 I. c% f7 o
  2269.   end
    4 ]9 p; N+ q4 H3 u
  2270. end
    $ ?6 b% P  C. \; X; U# j; ~% E2 c

  2271. 8 H5 W2 e1 k# {+ g* `4 M; Z
  2272. #==============================================================================( z* t0 n& h. N& [
  2273. # ■ Scene_File
    ! Q( N, v* B6 Y& ]5 A! Y2 h
  2274. #------------------------------------------------------------------------------
    " u' J1 X8 e! X% D) ~9 D
  2275. #  存档画面和读档画面共同的父类
    % m3 S" ~& w- S1 L7 D' p( Z. y
  2276. #==============================================================================
    ( \6 ]7 [+ S/ P' G" \/ C# h
  2277. class Scene_File  Scene_MenuBase( j6 Y+ i; X/ E$ ^- G4 e$ U" x
  2278.   #--------------------------------------------------------------------------
    7 C2 F! ]* q' ]7 M
  2279.   # ● 开始处理) O. O. U+ U2 Y( {8 {4 m
  2280.   #--------------------------------------------------------------------------
    3 W: N9 a: O6 N6 t: X
  2281.   alias sion_mouse_start start0 D, o( \( m0 \% t
  2282.   def start
    ' W9 n2 k3 D) A7 z1 n# f
  2283.     sion_mouse_start
    ) S/ b. D; C3 l/ ~: O" n
  2284.     @move_state = 0
    1 f/ H8 h, d9 w9 S, H$ s- P8 Q
  2285.     set_mouse_pos5 m) e; ?! Q' e" k) M6 O
  2286.   end% x, e$ S. p) M1 W; b7 E, ?/ o
  2287.   #--------------------------------------------------------------------------
    9 @7 C# ]1 }- `  n4 H2 S& j/ f
  2288.   # ● 更新画面7 K' _2 m0 ~* E. G) h# [; _
  2289.   #--------------------------------------------------------------------------
    ; T' l) C0 T: B7 D- `  F: V& u
  2290.   alias sion_mouse_update update
    ' M! h( F7 D% S: `% q9 U) v: z1 P( i' ^
  2291.   def update) v" V* Y3 v1 k
  2292.     sion_mouse_update: }1 l: V" i7 |9 C! I3 N
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos4 D" N+ p4 X$ h+ M
  2294.   end
    . x, |6 L- h! x$ [6 |  P1 Y1 W4 O, q
  2295.   #--------------------------------------------------------------------------$ H) e) x" Y% v! b1 T! W  v4 B: G$ c; ?
  2296.   # ● 更新光标
    ! H5 a  G: @0 t7 R
  2297.   #--------------------------------------------------------------------------' r' d7 D# r( V' a
  2298.   def set_cursor' T5 b: I' l( V, K/ |% C
  2299.     @move_state += 12 L1 l! ?8 i, m& |8 i+ R) c
  2300.     last_index = @index. [3 y6 Q- k" f
  2301.     if mouse_which_window == -2
    ( \' b/ c# E) u" a8 ]3 ^
  2302.       if (@move_state - 1) % 6 == 0; [' W1 |) f" t$ P
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1
    / k5 U1 T+ p. m, x3 ]3 `# O
  2304.       end1 F" `3 _. y! b6 i
  2305.     elsif mouse_which_window == -1# Q' p: [) q, R- _: v/ L
  2306.       if (@move_state - 1) % 6 == 05 E0 h; e* \2 l
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0" Y7 {+ Q8 A  |$ \* B/ k
  2308.       end
    & m2 b7 x6 W. q5 Y. \' [4 A( t. k
  2309.     else
    ) G9 r/ j* f. z, b; Z* t' B0 H& b9 N
  2310.       @move_state = 02 m6 G- W9 H* z9 E
  2311.       @index = top_index + mouse_which_window" p+ e1 V1 K; Q5 H# G( k
  2312.     end$ G. k, M! @$ x' J; [7 ^
  2313.     ensure_cursor_visible
    4 q& i# ~5 X, @- y. W' k) R+ [
  2314.     if @index != last_index
    - v% ]8 Q" B2 p! T
  2315.       @savefile_windows[last_index].selected = false
    $ Y  D3 L5 D% Q/ X  x+ _
  2316.       @savefile_windows[@index].selected = true
    ( x# I& H# m3 g# S
  2317.     end& {7 W9 I. {/ K* X- B
  2318.   end- V9 m! ~! G4 _8 i! @1 m
  2319.   #--------------------------------------------------------------------------4 S% o" R" n8 U& {4 H7 G
  2320.   # ● 判断鼠标位于哪个窗口8 Y* M# W1 r! e; |3 O
  2321.   #--------------------------------------------------------------------------5 |( P6 r/ q* z4 G  e- Y
  2322.   def mouse_which_window( `# _% ~9 l8 ~$ K! d
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    " f1 r" I9 w  Q, R
  2324.     if mouse_y  @help_window.height + 143 k+ T3 r7 G. N/ Q0 |
  2325.       mouse_row = -1
    9 @! @. @( {9 ?" }
  2326.     elsif mouse_y  Graphics.height - 14+ E+ b  ~# {9 x) H7 Y' L0 _: B
  2327.       mouse_row = -2. \( H* I2 S! t. L+ [
  2328.     else) I" a1 i! J4 r5 Y
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    # f* @" x; b/ p; x0 m" c
  2330.         (Graphics.height - @help_window.height)7 d9 _( {  e* p, o4 k( L' h2 n) S
  2331.     end
    + c. n/ l6 s) I( {- V: u
  2332.     return mouse_row
    8 K. |: R  d/ N7 Q9 e
  2333.   end
    ( f" X7 e" ?5 O- R$ R2 }
  2334.   #--------------------------------------------------------------------------! r$ ^" M  ~& ~6 R3 H: S! [
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    , `6 X1 B- `% O7 P
  2336.   #--------------------------------------------------------------------------
    ( W3 q% L: \% K. G8 X
  2337.   def set_mouse_pos$ H. B) `, j; G
  2338.     new_x = 40( f! X2 a) q! P
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    7 H0 W9 u, j4 V) ?+ {: |: j
  2340.     Mouse.set_mouse_pos(new_x, new_y)
    ! K  M  J1 [4 S/ O  L0 K/ O8 E0 O
  2341.   end
    ) W7 h& |) z0 o5 u
  2342. end( m1 Z- V+ T- I3 y: J

  2343. 4 l3 A' T6 y% K) w- R# d. e& z
  2344. #==============================================================================
    * w8 u8 r- a4 ]
  2345. # ■ Game_Event
    0 K4 {; }6 f) ?9 r
  2346. #------------------------------------------------------------------------------; h) d( K1 ]' w
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    # n1 s7 d; l" f9 R" Y4 ^
  2348. #   在 Game_Map 类的内部使用。/ ^4 t( Z, s3 l
  2349. #==============================================================================
    ' [' r0 f9 v/ q# f' g
  2350. class Game_Event  Game_Character0 ?) ~& E( X( A
  2351.   #--------------------------------------------------------------------------6 J* o+ K8 ?: \. @* c# ?
  2352.   # ● 事件启动
      s* R9 ^4 a- r) r5 Z
  2353.   #--------------------------------------------------------------------------% N# ?$ ?2 C/ H: ?0 D
  2354.   alias sion_mouse_start start
    * L' @1 `, Q% H! K# F
  2355.   def start
    ; I1 s$ X2 }0 x0 N0 N
  2356.     return if mouse_start && !Mouse.press(0x01)7 K" G: \8 A; @$ b9 }8 z: A
  2357.     sion_mouse_start
    % Y/ O0 _- g' |7 I5 ~. a8 {) i+ t
  2358.   end
    & E4 H; F  q! ]! ~& M: f  k! X' v
  2359.   #--------------------------------------------------------------------------
    7 c8 F  Q, x5 r) X3 a4 @8 k# t! Z
  2360.   # ● 判断事件是否由鼠标启动- K# r+ B& f% S
  2361.   #--------------------------------------------------------------------------: u, w4 u4 W: ~
  2362.   def mouse_start
    9 C) A  B# L$ E8 m
  2363.     return false if empty( }( {! e5 f" N
  2364.     @list.each do index3 J( v, }5 k9 `' a  {$ {
  2365.       return true if (index.code == 108  index.code == 408) &&
    ! L4 U6 M; s+ `' @( L
  2366.         index.parameters[0].include('鼠标启动')9 |% i- i4 P" V6 g6 n# R
  2367.     end
    6 p( z* L6 c' M
  2368.     return false/ g: f& i) Q' G3 j* V2 H4 c" n
  2369.   end
    / b4 g  X  D! A  R5 `2 o2 A: k8 y& Q
  2370. end
    : f" a3 V. b; Y! [( |0 `) B  y% B
  2371. 1 M. [5 ^! C& S3 `, D. p
  2372. ####泥煤的height
    ! ~+ b% N8 i8 c0 T8 r
  2373. # @height = height
    4 T. S1 E8 `- H& R

  2374. * \6 i0 L9 R1 m0 y: f, i4 O- j) o! z
  2375. class Area_Response8 }0 `, U9 D5 \  H* }
  2376.   attr_accessor type9 k* Y5 V3 V& @# s2 C! X5 g
  2377.   attr_reader ox
    ( I  d% ]! K/ e4 v: y) C
  2378.   attr_reader oy
    ) j1 b; w- F* u2 f  W; E/ |
  2379.   attr_reader width
    4 e7 u# |3 O: C3 T
  2380.   attr_reader height
    & g- v5 g( _' _( B0 X/ ?5 O
  2381.   attr_reader switch_id
    7 d/ W. C/ Q! A0 X/ U$ @
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    3 H7 b+ M6 B* H1 v4 o
  2383.     @type = type
    ) O; F- _6 P3 O, h9 d  @& @
  2384.     @ox = ox
    4 j0 v3 ?+ [; |  e" D( T& L
  2385.     @oy = oy
    : l# o. V/ G/ w# }0 l# z' C
  2386.     @width = width
    2 g: @% P( c1 Q& e+ q0 Q# ~
  2387.     @height = height7 ^3 h8 f  ~1 |/ L
  2388.     @switch_id = switch_id, C2 Q1 S3 W" P
  2389.   end
      Q5 {/ c2 \" H
  2390. end
    ( q* c( ]( Z6 H4 y
  2391. 3 w# X; ~9 U  S6 w
  2392. $area_responses = []
    , N% X8 k% x8 U$ b
  2393. / {( b! _! s" l2 h8 k
  2394. class Scene_Map9 E6 E' t2 A* E7 y$ e
  2395.   alias update_mouse_2013421 update_mouse_action
    9 o& f% o' p2 {7 u# t. D. J7 ?7 T
  2396.   def update_mouse_action1 J, r, U' q7 t3 r! f
  2397.     update_area_response
    & U9 Y2 Y% V) A! ^' N
  2398.     update_mouse_2013421
    ' {1 X1 f6 n% k: P9 i" L
  2399.   end
    % R3 P4 ~1 F# r# E
  2400.   def update_area_response$ C$ D) N" F; T, B8 O  O
  2401.     responses = $area_responses9 L0 V; C8 R; N- Y# `
  2402.     responses.each {response
    ! w) |- W$ B. r5 ?& S
  2403.       ox = response.ox, `5 M0 |" c$ f) I
  2404.       oy = response.oy
    ( ]" V' \1 h$ u; Q8 E4 B
  2405.       width = response.width! h8 K& i$ Y9 b+ B( N
  2406.       height = response.height7 ~8 p6 R: g- D$ D# Y" s! x5 H: S
  2407.       switch_id = response.switch_id
    ' `! G# B; n) o  K+ r, n
  2408.       case response.type
    & j1 c2 Y7 D6 l
  2409.       when 0" F) c# ~8 o" M3 L9 F& m7 b. y  T
  2410.         if mouse_in_area(ox, oy, width, height)" E! k0 ]' U3 e: |+ E: X5 z
  2411.           $game_switches[switch_id] = true* E3 f5 O  Y5 U. L3 D% H7 U  Q
  2412.           $area_responses.delete(response)
    1 @% k( a! g5 n
  2413.         end/ o0 ]5 @% A5 x
  2414.       when 1( k, z8 {0 e; p4 V$ g" E6 Y+ ~
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)7 M* u. z& z" T0 U/ F" z- L- S% Y
  2416.           $game_switches[switch_id] = true8 j8 p9 {. e' m, p0 Z6 ^" g) c
  2417.           $area_responses.delete(response)# o0 x. j5 ?% P0 l' h9 x! c
  2418.         end, a  V* Z* z5 e) e3 o4 p
  2419.       when 20 i; B/ L. `( Y; a+ j3 S7 h! `, ]
  2420.         if mouse_in_area(ox, oy, width, height)
    & @, b* v7 C$ J; Q, p* n. J
  2421.           $game_switches[switch_id] = true9 N6 T7 ]/ ?& L3 l
  2422.         else( ]9 D  G+ w$ U( m# p5 b4 ~
  2423.           $game_switches[switch_id] = false+ p& U1 z0 x/ t& X# M
  2424.         end/ z% g: @9 z* e( H; \
  2425.       when 3
    9 O1 v9 b1 y$ \8 A" t2 _
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,5 v0 K  P3 s, [( z% z
  2427.             (oy - $game_map.display_y)  32, width, height)
    # S! y" A% E+ K: ~
  2428.           $game_map.events_xy(ox, oy).each {event/ }5 l8 p) H0 R- s6 ~
  2429.           event.start
      r! ?8 Y& H6 `6 P* [( J1 R! W
  2430.           $area_responses.delete(response)6 h" l; m- \% Y, n
  2431.           return
    # }6 G! ^' w! d4 h& S; s
  2432.           } 7 c0 }' a; _2 B+ V9 z
  2433.         end/ B7 ]) P: S+ |9 z: s8 t9 ]1 L
  2434.       when 4
    ! I& E0 R7 h8 J; G
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,- B2 A$ u! f+ K
  2436.             (oy - $game_map.display_y)  32, width, height)" j6 p- B! X4 I9 B
  2437.           $game_map.events_xy(ox, oy).each {event
    7 `7 J! ~- A6 }, S; O7 g% Y
  2438.             event.start
    7 \# x! E3 V, P! q4 S5 L
  2439.             return; ?0 ^1 ^) `/ N# ]5 \$ m* g# G
  2440.           }
    1 I4 n, B+ A- G# T
  2441.         end" e! t+ u5 h( Q" i
  2442.       end* X5 i7 U" n; }8 H
  2443.     }  u# U2 h# _5 y3 v" a; |! ^5 N! Y
  2444.   end
    2 k/ h' U0 E0 r2 ?& R
  2445.   def mouse_in_area(ox, oy, width, height)
    3 t) Z, D; ^5 g4 ~/ C
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&6 }; f+ H7 d1 H  F$ l. n& G
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    2 E, W  _' h5 j- b- U3 {& R: p7 ~5 U
  2448.   end+ N8 h9 _0 ^* n3 d: L5 \
  2449. end; \  u, M* E; ]) G+ A0 X9 {9 b
  2450. class Game_Interpreter
      k- k$ y5 u! l' X4 B
  2451.   def area_response(arg)+ e0 U! ~: H' E
  2452.     $area_responses.push(Area_Response.new(arg))
    6 r0 r- x1 X( _6 r7 `0 M$ q/ T
  2453.   end
    ; b" s# [* e+ p; d7 X
  2454. end
    * s  _2 x$ P/ M: b9 `
复制代码

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

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

GMT+8, 2025-2-19 06:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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