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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
      e1 t; `9 M$ x8 n, ~4 s
  2. % y0 _5 j; t2 M' k' u6 H
  3.   Sion Mouse System v1.3e# Y4 Z/ l0 x7 ?7 J
  4.   5 _) J) S9 u. D' x
  5.   Changlog
    % `$ B2 o! W) y" W" e6 c& C! H  H7 j
  6.   
    * l* q: H; V+ j' R% R6 R7 a
  7.   2013.4.21 v1.3f
    # }$ [! l5 v& G9 S1 i
  8.    
    ( Q7 q4 J) y: B
  9.     1.3f 卷动地图 bug 修正' u  t) n$ X. y. \6 v: g3 x8 m  f
  10.     9 F& D7 P- `: \4 w$ R2 d  r4 G& G
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口% @8 b; ~0 f, C4 d
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    : E8 R  E* S) c( j3 z! Y  v/ [
  13.                               Mouse.unlock_mouse_in_screen 解除锁定- j! @! E6 n$ B' L- v9 o0 P
  14. ; H0 a6 C9 Q, ^1 l
  15.     1.3f bug修正
    # e4 P* |' [+ s+ C
  16.   
    % y" C  {% k6 Z& P' l" B
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及, T; }$ X6 S. s6 V
  18.           关闭菜单时,鼠标是否移动到原来的位置。# m" H& b: Q- j( c1 ~3 ?

  19. : e2 W0 z: e, [8 ]! V: Y
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处
    3 K" N- O+ R( ^; ?& u; A

  21. ( l1 j. ?$ P# h# x! \
  22.     1.3b 修正一些罕见的bug;: h. [- e3 l( F. _
  23. & `. l1 `4 Y) T3 d& J
  24.     1.3a 代码小修改;
    % y+ ^! y/ G3 ?
  25.           加入了鼠标点击启动事件的功能,
    " i+ R+ J, l7 w# s# I& N2 q) k1 S
  26.           在事件中加入“注释”: 鼠标启动  ,
    + t) T/ j$ r6 c
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。: [, `3 @7 ^1 o- t: v
  28.   
    7 K: {/ o* C6 Y+ W6 h7 V% x- G' |
  29.   2013.2.12 v1.2
    , _3 K  f$ w. ~7 J6 w! ^
  30. 3 `0 ~- S* Z! y+ i' O8 u
  31.     寻路逻辑优化;
    8 }1 v+ y- ^0 W( j- C+ t" b' s/ o2 q
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;
    ! _+ G1 L4 [. f2 v! u2 Z; @
  33.     现在支持用鼠标来操作载具了。
    * _* O/ F6 [) Y7 K5 X( f5 ]+ d6 C

  34. : O' B+ P  c- {3 b- Y* Q4 e- {
  35.   2013.2.8 v1.1
    ! s6 \* @- ]$ j3 h) E
  36. 0 R: N+ h7 r7 H6 I+ I" X# O; e. M0 ~
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;! A6 Y# ~: Z% e: D7 ^
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;2 I) z4 b+ |# z# y7 z) `
  39.     移动时,路径指示点的绘制更加稳定;
    / m$ J* |0 f0 d
  40.     现在支持默认存档画面的鼠标操作了。
    5 h$ |* F% H( R3 q& ~- ?: F

  41. 4 [1 P, x; a+ B2 M

  42. 7 N4 ?& E6 m9 {
  43.   OrigenVersion4 h& w* ], |. l! i( x
  44.   9 }# T5 @( p0 m# i% a
  45.     2013.2.7 v1.0 . }6 X+ ~; n. J1 G- i0 v, ~

  46. " s. O4 E! ~) N( Y9 P3 p
  47.   主要功能
    9 l' b* j; A0 p% ?( H( m5 j- B
  48. : n' K! g) J; L1 `% S  y( l
  49.       使用鼠标进行各种操作...
    - K( x0 A4 E/ h
  50.       将鼠标锁定在游戏窗口内
    - Y2 [/ r' \% o
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    : l! S# Z6 p- Q# ^7 G7 D
  52.       双击鼠标进行冲刺! Y  S; b0 r  E9 T& E3 H
  53.       更改地图卷动方式以适应鼠标移动( Y: W9 E# m% B+ v+ x
  54.       变量输入框改良
      F3 u' ?8 e- P; _7 c3 i3 D/ `
  55. 5 r; i5 ~' Y: l$ W
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    0 R7 K. B9 S* F4 q

  57. 2 c7 A# K  y% [3 W+ @# ?
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹: r& m- {* R8 J1 _& @% D. s- ~/ N
  59. # ?3 _4 ~& @/ X: s+ b
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭$ s/ q/ Y  a  ?5 `: A/ z! c

  61. - u7 w7 ?% m2 u# {7 U& U3 x: D

  62. ; ^5 l0 w4 V8 i2 i
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★. e; ^3 K5 _5 \9 v# @! L5 @& ^

  64. ; N) r* v0 P( m
  65. % J/ Y) n/ |/ j* `2 a
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示, N! @: L. v' E" K6 K; p
  67. ' {& \* S' w# w0 L8 P
  68. #==============================================================================
    ' d* X( d  n. t3 l1 m5 _- ~0 E; c
  69. # ■ 常数设置
    * g1 u1 _1 m# I
  70. #==============================================================================
    + U& C$ e6 b8 U5 L! y3 L& f
  71. module KsOfSion
    ( `$ I# v0 \# T9 \  b- G! ~
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false
    1 z. v" k6 I7 x5 Z
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑
    + x& |* `$ e1 C3 ?
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    ! f' U: |4 z9 j) |# }. @9 E6 Z6 ]
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量$ @0 f( s: \- J% h
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处, }  k) V; q" d) i: d+ R6 g! Z& ?
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧9 V% t$ _  l7 L3 R7 ~( A
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)
    , ~$ h4 k7 J& f2 P) Q+ a
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键3 t0 f$ S' x( {, u8 |" N
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    4 M" b- |% q$ d
  81. end
    / u1 e# _: S) @+ o* c( f

  82. 6 t, e+ Q% {8 R% \+ e
  83. #==============================================================================: m5 A5 v$ u7 b
  84. # ■ 用来显示路径点的类
    + g& u. E$ K$ T" H) T
  85. #==============================================================================1 m3 X  G. I8 r$ K$ `
  86. class Move_Sign  Game_Character$ i2 c' }4 l# e% p# k5 R, E
  87.   #--------------------------------------------------------------------------
    8 s; [( G& ~* e1 r
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图2 M! ^$ j) {* F8 j9 q# n1 Y& h7 _
  89.   #--------------------------------------------------------------------------5 a$ I+ q9 ?4 |! S
  90.   def init_public_members
    $ s, c/ u$ z6 k9 b
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹( k# f- T" z& D
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0
    ( @! e5 P& [: C% C
  93.     @move_speed      = 5        # ★ 踏步速度8 W. v: t8 U3 x4 \3 ~4 }! y
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    7 R# H- }9 w1 z3 K
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度: r) ^1 u; Q9 j; W( W( X
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)+ H1 R5 ]4 s2 y
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    6 S5 K6 V/ Y+ L) x# L, x. a
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    2 ]! R, j- z* H) F% U1 L5 F

  99. ' R2 N/ p& X: ^* Q# O% }
  100. - d- H7 f* X% O0 A/ E! k4 F
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★' ]: y; C/ B% }( _- A
  102. ' I: U( m+ ~/ c  u9 G. G

  103. / }" G4 p( I- d) K1 \1 L& `
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图, W% p1 f" C7 Y" m# T
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    * K4 z6 C, s, _1 d0 `& U
  106. $ C( u- n. B% F- R2 [
  107.       if $no_arrowpic_warn# u$ o8 P+ I2 H4 n, C  y
  108.         MouseShow_Cursor.call(1)
    7 I0 B9 y3 R, P9 p: d# T
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png- h8 T& L$ V5 D* |7 P9 ?- m

  110. / V& `3 \' m5 [* Q8 |9 _8 L' G
  111. “路径指示点”将使用游戏自带图片
    5 E: ^  m, a$ N3 o+ x( a* j

  112. ! d* s$ T3 [+ B9 G0 g
  113. 该提示可以在脚本内关闭')
    * ]2 r; y% S, h& O# t
  114.         MouseShow_Cursor.call(0)* j, X+ s( Q$ ~
  115.         $no_arrowpic_warn = false  P' x# D1 u2 q8 w( a2 b8 j0 X
  116.       end
    6 e+ w, R+ Z" P) }" _
  117.       @character_name  = '!Flame'
    # X8 U' v. n' S4 x+ B6 T
  118.       @character_index = 6
    ; G  L, b6 N5 j. p" e9 i7 L: e0 U1 p
  119. 4 A6 H4 _- k+ ~  Y
  120.     end+ }7 H0 j: H' @6 I1 H6 m% c
  121.     @direction_fix = false  # 固定朝向, x2 X8 \" B) [. R
  122.     @move_frequency = 6     # 移动频率2 Y& N- p4 e7 ~. O' b7 c# j
  123.     @walk_anime = true      # 步行动画
    , B* @) E3 t2 }9 m& Y
  124.     @pattern = 1            # 图案/ r! ]& V# o2 b: y$ G! o
  125.     @through = true         # 穿透) a7 Y- X* w& h1 u
  126.     @bush_depth = 0         # 草木深度' \# _4 t4 ^3 m- B
  127.     @animation_id = 0       # 动画 ID2 u/ I3 [5 [1 |+ L/ G' m
  128.     @balloon_id = 0         # 心情 ID
    ; D0 U5 U& v% g* y
  129.     @transparent = true     # 透明( ^6 n( Y" Y- ]2 j
  130.     @id = 04 A. U8 ?, \6 y% [! E* |
  131.     @x = 0
    0 V6 {& p* N: f+ t! C. o( l5 r* T+ B
  132.     @y = 0% {4 j' O5 n" v8 p
  133.     @real_x = 0
    % \% f" P% f- Z# ~; V1 v
  134.     @real_y = 05 S% f5 s3 H6 O# Q
  135.     @tile_id = 0# u( ~/ v  M7 |' P9 H
  136.   end
      X0 n- P6 @$ h
  137.   #--------------------------------------------------------------------------; C) S' ?  ~- [1 g2 a, F
  138.   # ● 定义实例变量
    / ^& m  H" e( d4 F$ v; X
  139.   #--------------------------------------------------------------------------' X  v! ], u+ _
  140.   attr_accessor direction' Q$ H- D' D- h. E: E. [% q
  141. end2 A. Q/ E6 O0 ?" ~4 B
  142. 0 P2 N$ v: i. S* A* l; J) N
  143. #==============================================================================
    3 C  o$ c9 x$ G+ V" X! d
  144. # ■ Module Mouse
    $ l& G( k! c& e- v
  145. #==============================================================================
    ! b; @7 ~8 O# y7 O7 C! x- f
  146. module Mouse( I% T5 _, V1 ?/ a; c8 `& Z
  147.   #--------------------------------------------------------------------------* {% v5 _5 }4 L- O' u- L
  148.   # ● API9 F* B" P! w5 t! o+ d4 [. W9 h
  149.   #--------------------------------------------------------------------------
    $ F, T( ?$ }& n& c8 B$ E
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    , K+ a0 `$ Z. T# |7 O. S
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    + y+ Q, J7 M3 t$ l: m
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l')5 u" w' A4 [- l3 G* T$ F5 ^! k! Q
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')5 o  R8 i% {  n( K8 V1 s0 b
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')9 S% n# @( }4 l" V) B  J
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l'); `* x6 B& j; @$ i
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')4 q$ d* ]7 Q; W& G
  157.   Window_Hwnd       = Get_Active_Window.call
    4 a& o" Z0 L& B. r

  158. , j; f4 Q. t% A7 q2 t
  159. class  self
    ! T9 y  I, y. l
  160.   #--------------------------------------------------------------------------
    7 x9 v! R2 {+ w, a; n( `2 M
  161.   # ● 初始化
    " \' n% C5 z$ Y4 ]. Q6 A1 D
  162.   #--------------------------------------------------------------------------
    2 P9 {% j2 N/ ^! B. [* z! O
  163.   def init
    % f- l! A  ]* }: O5 C$ I5 T* x
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    - n! Y& a0 G/ V0 m+ T( z  Y- d. F
  165.     @left_state = 07 b+ U" I6 @# j# \' k1 u
  166.     @right_state = 0
    * M/ R6 \& D4 `7 s. R
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    3 a8 x9 k# _% [+ ?% ^( J( P; W
  168.     @dk_count = 0 # 用于双击的判定
    4 z9 y3 i5 c  v- ^
  169.     @clicked = false
    * A3 G$ F+ e- i' W
  170.     creat_mouse_sprite
    ' d! b$ z4 y3 |
  171.     update
      f1 E! z7 U. w
  172.   end8 }5 p1 l5 }: i$ A' N. q
  173.   #--------------------------------------------------------------------------0 q2 Y' o: K( r! H2 E
  174.   # ● 鼠标指针精灵+ J: ~7 Y! {; K# u$ o4 M& f# k
  175.   #--------------------------------------------------------------------------
    0 f1 C( @3 W8 I0 f: h7 s
  176. #~   def creat_mouse_sprite
    4 ?% p0 F' F) ~8 u
  177. #~     
    , v2 A6 K5 h  N7 {! d/ w
  178. #~       @mouse_sprite = Sprite.new
    ! [: z# O+ L, C* {2 g
  179. #~       panda = 2#rand(2)+1
    1 u5 x% y8 }! F3 x; j
  180. + e2 {; O7 I: t
  181. #~      if panda = 1
    4 t) R( _/ _: F0 P3 |* H8 d/ Y
  182. #~        if File.exist('GraphicsSystemCursor2.png')
    / u& ~1 y5 R, C
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')2 q; [; W* @; Q7 K  G! b/ ?
  184. #~        end#with if File.exist
    . F! N" K2 R* ^  e* k
  185. #~    & [8 h! C6 I! |: R& M
  186. #~     else if panda = 2 #with if panda=1
    9 v9 b) ^9 m3 h" o2 m4 }
  187. #~      
    * ^4 h0 f, q" ^" f0 Z/ O
  188. #~      if File.exist('GraphicsSystemCursor2.png')7 V9 c- t. s0 o+ G! O0 ~; W
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')  l* P' }' v& K4 B& {
  190. #~      end#with if File.exist
    # G" Q% ~/ p% t, G% U) K
  191. #~       ) x& H5 `+ o5 r: N: V, F
  192. #~     else #with if panda=1/ K4 \  u  o* J+ K! w
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)+ y0 u# i$ I4 h2 G  T- t
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),
    # J& h% S! \3 Z
  195. #~       Rect.new(5  24, 24  24, 24, 24)): F, A3 V; m) M( c( j9 |! z6 v
  196. #~     end#with if panda=1
    ' z4 B$ x. U6 P# u* ?7 e
  197. #~     
    - `' m9 p) W& {! X
  198. #~     #with def9 z$ H0 E+ ~' g6 U% h+ s' H
  199. #~   end- N0 ^( o$ a/ q: p8 R8 F% D5 O
  200. def creat_mouse_sprite: [" @% ~& k' M
  201.     @mouse_sprite = Sprite.new5 L" ]% b1 f  d3 O  ]
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    : w3 q! E/ o: f* D$ p
  203.     @mouse_sprite.z = 99990 \0 K: j, l; g; H
  204.     Show_Cursor.call(0)% g2 p. m6 j( J. x: d
  205. end
    5 v' Q+ E* R' s, K+ E2 G' O" A
  206. 8 z! C) E, y! x
  207.   #--------------------------------------------------------------------------+ E  Z) B- w% Y" q* @9 B- @3 }
  208.   # ● 更新, A5 n' r* Y% y# V0 G8 P
  209.   #--------------------------------------------------------------------------
    6 a  ~* u) N: y, I
  210.   def update
    . ]+ h6 I3 y% ^- r. n
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos
    : r6 f* g- B3 S% v' H9 g
  212.     left_state  = Get_Key_State.call(0x01); h% e, |8 ?" M3 ]% B: h) \! S
  213.     left_state[7] == 1  @left_state +=1  @left_state = 01 _1 z: Y. `. q
  214.     right_state = Get_Key_State.call(0x02)) q3 a. Y) a( Z! \
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0
    ( L  l/ n$ G' k4 O
  216.     update_double_click
    ' r9 ]3 M, S6 K1 Z
  217.     @left_state == 1  @ck_count = 0  @ck_count += 14 B& m" |) y. c! n  O  c, C
  218.   end" e& G( i7 Q- a
  219.   #--------------------------------------------------------------------------* @; K* M) x" x7 T* A8 p" S2 Y3 S+ N
  220.   # ● 获取鼠标坐标+ V- _2 ]7 U  C( y
  221.   #--------------------------------------------------------------------------8 g3 e5 f  j  G5 O; k
  222.   def get_mouse_pos
    $ P, P2 i2 [4 k$ b1 B* W
  223.     arg = [0, 0].pack('ll')
    + I9 w7 \) j0 f2 c. R1 _
  224.     Get_Cursor_Pos.call(arg)1 D0 h) D5 ~7 i
  225.     Screen_To_Client.call(Window_Hwnd, arg)# s8 s* G& V9 B. y
  226.     x, y = arg.unpack('ll')
    : U$ E9 {7 `; h6 E0 P# u# g, ?
  227.     return x, y
    # w2 d+ b$ |! _, {1 e; s; |
  228.   end4 k2 D# N# X6 G, @  ~
  229.   #--------------------------------------------------------------------------
      A5 K& u& K7 y" }; C
  230.   # ● 将鼠标固定在屏幕内
    5 i) j  h, m& g" x) h5 x! G+ L5 ?2 a0 a
  231.   #--------------------------------------------------------------------------
    % P7 S( y. {, M; f
  232.   def lock_mouse_in_screen
    $ [" I; O  s4 Y) C) \
  233.     arg = [0, 0].pack('ll')  z/ D$ r. Q5 D, X6 W8 B
  234.     Screen_To_Client.call(Window_Hwnd, arg). d/ o- S) p2 t3 ?# |4 `% T
  235.     x, y  = arg.unpack('ll')$ M( l) I3 e% i6 Y4 p: b9 I
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    5 F: o8 o1 z( K! Z6 Z
  237.   end
    % m* U2 ~0 {4 ]3 G5 p
  238.   #--------------------------------------------------------------------------2 N( n5 I) s& W7 s' G
  239.   # ● 解除鼠标固定
    + v: ~, J7 Q8 J3 \
  240.   #--------------------------------------------------------------------------3 A* N# ?0 C% m3 m' B
  241.   def unlock_mouse_in_screen! j  L; v4 `7 u/ R
  242.     Clip_Cursor.call(0)
    & s3 G" y- W+ |5 a0 `% F+ l
  243.   end: e% L0 ?) P2 M; t
  244.   #--------------------------------------------------------------------------
    ; j: d/ D; f4 N+ h/ x/ B
  245.   # ● 鼠标双击判定2 l! ]6 C6 \: B0 x! i. v
  246.   #--------------------------------------------------------------------------
    # f0 f2 T+ ?8 I8 c
  247.   def update_double_click4 Q* N" m; S6 l& V( b4 `2 t8 T
  248.     @clicked = true if @left_state == 1! C+ o" Y8 h( P
  249.     if @dk_count  0 && @left_state == 1) \* I' k" A; ]+ a, t
  250.       @dk_count = 0; @clicked = false  y2 G6 B5 e4 l
  251.       return @double_click = true8 c& u& P- I: i9 n8 y
  252.     elsif @clicked
    9 @  [$ \6 K" e
  253.       if @dk_count  KsOfSionDbclick_Frame8 V" T# V) n8 A5 f+ y
  254.         @dk_count += 1: G, Y; C- ]: M6 G& Y; \  h
  255.       else
    - Q$ H# p# \) t
  256.         @dk_count = 0; @clicked = false7 D1 \" ^7 p3 b; r4 G3 B
  257.       end7 J- U9 n& L! b( K) K
  258.     end
    ( d1 Q. Y* `  I; T
  259.     @double_click = false
    " ]' s' V9 i9 ~' e2 N" l: w
  260.   end
    2 A6 U. T- e5 M6 y- j, O1 R
  261.   #--------------------------------------------------------------------------
    % T0 S; s; W: X, m$ F: e
  262.   # ● 按键被按下就返回true  F* u% C' P: B$ i" ~/ j( {; Y) _
  263.   #--------------------------------------------------------------------------0 P( P. J9 |& I$ h1 [
  264.   def press(button)
    # f- A9 F- K3 e) T( J3 z2 i5 f
  265.     case button
    ! V: G5 z8 g  T8 p1 i$ \
  266.       when 0x01; return !@left_state.zero5 q0 |" H2 `5 W. n( L) ^
  267.       when 0x02; return !@right_state.zero
    , e3 ^3 }  }" c+ o; O6 A
  268.     end
    % `. v; f2 J5 X1 h5 w
  269.     return false
    ( }+ q3 h% |" v8 I: ~# n
  270.   end) j" u; V( z) m3 C
  271.   #--------------------------------------------------------------------------
    ) Q- V5 Y# X" y3 b
  272.   # ● 按键刚被按下则返回true
      A( D, W/ u/ h) j" u
  273.   #--------------------------------------------------------------------------
    & s' P0 ]8 J& k( }# C
  274.   def trigger(button)
    0 N. I! T  ?" s, K* g
  275.     case button
    ; m' ?! I1 y5 W8 E
  276.       when 0x01; return @left_state == 1' @" t# o+ \: g. k/ J- y) s' o
  277.       when 0x02; return @right_state == 1
    5 Z0 z6 X4 ~) @
  278.     end
    3 t! k. D6 k4 C: P8 i4 Q
  279.     return false4 d" D# s/ `% z& g7 y; B
  280.   end7 r0 J3 Q$ ^5 {; O
  281.   #--------------------------------------------------------------------------
    $ O% x9 I! [! j% i  ]' k
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    . j/ R9 b  d  y8 g7 {) y
  283.   #--------------------------------------------------------------------------3 F- d2 I) E6 W% r$ T
  284.   def repeat(button)* i. W) o! ], p  e' ?- s5 q
  285.     case button
    " t9 `& R9 d1 \  A- g4 ^
  286.       when 0x01; return @left_state == 1 0 I& n/ ^0 w' Q+ Z. [% a
  287.         (@left_state  22 && (@left_state % 6).zero)
    + K1 K  K7 v1 M1 o
  288.       when 0x02; return @right_state == 1 2 l! G6 o/ e: A1 F
  289.         (@right_state  22 && (@right_state % 6).zero)3 f: }) M4 r% R4 P: U, b3 }
  290.     end
    + k  d! o. `$ t3 b$ {/ g) B5 [
  291.     return false
    ' C8 R& m  w; [4 c9 `" P: K% ^7 Y
  292.   end
    # u* S3 q" ?" x5 n" b- N3 c
  293.   #--------------------------------------------------------------------------
    9 N4 e: n( `. i8 E) Z0 \7 c3 m
  294.   # ● 判断是否双击鼠标
    7 T$ A& y. F# V" G
  295.   #--------------------------------------------------------------------------
    ; U* Z) k9 w+ H
  296.   def double_click2 T4 F" F! k! ~- M. I# S! S% I
  297.     @double_click
    9 M5 W% d# D5 X& V) Q. H' Q' @
  298.   end
    & x  C$ t2 e) I, E- @
  299.   #--------------------------------------------------------------------------
    , G$ q+ x# W( M. ^4 _
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)' _6 b$ Q! ~/ m* a' c3 \+ L
  301.   #--------------------------------------------------------------------------+ I% I9 k8 X* T3 M3 w$ Y
  302.   def click_count
    . x% h5 F4 j, a, l+ c/ I
  303.     @ck_count7 B% D5 O8 h  S  C( O
  304.   end* n; n7 H! D, c. X5 l
  305.   #--------------------------------------------------------------------------  u4 s0 F7 u" M. H% n
  306.   # ● 获取@left_state(按住左键每一帧+=1)' F$ ?$ i# u, C+ I0 ?
  307.   #--------------------------------------------------------------------------
    $ I$ B& e# ~6 k$ W/ r9 c
  308.   def left_state
    , ]0 o# r! H' [% p
  309.     @left_state! U# M& e. L$ T* N$ }* [: S
  310.   end
    % Z3 m+ D5 Y0 [- z5 N. t
  311.   #--------------------------------------------------------------------------7 z) s2 J: k# k5 R' ]
  312.   # ● 获取鼠标的x坐标
    $ E9 n" ]6 B4 D9 b3 }
  313.   #--------------------------------------------------------------------------" l+ @6 ^; X7 ?) J6 k
  314.   def mouse_x
    ' B) v% z. {6 O+ ]& N; L' r
  315.     @mouse_sprite.x; W0 g- ^: B% k. f) z1 U- ]
  316.   end
    . [+ E$ }  {3 B' Z% I6 k. x
  317.   #--------------------------------------------------------------------------$ ^6 y/ \' a2 |; ?0 F2 ]9 L% y' g
  318.   # ● 获取鼠标的y坐标
    , ?& a$ _: q! o, i
  319.   #--------------------------------------------------------------------------% M5 F$ Z8 J9 y& ?& z
  320.   def mouse_y+ @+ b" W5 \- N: r8 S" ?
  321.     @mouse_sprite.y% }' |, K- i( S' ~7 D
  322.   end# K, v# L. D8 Q, I  o% P# i
  323.   #--------------------------------------------------------------------------+ d- ]6 w$ ]; L
  324.   # ● 设置鼠标坐标
    1 Q* k; X: w: r& b. I+ k
  325.   #--------------------------------------------------------------------------
    4 Q" e. d* e6 l& q% R/ C) f) N
  326.   def set_mouse_pos(new_x, new_y)4 _: T2 a7 t, H: M( I, z/ K% }: H! }* k
  327.     arg = [0, 0].pack('ll')2 V( @# \! y) u9 k5 z8 I4 F
  328.     Screen_To_Client.call(Window_Hwnd, arg)3 p2 A. F. n4 ?
  329.     x, y  = arg.unpack('ll')
    9 r3 G# N1 C# \
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)* k$ b0 s& z9 @& @9 [$ }* D
  331.   end
    ' P5 o6 ~/ [5 d, u
  332. end #end of class  self
    ' z: `* R$ S2 W7 M( n+ f
  333. ( H# C" X& m+ a# b9 k
  334. end
    , X  i7 {1 [0 N% t

  335.   P: h% I: b% Q0 _0 B
  336. #==============================================================================* k# j. S. C9 Z: l3 ~7 L  a
  337. # ■ SceneManager
    ( v* R' g% C. v& {# l$ x
  338. #==============================================================================
    / r5 M4 V  ]( r5 P& V; }
  339. class  SceneManager: @$ z& E# b+ i5 d) I, `7 L
  340.   #--------------------------------------------------------------------------
    1 B: J4 n% {; ?2 C, ^: I# i  x
  341.   # ● alias
    2 ^4 U. C0 {) ]: `& T
  342.   #--------------------------------------------------------------------------
    8 s# B9 h$ U( Z, z' w, Z$ i! V
  343.   unless self.method_defined(sion_mouse_run)9 }8 f' P( \* a# F
  344.     alias_method sion_mouse_run, run2 X" l( ?) o+ P. Y4 v1 N7 `
  345.     alias_method sion_mouse_call, call0 ~# F0 g( W' {& S
  346.     alias_method sion_mouse_return, return
    . [: d( y/ ^; E
  347.   end7 f, b9 ^0 }+ b+ r
  348.   #--------------------------------------------------------------------------+ w2 l& A9 ]8 k- f) c: J* E# B
  349.   # ● 运行/ S* ~( Y3 S$ F! \
  350.   #--------------------------------------------------------------------------4 s9 \" m+ w0 B! j
  351.   def run2 o% E2 o( e8 D, O2 @8 \9 u. Q
  352.     Mouse.init" S) [0 A+ i# r
  353.     sion_mouse_run
    4 N' U& |+ m+ b4 `# S2 U
  354.   end
    ; P1 ~' E4 S) X+ o+ s4 s. r% m
  355.   #--------------------------------------------------------------------------
    6 \* O! J0 L  N7 Q
  356.   # ● 切换4 \% S( W- `& Q: ]4 E+ ?: I+ v
  357.   #--------------------------------------------------------------------------
    4 p' `; I  [0 v
  358.   def call(scene_class)4 u2 c. z* |1 N. w9 |/ ^$ q
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    1 k1 d+ I( ]$ x& ?7 v9 i
  360.     sion_mouse_call(scene_class)
      }2 ?7 \, L( ~! g( e9 d$ M
  361.   end
    3 _6 y- u  d- l+ M7 P3 s
  362.   #--------------------------------------------------------------------------3 L3 Q$ W/ k1 Z3 E0 P. M( [
  363.   # ● 返回到上一个场景4 S$ g2 C* ^' N
  364.   #--------------------------------------------------------------------------
    9 @  L! y. {* e, \# ?/ p
  365.   def return2 u* l7 x5 f) G3 ]- m
  366.     sion_mouse_return; N  b2 p" p+ A& N
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&' U6 o5 q+ }) C' s0 w5 s
  368.       @scene.instance_of(Scene_Map)! K' R0 y1 m* b+ `9 E$ Z- e/ R
  369.   end7 Q: }& ?+ H, ?7 G6 v; I  }
  370. end
    4 E  J& G1 D0 H2 F
  371. ) d% R% y7 h" @4 x$ f
  372. #==============================================================================/ i; ]  V0 D9 G7 y
  373. # ■ Module Input
    7 y/ `! K/ G9 n! L% S: ~
  374. #==============================================================================
    - S  I( I! S8 x2 h, L7 m
  375. class  Input
    ( B9 c1 j% }. V3 n' h- P
  376.   #--------------------------------------------------------------------------
    + X7 p- N% p/ h0 ?6 g
  377.   # ● alias& c- }' [/ Y! O& R' G6 r4 p
  378.   #--------------------------------------------------------------------------5 m1 h* ?  m# [  o: I9 q6 h
  379.   unless self.method_defined(sion_mouse_update)6 D1 e$ `7 G2 c
  380.     alias_method sion_mouse_update,   update' E5 x* p3 R+ m- X
  381.     alias_method sion_mouse_press,   press
    % o/ N1 ?+ A# R
  382.     alias_method sion_mouse_trigger, trigger) e6 }9 a2 K0 y( y/ Z
  383.     alias_method sion_mouse_repeat,  repeat
    9 b% r% n$ J& A) u, h4 a# x
  384.   end: L3 i' H8 b' v/ J9 J
  385.   #--------------------------------------------------------------------------
    6 w- S! ?# t6 y3 e3 c1 e# ?
  386.   # ● 更新鼠标0 ]. i; b. `; k' t
  387.   #--------------------------------------------------------------------------) ?. D' G; f: n) Y, h; N2 \+ t
  388.   def update
    % G6 E1 P5 e( B2 \. h
  389.     Mouse.update
    , H! s! t& {6 b6 Z" D
  390.     sion_mouse_update6 c& u# a* w( m4 e2 D3 n- |) X# }: D" x
  391.   end& u' p8 D! ]3 F1 d
  392.   #--------------------------------------------------------------------------
    8 q/ N' ^6 m& p
  393.   # ● 按键被按下就返回true
    : B% U# d4 o9 ~* Y, K
  394.   #--------------------------------------------------------------------------
    " p, q2 k+ o9 @5 W& s
  395.   def press(key)
    8 b, o$ @- f9 U$ g* }6 e
  396.     return true if sion_mouse_press(key)
      }# V  _9 ~, Y1 q
  397.     return Mouse.press(0x01) if key == C3 z4 B, @: |, G8 S) K  K6 t
  398.     return Mouse.press(0x02) if key == B
    9 L2 q+ o$ }: ]0 z5 N( Z# K
  399.     return false
    ( ~0 E9 k5 S$ k: ]# p
  400.   end
    2 }8 R# |! L/ q6 ?& |; H
  401.   #--------------------------------------------------------------------------
    % I; T. z' z7 N* B  x
  402.   # ● 按键刚被按下则返回true* g9 s* ?3 x5 W5 d: s* ^# R
  403.   #--------------------------------------------------------------------------
    7 T3 Z8 G, `* x' m
  404.   def trigger(key)
    5 S% I' ~3 k" n% \- h) b0 o. N; }/ q
  405.     return true if sion_mouse_trigger(key). q6 i% s  R5 W6 ^
  406.     return Mouse.trigger(0x01) if key == C7 I# B9 J( l% }( X$ t6 m( D. x
  407.     return Mouse.trigger(0x02) if key == B
    + z8 s+ U3 N- j  s; V* G' a+ |
  408.     return false3 |! b1 T: G9 Z# ~
  409.   end. h8 h! t' J+ b3 t' }( C
  410.   #--------------------------------------------------------------------------
    8 F" E3 M) T: x
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true
    0 ?( W2 T* p: _8 G: u) |1 F2 g
  412.   #--------------------------------------------------------------------------2 I0 r) C( E( \7 B; p( c
  413.   def repeat(key)
    ) s8 y. _% c4 H( P: Y
  414.     return true if sion_mouse_repeat(key)
    ! U8 e  f) F/ [. @6 f
  415.     return Mouse.repeat(0x01) if key == C: G" R8 H. E# |2 k
  416.     return Mouse.repeat(0x02) if key == B
    ! ]) T- z8 s' a  @: p  h# g' X& k
  417.     return false6 f5 _1 o9 P) q2 z$ c* C, [
  418.   end& z& ]% L- ]4 r; D
  419. end
    , u3 r1 }" K5 B7 U8 a, u
  420. , }" n" E+ I7 p* F) Z+ M6 F

  421. % {7 R# Z2 c& K+ z5 M. j6 R3 k$ c
  422. #==============================================================================
    ; \; w1 |4 Q: n
  423. # ■ Window_Selectable
    & b0 a( ~! Q; I9 e: Z# A5 v5 ~6 Y  S
  424. #------------------------------------------------------------------------------1 K- {6 O7 ?) m
  425. #  拥有光标移动、滚动功能的窗口
      X* {8 K: u% I( I* x
  426. #==============================================================================6 x' L# k' X6 j8 c1 t
  427. class Window_Selectable  ~0 h0 w& ^6 D$ p; m  H
  428.   #--------------------------------------------------------------------------
    % a" _" [8 \& M8 Q; e$ r- }
  429.   # ● 初始化
    1 r8 V7 D7 ?7 C$ h% c8 O
  430.   #--------------------------------------------------------------------------
    $ Z9 s1 e1 o6 v5 H" g, B. h: Z9 @
  431.   alias sion_mouse_initialize initialize
      q  b0 g2 w* T/ c) g$ o) y" Y& S
  432.   def initialize(x, y, width, height)% R% a0 O; r3 v
  433.     sion_mouse_initialize(x, y, width, height)! G+ r" W- d7 z7 T( Z9 z' h, `
  434.     @move_state = 0
    5 H4 z6 S* O/ O7 t9 `
  435.   end
    8 H% R4 o: Z6 i/ @
  436.   #--------------------------------------------------------------------------6 W: V$ Y. Y4 _- d0 m, V
  437.   # ● 更新( b3 M* G: `8 Q
  438.   #--------------------------------------------------------------------------
    ( H0 v2 W: k+ L8 r+ g5 G
  439.   alias sion_mouse_update update
    ) c7 f% V- j0 Y/ h0 h% @3 u
  440.   def update5 J$ ]' \' `; v1 F3 N
  441.     sion_mouse_update
    8 n& C  |; [. I9 b6 w' L* ^
  442.     update_mouse_cursor
    7 I, h  g6 P" A, k
  443.   end* [- k0 c5 J! n8 _+ p' A% {9 ?" O9 W
  444.   #--------------------------------------------------------------------------2 [& F+ a( d0 g$ Q  ?" J
  445.   # ● 启动后设置鼠标到index位置: i" h/ l( W# k
  446.   #--------------------------------------------------------------------------
    ( w2 ]1 e" j5 h2 C0 g# ?
  447.   def activate
    " Z% U9 J' f( X5 k0 Z& `% s( D* t
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos
    ; q, |% b8 P! f3 F* n
  449.     super
    4 r! T+ G' C4 i5 z/ a
  450.   end  p7 T- x8 o; c1 ~. M
  451.   #--------------------------------------------------------------------------& b6 A, T: D& s$ P. r8 @
  452.   # ● 更新鼠标和光标的位置* {* p! g1 T3 y, T) e
  453.   #--------------------------------------------------------------------------
    # }4 p* O7 _/ k: r% Y
  454.   def update_mouse_cursor% [0 q- ?6 Z0 A7 P8 r4 S) \
  455.     if active
    6 Y- ?! c  S8 e+ L# `6 M
  456.       if @need_set_pos: c% W3 x  d! y3 |: g( L. Y) u
  457.         @need_set_pos = nil
    ; D7 A- H+ V9 \  A5 u  h  k3 p1 J  V
  458.         set_mouse_pos
    6 d; }/ [: Z/ W7 a+ b5 w3 a/ l
  459.       elsif cursor_movable
    ' v$ U  b3 |6 H9 U: {# L7 ~  M
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    * S1 l; e0 A+ [  X+ r3 n
  461.       end" k4 m+ o, m7 Z, N: W, c2 D- v3 f  K
  462.     end* ?& r% u, }0 `- R6 h8 p* I4 E
  463.   end
    , I( [$ m4 F) _! i3 Q
  464.   #--------------------------------------------------------------------------0 ?' Q6 ^4 m, \0 @  U( _
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    - k6 K. N8 V) s! Z8 J
  466.   #--------------------------------------------------------------------------
    7 ^, @" m3 o- ]! S
  467.   def set_cursor: i7 o8 ^* h/ Z+ ~* l
  468.     mouse_row, mouse_col = mouse_window_area6 [8 @& Y! o/ q; F/ S6 n: o( Z
  469.     if    mouse_row == -1
    2 A6 o% ^0 ?3 R* K
  470.       @move_state += 1 if need_scroll# x- Y% f" \- i; u; ?
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ( i! }4 o- B2 ?
  472.     elsif mouse_row == -2
    9 \8 ]. S: v' c/ C( O# R. g7 `& s! s
  473.       @move_state += 1 if need_scroll0 a" }. K4 _( Z7 S3 `( H9 g
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ! ^) }/ Z9 c# b
  475.     elsif mouse_col == -1
    9 Z3 E1 \* i% {/ ], b. B4 r( B
  476.       @move_state += 1 if need_scroll
    4 e  M% y0 }& x$ u4 h8 S! K
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand; n7 t( P+ e" v7 ?: M+ q( z/ x
  478.     elsif mouse_col == -2
    8 U, E# @: g- L, U3 |+ |
  479.       @move_state += 1 if need_scroll6 r% O- k5 Z0 f% d5 L5 x; o/ M0 q
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand
    1 Y3 A- L& ]2 X3 Z( u
  481.     else
    ; |' E. ^  `- A0 X( H. j; E; d5 c
  482.       @move_state = 0
    & o1 X& v, d; k; q. h; N# R, @. K/ @
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    0 x# V) H  D/ ]5 |: I1 p% z/ Z" \" q. \
  484.       select(new_index) if new_index  item_max && new_index != @index5 J- ^( q: M" c+ u1 z
  485.     end
    % Z8 N3 U+ }9 C5 J' I# @
  486.   end" @" k/ s! H4 ~  V: p; @0 X
  487.   #--------------------------------------------------------------------------. s1 P4 Q, u4 h5 W* f! |! _
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    2 n  n. y' U/ V1 ?" d
  489.   #--------------------------------------------------------------------------  }/ F7 W% `; [; x, }* l6 V
  490.   def mouse_window_area
    % }: A" q5 |$ h0 H
  491.     if viewport.nil # necessary!4 ~4 G9 x8 F7 L% D) C) v8 y
  492.       vp_x, vp_y = 0, 03 C% k' G& K5 K7 k. J( y
  493.     else
    ) ^  a$ m& @) O( c+ X4 Y! Q/ O
  494.       vp_x = viewport.rect.x - viewport.ox
    ' [$ ~7 y% L. o) k& _
  495.       vp_y = viewport.rect.y - viewport.oy
    0 f0 x" u/ z" ?! k
  496.     end
    % o! B+ h2 u5 Z) y
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y, }* P7 Z% X0 z# }$ U1 w
  498.     item_x1 = vp_x + x + standard_padding $ s# v1 r$ k  ~' _
  499.     item_y1 = vp_y + y + standard_padding
    6 y% c% f/ k! |; O& z6 f& U
  500.     item_x2 = vp_x + x - standard_padding + width2 r0 g$ J/ H- B( h
  501.     item_y2 = vp_y + y - standard_padding + height
    2 u1 f; N+ y8 U7 s  S- T- B6 \" A" {
  502.     if mouse_x  item_x1
    ' _: Y) b. W; h! m
  503.       mouse_col = -14 W$ W" Q2 X6 p! ~. ]
  504.     elsif mouse_x  item_x21 a& f: |- t1 [- V" R5 Q$ ~
  505.       mouse_col = -26 R. }' h/ ^" z" u
  506.     else
      N' r- W4 t- E# ]& {" V' h
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    ; o( E- ]4 v, I, p7 A
  508.     end7 k; D+ C1 p. A7 X: G! Q& B
  509.     if mouse_y  item_y1
    . T- D6 G3 p0 s6 s  N
  510.       mouse_row = -17 F. O! b  e& X/ J
  511.     elsif mouse_y  item_y2
    $ F) L% U+ P$ \/ Y
  512.       mouse_row = -2
    # }5 ?* b/ L+ c* b) `/ c
  513.     else
      w7 d0 [" D0 }" B  I
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)% Z$ v8 P! d4 z4 m# S/ u" m
  515.     end+ Z1 T* {& }4 D
  516.     return mouse_row, mouse_col
    / i& h/ @! Q) u+ I5 L" V0 R5 Y8 [
  517.   end/ Y' @' ~, f! M8 A( E* r
  518.   #--------------------------------------------------------------------------
    " f5 j% l6 e% b2 o2 ~
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    0 P' n( N3 K% D: b* V, F- u7 X1 o- m
  520.   #--------------------------------------------------------------------------
    ' s5 h' f6 w  m* U
  521.   def set_mouse_pos
    ) n! x8 ^* s$ p; O9 S/ e
  522.     if viewport.nil # necessary!
      D- K) U+ d. H. u3 W
  523.       vp_x, vp_y = 0, 0
    5 K: y6 Y: `" i8 v; g7 w
  524.     else5 x  B4 D& m. |) P. {
  525.       vp_x = viewport.rect.x - viewport.ox
    1 Q4 c% S* h" U
  526.       vp_y = viewport.rect.y - viewport.oy
    & k, ]$ G- |' k3 d
  527.     end3 M5 w0 W5 d  {' B1 X
  528.     item_x1 = vp_x + x + standard_padding ( y9 k* s4 S$ l4 S; E
  529.     item_y1 = vp_y + y + standard_padding
    # {! B) D. `( `- a0 @
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index 2 M) b, Y/ M& t6 e" y+ N
  531.     row = get_index  col_max - top_row2 I% K% [+ L8 ~: I- n- x( R
  532.     col = get_index % col_max! c2 H& W) a- W3 o4 g0 c
  533.     new_x = item_x1 + item_width  (col + 0.5)
    % A# A! P, l* m& b. {3 {3 b3 e
  534.     new_y = item_y1 + item_height  (row + 0.5)5 E% G4 p6 ]( X
  535.     Mouse.set_mouse_pos(new_x, new_y)
      K" @3 Y+ W9 w* ~3 j) y" f! C. k
  536.   end
    : |) ]- Z8 I- X2 L. P
  537.   #--------------------------------------------------------------------------5 F  `6 L& U$ g: I8 q& @
  538.   # ● 判断菜单是否需要卷动
    * ^/ j, v7 n; l; A# D/ P
  539.   #--------------------------------------------------------------------------
    & w7 h, R  V' |. g2 [, f
  540.   def need_scroll( i% |0 ~, N7 C* d: N
  541.     item_max  col_max  page_row_max
    % R; n: `" _% ^6 w, \$ W' Q: m  v- g
  542.   end  T5 V! L5 p" F' O
  543.   #--------------------------------------------------------------------------
    3 v, u3 m, K: W8 ~5 J4 b+ I% ?
  544.   # ● 判断是否为水平卷动菜单1 o7 p) j+ `$ ?/ z4 b  B: t6 f5 b
  545.   #--------------------------------------------------------------------------
    7 c4 X8 J) x' M' u+ O
  546.   def is_horzcommand$ N0 W  ~) Q! J7 J; e% h7 H( O
  547.     return false
    2 R3 G) P- L) v7 b) R
  548.   end
    7 Q: H# a9 x% x# z+ O
  549. end4 q9 M+ e( k5 C( c9 [1 k) N/ x
  550.   ]7 z) H3 z+ ]8 }5 G
  551. class Window_HorzCommand- h' E4 v6 C* z% p7 z
  552.   #--------------------------------------------------------------------------
    " j3 M& O$ l! A- G' `  [
  553.   # ● 判断是否为水平卷动菜单
    # r* n% b" T5 U0 T5 f- S5 M. T5 O
  554.   #--------------------------------------------------------------------------
    & s. B4 Y6 m$ ^- ]1 `. [
  555.   def is_horzcommand  R0 a) x9 h1 R$ f$ P: O6 P8 ~
  556.     return true
    7 p" {; s. o9 ?2 [* m: J8 l% W
  557.   end
    & L; b+ {3 d7 E; H- v
  558. end0 [9 T# F7 \5 Y3 u* M

  559. - A7 p) w6 r& M& B. E( O, \) {6 r
  560. #==============================================================================
    3 P( D& H  }6 M
  561. # ■ Window_NameInput
    4 q. q: F* ~0 H  V$ h( B
  562. #------------------------------------------------------------------------------
    ) `+ S/ [! {* O* {$ I# j
  563. #  名字输入画面中,选择文字的窗口。7 t) |' K* s+ [' v; ~$ {3 h9 A
  564. #==============================================================================
    7 G5 H- ]# s: F; e; \; P
  565. class Window_NameInput
    3 P) {( Y4 B$ K8 w4 g! ^# U: s
  566.   #--------------------------------------------------------------------------+ F+ K' R3 }5 B1 E9 n
  567.   # ● 设置列数2 U' X, v$ P& \3 o6 P
  568.   #--------------------------------------------------------------------------
    " B  p& b. O% _9 b1 ]/ P: j' Q- Z
  569.   def col_max! y* p6 N1 d2 E2 s* O+ k. [
  570.     return 10
    ! `. S5 j/ b  g$ d0 ^  J
  571.   end+ I6 X  h: [. d/ P$ \1 D: p
  572.   #--------------------------------------------------------------------------) k0 l( E4 h5 ?; t8 n( t" o
  573.   # ● 设置填充的Item个数
    : O) p* g# s  I/ S
  574.   #--------------------------------------------------------------------------
    " b2 a: ]+ x" U; m4 i) p9 s" i% \
  575.   def item_max
    ' k% S% F2 i8 q# Y; n5 y
  576.     return 90
    . R2 B  e6 Z- S! O
  577.   end
    7 T5 ~1 v2 k3 \$ P
  578.   #--------------------------------------------------------------------------$ K% Z" P; J9 P0 G% |6 T+ A- b
  579.   # ● 设置填充的Item个数5 @  ^2 `8 l2 @- p5 H; t
  580.   #--------------------------------------------------------------------------
    1 t" B" n# T  [$ l% v
  581.   def item_width
    0 \0 t& b) j" u- F# R
  582.     return 32' ~# ~. E" u0 F4 k; ]- k
  583.   end( C6 ~2 V& A+ e# \; E
  584.   #--------------------------------------------------------------------------
    5 u- H$ a4 F$ G( I/ n
  585.   # ● 判断鼠标位于菜单的第几行、第几列9 F: E  S  a0 E) U
  586.   #--------------------------------------------------------------------------
    2 j, |7 i8 B" O6 n: |& o
  587.   def mouse_window_area# i+ Z( N# m, Y+ K9 b
  588.     if viewport.nil: U) F3 B5 j2 q; p4 T. L5 j8 Z
  589.       vp_x, vp_y = 0, 01 U( b- x, ^/ ]$ J4 @: P
  590.     else2 I0 o, [/ f# B% a& c! r+ }. a
  591.       vp_x = viewport.rect.x - viewport.ox
    & g# N% H3 g5 z- X7 U
  592.       vp_y = viewport.rect.y - viewport.oy& r4 X! v' s# i6 f7 [
  593.     end
    7 [5 d* E  l) Z! B" A  l- [! Y& i
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y0 E+ f$ Q& @$ N" q1 H8 @
  595.     item_x1 = vp_x + x + standard_padding # T1 v/ Z# r( h4 v3 h% ?9 q
  596.     item_y1 = vp_y + y + standard_padding
    1 Q3 l# V" T6 }6 W  ?/ f
  597.     item_x2 = vp_x + x - standard_padding + width
    6 B+ ]% B5 X, b! i/ @2 Q
  598.     item_y2 = vp_y + y - standard_padding + height/ t. f' {9 g( T7 W6 M
  599.     if mouse_x  item_x1
    5 @7 Y% x7 f) U6 p
  600.       mouse_col = -1. @% o0 G/ Z' a: u
  601.     elsif mouse_x  item_x2: z5 l; H# |  N2 f4 i& o
  602.       mouse_col = -2$ S6 o2 m& W9 w& C4 n+ o
  603.     elsif mouse_x  item_x1 + 160
    1 {/ I' k! R2 @0 v, Z* u
  604.       mouse_col = (mouse_x - item_x1)32- l' ]2 q# g8 z! Y$ S
  605.     elsif mouse_x  item_x2 - 160
    / f2 r$ k. T% F' B  r+ p
  606.       mouse_col = 9 - (item_x2 - mouse_x)32
    5 o, k% ?1 ^1 q
  607.     else9 @* E/ E* J. f
  608.       mouse_col = mouse_x  x + width2  5  4& V9 h1 C7 m+ r" I4 N
  609.     end
    + t% q# l# h6 q# A- Y( D7 V
  610.     if mouse_y  item_y1
    / `+ z& P5 E4 G" B# C, F0 C' `
  611.       mouse_row = -1* U+ F/ h0 |( u4 L* r1 t) ^
  612.     elsif mouse_y  item_y2
    * \" T) Y, J3 ~* z
  613.       mouse_row = -2! M+ e: E5 o0 s0 T. d( N0 B
  614.     else: F$ x- k8 _; \2 O0 U4 p+ R
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1)
    , ?2 S2 Q$ z9 _8 R1 t
  616.     end
    " R9 k1 n6 ]" |/ ?( v
  617.     return mouse_row, mouse_col
    & _" m0 d3 d1 u# k! e# l
  618.   end( E& R( B; d# r  [+ p7 p4 P1 H
  619.   #--------------------------------------------------------------------------- B2 z* v; L! Y  c6 m
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置1 V' T6 o" H8 C7 o( m" V
  621.   #--------------------------------------------------------------------------
    2 R: H* P5 y: W( i. R; v7 ~
  622.   def set_mouse_pos# P! W" w+ M& _
  623.     if viewport.nil # necessary!
    9 j8 O$ P5 j9 G1 ]6 L
  624.       vp_x, vp_y = 0, 0
    - w, `  i! Q, z: O
  625.     else" \0 {/ f/ |# u+ G2 L3 c  p0 S* A
  626.       vp_x = viewport.rect.x - viewport.ox
    7 k- e' }7 ^. U7 V- L+ x
  627.       vp_y = viewport.rect.y - viewport.oy' I& |1 f+ H; {, i& {# s. ^
  628.     end
    7 @8 j* \( V' u/ `- I% J  f
  629.     item_x1 = vp_x + x + standard_padding
    2 g( e: |$ U' q1 ?3 A0 s
  630.     item_y1 = vp_y + y + standard_padding
    ! Q) t. `$ e. i2 B3 A* y1 ]
  631.     get_index = @index  0  0  @index
    % H8 ~, H* Z- v1 u0 y
  632.     row = get_index  col_max - top_row
    # k; b& |- I3 y4 J" Z+ k1 w1 W
  633.     col = get_index % col_max
    : `" {5 s! Z  P' U
  634.     new_x = item_x1 + item_width  (col + 0.5)
    5 I0 X/ g  w0 L1 o9 k& M  m
  635.     new_y = item_y1 + item_height  (row + 0.5)
    + n2 `0 \, K4 m: z, r
  636.     new_x += 14 if col  4
    2 W- L( Z9 W) I$ ]- q& w
  637.     Mouse.set_mouse_pos(new_x, new_y)
    / c, d, l" @. ?. `- j, m$ H. e
  638.   end
    * d. z& W: G! k6 D
  639. end
    * \! w. M; D6 Y9 Q! {1 s
  640. 2 V  g! L( w/ k
  641. #==============================================================================
    - m3 g9 B& D1 Z) ]' H
  642. # ■ Window_NumberInput* w/ Q! {% {% S9 ?3 {% r
  643. #------------------------------------------------------------------------------, w) Q; L1 O. R; O* j3 Z8 f
  644. #  重写了数值输入的方法以适应鼠标  _$ e$ R' l1 U8 N- g
  645. #==============================================================================7 V5 ?" f$ L3 N; b. ^$ F
  646. class Window_NumberInput  Window_Base- Z# Y& c. Z6 @. i% I3 X
  647.   #--------------------------------------------------------------------------- H. Y3 Z3 L% y
  648.   # ● 定义实例变量& ]$ _( k+ o  i2 r& R$ T0 X5 S
  649.   #--------------------------------------------------------------------------4 I3 ^5 U' h6 e# R4 @3 a, ?7 }
  650.   attr_reader extra_window
    . p/ ]- t0 V$ p# w
  651.   #--------------------------------------------------------------------------
    # A% N. U: O& Q7 g# C" I
  652.   # ● 初始化
    # G* u/ m8 K& o
  653.   #--------------------------------------------------------------------------# |% p( H0 v1 C4 Y  Z. }
  654.   alias sion_mouse_initialize initialize
    6 g0 y. ^2 [" P% ?4 t( I6 b( L
  655.   def initialize(arg)  B: {7 }, P) D. P
  656.     sion_mouse_initialize(arg)
    $ }* O- u3 q" E2 N
  657.     create_extra_window2 H' N5 o. \! H2 {/ B& @2 H
  658.   end
    3 @, k1 W7 F' h9 N! |
  659.   #--------------------------------------------------------------------------
    - Z& r" w) B5 G4 [! _1 u# U2 e' ~+ T
  660.   # ● 启动
    3 t4 m% O+ a) ]. D1 V
  661.   #--------------------------------------------------------------------------
    , {" b6 e7 Y9 G5 ~- x
  662.   alias sion_mouse_start start
    , Q' k4 `7 Y4 \0 A' X3 T
  663.   def start0 G4 C! n/ p' `. g4 {
  664.     sion_mouse_start4 r% ^8 @! W" i$ G& }) J
  665.     deactivate
      C) b% h5 N" r+ O% f2 X! X+ L
  666.     extra_start9 f6 N( P8 _' U& f. H; I
  667.   end
    ! Z+ [( a1 k( [
  668.   #--------------------------------------------------------------------------0 M! T8 ~& W0 E8 p3 H4 n/ S0 P
  669.   # ● 创建新的数值输入窗口
    6 k/ |- B- u. r. {) h+ c
  670.   #--------------------------------------------------------------------------
    ! @) n+ Q- k$ q) j8 O8 ]. u
  671.   def create_extra_window+ \0 y* D/ Z: k$ w6 p- ^& K
  672.     @extra_window = Window_NumberInput_Ex.new7 E* J: v6 E0 r: P; e' u
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    1 }3 X; o; F5 R0 s1 P
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }
    8 U; X3 ]2 s9 T1 F4 \- Q& k" h
  675.     @extra_window.index_proc   = Proc.new {n @index = n }
    ' U& Z8 R% \* v5 f3 {3 N/ b
  676.     @extra_window.close_proc   = Proc.new { close }' L5 U+ z2 O( O) h+ B& h
  677.     @extra_window.refresh_proc = Proc.new { refresh }+ D7 H  A9 Q5 o. B; H8 V
  678.   end" z# _2 ^) f  j5 u
  679.   #--------------------------------------------------------------------------
    ) g7 m4 {" L+ M, O9 c
  680.   # ● 激活新窗口
    " u5 ~$ k2 A8 l  _. ~# d/ Q
  681.   #--------------------------------------------------------------------------
    - j" p; n: {- M: ^
  682.   def extra_start
    & ]+ t& D3 u6 l6 h
  683.     case $game_message.position8 [9 T6 B4 {; ]$ O& ^0 F
  684.       when 0; @extra_window.y = y + height + 4
    8 ]! N* @: E. j0 s" Z
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    ; B$ m  i) b2 Q3 H* u+ n/ G
  686.       when 2; @extra_window.y = y - @extra_window.height - 4& Q4 N# B& q" E; L+ c. m- {
  687.       else  ; @extra_window.y = 8( |; ?3 `6 x$ y& j
  688.     end! l1 \1 A3 L* S, e% M
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    7 A" N; Q- i' \+ y
  690.     @extra_window.digits_max  = @digits_max: j3 E+ O) D. @& b
  691.     @extra_window.number      = @number
    ) |2 P5 {/ @$ V: w6 s
  692.     @extra_window.open
    8 {6 L; ], m4 W: ?5 C0 i
  693.     @extra_window.activate. w" Y+ A% Z1 W. J* L
  694.   end* U& G# Y- m. ^$ c! F' F0 q6 ?
  695.   #--------------------------------------------------------------------------6 f1 J+ _4 |9 Y7 l9 Y! r% C9 {
  696.   # ● 更新2 q$ l2 l. R0 l' F4 e6 k1 V+ m' Y' F
  697.   #--------------------------------------------------------------------------$ f: N  n9 z0 K4 O1 _; s
  698.   def update
    - f$ b6 d& O, [/ I
  699.     super. c( l. G2 R; C3 \" N+ |
  700.     @extra_window.update
    + ]- {* x& t) \6 A( l  X8 u
  701.     update_cursor6 l* t( o5 g7 O4 L
  702.   end+ F  k* p' U' h: X1 `! x
  703.   #--------------------------------------------------------------------------6 K9 q- e! p+ `7 c
  704.   # ● 关闭窗口  s! [, `" u: b  y
  705.   #--------------------------------------------------------------------------
    $ a. V+ p1 e: X! {
  706.   def close
    - |8 [- z6 Y7 f$ W7 `) g
  707.     super4 q5 l8 h0 r. x$ ]- J
  708.     @extra_window.close3 I! e1 ]0 n3 b: V, U
  709.     @extra_window.deactivate7 R2 s; ?1 B+ l/ ?! q( F
  710.   end7 F- v, F5 D9 f7 Y. h7 d1 c8 m
  711. end
    ( d$ E* P3 n% i$ |

  712. , H; L( t5 w* ]) r# Q; a  c0 L+ v" g
  713. #==============================================================================
    $ G/ r& b7 d7 x% H5 P0 A1 B# {
  714. # ■ Window_NumberInput_Ex, k2 X/ j- v, t; u% w
  715. #------------------------------------------------------------------------------$ w5 ~% B2 u$ \
  716. #  新的数值输入窗口(NewClass)
    . l! i# {9 E  z, J! ?) k
  717. #==============================================================================
    9 {9 |  W& O: [8 {3 C) O
  718. class Window_NumberInput_Ex  Window_Selectable
    . \) {8 S$ ?) Q7 V3 Y
  719.   #--------------------------------------------------------------------------% J9 Z$ }8 F1 L# O" v+ i) R+ l
  720.   # ● 定义实例变量* S2 m, |. x. ~+ y. g1 K5 ^/ Y
  721.   #--------------------------------------------------------------------------
    / G. c! E; y& ?& ~
  722.   attr_accessor number_proc7 L: e! B6 N! z0 b: U! B& B
  723.   attr_accessor index_proc
    ) |3 B. f5 |3 y! O0 h
  724.   attr_accessor close_proc
    5 o% o1 {, X* R# a4 d! N- q
  725.   attr_accessor refresh_proc' o5 D$ n+ x% g1 X! d
  726.   attr_accessor number
    1 g1 n4 S' Y) B; h) [+ T) m0 r
  727.   attr_accessor digits_max
    ( x, y$ [0 u: [; A/ a
  728.   attr_accessor variable_id- n6 g# n9 d; t* _, W
  729.   #--------------------------------------------------------------------------
    # T( u  f2 i# F; H" ^, m
  730.   # ● 数字表
    $ N" E  Q3 A- f* Z% B
  731.   #--------------------------------------------------------------------------. k; O, n. @8 ~: W4 n* w% e: z5 R) u
  732.   TABLE = [  7,  8,  9,
    ! I- D6 z7 J! p! c9 H
  733.              4,  5,  6,
    3 q3 W2 Y4 ?$ l
  734.              1,  2,  3,; x+ T6 j% C" v
  735.             '←',0,'确定',]9 S* ?# T! I6 I0 H/ s
  736.   #--------------------------------------------------------------------------! v+ a  b# e0 \7 U# [% H% \* R8 j
  737.   # ● 初始化对象- g% {3 k( A1 Z* X* {9 G! p) `
  738.   #--------------------------------------------------------------------------
    ) ~/ `& N2 L8 B$ M- E% }8 a1 S
  739.   def initialize! N4 A, M: x  q1 y' k* V
  740.     super(0, 0, 120, fitting_height(4))
    * K& ^9 s3 ]+ q* b
  741.     self.openness = 0
    1 t" C8 g4 W0 ?  x% H4 v% u, m
  742.     @index = 0. Z5 A( ~/ G3 o' K- T
  743.     @number = 0" @+ b/ K2 u6 ~- S. }& ^: ~5 k% m$ P
  744.     @old_window_index = 0) u) u: J' v. }( _
  745.     @digits_max = 0  m% z$ f5 @( \$ f
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }2 j( w' a5 ~1 b; o, C8 i$ U
  747.   end
    0 p9 R6 |0 Y: I% [& L5 X0 v
  748.   #--------------------------------------------------------------------------
    # A9 y# ]+ h" v* y- K' g" b
  749.   # ● 获取项目的绘制矩形
    + S& B# r# p- }9 h: X
  750.   #--------------------------------------------------------------------------
    5 S9 V, w! l2 E4 _2 \) _7 x
  751.   def item_rect(index)
    . c* {& V& W& f
  752.     rect = Rect.new* a: L1 ?5 N& H) n5 x
  753.     rect.x = index % 3  32
    ' J3 C) |8 U% `$ r' ^
  754.     rect.y = index  3  line_height) c4 V0 X+ p& F
  755.     rect.width = 32
    9 W! x7 y8 j; ?* C& `- b+ j9 e% }
  756.     rect.height = line_height0 }! }( ]9 D; p+ f- [
  757.     return rect
    & B  L# C/ g3 D: ^
  758.   end* |; ?4 v$ @( ]1 a) r: |# d; }
  759.   #--------------------------------------------------------------------------- q3 e% c) m9 Y0 q/ R0 ?+ x
  760.   # ● 将光标设置到鼠标所在的位置
    - n, A' J( W5 ]# v7 |) E5 [8 x
  761.   #--------------------------------------------------------------------------
    - {# }. b8 e4 E& Y/ C
  762.   def set_cursor& i" h$ w5 N' m: Q$ q
  763.     mouse_row, mouse_col = mouse_window_area
    % T' `, Q9 M" N2 E
  764.     if mouse_row = 0 && mouse_col = 06 n1 ]% H1 L! g; \8 W6 Q
  765.       new_index = mouse_row  3 + mouse_col
    ) D- W( z/ B  ?9 X- w% W$ w5 F# w
  766.       select(new_index) if new_index = 11# w: _/ x1 e  f8 T" i4 F
  767.     end
    7 g$ ^( R# f6 a& Z1 W1 Q" T
  768.   end0 H$ r' y3 N: j3 u
  769.   #--------------------------------------------------------------------------
    $ k3 d* y$ R. G6 I& k$ ^
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列3 O3 ~) `1 C9 T, |7 a2 p
  771.   #--------------------------------------------------------------------------
    3 x7 S2 V& I2 P! R% q2 A, V6 \% o
  772.   def mouse_window_area
    ( Y, W( m% ]% o2 N- ?
  773.     if viewport.nil
    $ C7 Z% _  ?1 Y' V. Z
  774.       vp_x, vp_y = 0, 0  i8 j5 Q% h1 A! O( f, V
  775.     else
    ! l. d% ]+ W% N" A
  776.       vp_x = viewport.rect.x - viewport.ox0 T& q+ S8 Z; k
  777.       vp_y = viewport.rect.y - viewport.oy; f1 G  W& p% C$ W9 y/ u2 X% K
  778.     end0 g9 n' R7 i: Q9 j; L7 c, I
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y2 ?6 }; X/ L' s
  780.     item_x1 = vp_x + x + standard_padding - h) y  a* c: N; g+ i6 g
  781.     item_y1 = vp_y + y + standard_padding
    6 k. Y: K" T! c4 z8 H( j+ h# }- c
  782.     item_x2 = vp_x + x - standard_padding + width1 ^, n  X% p0 D/ s) f* Q- a
  783.     item_y2 = vp_y + y - standard_padding + height
    1 R2 R2 ^& Y( r5 |; \3 D# m
  784.     if mouse_x  item_x1& n% _; i9 w7 s$ B& S
  785.       mouse_col = -17 W1 J6 N1 M4 h/ `
  786.     elsif mouse_x  item_x2( O" e8 r3 t" v+ l$ H
  787.       mouse_col = -2+ [" L" @& n0 J- B
  788.     else6 D" A/ g) v1 R0 K- K0 c4 W
  789.       mouse_col = (mouse_x - item_x1)  324 i% f5 x! v  o* y
  790.     end! M1 b9 S! _$ ]5 x! {, t# f- c9 G
  791.     if mouse_y  item_y1
    ! _) Z' u# _/ _' D8 u7 c
  792.       mouse_row = -1
    3 z6 g# R; f  w6 i
  793.     elsif mouse_y  item_y2
    ( W1 H# ~& ?) I" s- J0 r
  794.       mouse_row = -2
    4 a+ T6 k8 O' x' N
  795.     else
    & m% S0 v& O6 j
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)8 Y- I% I/ ~* l$ y
  797.     end' i3 ]9 S" o6 X
  798.     return mouse_row, mouse_col4 ~0 U9 e  @+ S  c) v$ ~# {- V
  799.   end
    # `  k: a) {  d4 R, M2 E' Z
  800.   #--------------------------------------------------------------------------2 o2 {3 @% e/ E2 k
  801.   # ● 获取文字
    ; |' B1 P. l2 _( G6 ^
  802.   #--------------------------------------------------------------------------
    % D7 k, d2 v# m) B# ]( W+ x8 d
  803.   def get_number
    ) e8 L+ G. @* R* x$ B5 k9 e+ A! D8 J
  804.     return false if @index == 9  @index == 11' O# s: s; F) y6 C6 d- Y
  805.     return TABLE[@index]
    % C! W1 ^# ^) c. F" C4 H
  806.   end' \( X" W/ s: F, ~0 M5 N0 \5 F
  807.   #--------------------------------------------------------------------------
    1 X, f3 e4 Z* T2 n  n/ W6 }% |
  808.   # ● 判定光标位置是否在“退格”上: {$ w; k5 `6 j8 F8 o
  809.   #--------------------------------------------------------------------------8 h# @+ z+ o; ?/ f
  810.   def is_delete
    & f$ P* Z* O; I' R
  811.     @index == 9
    0 ~. W2 E+ `; s( d* G5 d
  812.   end# B" s& r3 q0 x2 E8 h
  813.   #--------------------------------------------------------------------------
    # y* x4 j6 P" K  E
  814.   # ● 判定光标位置是否在“确定”上
    ) q+ Y# @1 F& D7 c* n* p
  815.   #--------------------------------------------------------------------------$ q) ^  A" p& j
  816.   def is_ok
    $ {( I" ^4 G0 k- \
  817.     @index == 114 {/ h  b% u: ]7 @% q- ^) d
  818.   end$ Z$ D4 v1 F4 ?# f% U) @) l
  819.   #--------------------------------------------------------------------------
    ) Y/ `3 a+ H5 n+ X' T
  820.   # ● 更新光标
    ( r3 m. [* l( E% |5 }$ U
  821.   #--------------------------------------------------------------------------8 Z! B" m2 y/ s) {5 x# ]" _
  822.   def update_cursor+ Z2 d8 x* p8 k/ E6 `( K" P4 ~
  823.     cursor_rect.set(item_rect(@index))
    , ^, o; }# a  C, s
  824.   end$ ^& ]2 Y" a, `5 R, P
  825.   #--------------------------------------------------------------------------
    9 [$ Y) l- u$ @6 U
  826.   # ● 判定光标是否可以移动
    : x, g+ q0 F; A9 P+ G
  827.   #--------------------------------------------------------------------------
    5 }0 }1 {: Q# r9 q8 L
  828.   def cursor_movable1 p" t/ _* w5 q, j1 Y% v3 k& J
  829.     active; _! N  J( }2 l* I# @, x
  830.   end
    & k( p7 @1 G) \0 I9 i
  831.   #--------------------------------------------------------------------------
    8 N) U8 Z% f% ~- T3 M/ p
  832.   # ● 光标向下移动
    ; Q+ D7 v8 K3 e1 d$ P
  833.   #     wrap  允许循环4 J* X: R9 @9 ?+ f& \
  834.   #--------------------------------------------------------------------------
    : \6 }, {& {, E- U1 s8 C6 R
  835.   def cursor_down(wrap)4 i% l1 K, e6 n- ]( C
  836.     if @index  9 or wrap
    1 i- L2 }% `% t% F) p
  837.       @index = (index + 3) % 120 x- \7 ~' X* O0 Z- {# O
  838.     end
    . B/ V  Q$ r1 Y8 y& x
  839.   end$ y# B! l. w4 S  x) h) a
  840.   #--------------------------------------------------------------------------
    ( Y/ b2 S" c. m
  841.   # ● 光标向上移动
    0 t9 Z4 q  n2 y4 I6 K& E9 q
  842.   #     wrap  允许循环
    $ K& I1 o& d+ u% {0 T5 q1 V
  843.   #--------------------------------------------------------------------------8 p5 P: J, S$ O. m6 [3 g
  844.   def cursor_up(wrap)+ ?( m5 ^* u3 v  E4 ?  h+ L( @
  845.     if @index = 3 or wrap5 W! e2 u/ H$ a+ R3 R6 i# p( r/ g) k
  846.       @index = (index + 9) % 12
    : a$ f" G  O0 S5 {
  847.     end
    , a- x5 E% a7 |, |. P. P
  848.   end" [% d8 m! f; u# C2 D) U
  849.   #--------------------------------------------------------------------------
    3 G( y% }- D1 a- a8 t. J3 n
  850.   # ● 光标向右移动+ P$ x8 w; |) H+ M
  851.   #     wrap  允许循环' A; j/ m; b5 d
  852.   #--------------------------------------------------------------------------% M# A  I6 [; V  j2 e1 m+ r; P
  853.   def cursor_right(wrap)
    , Q. D( |7 v3 x7 `' u8 X
  854.     if @index % 3  2
    3 o# W% L8 V# l$ f% ~* Y
  855.       @index += 1
    - G- j6 K" T% H! W7 i5 T6 x9 k
  856.     elsif wrap
    ' h+ N2 K# d' {0 Z) W
  857.       @index -= 2) \; Y# J# K7 J* |4 M
  858.     end. L" ?6 V4 \& i. R# P$ Q6 ^, E
  859.   end. Y- H1 z+ T# q
  860.   #--------------------------------------------------------------------------' i3 U4 \$ x/ q
  861.   # ● 光标向左移动9 P' U' R5 O# f7 F3 m) x
  862.   #     wrap  允许循环
    6 m. G( [6 Y: i+ F$ o! {/ a
  863.   #--------------------------------------------------------------------------) e& w' e3 H' d" p
  864.   def cursor_left(wrap)3 I) t& L0 L6 [
  865.     if @index % 3  0- r: J/ _; n7 M: o  t2 |
  866.       @index -= 1+ \) \1 M( I! n3 C/ L. O
  867.     elsif wrap! k/ K1 _, P; C+ _2 l+ d
  868.       @index += 2
    3 G  K6 ?# y2 A- ^8 m  M" ]' G- A
  869.     end( E" O" ?2 w% t9 f6 {" T' a
  870.   end- b$ |6 J+ A( F2 L: ^; t4 R
  871.   #--------------------------------------------------------------------------
    3 U* [1 q& U- P, ~% g9 M
  872.   # ● 处理光标的移动
    5 O) J' h) M, m- U: u
  873.   #--------------------------------------------------------------------------' ]; F, A& p8 \6 |4 Y- E
  874.   def process_cursor_move
    " Y0 \7 F. H. C3 `4 ]- c8 i3 `  s
  875.     super1 ^& T0 j. u+ x* [1 J: b" O) O: t
  876.     update_cursor& l" U# V6 u: i5 S* f3 r# T
  877.   end1 E" K0 _6 Q$ t$ v; Z
  878.   #--------------------------------------------------------------------------
    9 s# G2 k# o+ _3 O5 A) i; m+ b
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
    : A4 O+ _% V0 O% T* l6 @$ \; |
  880.   #--------------------------------------------------------------------------0 D4 v5 j( P8 T5 x6 @! Z
  881.   def process_handling
    7 |9 t1 S3 K# w+ W$ d
  882.     return unless open && active/ ?+ t7 h9 M6 L# B$ S
  883.     process_jump if Input.trigger(A)
    1 G3 l" `0 [. P9 p$ r& l# [7 f  o
  884.     process_back if Input.repeat(B)! N9 R. i) E- v* v$ s
  885.     process_ok   if Input.trigger(C)
    7 J% b# W' f* ]1 Y% L1 o4 v. C
  886.   end5 e* ~' n% o, Y7 P' Q& a$ p* }5 Q
  887.   #--------------------------------------------------------------------------
      e0 E/ R5 ]+ b
  888.   # ● 跳转“确定”
    3 @$ J9 A8 e' d& q
  889.   #--------------------------------------------------------------------------
    $ |- V& L1 V& I' [8 {  M
  890.   def process_jump
    4 b& d- S2 C3 e% K& @& M; x
  891.     if @index != 11
    + J; p/ t' }2 y* ^) u7 o
  892.       @index = 11+ t! K; P+ ~9 z
  893.       Sound.play_cursor. U0 w% Q  U/ F8 T# ]6 ~, m$ H$ |
  894.     end4 q% r, A9 _% ]- U! x  N$ J
  895.   end6 Z+ [5 p6 O6 y0 o/ e9 n
  896.   #--------------------------------------------------------------------------: ^, i" D. Q0 ]# |& P) c
  897.   # ● 后退一个字符
    & T3 h/ i: d  D% V1 n4 Z
  898.   #--------------------------------------------------------------------------/ _  v3 D5 ?( ]7 A! u8 e* }
  899.   def process_back
    ( R, u0 G. }5 m/ }6 n5 a1 h" D
  900.     Sound.play_cancel
      f& p& _5 U# A' f
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    ' ^7 C3 c/ L0 N" @! ?' O
  902.     n = (@number  place) % 10
    - d; M6 G- F" H$ M; p$ S
  903.     @number -= n  place* o! s; R; \" v% Z7 s
  904.     @number_proc.call(@number)
    0 p7 H# ~! \- [- Q+ l0 ]
  905.     @old_window_index -= 1 if @old_window_index  0
    + w7 b: K$ j9 U1 R! X
  906.     @index_proc.call(@old_window_index)
    + X* J/ f# ^( k) u2 K
  907.     @refresh_proc.call7 i* d8 e2 y) X$ _& u
  908.   end, f# b, Y& o+ ?
  909.   #--------------------------------------------------------------------------
    1 d6 _% N0 @+ j$ _# C5 F
  910.   # ● 按下确定键时的处理$ P* N1 [  p. _" g) B% \  B7 s9 V
  911.   #--------------------------------------------------------------------------
    $ C+ L2 C- ~; Q! K
  912.   def process_ok# p; I' i- a* d5 r, @$ m  ~
  913.     if get_number
    $ V+ V( F9 w  g  Z1 V+ H
  914.       Sound.play_cursor
    & N3 C6 |2 O" k* V" X9 Q
  915.       place = 10  (@digits_max - 1 - @old_window_index)
    $ ?+ A  l4 s8 }2 i
  916.       n = get_number - (@number  place) % 108 g+ _4 ~& G- E( C. P
  917.       @number += n  place
    ( X# \! n  ?6 ~; R) r2 J
  918.       @number_proc.call(@number)
    : p: m5 t# E% f) ~+ Q5 z  b6 p
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1( w8 B# v  u- r) e# {
  920.       @index_proc.call(@old_window_index)# W' S2 D% A; _
  921.       @refresh_proc.call0 U: O/ z- N* d% K' ]
  922.     elsif is_delete9 @' M# e0 Q- d( K% j1 h
  923.       process_back
    8 k( O. E5 ~6 b9 P
  924.     elsif is_ok" t8 a1 i$ y2 e5 v1 o' B3 t9 a
  925.       on_input_ok# b" b* N' S( j) u: e( F, K/ Y
  926.     end; f. }- F' O/ K3 M* v0 S: t( `
  927.   end
    / d: ?; J# H6 x' ?' h
  928.   #--------------------------------------------------------------------------* d+ [1 U+ o8 ^, S
  929.   # ● 确定7 {9 N, U% F1 P/ k2 z, s8 _
  930.   #--------------------------------------------------------------------------% r5 k6 d7 \5 c+ v: n
  931.   def on_input_ok
    3 U) g! s, P+ X+ |, u
  932.     @index = 0
    : U7 L+ V- B& x0 m3 z: ]$ y
  933.     @old_window_index = 0) D$ f8 {) i# K% [+ J% Y: W
  934.     $game_variables[@variable_id] = @number6 m8 e; b6 b6 |: _% Q
  935.     Sound.play_ok# z3 e# {* h+ Y3 M' C) u
  936.     @close_proc.call0 y- ]  ?: t! V: p2 @1 k5 S
  937.   end
    $ Z4 Z& B/ E4 A4 |4 Z
  938.   #--------------------------------------------------------------------------
    ( p- h& M. N) P
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    1 \' _, ~) ?- v9 _0 o
  940.   #--------------------------------------------------------------------------
    ' L" r0 u9 R1 |3 ?7 F9 N
  941.   def set_mouse_pos; n/ Q  Z* s  ?
  942.     if viewport.nil # necessary!
    - ]8 W* u( R  L7 H* p
  943.       vp_x, vp_y = 0, 0
    * I& |5 G2 J3 {$ X, j/ H0 a  ^
  944.     else$ b3 a) |& ]) }, |* V
  945.       vp_x = viewport.rect.x - viewport.ox
    / W! M( R: Z$ S1 C5 z4 n
  946.       vp_y = viewport.rect.y - viewport.oy) r5 l7 f  n6 R% J: t9 ^% R% O* Y
  947.     end
    5 G2 t& g! o: G! m
  948.     item_x1 = vp_x + x + standard_padding
    / [4 ]+ _, p/ G
  949.     item_y1 = vp_y + y + standard_padding
    7 h% M$ s) C7 r+ b- c8 i
  950.     get_index = @index  0  0  @index
    2 K1 h( M9 g6 I5 Y$ F/ W0 M
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5). w" h8 g/ l5 ^! K2 ]* D6 s
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)
    & e! b) b2 o4 L3 m, i( a* ^
  953.     Mouse.set_mouse_pos(new_x, new_y)2 X* `1 _8 m9 u* b' t/ }( v
  954.   end& E2 }2 }% }- J( Y! ?3 i. f: e5 f" Z
  955. end; W6 Y( v) K6 \' F; q" E

  956. 4 z/ T" X( P# y! X
  957. #==============================================================================7 t$ D- R& M! ~; p) d$ g( N
  958. # ■ Window_Message& y7 @9 a( w" b5 b" F: J
  959. #------------------------------------------------------------------------------
    ( u1 Z& ?- l$ \. S
  960. #  显示文字信息的窗口。3 w* X8 b& m% W( A) q: i4 q
  961. #==============================================================================- }1 ?$ F: p) X; ?$ Y( `! y
  962. class Window_Message  Window_Base
    7 b" `% [. R$ n1 m) u
  963.   #--------------------------------------------------------------------------& v5 {! ]/ g- c+ @2 V0 N' {& m" L+ g
  964.   # ● 处理数值的输入(覆盖原方法)
    ) C( O( a7 }2 @5 x) w5 T
  965.   #--------------------------------------------------------------------------
    % E7 Y0 S- R9 w% w# k" d/ t) m
  966.   def input_number
    ! W8 J4 o5 {. [: w2 w8 J8 ?% H; K6 r
  967.     @number_window.start) J) b/ K; a/ n1 q7 I) ?" K" c
  968.     Fiber.yield while @number_window.extra_window.active
    ( D, a0 C+ v# l$ C" B
  969.   end5 w0 y9 A) d8 g( J& s
  970. end
    0 V% E" E( W) A0 Z. R$ n' R
  971. ) L0 f2 X$ `7 w/ e
  972. #==============================================================================) h# C# N- |2 R% q( M$ U: N% x/ m
  973. # ■ Window_PartyCommand9 c0 |, M( H; ?$ H  }' O4 R
  974. #------------------------------------------------------------------------------
    9 y" M# b7 F: L2 l" G- r: |* T
  975. #  战斗画面中,选择“战斗/撤退”的窗口。  `4 v' r& L" ?/ W& W* O" W
  976. #==============================================================================$ G6 A( X2 q, L& u. H# m1 `
  977. class Window_PartyCommand  Window_Command
      ~0 }  }5 u- w; q& J
  978.   #--------------------------------------------------------------------------
    1 w, e* X* U* ^! C2 P* j' Y6 R
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    * n4 `2 k* {  @* K2 n6 [! s9 F* p
  980.   #--------------------------------------------------------------------------' N. O8 a3 K0 a( T. W" V/ E
  981.   def set_mouse_pos. X1 R$ f% G( J% P0 @
  982.     if viewport.nil
    # W6 @6 z# b' S) ^8 H& q
  983.       vp_x, vp_y = 0, 0. l1 X! z: N' h+ ^8 Z. L9 p; w
  984.     else
    & l+ T7 j, I8 S) L$ L
  985.       #vp_x = viewport.rect.x - viewport.ox3 w( E1 e, s8 r( `/ ]8 o
  986.       vp_y = viewport.rect.y - viewport.oy
    8 J# o; ]& R+ J5 O: ?
  987.     end
    % H5 c+ }2 T  j# {& @( F5 `4 C1 ~
  988.     item_x1 = x + standard_padding
    - Z1 j  U1 h( @( P1 N8 h: ~
  989.     item_y1 = vp_y + y + standard_padding
    4 B  g- Q6 r1 z4 j/ g0 ~% B5 x
  990.     get_index = @index  0  0  @index . t/ _2 r* A+ }6 B1 N
  991.     row = get_index  col_max - top_row7 l& B7 c4 {& \+ x! Y/ H" }+ D3 F3 ~
  992.     col = get_index % col_max
    7 @6 O4 }3 B7 L
  993.     new_x = item_x1 + item_width  (col + 0.5)) L3 r: ]& O. l* j* K7 A9 a# f4 \$ ]/ \
  994.     new_y = item_y1 + item_height  (row + 0.5)
    9 o/ m3 @- L# d( ~
  995.     Mouse.set_mouse_pos(new_x, new_y)2 @- r. }1 H& r9 ]
  996.   end
      r/ c2 ]0 d* C* h0 }
  997. end' m, u8 b7 C: v: |; x6 N

  998. / d, S% p% J# a) V" e" P0 o
  999. #==============================================================================
    1 E" R  i3 z' ^( B
  1000. # ■ Window_ActorCommand0 X* w, i& L7 f+ I3 X0 r8 Y
  1001. #------------------------------------------------------------------------------" @2 C5 ]0 S  |9 J$ i6 d9 s
  1002. #  战斗画面中,选择角色行动的窗口。5 y& Q( [1 s/ U. n
  1003. #==============================================================================
    6 S0 [9 [/ u+ m: h( a: q1 ?& Y
  1004. class Window_ActorCommand  Window_Command+ F$ V1 v' h4 C
  1005.   #--------------------------------------------------------------------------
    - [! e3 S8 d. K4 u! S* V/ w
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置4 W, Z; f2 m9 l5 `6 c. v. I2 X" `
  1007.   #--------------------------------------------------------------------------3 O" b, `  ^# x: ^
  1008.   def set_mouse_pos; S3 l9 q& t0 d- t1 M1 u
  1009.     if viewport.nil/ g! n: D- `( \$ ?" r' S4 i4 q
  1010.       vp_x, vp_y = 0, 0
    $ c& z, g+ ~8 _9 B6 H' \& k+ k8 l
  1011.     else7 E3 ?% @& I9 U9 W5 |; |
  1012.       #vp_x = viewport.rect.x - viewport.ox
    0 \! v  H8 j/ c
  1013.       vp_y = viewport.rect.y - viewport.oy
    + C0 V0 Q! m. a9 A
  1014.     end
    8 m; ?. q! I) k' N& g7 }" A
  1015.     item_x1 = Graphics.width - width + standard_padding: r0 x1 H* {( l0 p6 L& Y: m/ i9 l. j) r
  1016.     item_y1 = vp_y + y + standard_padding- |* a0 s* O( D6 n/ Y
  1017.     get_index = @index  0  0  @index 5 n1 P* |  F0 {
  1018.     row = get_index  col_max - top_row7 F3 D0 H5 O! [7 j( F
  1019.     col = get_index % col_max
    , X0 H6 N. ^* D$ l
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    + x+ m2 t/ y" P9 Z8 \8 J& S: I+ L
  1021.     new_y = item_y1 + item_height  (row + 0.5)
    / w* v6 H) z% G, q: r" ]! z
  1022.     Mouse.set_mouse_pos(new_x, new_y)
    3 E! x7 G/ U" ?1 X# g8 V
  1023.   end
    0 k, \6 t& {$ G( l) f; o
  1024. end
    % D9 ]' \3 Z6 G1 q( T

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

  2145. , o2 ^9 u3 y0 Q4 N0 {
  2146. #==============================================================================3 m# I# Y7 ]7 i  ^( o: C: \) y' v
  2147. # ■ Game_Map
    ) u- ~9 G: ?9 B5 D; B
  2148. #------------------------------------------------------------------------------
    ' V0 V4 k& ^8 J/ A% u- D( P1 i* D
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。& b1 W4 W6 m/ \/ M6 O+ X
  2150. #   本类的实例请参考 $game_map 。
    * _7 J& `9 O( Y1 O' ]; v
  2151. #==============================================================================
    5 _1 A( w: L. C( ^2 K' V7 Q
  2152. class Game_Map; ?; Y/ a# C4 E( N
  2153.   #--------------------------------------------------------------------------, b% J7 G$ P, q6 m
  2154.   # ● 定义实例变量1 W2 B2 b# [# c/ Z& f% O
  2155.   #--------------------------------------------------------------------------
    1 y8 p7 d6 X# Q
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据) J& N1 U& G1 Y3 f. R4 Z7 M5 H
  2157.   attr_reader mouse_map_y # 同上
    ! p* M) F8 e# s9 Z! L
  2158.   #--------------------------------------------------------------------------/ S1 ?* @7 C9 C& }
  2159.   # ● 初始化对象8 F" U1 V/ H+ A; p; X
  2160.   #--------------------------------------------------------------------------
    $ L1 |- t$ `- K+ T
  2161.   alias sion_mouse_initialize initialize9 M/ w5 R$ h) l) k: V9 W
  2162.   def initialize
    2 s; ]) a/ B- e
  2163.     sion_mouse_initialize! c3 D5 p  W5 c2 d( @
  2164.     creat_move_sign  ###* O) i' S3 f8 F
  2165.     set_constants
      E( ?. l6 T7 m: f
  2166.   end* c, [7 B! C# U
  2167.   #--------------------------------------------------------------------------
    , A; Y. A( [3 S& I9 m6 N( f
  2168.   # ● 更新画面/ v. \0 m' G7 [9 r/ u: ]% {7 L& J# {
  2169.   #     main  事件解释器更新的标志9 M! B# R, k( D# S! l
  2170.   #--------------------------------------------------------------------------. f& K0 G* i! o) l
  2171.   alias sion_mouse_update update) i4 r/ \& W1 o
  2172.   def update(main = false)
    9 R5 g/ ^' z% g8 k! B) r4 C9 d
  2173.     sion_mouse_update(main)) O2 o& u( a: o: G0 L
  2174.     update_move_sign7 V. ]/ |. ?# L0 o4 H. |, n
  2175.   end
    ( t" t; a1 P, ^$ k! p/ s8 w7 Y2 O
  2176.   #--------------------------------------------------------------------------: G# ]- z1 z" {! d) X
  2177.   # ● 创建显示路径点的事件
    # a4 w/ z( t3 W0 G( o9 W1 I
  2178.   #--------------------------------------------------------------------------
    2 U  d  d( s' w5 K
  2179.   def creat_move_sign8 V+ V' F0 P& q6 i# b
  2180.     $mouse_move_sign = Move_Sign.new% L% \, S; [& A) B' b1 J
  2181.   end4 I  {, K& ], n, k& i: F3 L
  2182.   #--------------------------------------------------------------------------8 x* m$ b0 D+ Y9 O+ [; a: J1 N
  2183.   # ● 更新显示路径点的事件
    . ~$ ^+ f3 D$ Z+ ]* b
  2184.   #--------------------------------------------------------------------------
    6 Y- n3 ^! C- R9 o. a
  2185.   def set_constants
    ( \/ E* Y) q; P4 O4 z* x' P
  2186.     @mouse_pos_setted = true$ q9 X# L. F* ^: N5 Q) T: r
  2187.     @set_pos_prepared = false
    ) L/ E" Z% u* t) F, i2 R
  2188.     @mouse_old_x = 08 X. o; V! f! q2 ?
  2189.     @mouse_old_y = 04 q  t/ e6 H5 V. r" s. I. C
  2190.   end" h8 G5 v4 d2 o
  2191.   #--------------------------------------------------------------------------
    : t8 S; m0 F7 u- X3 b4 F9 A; |
  2192.   # ● 更新显示路径点的事件# W  _0 Z3 P: j& J
  2193.   #--------------------------------------------------------------------------) l% F- q- C3 C% R
  2194.   def update_move_sign' D9 A0 E/ K* n
  2195.     $mouse_move_sign.update
    " _2 |% C* T/ B
  2196.   end
    * ^1 G9 G) a) Z: ]
  2197.   #--------------------------------------------------------------------------
    + D' _! g1 D) K* I3 F. G# k4 _
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    : R8 C6 o) \! x8 O: {
  2199.   #--------------------------------------------------------------------------
    ; E* D" T% X1 }. T4 M+ C. Q
  2200.   def get_mouse_map_xy
    4 B8 n$ a7 r! n" k% g7 ?5 O
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y8 q; R! N) m' l/ F
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)& I7 W( a5 T9 G% Z. n+ K' K
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    5 {* x2 D: L( R0 P/ f( c9 ^
  2204.   end
    + M1 E/ _! {" l1 f. h
  2205.   #--------------------------------------------------------------------------
    , M) \) I% w8 ]/ Z1 a: T& b
  2206.   # ● 返回地图画面时重设鼠标坐标/ X4 u7 m/ L6 _) ^
  2207.   #--------------------------------------------------------------------------
    & _6 w6 C7 L4 a* d; }. z+ V2 Y
  2208.   def reset_mouse_pos# T0 z4 ]5 r6 X, T( R
  2209.     return if @mouse_pos_setted
    8 u7 V1 e. `8 D4 |" q7 N* y
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)
    8 F' `; I) J3 _6 i0 \- Q' W8 Y1 D
  2211.     @mouse_pos_setted = true
    1 o% `/ o! H# c" Y1 Z
  2212.     @set_pos_prepared = false7 G% x% R8 z+ u" |; P/ j( @) W
  2213.   end
    - F# F3 H. G+ Y( m' A, v
  2214.   #--------------------------------------------------------------------------
    * y* ~% {$ d0 t3 ]
  2215.   # ● 重设鼠标的坐标
    ( @% G1 @' O5 N" H! e( j9 S" d
  2216.   #--------------------------------------------------------------------------! K7 L6 i/ n9 `6 X, f* L
  2217.   def prepare_reset_mouse_pos
    ) J9 K* h$ E0 {( s% s
  2218.     return if @set_pos_prepared
    , e- v* o9 l4 ]/ R/ x( P# g' [. h
  2219.     @mouse_pos_setted = false
    8 [  v" F2 v& ]/ i' J2 A
  2220.     @mouse_old_x = Mouse.mouse_x0 L! `2 t0 s; P" |. _
  2221.     @mouse_old_y = Mouse.mouse_y
    + e  v8 c$ [# i" r' K3 L) t- d7 s
  2222.     @set_pos_prepared = true: w; d1 G( d* P! F2 U6 z4 q0 c; b
  2223.   end; g) ^# j# z* V$ k% n) W. _
  2224. end3 i1 K$ |, B) Z5 y
  2225. , U, ?: P% |: H* p+ J
  2226. #==============================================================================
    2 l% C) N3 {8 f3 J( i
  2227. # ■ Spriteset_Map
    8 q1 W2 i9 b: H0 Q
  2228. #------------------------------------------------------------------------------) y& n8 M9 O1 ~( a, @: X" X
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
    1 |  a$ _4 c& u! d
  2230. #==============================================================================6 \4 I0 o- p& L$ y. R
  2231. class Spriteset_Map$ Z6 {7 J* |! j" u& r, H
  2232.   #--------------------------------------------------------------------------
    # B6 @% {6 U* r) p) E- C* ]
  2233.   # ● 生成路径点精灵
    * i5 V# \2 s: f8 h
  2234.   #--------------------------------------------------------------------------9 f+ w1 P; `2 j6 N
  2235.   alias sion_mouse_create_characters create_characters
    . a0 g. |( x5 r6 o, o/ V
  2236.   def create_characters, y7 {3 j$ g8 d5 c6 l
  2237.     sion_mouse_create_characters
    0 L5 A. u5 v2 M
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    9 h  q* g* F9 k4 g) K: L/ p
  2239.   end; _) C3 j& g/ I6 w$ @) }
  2240. end/ _: g" g3 a$ Y6 d

  2241. 6 C) N$ I  j  j1 u7 X
  2242. #==============================================================================: S. s+ A$ ~% D/ y3 |& r2 L
  2243. # ■ Scene_Map* ?# x6 E; U/ Y& u* L
  2244. #------------------------------------------------------------------------------9 G' I7 X+ `3 t7 n$ N; E. J
  2245. #  地图画面
    8 C/ d6 E* [4 h' h
  2246. #==============================================================================
    7 e0 W* g! r, }+ I$ m  u- V- n
  2247. class Scene_Map  Scene_Base+ \) _! `% j* P3 l5 I, [& t8 \9 x
  2248.   #--------------------------------------------------------------------------
    3 S. S' I5 Z) B% l, `
  2249.   # ● 画面更新# r6 r: Z7 W+ o$ D3 W( u
  2250.   #--------------------------------------------------------------------------
    6 R; T5 K2 o( i
  2251.   alias sion_mouse_update_scene update_scene
    ! F/ a1 y8 E+ t4 H
  2252.   def update_scene+ l' P" J3 x3 s$ D2 _7 L; w
  2253.     sion_mouse_update_scene0 L9 E; ^9 v5 ^% t3 D0 L% P
  2254.     update_mouse_action unless scene_changing+ s& w9 E# u- ]% p
  2255.   end/ e; c' [' ]; i, O7 e0 @1 |" Q
  2256.   #--------------------------------------------------------------------------$ ]! G* d1 `& }" m- a
  2257.   # ● 场所移动前的处理7 l4 Q) K4 H1 s( w" j6 X
  2258.   #--------------------------------------------------------------------------9 J1 Z1 H3 S$ [% h# X
  2259.   alias sion_mouse_pre_transfer pre_transfer
    1 a  C, s* e1 x
  2260.   def pre_transfer: \9 l# r5 g" D; }  M- P' T
  2261.     $game_player.reset_move_path
    2 b6 D: _- C1 l7 B; C
  2262.     sion_mouse_pre_transfer
    . C" M& V' r/ E2 v3 C9 Q) v0 ~" v
  2263.   end
    4 K  ]* F; x1 d+ m
  2264.   #--------------------------------------------------------------------------
    , g- Q: H. J, _6 K4 R% Z' M
  2265.   # ● 监听鼠标左键的按下
    7 Z0 y  ^5 o, |6 }8 T  [
  2266.   #--------------------------------------------------------------------------
    + V" f# M* T" y
  2267.   def update_mouse_action
    & [; _" r0 J4 y7 D
  2268.     $game_player.left_button_action if Mouse.press(0x01)* j# u2 ~8 s# J# z# H/ C2 N
  2269.   end- B5 R: A" \. l$ y! q+ F' Q) i9 ^" h
  2270. end2 ?, A5 B7 G7 f- g, k6 Q) L
  2271. 7 h' U2 _0 Y' U6 j
  2272. #==============================================================================
    & U, r* _! P' S$ N
  2273. # ■ Scene_File1 \2 _$ i# {, H' \" h
  2274. #------------------------------------------------------------------------------5 N; @# N5 I8 t. a# `  B
  2275. #  存档画面和读档画面共同的父类0 U+ T7 q. c) k
  2276. #==============================================================================
    / ~+ h% @' P3 H% W- L4 o
  2277. class Scene_File  Scene_MenuBase4 T: f* H3 p5 z
  2278.   #--------------------------------------------------------------------------' X7 m6 E" v/ N
  2279.   # ● 开始处理
    ! v8 q4 u" m) L# E# B$ i6 p
  2280.   #--------------------------------------------------------------------------& Z9 s* V: Z$ X7 ~
  2281.   alias sion_mouse_start start
    + z. t0 F6 B" K3 }9 j0 i
  2282.   def start
    + _1 ^  m4 d6 e" e$ R8 i
  2283.     sion_mouse_start! \: ^! Y1 l2 S9 p9 ]5 t
  2284.     @move_state = 0( v5 F' j: l. T
  2285.     set_mouse_pos
    & @& p  T* E  @* }' ^2 |
  2286.   end
    : M  ~. N. U" W6 Z7 G2 a$ d# y
  2287.   #--------------------------------------------------------------------------. H0 D" N& c  z7 K7 X
  2288.   # ● 更新画面
    # O0 t* g9 U5 v/ f, n' X9 p
  2289.   #--------------------------------------------------------------------------
    - m/ d  Q) t3 R6 a6 i- _
  2290.   alias sion_mouse_update update& H7 {+ n7 \1 e3 A" W! _
  2291.   def update
    # W2 w* W* {2 r8 ~9 ?+ h. e
  2292.     sion_mouse_update8 t  l6 A# s4 v& i' l2 g) j
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
      U1 t5 \. L1 T# d% n
  2294.   end
    + h8 O! Y) d; W7 ^+ P1 E+ N3 p- o
  2295.   #--------------------------------------------------------------------------
    # k5 {5 x- A& S# q
  2296.   # ● 更新光标# r8 d9 A# A! L9 E* i' X
  2297.   #--------------------------------------------------------------------------
    ) r+ T9 M; z" L4 R5 C& {
  2298.   def set_cursor
    4 R5 W, H0 w! [% C
  2299.     @move_state += 1
    + B8 e, X4 z- N" x3 A* y" l$ u) K$ {- g
  2300.     last_index = @index' N  M* h; b& S6 }
  2301.     if mouse_which_window == -2! e  o  X' H5 q
  2302.       if (@move_state - 1) % 6 == 0
    . {7 Z; Q" t* t; _' }+ d
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1! Q0 V" A% u% U  L9 a" t
  2304.       end8 g9 V5 b8 _" Z* T
  2305.     elsif mouse_which_window == -1
    - F/ Q( k; y1 b2 x
  2306.       if (@move_state - 1) % 6 == 0& d! Z+ q/ ]- i1 m/ u
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    : P( O- @  r1 U- a
  2308.       end
      Y" W) _1 C/ L- M# y* B
  2309.     else+ F- v" P* j: u: @# ?
  2310.       @move_state = 0& _2 \& e/ C5 E  S  B
  2311.       @index = top_index + mouse_which_window( I- p$ n5 l. Y; ~. D
  2312.     end
    3 P6 z( L& m7 k" a& h8 |
  2313.     ensure_cursor_visible
    ( L8 v! N7 G( d/ {  B8 ~2 `5 l3 n
  2314.     if @index != last_index
    % k2 g+ |  Z; w' k
  2315.       @savefile_windows[last_index].selected = false
    " g1 P7 i' k! H
  2316.       @savefile_windows[@index].selected = true
    / S- Q$ ?5 ~" Q! \% r, e- R
  2317.     end2 T# `% j4 L' w! O8 [/ a) q
  2318.   end
    ) S% b# z( _4 F0 G9 e/ l$ g1 b
  2319.   #--------------------------------------------------------------------------) `2 a& R- ?% v
  2320.   # ● 判断鼠标位于哪个窗口; R* r3 B$ R2 y. c/ U4 ]( Y
  2321.   #--------------------------------------------------------------------------* [6 S% [3 F6 N" X3 M
  2322.   def mouse_which_window+ l3 w0 p5 i9 Z* g( s, j7 M
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y' E$ J3 O7 t2 W* k# }' ]
  2324.     if mouse_y  @help_window.height + 14' C9 C* V) Z5 N0 X
  2325.       mouse_row = -1/ T3 c- n) G2 @6 n# C' m
  2326.     elsif mouse_y  Graphics.height - 14
    & |, V, P5 R, K" N0 ?" }- i# F* v
  2327.       mouse_row = -2+ |8 ?& g1 S- x1 y
  2328.     else% I7 F, m, s8 f* W
  2329.       mouse_row = 4  (mouse_y - @help_window.height) 2 N7 {2 @4 R/ h, d
  2330.         (Graphics.height - @help_window.height)3 ?: R! H; {* E% w5 Q3 I/ V
  2331.     end
    + N1 k7 ~0 a7 w) Q! A" ?4 r
  2332.     return mouse_row
    + t( X) D/ L# e. j: C2 S9 x% T
  2333.   end5 i8 p# _8 |' W! S' `( V( F5 w
  2334.   #--------------------------------------------------------------------------! b9 r; l( D, h0 G
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置1 q- L5 H) h" }' p( r& P0 s  Z5 \
  2336.   #--------------------------------------------------------------------------2 ?; l( x# C1 f. {4 g
  2337.   def set_mouse_pos3 u% Q; A; u9 |2 o! K5 X( a
  2338.     new_x = 40! N; D, \  A5 i
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24
    9 U2 g4 i! S5 u
  2340.     Mouse.set_mouse_pos(new_x, new_y)3 \% @) T# U2 Z- S- ~" Y( {& j
  2341.   end
    1 H% F5 f6 c4 ?( ]" S- z
  2342. end4 I/ B; \! R" D* y( \

  2343. . n4 E: k9 n1 X5 Z9 B. z3 W$ V
  2344. #==============================================================================, V8 D7 h: W; Y
  2345. # ■ Game_Event
      h. M* o  n' \/ ^4 Z/ f
  2346. #------------------------------------------------------------------------------0 d: O+ J3 d3 U
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。8 o1 U1 e; }" d
  2348. #   在 Game_Map 类的内部使用。) p2 _3 w; g2 T& |% j+ D7 G! J" p% V
  2349. #==============================================================================5 A& U( x9 H/ O
  2350. class Game_Event  Game_Character
    + m+ ]6 R5 s7 J& U8 b
  2351.   #--------------------------------------------------------------------------- A" e1 X2 A; R
  2352.   # ● 事件启动" u% i& Y/ T3 [
  2353.   #--------------------------------------------------------------------------8 f. U$ `# T* }7 K0 O
  2354.   alias sion_mouse_start start
    : U% A4 a+ K/ c: P' v" A2 M; T
  2355.   def start8 Q5 ~1 S4 Z5 d5 v$ y
  2356.     return if mouse_start && !Mouse.press(0x01)5 l( b! p. L4 {8 P- \. `1 R; u
  2357.     sion_mouse_start& N% }' k* t  J' F5 y; x! M0 V
  2358.   end: X! Z; F5 _+ C' {( X
  2359.   #--------------------------------------------------------------------------, g: j% ~. P& X" T2 e' G
  2360.   # ● 判断事件是否由鼠标启动
    8 r/ q6 r6 x7 [2 q4 B# e
  2361.   #--------------------------------------------------------------------------3 N1 Y0 f6 z8 ~. s7 v+ a
  2362.   def mouse_start# [- F8 h+ C/ f7 i
  2363.     return false if empty
      J. h0 L. b9 ^3 ?
  2364.     @list.each do index
    $ w1 k% {4 X+ V4 [& s) G' ?
  2365.       return true if (index.code == 108  index.code == 408) &&
    3 |& K$ H8 W3 i, j0 z3 y
  2366.         index.parameters[0].include('鼠标启动')8 s# n8 @" r. p$ ?
  2367.     end6 F) Q3 ^: I6 x, t, V
  2368.     return false& o8 t3 c& Z5 I6 M
  2369.   end% O$ a7 e' M0 Z  l
  2370. end' r  i# e1 D  l; b! h8 }
  2371. % l6 C6 B4 [2 A: ?% `, l& r0 T
  2372. ####泥煤的height
    . f# n0 D$ C0 b" S# N7 r7 n$ _" O
  2373. # @height = height2 b4 Q) l9 d& y/ K8 |* o, v

  2374. ! i, f$ N; @+ _( z/ i
  2375. class Area_Response. k2 S! i8 S" ], w9 o1 i
  2376.   attr_accessor type2 ]5 ^) D% N: ~  O/ o& C
  2377.   attr_reader ox2 G, L% Q  B  G8 y4 @  x
  2378.   attr_reader oy) J9 f# @1 I2 _% R9 a) c, b% ]
  2379.   attr_reader width% `- ]  p; c3 O( _- v9 a/ r/ e9 M2 d- @
  2380.   attr_reader height9 H/ }+ y: _+ d$ j% k, C
  2381.   attr_reader switch_id
    0 N8 Q. I! }( z; j/ p3 l  i
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
    ; n$ M) E. X' s9 g& e0 ?1 Y
  2383.     @type = type9 i9 p+ q5 g7 S. h
  2384.     @ox = ox9 Q: ^  j8 [6 p- e8 Z
  2385.     @oy = oy0 g& J3 E+ V4 h3 A* ]5 }
  2386.     @width = width1 V3 ]  \: a' W, l
  2387.     @height = height# z% z$ A2 _  h& {$ _
  2388.     @switch_id = switch_id! m" b. @7 z4 _$ _
  2389.   end
    , q# g* L4 J; N- h) R) H
  2390. end& a2 z& ~& b# @% L! ]" v1 i  x

  2391. . u+ r/ q' K5 S
  2392. $area_responses = []
    * U% Y% p. C! O: N& {

  2393. 1 B5 A2 b5 s- {2 C8 S# |
  2394. class Scene_Map
      |! p7 r' d* m" c2 L$ d! d
  2395.   alias update_mouse_2013421 update_mouse_action
    " M! I& u* U* k/ `& @/ Q$ ~
  2396.   def update_mouse_action+ Z% z& Y8 ~0 q% d
  2397.     update_area_response, ~2 i0 Q% H( h
  2398.     update_mouse_2013421
    ; ?4 Q2 F. ~% l) L0 j  y* z( F( t: P
  2399.   end
    - d/ q2 c1 d2 `1 D
  2400.   def update_area_response9 y! C, p$ z* ~. q* w7 c' }- y
  2401.     responses = $area_responses
    8 y5 ^6 L$ B+ w2 H( |, Z
  2402.     responses.each {response- f4 k7 q: _- J  s
  2403.       ox = response.ox
    6 z+ R9 a; _2 P/ X5 d
  2404.       oy = response.oy: r- S8 @* @0 B
  2405.       width = response.width: e" y. q$ Y( B; W6 q
  2406.       height = response.height
    1 A4 C1 }5 _0 C( o
  2407.       switch_id = response.switch_id
    # r9 r, I. s; W3 M' b2 w+ {
  2408.       case response.type- S4 U" l8 v) @: F, S2 R3 {6 w
  2409.       when 0
    ( x1 j) x3 O  _8 n( B" {
  2410.         if mouse_in_area(ox, oy, width, height)
    . Z; E$ {% T( X8 v0 c
  2411.           $game_switches[switch_id] = true
    0 W, h  N% j& g
  2412.           $area_responses.delete(response)1 A  c+ E1 a  b9 q/ `3 J6 x
  2413.         end8 |! X: c  j, K- t, B
  2414.       when 1
    ! X3 T, R& e8 t7 a
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)/ O" o; ]1 \  ~0 Y) b9 f; U; j
  2416.           $game_switches[switch_id] = true1 X2 N+ g2 P. D- b
  2417.           $area_responses.delete(response)
    , G' v: V$ U/ F8 i# E
  2418.         end
    * I6 b' m1 F$ f, a
  2419.       when 2
    0 L  \& w1 N% a0 \
  2420.         if mouse_in_area(ox, oy, width, height)
    * n* g' {1 ~- Z
  2421.           $game_switches[switch_id] = true
    ) n4 _7 e( U0 J: a6 @9 M* `
  2422.         else- L1 a, m  ?* R3 C3 D- Q5 _5 q
  2423.           $game_switches[switch_id] = false
    8 [3 [) X2 M6 h0 W; N% |
  2424.         end* U. G0 \2 Q0 f
  2425.       when 3
    * c+ \2 o& X; c( e6 |1 \0 J- ], A
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    " W5 Z% S% z" n
  2427.             (oy - $game_map.display_y)  32, width, height)
    0 {8 p' E5 M3 e' n
  2428.           $game_map.events_xy(ox, oy).each {event7 Y5 U* D5 U; w4 Z/ z
  2429.           event.start; H  m/ u2 a- y3 p
  2430.           $area_responses.delete(response)
    $ U9 e, H5 t& |$ n# ^
  2431.           return
    6 W. o; {5 ^& h
  2432.           } 1 x8 z, c1 {4 a0 n' F& D
  2433.         end) X( o8 u. F, D. v4 V
  2434.       when 4" ]  L' [8 N( |6 d7 D$ g
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,& K2 a; d5 T2 }! r+ v
  2436.             (oy - $game_map.display_y)  32, width, height)
    ! S9 E% S! r& K! R' }2 x
  2437.           $game_map.events_xy(ox, oy).each {event
    , V8 _* k: [5 i, [% G2 t8 K% k
  2438.             event.start. f3 P2 m) C2 G0 l
  2439.             return& F! }8 r4 p* w" n, K" M# X6 x  v
  2440.           } # h3 V* e3 \- B6 i
  2441.         end% p& ?2 Q5 Z8 m8 Q
  2442.       end$ `* `+ s# K" c
  2443.     }
    * b* [) A1 L' V; g# A3 ?! Z
  2444.   end
    ; V$ ^* L4 t) C7 c
  2445.   def mouse_in_area(ox, oy, width, height)
    & q- `1 a5 v3 e6 F6 j" Y' e
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&& {- [8 h: ~2 E( c
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height
    % |4 V& h. j' l* |! `. P* t$ I/ _
  2448.   end
    ( z) d0 P0 l# C" C
  2449. end
    & d, U! k. f* I2 Q, u* J, k1 A
  2450. class Game_Interpreter
    & B5 ?; r- i0 }7 S) i
  2451.   def area_response(arg). m4 `: r2 k$ P  [. ^
  2452.     $area_responses.push(Area_Response.new(arg))% F# O* ~: G  @% y* E
  2453.   end. L  F* r" w) p
  2454. end' Q# I" b( h/ O$ F
复制代码

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

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

GMT+8, 2025-9-11 08:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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