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

Project1

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

存放腳本

[复制链接]

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

贵宾

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

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

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

x
純屬給LBQ腳本:
  1. =begin #=======================================================================
    ' ]  }: X- f4 _; L& N8 H% q' E
  2. 5 E7 o  z" O8 ~$ n+ N
  3.   Sion Mouse System v1.3e  Z: Q- i5 m; e. ~9 c
  4.   * K& V+ u' X. T# I, D% ^/ ~
  5.   Changlog
    ( e/ w' ~/ m& z  z( s5 B% P% e
  6.   
    - |" O% N+ I; X8 Y1 r- k
  7.   2013.4.21 v1.3f. a9 ?: G1 Y* S' X' K( ~* N
  8.     ' J8 f! B& U1 s. x( R' p6 t6 |1 Q
  9.     1.3f 卷动地图 bug 修正
    / U/ V& q0 ?( b3 W- A$ D, p, F
  10.    
    6 p' L3 ~1 M8 z: I
  11.     1.3e 逻辑优化;提供解除鼠标固定的接口
    ( X, R4 S6 `- d1 A2 O  o$ G& e
  12.              在事件中执行脚本 Mouse.lock_mouse_in_screen 将鼠标锁定在屏幕内
    % M3 y- ]7 K! O, n+ `# a! ~5 ]
  13.                               Mouse.unlock_mouse_in_screen 解除锁定
    6 e6 f: K/ N) t9 o8 \+ w# r( \* e

  14. / b# D5 x2 k1 M/ W2 H0 J
  15.     1.3f bug修正4 |4 }( B8 D7 m3 S# P
  16.   % G$ ]- [5 ]$ n' \( H1 s, k; G
  17.     1.3d 常数设置增加:Menu_Set_Pos,用来设置打开菜单时鼠标是否移动到光标处以及) t- s5 v( l. j2 P7 X; C
  18.           关闭菜单时,鼠标是否移动到原来的位置。, X! E0 M0 f" e7 d- O
  19.   A' @" \, A4 K2 h
  20.     1.3c 打开菜单、光标移动时鼠标会移动到光标位置处5 D; E" }8 i  I8 @2 s
  21. - L, V3 X' Q" m% l3 x9 `. h
  22.     1.3b 修正一些罕见的bug;
    ( a! g7 c2 G* t9 u

  23. 3 \% r) h6 Q3 L
  24.     1.3a 代码小修改;  ~) F) r1 u# j" n
  25.           加入了鼠标点击启动事件的功能,7 U4 `% P( ~( D$ \
  26.           在事件中加入“注释”: 鼠标启动  ,/ \; u% U5 j4 {; W% p, v$ l
  27.           该事件将无法用其它方式启动,只能用鼠标左键点击启动。4 s$ V. R) D, R/ i( F  j( z  E
  28.   
    2 ~$ b  v. Z( G$ W
  29.   2013.2.12 v1.2( S& _! y/ Z/ U( c6 \% y% s0 ?
  30. 9 a- ^. I$ |& }4 @/ p: T7 u
  31.     寻路逻辑优化;
    8 Q; ^; I4 `8 B( V
  32.     优化了事件判断,现在点击事件附近的格子,移动到指定点后不会触发该事件了;) o3 _; y+ D0 M" O: H- T  P
  33.     现在支持用鼠标来操作载具了。
    4 T* j( l0 b$ D& K; t- w
  34. 5 e( B3 ~) {, A( e2 K0 n
  35.   2013.2.8 v1.1
    0 k4 R6 j: ?. Y8 s8 m& ?1 m
  36. + s. p2 ?( \) g6 U. r$ M
  37.     优化了事件判断,现在可以方便地启动柜台后面的事件;
    # k% ~+ B7 W+ t0 o) c/ [, {/ x9 W: i
  38.     修复了某些菜单(例如更换装备的菜单)掉帧的问题;, g7 l- n9 u3 r
  39.     移动时,路径指示点的绘制更加稳定;
    , l* f& U( @' w  o4 C9 V2 y
  40.     现在支持默认存档画面的鼠标操作了。
    2 F/ l% ]+ U+ C6 ]7 ?

  41. ) T7 W5 Y& k" \2 v2 j, H

  42. * h0 C: u1 N. _( y
  43.   OrigenVersion9 s4 g. w* u* w# a
  44.   
    ( s: e+ q2 v2 _
  45.     2013.2.7 v1.0
    " ]) |$ o+ y  n: l/ v
  46. ( _" L$ D( q' u2 x' \/ G7 v
  47.   主要功能
    % N& C7 z4 S9 [5 ~
  48. . t! X8 X4 E. c* r6 A! U4 |6 K
  49.       使用鼠标进行各种操作...( F! ^* s5 Q' I; |7 o' i
  50.       将鼠标锁定在游戏窗口内
    ) p+ b# a9 B6 ~1 H& @7 f
  51.       自动寻路,按住 D 键可以扩大寻路的范围
    : ~5 i) L! p0 y4 Q6 _. Q/ n& i
  52.       双击鼠标进行冲刺
    ) e1 J* z. I0 ?+ g& R0 @; b& z
  53.       更改地图卷动方式以适应鼠标移动
    2 Z. p7 F, e. a4 p8 T8 L& N& ?
  54.       变量输入框改良# R+ d& Y- k9 v$ L

  55. 3 Z% G# P) i/ ~; ^2 f" Z
  56.   ★ 鼠标指针图片 Cursor.png 放入 GraphicsSystem 文件夹
    ! m2 [% v6 Z/ z

  57. 2 L  G) [- I1 y6 _2 @/ n& ^
  58.   ★ 路径点指示图片 $Arrow.png 放入 GraphicsCharacters 文件夹
    5 S- ~; r+ @( L
  59. " a. R& ^" x! z# Y7 r
  60.   ★ 如果未放入会弹出提示,并使用RM自带图片代替缺失文件;该提示可以在下面关闭- s% _9 d5 z. n/ H

  61. % |- G2 N% x" C  R* |0 b

  62. " M$ U) K6 }! `9 B, `
  63. =end #★★★★★★★★ 可能需要设置的参数都在下面用“★”标出了 ★★★★★★★★★★* }/ c: e( j! s' b8 `& O
  64. 7 r5 F& B" P5 s: b; r# }" I
  65.   H1 W% e5 C: Y% b- X' D/ A
  66. $no_arrowpic_warn = true   # ★ 设置为false不弹出图片缺失提示
      v$ F. X2 D! ?7 H

  67. + Y3 d# I- q' l, W* }. }, j# i" U
  68. #==============================================================================" Z% Q+ y  ~7 @9 C4 x
  69. # ■ 常数设置 1 L2 j& f4 Q) M3 b& ?  s! A
  70. #==============================================================================
    & W/ u$ P# Y6 C4 @- v
  71. module KsOfSion
    & R; X0 e* P) `3 e/ y; P5 g1 ?
  72.   Clip_Cursor    = false    # ★ 鼠标锁定在游戏窗口内,需要关闭设置为false/ j5 ^0 D0 l/ L, z
  73.   Dbclick_Frame  = 20      # ★ 双击的最大间隔帧数。在地图画面双击进行奔跑9 i7 u' E* k7 K$ d( y5 m
  74.   New_Scroll     = false    # ★ 更改地图卷动方式,需要关闭设置为false
    : Q5 N8 d+ o8 I7 r6 x$ @; z
  75.   Map_Scroll_Spd = 1.0     # ★ 更改地图卷动速率,请确保此值为大于0的float变量3 ^: c, e# s4 I: j: ~
  76.   Menu_Set_Pos   = true    # ★ 打开菜单时将鼠标移动到光标处, j: N6 o) G+ j0 u; m
  77.   Break_Steps    = 30      # ★ 鼠标寻路最大步数,防止路径太长导致卡帧) _, C' h; w, n3 H1 m; g; C  Y
  78. #                             “30” 是默认显示格子数 长(17) + 宽(13)! `3 @% U: G' }! x
  79.   Find_Path_Key  = Z      # ★ 扩大寻路范围至全地图按键 Z 对应 D键
    % w/ D( K6 Z. {( m% C
  80. #                               RM几个内置的空键位 (X = A)(Y = S)(Z = D)
    ; D* ]4 w& W) w& s
  81. end
    " E, m, n& I# [$ }6 Y; k

  82. 0 ?# B2 n5 _2 ~* ?' S; r" `7 X
  83. #==============================================================================6 K! Y* `* ]3 ?: u$ u: |7 l
  84. # ■ 用来显示路径点的类
    7 l# O8 G' v0 W9 D
  85. #==============================================================================* P9 i2 f0 ]! S0 n' p( O" @
  86. class Move_Sign  Game_Character& L1 I2 y6 v& l  o. g' j
  87.   #--------------------------------------------------------------------------! J1 V  \+ \& p. f" Q
  88.   # ● 设置目标点指示图的各种参数,请注意要使用的图片是行走图$ O; G( v! r* x/ U+ |4 P( }( t
  89.   #--------------------------------------------------------------------------
    & J9 N) z+ F! [0 w" ~( v
  90.   def init_public_members
    . |( ?) w5 a* F) {
  91.     @character_name  = '!$Arrow'# ★ 路径点箭头,置于.GraphicsCharacters文件夹5 \/ Q2 `# ~3 y; G
  92.     @character_index = 0        # ★ 图片索引。$开头的行走图设为0* O& E3 a' U: O# @0 d
  93.     @move_speed      = 5        # ★ 踏步速度7 @3 Q% b) ?5 h  Q- O3 D
  94.     @step_anime      = true     # ★ 踏步动画(如果想使用静态图标就关闭这个)
    0 g3 Q; u* ^1 i# v9 O4 ~
  95.     [url=home.php?mod=space&uid=316553]@opacity[/url]         = 255      # ★ 不透明度. I0 p7 C' v9 Z" X6 w# c
  96.     @blend_type      = 0        # ★ 图片合成方式,默认为0(正常)
    2 g1 ~9 e5 L, y! S  Z% z
  97.     @direction       = 2        # ★ 朝向,2 4 6 8 分别对应行走图第1 2 3 4 列
    - S7 w% ~! S6 e0 f( t4 d9 X
  98.     @priority_type   = 1        # ★ 优先级(默认与人物同级:1)
    : |0 q( U# r3 Y

  99. 4 \% Q0 A. j+ r* v; R
  100. # E! x9 {: G+ K1 g
  101. # ★★★★★★★★★★★★★★★ 参数设置完毕 ★★★★★★★★★★★★★★★★★★★
    0 [+ @7 O' E4 ~  Z* @
  102. ( c9 Z+ N+ ]8 j- z& T/ _2 Y

  103. . }& {3 B. Y& q: H
  104.     # 如果 $Arrow.png 不在对应的文件夹内,弹出提示,并使用游戏一张内置的行走图6 Z/ e6 \, S2 h; V1 u; Y
  105.     unless File.exist('GraphicsCharacters' + @character_name + '.png')
    $ k" S' D& o/ P# E- X0 {& F
  106. " C1 X2 V+ P  z% [
  107.       if $no_arrowpic_warn  a# P" f+ N. X, F& u
  108.         MouseShow_Cursor.call(1)) ~6 |: }$ k' \: i$ O
  109.         msgbox('未找到文件:GraphicsCharacters' + @character_name + '.png
    * X: N1 Z* E3 Y, b5 H# E/ I% S
  110. . w" h  i5 K* ], j9 K
  111. “路径指示点”将使用游戏自带图片5 L" J- f0 d+ s" H: O4 I6 A

  112. 0 t# |6 m7 G  e. u8 G  P
  113. 该提示可以在脚本内关闭')
    3 R6 @, G/ h" I* q: B$ z
  114.         MouseShow_Cursor.call(0)* ]; [" ~6 Y9 I3 \
  115.         $no_arrowpic_warn = false( y0 B, w. r4 j3 p$ p8 W# Z
  116.       end
    9 H2 {: E0 @6 \. r- Y4 |
  117.       @character_name  = '!Flame'
    ! y; L+ a. C8 R7 E! ]
  118.       @character_index = 63 X; W+ o' H) f

  119. $ x+ F" p4 G% T4 i# B7 h& A$ x" v
  120.     end
    4 A! r/ \$ h. T( s$ D
  121.     @direction_fix = false  # 固定朝向8 V$ @6 U2 i* {2 m
  122.     @move_frequency = 6     # 移动频率
    / I3 X+ M+ l' k' O5 |. n- a# L  K
  123.     @walk_anime = true      # 步行动画# z) s" a/ o# R% M* F  c% X  h+ _
  124.     @pattern = 1            # 图案
    - \+ d3 N! W0 y  i( b
  125.     @through = true         # 穿透/ I' R! O1 r0 W
  126.     @bush_depth = 0         # 草木深度/ W) e" p2 C# N- v* e+ u/ Q
  127.     @animation_id = 0       # 动画 ID2 f* d( e, T7 B& a) A% h. l
  128.     @balloon_id = 0         # 心情 ID7 F& i; g6 J) @  B; v9 Y7 e
  129.     @transparent = true     # 透明
    6 ^. m7 M6 d8 t! x  z7 i8 {& U3 p
  130.     @id = 0
    5 J& i9 j( E1 r; T- l: F% k
  131.     @x = 0; V2 c8 Q, q6 O2 o
  132.     @y = 0
    3 O3 E2 z  w& G, m
  133.     @real_x = 0
    3 f& s" ?" U; n/ l
  134.     @real_y = 0, V5 O' m: B( ~* F% P1 D
  135.     @tile_id = 0" r( O9 J8 }, i7 X5 n" Z
  136.   end
    ) O  l5 D1 b) s
  137.   #--------------------------------------------------------------------------8 q& B3 ?" r( O# s: U2 x
  138.   # ● 定义实例变量
    0 C+ x3 W; W* ^% t( k
  139.   #--------------------------------------------------------------------------
    ( H; p; o+ _" ]9 H# s1 C  I/ i0 w/ l
  140.   attr_accessor direction
      K9 r2 F% G3 \* v3 O; _
  141. end
    : ^5 d+ i: G5 |; ]: {8 N
  142. - H" V* e7 }) @0 [
  143. #==============================================================================# {+ [) A- q  w- w/ e# ~5 T" I
  144. # ■ Module Mouse+ ?1 M9 I/ Y8 \
  145. #==============================================================================
    ( E5 N+ ]9 p, A: E/ W
  146. module Mouse) b4 n6 @5 p) z! N' {! `" s& E
  147.   #--------------------------------------------------------------------------
    ' ?6 i) p+ P# Y2 W7 `) ], |3 d
  148.   # ● API2 G& f& q+ m6 G1 l% ?2 ]
  149.   #--------------------------------------------------------------------------
    ' L: Y: f' ?! [
  150.   Show_Cursor       = Win32API.new('user32', 'ShowCursor', 'i', 'l')
    1 u1 g4 M" {2 q! g) l
  151.   Get_Cursor_Pos    = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
    ! n1 A  D8 d6 D  \" x) G
  152.   Set_Cursor_Pos    = Win32API.new('user32', 'SetCursorPos', 'ii', 'l'); W+ @3 M* o0 J& x( L, q
  153.   Screen_To_Client  = Win32API.new('user32', 'ScreenToClient', 'ip', 'i')
    5 U6 L' t/ f0 O5 w0 _
  154.   Get_Active_Window = Win32API.new('user32', 'GetActiveWindow', nil, 'l')
    3 k8 c: n* ~# u4 u: T7 @3 `
  155.   Clip_Cursor       = Win32API.new('user32', 'ClipCursor', 'p', 'l')0 z2 h* z) a/ |* s/ O' A& E
  156.   Get_Key_State     = Win32API.new('user32', 'GetKeyState', 'i', 'i')" I- w! C0 s3 s3 [3 Z
  157.   Window_Hwnd       = Get_Active_Window.call; ^0 I$ G/ i) h) X
  158. : h6 q$ c- ?3 Z4 @- d
  159. class  self
    * G/ Y9 c$ ]2 _( m  W& }5 t
  160.   #--------------------------------------------------------------------------6 n- M0 U* T& u- `
  161.   # ● 初始化( _; L" s  i0 E8 ~
  162.   #--------------------------------------------------------------------------2 q/ M9 y. d. _
  163.   def init
    . z! r: ?+ o, y6 v3 b/ P
  164.     lock_mouse_in_screen if KsOfSionClip_Cursor
    " I* y- x- U9 E. e/ T' [
  165.     @left_state = 0
    6 i& W  i/ z* E% M7 ?; S7 N1 d; k
  166.     @right_state = 0
      v1 A, S$ ]7 J$ `
  167.     @ck_count = 0 # 帧数计,单击以后从0开始
    * I$ D6 ^: J2 Q" ^$ f8 Q& D4 R
  168.     @dk_count = 0 # 用于双击的判定
    : k; `  T7 i9 s; e
  169.     @clicked = false: A) f5 D# [& R7 Q
  170.     creat_mouse_sprite( T, t+ N/ g8 j+ t% ]/ k
  171.     update  f) T3 r) R2 k) l1 i. }
  172.   end
    7 ?% C9 P$ h2 ^7 O: M& T
  173.   #--------------------------------------------------------------------------
    6 g  i3 D+ s! _" K2 G9 m
  174.   # ● 鼠标指针精灵
    8 @$ V* S7 b6 W' a3 x$ T, _
  175.   #--------------------------------------------------------------------------
    5 D. a7 n% Y# r, @3 C
  176. #~   def creat_mouse_sprite
    9 q* D' E4 k3 e; f+ N8 n
  177. #~     
    ' c- t7 P8 V0 w. l' E0 a7 D
  178. #~       @mouse_sprite = Sprite.new
    $ [" f. s! y, e1 O* D3 j2 _  I$ Q
  179. #~       panda = 2#rand(2)+1: D8 C5 C3 M  X, k( D
  180. 7 i8 N# W% h4 D$ h" `
  181. #~      if panda = 1! G2 `( T! U; H! z& D) u9 P
  182. #~        if File.exist('GraphicsSystemCursor2.png'): I$ Y2 U9 |- l& |1 ?; w& C- A5 R# k
  183. #~         @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')( a6 R; h" Q3 U) J" w, H2 x
  184. #~        end#with if File.exist
    ! z5 R; Q$ v! N- d+ j2 j+ q/ D
  185. #~   
    & i# O' u1 {2 C2 C3 d
  186. #~     else if panda = 2 #with if panda=1
    & [: \" Y3 F% K- P' u' k4 ]
  187. #~      # H" k/ j+ f, K2 I$ X1 f9 s
  188. #~      if File.exist('GraphicsSystemCursor2.png')
    7 _. m- `: [3 i. {
  189. #~       @mouse_sprite.bitmap = Bitmap.new('GraphicsSystemCursor2')* M4 `7 z2 q  q" P5 {5 Q9 }! S: H
  190. #~      end#with if File.exist+ ~  V, [9 o" f& O* i
  191. #~      
    6 B1 k/ b$ U- y0 ]3 j) n
  192. #~     else #with if panda=15 |0 P# l" I+ Y3 V% b
  193. #~       @mouse_sprite.bitmap = Bitmap.new(24, 24)
    7 s, J; }. p* l  F
  194. #~       @mouse_sprite.bitmap.blt(0, 0, Cache.system('Iconset'),! k9 W& _. ^, ~  F9 d7 l
  195. #~       Rect.new(5  24, 24  24, 24, 24))0 L8 L3 O8 h* K) C" I/ e, g/ G4 N: X
  196. #~     end#with if panda=1- C3 g. q3 z+ D6 B! L
  197. #~     $ X+ O% f3 M7 E# p4 L) F
  198. #~     #with def
    . s9 Y( G9 j% i/ C* i* F7 ~
  199. #~   end
    0 o+ R& k$ K; O4 J+ `! g' C
  200. def creat_mouse_sprite$ P; j) R* X5 b
  201.     @mouse_sprite = Sprite.new
    6 c7 Y( U& H3 f
  202.     @mouse_sprite.bitmap = Bitmap.new(GraphicsSystemCursor#{rand(2)+1})
    ! V- {7 J3 J0 ?% ~, D7 N( o
  203.     @mouse_sprite.z = 9999
    ! X& b/ E7 J$ d& N6 O+ h( q" G
  204.     Show_Cursor.call(0)$ A! Q% H" e' F: G+ z& g% C* p) J' t
  205. end
    6 q! m( O$ ?; h
  206. 6 [+ j9 @7 h$ k" M  T
  207.   #--------------------------------------------------------------------------7 `0 P/ I; a* |
  208.   # ● 更新. a- l0 R, h; S+ S, K
  209.   #--------------------------------------------------------------------------
      I$ A' r- y1 V/ R, C3 n$ F0 o
  210.   def update
    8 p( f' @: }2 o4 L6 d( ~
  211.     @mouse_sprite.x, @mouse_sprite.y = get_mouse_pos8 v- O! I7 C/ h4 U
  212.     left_state  = Get_Key_State.call(0x01)
    % Q9 O" T/ P6 F0 x4 z  e3 I
  213.     left_state[7] == 1  @left_state +=1  @left_state = 0
    ! ~8 }  ]; g) o  a* s
  214.     right_state = Get_Key_State.call(0x02)
    / R) y- i3 X% P' K5 a2 o8 y+ C/ q
  215.     right_state[7] == 1  @right_state +=1  @right_state = 0/ h) x, h" j9 q
  216.     update_double_click
    ' W2 F& N0 Z& [1 |2 W0 X
  217.     @left_state == 1  @ck_count = 0  @ck_count += 1
    : B+ t  G+ @( ~0 V3 U& M2 w4 O: Q
  218.   end
    4 m! s. R5 S' B) t% W! z/ U7 T& E
  219.   #--------------------------------------------------------------------------
    ) u& [" L  q) T, y
  220.   # ● 获取鼠标坐标' S) i( B" P# V5 {9 @- U
  221.   #--------------------------------------------------------------------------5 c# ^- d- m, @2 Z) g3 O; p
  222.   def get_mouse_pos. b- H- n7 _% _9 S; v( O( ]' F
  223.     arg = [0, 0].pack('ll')
    7 e9 ^( P, ]: Q/ {# U
  224.     Get_Cursor_Pos.call(arg)2 v& m! U& M: W# ^0 T, k, W. D2 \
  225.     Screen_To_Client.call(Window_Hwnd, arg)) g6 E& r/ u+ j9 k" c
  226.     x, y = arg.unpack('ll')" L' P# r- ~: J3 |  G. [+ a
  227.     return x, y5 c) Q% L+ N+ {& H3 W
  228.   end! n! X' n* N2 e' G5 k) {" ^% v7 @
  229.   #--------------------------------------------------------------------------
    6 N! c' o9 X( M# W
  230.   # ● 将鼠标固定在屏幕内! Y4 L2 B6 E$ S' @6 Q
  231.   #--------------------------------------------------------------------------
    3 c, I+ \/ N1 X' M) s
  232.   def lock_mouse_in_screen% M2 l0 U1 i4 y  ~4 Q# H& I. J
  233.     arg = [0, 0].pack('ll')
    7 e: a1 N9 l: u0 C/ L2 Q
  234.     Screen_To_Client.call(Window_Hwnd, arg): t: O% {" s% v9 E; @2 l
  235.     x, y  = arg.unpack('ll')
    # Z$ h2 b. T$ Y  X- f
  236.     Clip_Cursor.call([-x, -y, Graphics.width-x, Graphics.height-y].pack('llll'))
    3 k5 g! I6 o& l0 G3 m, {
  237.   end
    4 T, B, p) _) I/ q
  238.   #--------------------------------------------------------------------------
    ! @! }( h3 p) X/ P8 I, s. i
  239.   # ● 解除鼠标固定! |# u! e- a: ^% ]0 e1 J+ F7 g
  240.   #--------------------------------------------------------------------------
    ' d  Y4 P$ T$ H; G
  241.   def unlock_mouse_in_screen
    3 q, x, @5 \/ g; Z; Y$ p6 \
  242.     Clip_Cursor.call(0)
    ! g7 N" i  ~) a  ?7 U
  243.   end
    0 r7 p4 S# E8 {2 U# ?. |
  244.   #--------------------------------------------------------------------------$ r# S9 n4 M/ r7 T; ]; [. |; h
  245.   # ● 鼠标双击判定
    & p; I; R, P0 g$ }5 F; H( \0 y
  246.   #--------------------------------------------------------------------------- u, q2 N; Q0 C
  247.   def update_double_click4 V, O% O# S0 L1 ~* A- F. A! ~4 \
  248.     @clicked = true if @left_state == 1
    4 E. o' q5 P0 S! g" L
  249.     if @dk_count  0 && @left_state == 1+ `5 Y( H7 S  t; ^  x( r' K
  250.       @dk_count = 0; @clicked = false, H8 ~- {6 ]7 Z! g8 |2 \: q8 \/ z
  251.       return @double_click = true3 Q0 L7 v. \$ k/ v, a! f3 N, K
  252.     elsif @clicked
      X3 ^0 D! H" z0 P
  253.       if @dk_count  KsOfSionDbclick_Frame- N) M' J) f% [: I4 c
  254.         @dk_count += 1
    + p( C8 X7 K& l6 b
  255.       else0 @+ F5 \. V  _3 ^
  256.         @dk_count = 0; @clicked = false! Y( q- t# n- E0 {$ g
  257.       end5 M1 ~1 [8 ^# @9 p* b+ E1 m
  258.     end
    ( V) E: R; l  j  V; \) l7 |# _  ?5 ~
  259.     @double_click = false
    4 ?8 L6 ]2 t, b& V
  260.   end% U. [. ~5 ]8 z' L- n7 E' }
  261.   #--------------------------------------------------------------------------
    * t# n' h3 |8 H; Q
  262.   # ● 按键被按下就返回true  n5 ~9 b* A2 o! d/ ?+ W7 Z
  263.   #--------------------------------------------------------------------------3 b: r5 z: x' R; v; b9 e: I
  264.   def press(button)* c6 d/ K0 F1 P  v
  265.     case button
    1 k+ D# V4 f1 ~
  266.       when 0x01; return !@left_state.zero
    * R1 F* Y+ |1 Q1 U2 d* W/ B
  267.       when 0x02; return !@right_state.zero
    * L/ t. N9 Z, Q$ j( O3 H; W# ~' }- J
  268.     end
    3 [$ L. _/ w* ~; v5 b
  269.     return false
    0 W; N+ S7 i; X# }9 C' Z' Y/ Z
  270.   end
    * c7 S2 V2 N7 v: v! D8 i! N9 H( N
  271.   #--------------------------------------------------------------------------
    7 @5 X6 x( F5 I
  272.   # ● 按键刚被按下则返回true
    ' [0 u" H- B1 s+ E; A8 }( B* G( Y& ~
  273.   #--------------------------------------------------------------------------
    9 q$ d7 h0 m2 P; K5 v
  274.   def trigger(button)
    . j: A' G% K( v% [
  275.     case button2 w$ q9 |7 N9 q
  276.       when 0x01; return @left_state == 1
    6 F  }; U: S. q. V% U
  277.       when 0x02; return @right_state == 15 f' F; @) }" o9 M3 ]
  278.     end
    7 W7 [4 x+ E& s' M) ~
  279.     return false' h' K3 H2 [* z$ D7 `- M
  280.   end; C/ _$ |$ e2 m7 I+ g
  281.   #--------------------------------------------------------------------------
    9 W( |/ [6 e- p4 G! n; `
  282.   # ● 持续按住键一段时间的话,每隔5帧返回一次true% Q* Q. ?' [6 D* [8 |
  283.   #--------------------------------------------------------------------------( k$ _0 C: v/ }# {! W' J; b7 f
  284.   def repeat(button)& Q4 W" P; p, B( V# T% w( q; ^+ |
  285.     case button# d/ o% ]) b- t7 H6 ~' F+ E
  286.       when 0x01; return @left_state == 1
    2 {5 ?8 w6 n9 g  l6 Z. d6 n
  287.         (@left_state  22 && (@left_state % 6).zero)( f' y" w4 t0 k
  288.       when 0x02; return @right_state == 1
    # S$ ~8 Z% f) l+ B
  289.         (@right_state  22 && (@right_state % 6).zero)
    # z+ o+ z8 l# L( H* t! {( B& X
  290.     end
    8 x# @4 y5 B5 `0 R3 [5 N1 @7 I
  291.     return false: d) _9 m# z: [4 x
  292.   end
    9 G$ x: u" M* X% A- N
  293.   #--------------------------------------------------------------------------
    / j2 V! s/ ~# \
  294.   # ● 判断是否双击鼠标8 f  M: Z4 \# u' g( `) U
  295.   #--------------------------------------------------------------------------! r4 k8 u5 ~0 ?" X
  296.   def double_click' w3 s$ U; ]" r' a9 w6 F
  297.     @double_click6 D# i) X" {4 Q! r6 s. M
  298.   end
    $ c9 Z0 T) y/ \' I( y
  299.   #--------------------------------------------------------------------------7 p1 }% [% V* F6 E3 c$ Q! r
  300.   # ● 获取@ck_count(每一帧+=1,单击后重置为0)
    * I3 {. T. j6 J
  301.   #--------------------------------------------------------------------------
    5 _! v- e5 x% H
  302.   def click_count5 ], ~& ^) l3 o9 N7 @& ]
  303.     @ck_count9 Z0 [8 Q: I- T, ^) z% s
  304.   end
    9 d# c' z, K9 z8 P' r' D
  305.   #--------------------------------------------------------------------------1 c* K4 a9 p! k# ]0 r- X% N8 P
  306.   # ● 获取@left_state(按住左键每一帧+=1)7 `+ d' d4 l! x" s) Q3 a
  307.   #--------------------------------------------------------------------------
    " Q2 d! ]4 O# H( P, J% \% m
  308.   def left_state
    5 d' Y+ {( |4 q1 y0 c+ }. h2 o
  309.     @left_state) `0 W2 c2 [6 D/ v
  310.   end
    3 `8 D: m& q0 L8 Y
  311.   #--------------------------------------------------------------------------
    / Q& Z* ]4 e8 j' N. d1 E. y
  312.   # ● 获取鼠标的x坐标0 B. ~+ t0 H# O( `
  313.   #--------------------------------------------------------------------------8 m7 ]8 k+ ?3 @2 b) d: D4 x! J( |7 E- B
  314.   def mouse_x
    & h; C2 \7 t6 j5 r* f' x$ |0 t0 F+ H
  315.     @mouse_sprite.x5 D  v- k" c5 M7 |2 B2 Z( r9 \
  316.   end1 L0 d' L4 P7 L, B. P
  317.   #--------------------------------------------------------------------------
    ' W& T' Y6 r8 q$ P' A
  318.   # ● 获取鼠标的y坐标
    ( C1 Y! E7 |. K1 {9 T
  319.   #--------------------------------------------------------------------------, b& [& D3 v: Z
  320.   def mouse_y8 a3 P2 X1 W! o* O( k* V! N4 s2 S
  321.     @mouse_sprite.y* f/ _5 G+ `% l7 M) H' t, h
  322.   end. |0 j; j3 l- O4 r1 p! ~8 g# A4 O
  323.   #--------------------------------------------------------------------------# L- k9 P5 g: _# y! D7 A' @( M- M
  324.   # ● 设置鼠标坐标
    * E" {% M0 a* t) ]6 @) B* M. r1 M1 ~+ e
  325.   #--------------------------------------------------------------------------
    + Z7 ?- r- C+ d3 T
  326.   def set_mouse_pos(new_x, new_y)9 }; y6 m: L8 j7 `8 l3 A
  327.     arg = [0, 0].pack('ll'): j, t- K, X5 q+ j1 T# e
  328.     Screen_To_Client.call(Window_Hwnd, arg)& p' ]8 `3 u$ b' M, p0 E
  329.     x, y  = arg.unpack('ll')
    8 g/ W  K3 Q1 h( \+ B
  330.     Set_Cursor_Pos.call(new_x - x, new_y - y)* U( Y% a, l3 O! i& {
  331.   end
    9 @5 a3 o1 }. K* N' u
  332. end #end of class  self
    4 ^# N6 C/ r! g, D- H

  333. ! q% L2 _: k4 N( H6 Z% Y3 Y
  334. end5 n. D% x7 T# Q

  335. / y6 J7 k( J* Y: p: i8 d
  336. #==============================================================================( Q  H2 y. E' B9 }& z
  337. # ■ SceneManager
    1 v2 L8 q4 n9 @  V
  338. #==============================================================================, p$ J8 W3 i! n
  339. class  SceneManager% n+ ~5 B0 y; J: z! F7 T: ^
  340.   #--------------------------------------------------------------------------& D' K6 w# H) q) [! N
  341.   # ● alias6 b$ o$ w* p9 M* E9 j2 I
  342.   #--------------------------------------------------------------------------. c$ a; H" F. [% \" v- y6 M
  343.   unless self.method_defined(sion_mouse_run)8 {6 T+ c. Y9 T4 l
  344.     alias_method sion_mouse_run, run
    6 {& K! ^& L3 A2 H2 I  u  t1 |
  345.     alias_method sion_mouse_call, call* U4 C7 L& r7 Y; V$ Z+ M4 _
  346.     alias_method sion_mouse_return, return
    9 Y8 E" ?" o1 u! R) ~
  347.   end
    2 `4 ^% `' X2 s
  348.   #--------------------------------------------------------------------------" ~/ T# L( D. }. t4 L
  349.   # ● 运行! I( A+ _+ w5 L
  350.   #--------------------------------------------------------------------------$ ~/ w& G9 {9 r
  351.   def run5 D& p2 m( x* v- k
  352.     Mouse.init' r9 k( R2 J; f  J
  353.     sion_mouse_run
    & i5 x  \. k! m. J  ]
  354.   end
    2 i4 o) w+ i$ D
  355.   #--------------------------------------------------------------------------
    6 R" q3 N, b2 v7 v
  356.   # ● 切换
    9 O0 E1 B. X6 e" H; |* N
  357.   #--------------------------------------------------------------------------
    " Y- K+ W) K+ Y
  358.   def call(scene_class)& e4 f3 ^$ s! |% ^
  359.     $game_map.prepare_reset_mouse_pos if @scene.instance_of(Scene_Map)
    9 r2 S1 F  `+ h0 E: @. ]2 [6 H8 N
  360.     sion_mouse_call(scene_class)
    / M( q; l' x. S3 @9 s# P+ d
  361.   end
    ' ]! o5 j3 N7 G+ c
  362.   #--------------------------------------------------------------------------
    . l2 d$ o  m; t" `
  363.   # ● 返回到上一个场景
      D9 u4 E- L& k: z8 f) B! [- _2 L
  364.   #--------------------------------------------------------------------------) g# C6 O4 k$ p6 v, h
  365.   def return
    - V9 d! j' O* b7 [, J
  366.     sion_mouse_return
    - q% N- \* H: S- U1 j& q. J
  367.     $game_map.reset_mouse_pos if KsOfSionMenu_Set_Pos &&5 }7 U1 q$ X0 B- S; M: t9 i4 t
  368.       @scene.instance_of(Scene_Map)
    & G3 w$ O1 A6 O5 q& Z, K1 n4 j
  369.   end  \$ D" ~& O: m8 h
  370. end) N5 l  b1 W9 P3 s- Y, c3 i  Q
  371. 4 X: d. ^# g" b5 T1 g9 x; c$ g
  372. #==============================================================================4 c' g  {* b0 _  A# P. V, z
  373. # ■ Module Input, }- }, e( Y2 K% X2 i. a6 b% q
  374. #==============================================================================  g3 L! c+ [+ ^# q5 n  Z# i
  375. class  Input* z) I6 O7 E! Y9 |. m2 K$ x
  376.   #--------------------------------------------------------------------------
    0 e) {. ?* ~) P: x' u& A% x1 ~; R6 J! M
  377.   # ● alias* _- Q6 g' H  M
  378.   #--------------------------------------------------------------------------# K1 s3 Z8 W0 `8 E- D+ [$ s9 B  z3 A
  379.   unless self.method_defined(sion_mouse_update)
    6 q9 I9 p9 O5 `% b3 L$ U
  380.     alias_method sion_mouse_update,   update7 Y5 @+ r: @3 ?3 K+ N! }# Q
  381.     alias_method sion_mouse_press,   press
    5 I; k. ^& a# ^, \
  382.     alias_method sion_mouse_trigger, trigger
    5 B: w( V" Y/ F& R+ G8 \
  383.     alias_method sion_mouse_repeat,  repeat
    6 R+ g5 {. V5 ~5 J# D' V$ h/ y5 D1 p
  384.   end& Q; m  F$ ?- W% C, G7 k& l: Z2 J+ O
  385.   #--------------------------------------------------------------------------
      l5 ^4 M4 @" y- p$ m8 X1 V
  386.   # ● 更新鼠标
    9 }9 W# v/ _, Y# O( o6 b; Q
  387.   #--------------------------------------------------------------------------& m2 M8 |2 o. o0 n" f( G/ W% c: j. r
  388.   def update- p; Q% S6 `; k! |2 @1 Z
  389.     Mouse.update
    % {  c8 l$ l+ f( ^4 ~8 ?
  390.     sion_mouse_update; V5 M5 E4 |/ _$ @
  391.   end
    , z! l6 K/ Q# h; F+ |6 Z
  392.   #--------------------------------------------------------------------------) G+ l9 d% K7 L( H8 X
  393.   # ● 按键被按下就返回true
      r8 j/ Z2 K, u. ~8 k6 `4 q1 d7 D
  394.   #--------------------------------------------------------------------------3 {; l$ [: B- e
  395.   def press(key)
    6 f- R: g/ U; W( L, r, n& _& I
  396.     return true if sion_mouse_press(key)
    & m& `5 g6 H/ q$ B) ?
  397.     return Mouse.press(0x01) if key == C/ m3 |% K" A* V; `8 L& Z2 }
  398.     return Mouse.press(0x02) if key == B1 l! b, _; f- ~9 G2 L0 z: a; |
  399.     return false
    ! X3 [6 z; m( d0 k
  400.   end6 i$ X3 @: O  s1 j6 I( Z
  401.   #--------------------------------------------------------------------------, @  I. v0 @" n/ t+ g1 j* N
  402.   # ● 按键刚被按下则返回true7 E8 K9 D6 Q3 E/ E+ T2 s
  403.   #--------------------------------------------------------------------------7 g1 G" F# y9 K) K- f
  404.   def trigger(key)! M  I9 r# J( l5 |# J# @: a9 [
  405.     return true if sion_mouse_trigger(key)
    , X: ^: [) Z# w( [' L5 ]- @
  406.     return Mouse.trigger(0x01) if key == C
    8 ~% }. r6 |8 _3 ^
  407.     return Mouse.trigger(0x02) if key == B; j5 H  M& W, L/ f, Q( B
  408.     return false& ^+ A2 ]# |3 d" @/ y! P
  409.   end
    . \0 p; R, r' j- m. _
  410.   #--------------------------------------------------------------------------
    $ ]. O; {9 X( n! u3 G* ~  y+ n
  411.   # ● 持续按住键一段时间的话,每隔5帧返回一次true2 p! b% s5 t" B/ S
  412.   #--------------------------------------------------------------------------
    : A$ I# n; C# |0 h+ M  s
  413.   def repeat(key)9 ]5 _" t+ W6 W* p
  414.     return true if sion_mouse_repeat(key)! `, z" _+ e+ l8 L
  415.     return Mouse.repeat(0x01) if key == C
    8 |0 i6 C  R. e8 n+ T9 H: e
  416.     return Mouse.repeat(0x02) if key == B
    ! R0 v! _) K# u0 `- V  O8 z) r
  417.     return false) b! ^; `0 ~- e, j- ]* b+ v
  418.   end
    . ]; }! @0 i$ q) u
  419. end" A- R- M- B% y( x

  420. , d( R8 x$ Z" k0 |3 S
  421. 3 c, `% p" u; v) X, T( `1 P& W
  422. #==============================================================================; r8 j1 b% y9 M; n: t
  423. # ■ Window_Selectable/ R1 Z& K- c" }& `
  424. #------------------------------------------------------------------------------" ^  b  z' v0 Z+ W6 g. }2 I' a. ^
  425. #  拥有光标移动、滚动功能的窗口1 e2 h# M. h2 y2 P# Y/ c7 x4 B
  426. #==============================================================================" V/ M# h0 ~' c# A
  427. class Window_Selectable
    2 L( m; b' {5 v* y+ x
  428.   #--------------------------------------------------------------------------
    7 h5 ~+ k5 s7 d4 |- Y- s
  429.   # ● 初始化2 s( T0 N# x! |% N
  430.   #--------------------------------------------------------------------------9 L1 C/ L" w% D0 S2 J9 U
  431.   alias sion_mouse_initialize initialize: X* h; X4 x: C, N9 V. {, m
  432.   def initialize(x, y, width, height); n% t0 X( y7 j
  433.     sion_mouse_initialize(x, y, width, height)
    / e- }9 Q" O) N) v2 i: J0 r; E6 c
  434.     @move_state = 0
    , ]+ Q6 l# |( T9 \
  435.   end9 V) o) x9 f. E  M* X
  436.   #--------------------------------------------------------------------------4 l0 O' V% J* h) a& K' r4 ^
  437.   # ● 更新  p4 [' O. |9 G) C
  438.   #--------------------------------------------------------------------------3 p# j  i8 v3 f; C
  439.   alias sion_mouse_update update
    ( u5 u8 T2 ]% J7 ~7 I" ^) P0 H! w  I
  440.   def update1 K  G/ o6 t6 s! V
  441.     sion_mouse_update
      Z2 F5 M, j9 _  P% t1 m! d& I( k
  442.     update_mouse_cursor$ P$ L6 g! T! q0 j' G# g& i1 S
  443.   end( C3 v: n' D" X
  444.   #--------------------------------------------------------------------------
    3 F% P- J6 X2 f( ]( R0 C  i, h
  445.   # ● 启动后设置鼠标到index位置: x. h5 v& I- y
  446.   #--------------------------------------------------------------------------) E. H  M: L+ w7 H. s2 h8 j
  447.   def activate1 M$ A. {$ y& c2 x5 B" Z% u
  448.     @need_set_pos = true if KsOfSionMenu_Set_Pos5 q3 j: N' g% S& A
  449.     super# |8 @2 {% u" J1 C1 q: T3 [
  450.   end) K- a) \9 {) v
  451.   #--------------------------------------------------------------------------5 t/ ^0 ?  {' V6 ~7 b7 i* k# N
  452.   # ● 更新鼠标和光标的位置
      U7 Q' h4 u3 b
  453.   #--------------------------------------------------------------------------
    ' K' R! x& D' d! {) p
  454.   def update_mouse_cursor
    0 K( h# E6 ?& {3 K+ D
  455.     if active
    4 s, Z- P4 S  Y2 A) w/ _
  456.       if @need_set_pos& f7 @+ I' h# V! Q
  457.         @need_set_pos = nil
    6 Y1 j0 h8 J( p4 S
  458.         set_mouse_pos: t% z5 Y  B6 {, v
  459.       elsif cursor_movable! n2 O% T0 s6 z3 g; m
  460.         Input.dir4.zero  set_cursor  set_mouse_pos
    % x, X% m  A# X; X
  461.       end2 Y, i% o  i1 p+ ]  Q
  462.     end
    ) ^" R# T3 N0 f. H
  463.   end9 N' |: S1 \  v+ t: O4 l
  464.   #--------------------------------------------------------------------------
    # s+ w! x4 V+ y1 i4 r& N7 D
  465.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
    9 R7 c, p6 {! A4 \4 @9 {
  466.   #--------------------------------------------------------------------------
    6 A0 T0 X- g0 k4 }( }3 a+ S" T+ `
  467.   def set_cursor2 h# Z% {. L# e5 |" O. q" W) j) e
  468.     mouse_row, mouse_col = mouse_window_area
    , M- P6 e7 K( q& P! ]
  469.     if    mouse_row == -1& n1 g% z3 B: K  c, H/ K
  470.       @move_state += 1 if need_scroll
    5 t, E) Y5 @/ |' D$ E2 o
  471.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand
    ) b: O; `5 {5 e; n  Y, @
  472.     elsif mouse_row == -2
    + V' m* i; b; \* ?4 K( L3 Z0 J
  473.       @move_state += 1 if need_scroll
    " W" T4 c% k% y( G; W, S  |
  474.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand
      T4 U7 K! T: u& K2 y" M
  475.     elsif mouse_col == -1
    0 X# p/ @+ I% B' d# k8 x0 b1 s5 y
  476.       @move_state += 1 if need_scroll- b! h! y: r5 m6 P. H
  477.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand
    . M" I" K6 w6 e
  478.     elsif mouse_col == -2
    ; w1 B2 V6 H  h( ^1 u" o
  479.       @move_state += 1 if need_scroll5 I5 f& j1 H" j8 p3 i/ a* Y' d+ F% T
  480.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand! ^$ s: {: r6 m, [
  481.     else
    1 p, H9 t9 L3 x* o" G# j( v9 b+ ^
  482.       @move_state = 0
    0 w9 S; d3 z$ ^3 y
  483.       new_index = (top_row + mouse_row)  col_max + mouse_col
    ' W6 s/ m. M3 U9 _9 `
  484.       select(new_index) if new_index  item_max && new_index != @index" x4 ?* B! ?3 \9 U" X& _
  485.     end
    6 V, G: o; Q( z
  486.   end
    # L* N0 |! T  C+ z+ x
  487.   #--------------------------------------------------------------------------
    0 ^+ q0 k! r- o2 S2 V5 D
  488.   # ● 判断鼠标位于菜单的第几行、第几列
    ' K8 X% L. U7 t: Z
  489.   #--------------------------------------------------------------------------
    . ]$ Q& }* h4 Y& @+ w# W' ~" {
  490.   def mouse_window_area
    ! A4 Z3 M" H; D4 Q- Y, G( ]7 d. }& i) J
  491.     if viewport.nil # necessary!
    % p+ J" X: ^  s/ |) u7 h2 {
  492.       vp_x, vp_y = 0, 0: M' @# _0 R6 w1 `# _+ x
  493.     else( ~4 ~+ e) E4 E6 _( t+ T5 Z1 u
  494.       vp_x = viewport.rect.x - viewport.ox7 a, q" f5 ?5 r
  495.       vp_y = viewport.rect.y - viewport.oy
      g+ S0 B- K5 @! l* n
  496.     end
    % I. ~7 p. i: W' x5 [1 {
  497.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y; `, j1 ?  B) N( H
  498.     item_x1 = vp_x + x + standard_padding / l6 p) H( y9 {( h+ }
  499.     item_y1 = vp_y + y + standard_padding5 m5 A( a* }( Q3 A! p3 H
  500.     item_x2 = vp_x + x - standard_padding + width& o! {1 l% m* J) {3 b- l
  501.     item_y2 = vp_y + y - standard_padding + height
    ( e( n- m5 o$ G* z0 e8 s
  502.     if mouse_x  item_x12 l" \3 P, X3 ^5 _# N# }/ f! B
  503.       mouse_col = -1; i& Y' X* V2 Y+ z: o, f
  504.     elsif mouse_x  item_x2
    $ E) X% K( v4 }: V4 ?$ f
  505.       mouse_col = -2
    4 @% K! }  S2 N
  506.     else
    # h! \0 ]: x1 \, Y$ N* T# n! x
  507.       mouse_col = col_max  (mouse_x - item_x1)  (item_x2 - item_x1)
    4 b' o7 Q  y# t9 l
  508.     end' [$ r1 `4 z1 L  p, E
  509.     if mouse_y  item_y12 U2 c& P5 ^* [1 i
  510.       mouse_row = -1# h! W  K) M3 f: ~
  511.     elsif mouse_y  item_y2% a2 s8 {  k5 y; g
  512.       mouse_row = -2
    / |- }% c& u4 p
  513.     else1 \& y8 W3 x: y7 Q& l+ c: U
  514.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)8 X& G$ o6 V; a& Q( b
  515.     end8 O2 ^8 f. p6 h
  516.     return mouse_row, mouse_col
    6 |% A+ i8 k# V7 k2 u
  517.   end
    1 z8 t" D  n) C8 k+ ^9 L6 X  Q
  518.   #--------------------------------------------------------------------------
    & v8 N+ \! B& W% r% t# O% @9 U' v
  519.   # ● 方向键移动光标时将鼠标移动到对应的光标位置# ?) O) e" ?3 u, d% Y
  520.   #--------------------------------------------------------------------------
    8 S/ x. ~* k, U
  521.   def set_mouse_pos
    ' O1 J/ ?9 ^% u8 h* O
  522.     if viewport.nil # necessary!
    8 k( ^, K* z7 n* ~7 ?# F, o
  523.       vp_x, vp_y = 0, 0
    / g2 {* I! J- w1 y2 P4 l
  524.     else! n% F! E- i8 E0 t6 Q
  525.       vp_x = viewport.rect.x - viewport.ox) `) \8 f! ]) c) k
  526.       vp_y = viewport.rect.y - viewport.oy
      m' {* q6 i( Z/ [' ~, R4 P
  527.     end
    ( z& a; k) w9 S* _, B6 `
  528.     item_x1 = vp_x + x + standard_padding 2 z( I* k4 Y8 X
  529.     item_y1 = vp_y + y + standard_padding
    ) t, @6 ~0 l) K/ G" f* A
  530.     get_index = [url=home.php?mod=space&uid=370741]@Index[/url]  0  0  @index
    , B& K" o! D$ v! a2 d9 u% W
  531.     row = get_index  col_max - top_row5 Q( f/ X" w8 Q* C0 a
  532.     col = get_index % col_max7 Z- h& }. E; N% Z' U0 J
  533.     new_x = item_x1 + item_width  (col + 0.5)
    4 R& Y+ M9 @( ^# n
  534.     new_y = item_y1 + item_height  (row + 0.5)) A/ V' V5 Q* _4 O2 B
  535.     Mouse.set_mouse_pos(new_x, new_y)
    . R" U$ r; u6 }0 \9 B, H
  536.   end) z' M3 @) t! O, T0 {! l) Q
  537.   #--------------------------------------------------------------------------* e8 v4 s' ]  Q" ^
  538.   # ● 判断菜单是否需要卷动
    + Y9 d' }2 V, ~' `" {, }9 E
  539.   #--------------------------------------------------------------------------5 e7 ^8 R2 O% g5 y
  540.   def need_scroll
    1 V; @, B' f% ]0 `8 R
  541.     item_max  col_max  page_row_max4 d: V7 ~, {9 J+ k# D
  542.   end$ L. G5 G" p7 \6 `/ V+ Q8 h
  543.   #--------------------------------------------------------------------------
    1 {! I3 P' m  Q* v! |$ c
  544.   # ● 判断是否为水平卷动菜单$ i8 ^: l. ^6 @7 @
  545.   #--------------------------------------------------------------------------
    " a8 M+ I1 D( |  S9 J  |
  546.   def is_horzcommand; N# w" j# X% N0 M8 s5 b+ `
  547.     return false
    + L( q2 p. G' e) f2 J  Y5 u
  548.   end7 k2 `; e% {: c+ B, n' G. _4 J0 u  r
  549. end, h/ J. o2 @& |+ c
  550. / Q# D4 @, L) t& M
  551. class Window_HorzCommand- a# b& l( g. U/ |- A" r7 R) C
  552.   #--------------------------------------------------------------------------9 `/ d: r7 H& O7 x: J9 ~1 Q8 n0 q
  553.   # ● 判断是否为水平卷动菜单4 j7 [3 y+ o3 ^/ _0 @$ \+ t$ n
  554.   #--------------------------------------------------------------------------
    ; `/ a! O& W; I7 c
  555.   def is_horzcommand
    4 O( n- E% k0 J) D2 o0 ]
  556.     return true
    0 R% S- e, ^- X6 t& N# Y
  557.   end0 v5 n; L0 y2 g- R
  558. end( K# S7 n4 s" j, y* e7 _3 z) K
  559. 0 Y; J: I. I: a# K
  560. #==============================================================================
    8 N' R8 T' W3 o/ N! q9 c
  561. # ■ Window_NameInput
    ' Y* m% j+ I5 T' l; d
  562. #------------------------------------------------------------------------------
    # O' W' a! k3 W/ |1 B: ?: z
  563. #  名字输入画面中,选择文字的窗口。# k2 K: V' C+ A6 B. ]& g' c# d! |
  564. #==============================================================================
    / l! J/ a1 x% Z4 a8 N
  565. class Window_NameInput
    % E# \* z/ k: V* D$ g) k
  566.   #--------------------------------------------------------------------------1 x& }+ E6 A8 o$ Z7 c# }
  567.   # ● 设置列数- J" ~2 H/ Z2 R2 j  s9 Q  o* j
  568.   #--------------------------------------------------------------------------
    * T2 x, b% |# v1 }+ r
  569.   def col_max; D- z7 ^  K2 W& T2 ]& F0 h
  570.     return 105 g) O" y$ E7 M+ B
  571.   end* K' F+ H+ G# n( n" @
  572.   #--------------------------------------------------------------------------
    9 ]- Y, w5 \) Y' L  C& K) F
  573.   # ● 设置填充的Item个数% P6 D* O' R  E# t$ L
  574.   #--------------------------------------------------------------------------
    3 I  _4 }/ d5 k" Q; a& I( c2 \; N* N
  575.   def item_max
    ( s0 f0 b) |" x( F7 g: c
  576.     return 90& u& ]: a0 N4 Y- j; b. ^) ]6 }5 X4 t
  577.   end' Q" F9 S/ Z  e# o
  578.   #--------------------------------------------------------------------------
    # @8 T$ o9 ?5 e& r$ h, ^6 H! G
  579.   # ● 设置填充的Item个数
    ' z7 B7 e. S1 X. V
  580.   #--------------------------------------------------------------------------
    0 ~: A" v. D3 U/ [0 }) ?
  581.   def item_width
    5 ]. f1 W5 {9 g, V9 s4 @) W6 q& E" p
  582.     return 32
    - M) G8 u8 M  D: b& m; U
  583.   end
    # S3 J( {, N; n5 e5 z$ f& }) D. h
  584.   #--------------------------------------------------------------------------
    6 ]& h9 r( `1 N/ w7 Z% W5 q
  585.   # ● 判断鼠标位于菜单的第几行、第几列
    7 _. q2 N; W$ {
  586.   #--------------------------------------------------------------------------' J9 T3 a2 c2 K% I. E3 s
  587.   def mouse_window_area  J: Z  A9 A% o% U/ f9 H
  588.     if viewport.nil  L% L+ i' W2 s( }
  589.       vp_x, vp_y = 0, 0, l( A7 b2 |. X* {, O
  590.     else
    5 i4 Q* _6 c8 r1 A& G# d8 w' ?
  591.       vp_x = viewport.rect.x - viewport.ox; w# ~8 ?, K( I) Z4 Y% f8 Y
  592.       vp_y = viewport.rect.y - viewport.oy
    . I8 K% o7 x0 I& {
  593.     end9 n% m+ a  \( [0 x
  594.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    9 d( s+ p$ V1 O( M' D6 i0 ~: W
  595.     item_x1 = vp_x + x + standard_padding
    " ^8 R# E# s% G: q4 N
  596.     item_y1 = vp_y + y + standard_padding
    $ s: i- B+ S: C) i
  597.     item_x2 = vp_x + x - standard_padding + width
      A" n/ ~! q# U- N2 u
  598.     item_y2 = vp_y + y - standard_padding + height
    ) n1 |8 o" q; }$ c$ g- J- d
  599.     if mouse_x  item_x1
    9 U1 W) N' L9 Q5 V8 L; D
  600.       mouse_col = -1; R( c0 R% D' m! F
  601.     elsif mouse_x  item_x2
    6 h$ t' s# f6 i' e% Y( }
  602.       mouse_col = -2
    ; ?1 a+ P  G. |4 W4 [' B" N* d  `
  603.     elsif mouse_x  item_x1 + 160
    3 E- T9 }: C# ~! t. @; G
  604.       mouse_col = (mouse_x - item_x1)32
    . s3 \* G* _+ U4 g6 Q
  605.     elsif mouse_x  item_x2 - 1609 r/ o4 Q2 v: `7 X; x% [9 q3 m1 f- [
  606.       mouse_col = 9 - (item_x2 - mouse_x)32% W' K! }" h; _+ L
  607.     else
    # [6 Q, P& d6 H3 f# y1 P$ r
  608.       mouse_col = mouse_x  x + width2  5  4' H( D) d" O6 |( |2 ?  X7 E  B
  609.     end" I9 b5 F; k" h1 x) c; j+ ^
  610.     if mouse_y  item_y10 h: n$ c$ h$ ^' o9 T/ o
  611.       mouse_row = -1: L9 ]; M: a- G* A
  612.     elsif mouse_y  item_y2* }% z9 f; n5 q+ V* J% |
  613.       mouse_row = -2+ J; I8 n7 E; x' A3 e9 T
  614.     else% c7 C, j+ `0 \  P& S8 a$ Y
  615.       mouse_row = page_row_max  (mouse_y - item_y1 - 1)(item_y2 - item_y1). e% C: T/ V- y: G; w3 {. [# j
  616.     end
    : x% E$ A+ P& I0 M
  617.     return mouse_row, mouse_col
    & Q/ A3 u7 u1 b! ^2 ]
  618.   end: i7 X: Z9 N, w
  619.   #--------------------------------------------------------------------------
    $ V4 n# ^: k4 G
  620.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    3 V( E. R, A# ^
  621.   #--------------------------------------------------------------------------: O9 F: O8 q' x/ S, G
  622.   def set_mouse_pos/ @. m: h1 ^! m% V" S9 J7 H" a
  623.     if viewport.nil # necessary!" w- G$ F* J# _5 b& i
  624.       vp_x, vp_y = 0, 0
    + F! v1 r5 b/ @# {3 i
  625.     else
    + A4 r% O# r; ~0 n( U- ]  X9 N
  626.       vp_x = viewport.rect.x - viewport.ox+ R$ Q0 @- E6 I4 q
  627.       vp_y = viewport.rect.y - viewport.oy
    ; W( j) V, f/ v# X
  628.     end
    ( ]: W. C$ m6 x4 }4 U! b7 m
  629.     item_x1 = vp_x + x + standard_padding # V1 l& z- V1 t! I( N, a0 a
  630.     item_y1 = vp_y + y + standard_padding. e, B8 X$ E: W( Q
  631.     get_index = @index  0  0  @index
    3 U$ ^/ p- v" X9 T2 o9 G5 w' t1 Y& n; y
  632.     row = get_index  col_max - top_row8 z4 s% J) [; Z' t8 K8 \5 A) R
  633.     col = get_index % col_max8 l1 O( j: p. y/ o& D. d) f( M0 }
  634.     new_x = item_x1 + item_width  (col + 0.5)
    6 E, ]  d1 T  `6 O- q: _1 H
  635.     new_y = item_y1 + item_height  (row + 0.5)
    # z: M/ M7 n4 [
  636.     new_x += 14 if col  48 D% v0 o6 X+ S$ Q3 e, H
  637.     Mouse.set_mouse_pos(new_x, new_y)
    % z. S* \8 w3 y+ {* g
  638.   end# @0 C: v+ B8 ^2 C- v7 q
  639. end9 v- F3 |/ p3 `% K7 c* B
  640. ' M+ ?& Q: I% r" V2 L  |
  641. #==============================================================================. D1 I8 q0 E1 l! m- C
  642. # ■ Window_NumberInput
    % E0 s  T  P+ F- \4 M- [
  643. #------------------------------------------------------------------------------0 @2 G  E' z9 E; R( s- `% R  R
  644. #  重写了数值输入的方法以适应鼠标
    9 ]- _9 z4 I  W. Z% H0 |( }) o: A
  645. #==============================================================================
    # k& \& H( E' c& O- ]- A, b
  646. class Window_NumberInput  Window_Base
      m6 P! @. {  P+ d' T
  647.   #--------------------------------------------------------------------------5 S& Z* o7 ~- E7 o% q/ Y
  648.   # ● 定义实例变量+ T( r" H+ J" x5 {) q5 w! e
  649.   #--------------------------------------------------------------------------
    6 \6 Q$ ^- W9 V# l& W3 F+ _
  650.   attr_reader extra_window
    . o' |; q8 j( s( r
  651.   #--------------------------------------------------------------------------2 t! X! T+ r- Z4 E) |$ e$ [
  652.   # ● 初始化1 i6 E! k+ m/ W) F6 N+ L2 H4 F/ C4 [+ I
  653.   #--------------------------------------------------------------------------
    - m5 I! z; ~) R4 z
  654.   alias sion_mouse_initialize initialize$ x( L, H: J& j% Z) m2 X7 [0 Q
  655.   def initialize(arg)5 ~" ~# m7 r6 u- B4 w% L
  656.     sion_mouse_initialize(arg)! D9 |0 ~& |4 j' g7 h) n( _
  657.     create_extra_window1 u  Y7 U1 M8 @7 k& R
  658.   end
    " }4 Q: [, e7 `, h* p; K0 ?
  659.   #--------------------------------------------------------------------------
    6 o6 V. X; Q# f+ \2 v
  660.   # ● 启动
    7 |" _8 R. M! M5 P1 I  l( P5 X
  661.   #--------------------------------------------------------------------------
    ) r0 P- u5 m' C4 k: ~: B2 s$ ]7 X
  662.   alias sion_mouse_start start9 J: O/ x1 o& Z9 S$ z- h! |4 O. p6 S# {
  663.   def start
    # z+ s0 \$ }+ I6 O
  664.     sion_mouse_start
    ! t+ r0 g& I$ |6 g
  665.     deactivate6 C' L% `$ o* \$ J
  666.     extra_start
    , @7 E- o7 i7 L, F
  667.   end9 v" c. [4 G6 R+ D: _( O: v$ z/ k- ^
  668.   #--------------------------------------------------------------------------& P& J5 K0 ~. ?3 v8 P9 t, q
  669.   # ● 创建新的数值输入窗口
    , u( b1 J! c! B( A# v# L' W
  670.   #--------------------------------------------------------------------------% x# {. D0 c& c! ~2 H; a
  671.   def create_extra_window
    0 C6 F: z$ n; R
  672.     @extra_window = Window_NumberInput_Ex.new3 y/ m8 R' }. Q$ u
  673.     @extra_window.x = (Graphics.width - @extra_window.width)  2
    * S9 H) `+ \$ S% t' k/ c5 c
  674.     @extra_window.number_proc  = Proc.new {n [url=home.php?mod=space&uid=27178]@Number[/url] = n }" V- m  I$ p# |4 o5 `: p& R8 k
  675.     @extra_window.index_proc   = Proc.new {n @index = n }% P) M6 N) `9 G2 I3 d  Y
  676.     @extra_window.close_proc   = Proc.new { close }
    # g2 L% Y/ y0 r) v. Z
  677.     @extra_window.refresh_proc = Proc.new { refresh }
    4 S! \9 \" O; `
  678.   end
    & w* t8 |) `2 t
  679.   #--------------------------------------------------------------------------- J) I. a* y( A4 [4 i
  680.   # ● 激活新窗口% @- |+ _6 w3 M+ R  ]: T
  681.   #--------------------------------------------------------------------------9 p* B5 y* g6 z5 s3 N; o# k: n
  682.   def extra_start- h3 J% B" e) {1 D( I8 Z
  683.     case $game_message.position
    2 W) a- T4 P3 C4 y3 |+ U
  684.       when 0; @extra_window.y = y + height + 4
    : A9 f' }/ y  N* S
  685.       when 1; @extra_window.y = @message_window.y - @extra_window.height - 8
    5 z. f0 T& C. V0 c% W; ]+ q: l
  686.       when 2; @extra_window.y = y - @extra_window.height - 4
    % t( L+ b* M# Y* W
  687.       else  ; @extra_window.y = 8
    ! w' [. j! G; U; o9 h3 r
  688.     end( x8 V+ E8 K% a9 C6 V
  689.     @extra_window.variable_id = $game_message.num_input_variable_id
    7 |4 v. W% C( c, e
  690.     @extra_window.digits_max  = @digits_max
    $ K: k0 O' z% V- [! w. s
  691.     @extra_window.number      = @number( w" O' `) o8 B' g
  692.     @extra_window.open3 r! X$ \- K  g: p
  693.     @extra_window.activate7 M$ g. I; y! T- y
  694.   end
    . Q& B. l- a4 I& X
  695.   #--------------------------------------------------------------------------
    * _5 \. A6 [/ I
  696.   # ● 更新
    5 o, q4 m: M% U: x- m9 V4 j4 }0 D
  697.   #--------------------------------------------------------------------------1 H, w4 H; q  H3 l
  698.   def update' h  P( r: i; M; Z; D& |
  699.     super9 b' z4 Y) e! g9 ?
  700.     @extra_window.update
    ' X+ i, k- N( v4 t+ S/ v
  701.     update_cursor, p' Y; X  K3 `0 J+ k& g/ i/ `
  702.   end) H2 R! x$ `; _' Y/ ~
  703.   #--------------------------------------------------------------------------% i  c9 W& }" `3 \' c0 Q; n6 O+ [2 E
  704.   # ● 关闭窗口
    3 E* n6 n5 B$ S7 v1 z6 r
  705.   #--------------------------------------------------------------------------
    / v, T7 I: |! x2 |& a9 A
  706.   def close
    * c8 b7 ?, \8 Z0 W, L6 \
  707.     super! N/ H! g4 z: S. j4 ]6 w. V
  708.     @extra_window.close
    - n* K# w: L& ?3 e% e
  709.     @extra_window.deactivate
    ! [: Z7 q9 e' W+ p/ r6 r
  710.   end
    ' |6 j( o) _/ _: {
  711. end
    * ?# h: X- V& o1 [" ^/ r. Q

  712. 1 C* G8 M2 b! j7 l+ G
  713. #==============================================================================
    + f6 ~- X. R& f# |8 j4 |
  714. # ■ Window_NumberInput_Ex' Z5 g7 u# C! T
  715. #------------------------------------------------------------------------------+ c. z: ^0 I& P; i: G
  716. #  新的数值输入窗口(NewClass)" v  A1 n( U8 V& A# Y( e2 K: k, S
  717. #==============================================================================" Y# |2 f4 J& Y: F4 _0 E, P
  718. class Window_NumberInput_Ex  Window_Selectable
    # t0 w3 T' @1 H# N7 r
  719.   #--------------------------------------------------------------------------4 D1 B1 D4 l- H7 I& ^
  720.   # ● 定义实例变量, y  A  A6 l; |, e2 D
  721.   #--------------------------------------------------------------------------" h% E4 Y0 ^1 p0 v
  722.   attr_accessor number_proc: b' H" a  G4 [
  723.   attr_accessor index_proc" t+ b5 P! V4 D; Y5 f  E
  724.   attr_accessor close_proc
    5 f5 m; ?  j0 y
  725.   attr_accessor refresh_proc* C; w% d. U; r2 `
  726.   attr_accessor number" r. i4 x9 X: g- ~* T3 S
  727.   attr_accessor digits_max
    6 j) Q: }- O, l! Z( u
  728.   attr_accessor variable_id/ x7 }! c" I1 ]7 E- p$ C9 |+ I
  729.   #--------------------------------------------------------------------------4 r8 i) x5 s4 ^; o. J4 j" M3 O
  730.   # ● 数字表9 I& [( j6 G0 k% u0 W4 R# V7 M6 K
  731.   #--------------------------------------------------------------------------
    8 e& I  L2 B& d: \9 H5 u/ B8 Z* l* Z5 R
  732.   TABLE = [  7,  8,  9,5 e, P! T/ U* y. i
  733.              4,  5,  6,7 J( v7 g% Q2 H9 _
  734.              1,  2,  3,
    ) r1 B5 p/ W0 J( J( ^
  735.             '←',0,'确定',]9 u6 M# f: O) j) E5 d) _0 |6 Q
  736.   #--------------------------------------------------------------------------/ ]0 [; G( m& A; V: @* j
  737.   # ● 初始化对象
    " l" f7 u& `- F3 Q
  738.   #--------------------------------------------------------------------------, T. A3 q# V- {- X
  739.   def initialize4 a. z7 @: K/ G9 T
  740.     super(0, 0, 120, fitting_height(4))' u4 [0 T- i, M4 d
  741.     self.openness = 06 ^: F+ ^* ~. k$ E  g: W
  742.     @index = 0* ]6 N5 H/ p& Y# s- ?0 T7 {- S
  743.     @number = 0
    # l) o& j# s* z* Q6 H5 O
  744.     @old_window_index = 0# Q5 x9 \: t9 C1 J- f# E. q6 w" x: G
  745.     @digits_max = 0
    % r  K- P' [6 z/ M" v& R9 ~5 B. {( X
  746.     12.times {i draw_text(item_rect(i), TABLE[i], 1) }0 T8 V8 b, f: e- W/ V6 W- p% l
  747.   end1 D9 M  C2 K. {* ]( M- J0 Q
  748.   #--------------------------------------------------------------------------
    6 ?" n7 I% b* H. h+ }9 B4 }% b
  749.   # ● 获取项目的绘制矩形
    8 `5 {- [+ R) x! A3 o( S1 ^
  750.   #--------------------------------------------------------------------------
    ' z; O9 t' x% _5 X
  751.   def item_rect(index)# @9 \! R' e* X% Y
  752.     rect = Rect.new
    ) ]* b, J: O. o% e0 t
  753.     rect.x = index % 3  32% `. q6 w9 z8 W- B
  754.     rect.y = index  3  line_height
    ; i  x6 [6 k3 ]+ n2 m  B
  755.     rect.width = 32
    $ \( E4 `9 K; A* ?
  756.     rect.height = line_height! ^5 P9 j. S  b( k6 U9 L  k5 E( r
  757.     return rect$ {, ?2 {% S! c% d3 Y4 e% K- E
  758.   end" ~" c* q9 P2 t6 ]/ J
  759.   #--------------------------------------------------------------------------$ d% K& n$ }5 ?: ~$ o# v# a  `
  760.   # ● 将光标设置到鼠标所在的位置3 _7 R* a% @; z* R  T* L5 ^
  761.   #--------------------------------------------------------------------------
    " p- O* h. L/ b, C" L; c# u* N
  762.   def set_cursor! d9 Z+ ^( V- n/ ]+ W2 J
  763.     mouse_row, mouse_col = mouse_window_area
    ' u+ C8 x7 `- U: Y2 w
  764.     if mouse_row = 0 && mouse_col = 0
    % Y6 D# j. G& T  X
  765.       new_index = mouse_row  3 + mouse_col
    8 u- r; b  a; g6 H# }
  766.       select(new_index) if new_index = 11
    ( S' k; P" T$ M5 @
  767.     end% x' M- i1 [/ Y( |: }0 Z" J- Q
  768.   end
    ( N- p  r2 O; e! t
  769.   #--------------------------------------------------------------------------# u" u" M- u# p8 F0 s3 w
  770.   # ● 判断鼠标位于新数值输入窗口的第几行、第几列
    9 H. l# _! ]  s* F: z) ~
  771.   #--------------------------------------------------------------------------
    : p. i1 K; M  J
  772.   def mouse_window_area
    ) U1 W2 A! d" v9 F
  773.     if viewport.nil. @* s5 |- {$ H- y
  774.       vp_x, vp_y = 0, 0; I$ R# m" M4 W) ~* t! s  x5 v7 h' a7 K
  775.     else
    + U. |+ Q, y; R" m; c
  776.       vp_x = viewport.rect.x - viewport.ox
    - o0 T" f/ C6 H
  777.       vp_y = viewport.rect.y - viewport.oy
    " j" F+ j6 b( k5 W5 M1 A. V
  778.     end$ O( N' F$ i6 `' ^  J5 w
  779.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    ; D, f. b1 p  w+ {3 M& Y3 r
  780.     item_x1 = vp_x + x + standard_padding
    ( g1 f+ \; P  X, B; d
  781.     item_y1 = vp_y + y + standard_padding' c5 n5 d, E8 m. L* D7 z6 l8 F
  782.     item_x2 = vp_x + x - standard_padding + width* f0 ~! s: R  r4 ^3 H9 g& w( i
  783.     item_y2 = vp_y + y - standard_padding + height6 w( l# {# T- H9 w
  784.     if mouse_x  item_x1
    ! B, R$ e& J- a! H2 }2 A
  785.       mouse_col = -15 t, v, ]8 w  B/ h" v: E+ Y% z
  786.     elsif mouse_x  item_x2
    ; W* ?9 {' D4 F
  787.       mouse_col = -29 f/ u8 S% A) m/ x1 A, N% h2 O
  788.     else
      F) n# Y+ n8 N; [9 p
  789.       mouse_col = (mouse_x - item_x1)  32
    6 D" x" K, r4 f, n4 Q, G
  790.     end
    5 m8 Q' |: b; c3 t) p" u
  791.     if mouse_y  item_y1
    5 |2 k+ [5 ]5 s: H+ @- t
  792.       mouse_row = -1
    7 L+ U# e9 A5 r9 [- z, ^. C
  793.     elsif mouse_y  item_y29 P3 q1 F  V. W
  794.       mouse_row = -2: L, L0 h, e5 E4 ~' m0 G
  795.     else9 |: T" s( \1 s% g& n7 a* D- f
  796.       mouse_row = 4  (mouse_y - item_y1 - 1)  (item_y2 - item_y1)
    * |( s1 l/ x/ A5 E
  797.     end
    ! i/ N0 b3 C! i) }4 N
  798.     return mouse_row, mouse_col
    + I9 C; w# x- q9 S$ L
  799.   end# @% n& F6 v8 j2 n2 B. R+ V" V# O
  800.   #--------------------------------------------------------------------------
    7 J' G* f$ ^  Y' h
  801.   # ● 获取文字
    6 p% t9 C' e% E5 Z0 z% z
  802.   #--------------------------------------------------------------------------
    3 f- _; V* V- w# e" ?" i7 k8 s
  803.   def get_number& ?  w: m1 d" e# S- w) ^9 f
  804.     return false if @index == 9  @index == 11
    $ T8 |4 Y) L3 f2 {1 M& s0 K
  805.     return TABLE[@index]
    " x, Y6 X8 |0 J8 P5 f6 v0 x
  806.   end
    - k) t/ E) ^8 m* {6 ^( k8 r
  807.   #--------------------------------------------------------------------------
    1 `/ ~" ]: J2 D7 y
  808.   # ● 判定光标位置是否在“退格”上9 E7 ]+ c% J5 o; Z7 X3 @
  809.   #--------------------------------------------------------------------------% N& z) {: G$ Q' C% d; d( R0 j
  810.   def is_delete
    : D. \/ y. ~0 D0 g& P
  811.     @index == 9
      P6 X9 b2 }; S$ E) R# d
  812.   end
    ) C/ x  H1 L' \% r. e
  813.   #--------------------------------------------------------------------------) {. a) q4 S# D4 p0 I9 d
  814.   # ● 判定光标位置是否在“确定”上
    ; }+ c# z1 \! K, n# [; ?
  815.   #--------------------------------------------------------------------------
    5 q1 X$ |% N( D5 W; X
  816.   def is_ok
    , ^2 L" [6 H: f$ @& U
  817.     @index == 114 u( p# k: K- `9 w. P  ]5 W
  818.   end0 M" M, e0 m, g7 q& u
  819.   #--------------------------------------------------------------------------
      y& b; P* o! P) q# Q# B& e% n6 i
  820.   # ● 更新光标
    # J) s  a1 t+ U- a8 w
  821.   #--------------------------------------------------------------------------
    % o" r5 j. A& {0 e/ m! ]
  822.   def update_cursor) e) q, k3 ]- V
  823.     cursor_rect.set(item_rect(@index))* ?# ?; e7 F7 a4 O) a6 k
  824.   end8 c, [0 f. l- n3 ^6 k: [; h
  825.   #--------------------------------------------------------------------------
    9 o2 |1 _' y8 }& |
  826.   # ● 判定光标是否可以移动
    $ C  {! S' u) u' t
  827.   #--------------------------------------------------------------------------
    ( C7 \/ ~+ f  Y7 y+ {7 t2 T- |
  828.   def cursor_movable
    3 S3 Q" z5 b" q' h5 ?: |3 A
  829.     active
    . {, E* n+ K, \$ x
  830.   end
    ! x& L# K& O+ h9 C2 a
  831.   #--------------------------------------------------------------------------
    , H  O2 M, B( K9 q8 @
  832.   # ● 光标向下移动
    / u" U: f+ ~3 ]2 c0 b) V; D1 R# d" ~
  833.   #     wrap  允许循环
    $ R' N& ]4 f' Y0 N" G6 O$ [
  834.   #--------------------------------------------------------------------------+ R1 H& K+ |. @' F$ Y
  835.   def cursor_down(wrap)
    * I* ^( z  f0 i2 Z
  836.     if @index  9 or wrap
    6 ^6 q- X. N1 u6 B2 G
  837.       @index = (index + 3) % 12
    $ c8 q# L8 E9 S9 v% ~
  838.     end! d' t% D0 `1 |9 l; l. x
  839.   end, y. q  Z5 W; f5 G6 }
  840.   #--------------------------------------------------------------------------. n. {+ u  s( k: W/ w9 u% Y# K
  841.   # ● 光标向上移动+ A& }8 O* |: \
  842.   #     wrap  允许循环9 a0 _& x/ U, n* W6 N
  843.   #--------------------------------------------------------------------------5 K0 T/ e: x, e! I( q8 H: z
  844.   def cursor_up(wrap)- A, G6 V: F2 W
  845.     if @index = 3 or wrap
    7 }4 ?, N2 Q8 Y7 _& o/ u
  846.       @index = (index + 9) % 12! V' Z# {  C( }" [
  847.     end) e6 b# n- _0 _2 s9 A: W- Y
  848.   end
    * M" H* S/ M/ c% s& b3 N1 G- _% V
  849.   #--------------------------------------------------------------------------0 U9 a' H1 Y# n7 d, X
  850.   # ● 光标向右移动- l$ g3 L& f) _: ^. E
  851.   #     wrap  允许循环
    ; \/ h  Z/ i" t+ b9 t) e# S, x
  852.   #--------------------------------------------------------------------------
    7 Y0 B; H# ]( j# ~6 `5 L. F. @
  853.   def cursor_right(wrap)- q" g3 w# G) m6 ~2 \: G5 i
  854.     if @index % 3  2" s0 P- T9 h, F1 b
  855.       @index += 1  v2 y* y4 i- `" R! ?) ]/ b$ a
  856.     elsif wrap0 U8 N6 m2 G& U+ i0 Q
  857.       @index -= 2% f, L: L! `* {$ f9 c( u- W/ {
  858.     end. _8 Z7 D# p" N$ L
  859.   end
    ) u( W4 z% ~* `& ?5 @  x4 V5 v2 o
  860.   #--------------------------------------------------------------------------% ~' p" Z: T: G" s
  861.   # ● 光标向左移动& n2 E+ i7 M: }* R& M' r
  862.   #     wrap  允许循环5 T8 v2 \. K7 T; B1 J
  863.   #--------------------------------------------------------------------------2 h2 m1 V& Y% Q3 \8 k) e8 [) n* ?# G! l
  864.   def cursor_left(wrap)6 p8 {! g; D  v/ D; N& x
  865.     if @index % 3  0$ n3 D( ^! V" j* a
  866.       @index -= 1+ W2 G9 ]2 ^& ~6 V5 N
  867.     elsif wrap
    : L3 ~7 f) r/ I' K- G7 T# R
  868.       @index += 2% u. F$ b( E3 T' Y# Z' T
  869.     end5 l: P, q" V, s4 _( v2 b# T1 R( g
  870.   end3 C) }' i0 u9 L0 K5 ~- u" {
  871.   #--------------------------------------------------------------------------
    3 }5 h/ ~/ D9 y$ s) [
  872.   # ● 处理光标的移动5 _, F" p; u$ g/ C0 u- W1 n
  873.   #--------------------------------------------------------------------------
    * _6 e' M7 o1 q2 k) U# Z, K$ X
  874.   def process_cursor_move
    5 b- m9 H" u0 E. p
  875.     super  V# [4 i0 Q0 s2 ~% y( }: c/ l& F9 \
  876.     update_cursor1 Y* V4 \& B) B( e3 \: N
  877.   end
    & ]8 g9 t; f1 s! j4 @
  878.   #--------------------------------------------------------------------------. P3 @' ?9 x9 H- H; n
  879.   # ● “确定”、“删除字符”和“取消输入”的处理
      s/ H6 V1 {# ?7 Y7 o0 o
  880.   #--------------------------------------------------------------------------, R3 U7 D. F' K  e4 O2 v
  881.   def process_handling
    2 J% S1 @4 O8 s( O! H+ Z( z
  882.     return unless open && active
    6 d; E( R" O8 c0 w% p
  883.     process_jump if Input.trigger(A)  ^! t0 E2 W1 k5 d" P
  884.     process_back if Input.repeat(B)
    2 X% M6 I% |& J) B
  885.     process_ok   if Input.trigger(C)' h4 d& y1 F4 z( |1 o
  886.   end9 i/ z- o# \, I! i0 p1 {
  887.   #--------------------------------------------------------------------------
    ' I0 }8 L  t+ n  c/ A
  888.   # ● 跳转“确定”2 {8 Y8 u; n6 `7 }! L/ q
  889.   #--------------------------------------------------------------------------8 g( R2 ~# k8 S# e* n( J. o
  890.   def process_jump2 e4 N! J$ `  L* c6 t( G: z0 @' Y
  891.     if @index != 11  P2 J: C: T% {2 Q" `2 q8 q
  892.       @index = 11& Y- L  k9 [- B4 i. `
  893.       Sound.play_cursor6 z$ E5 X8 A2 }0 ?9 f: L
  894.     end/ ^1 `% x: l# z2 _
  895.   end7 ~% e, Y) u4 A5 l" ]
  896.   #--------------------------------------------------------------------------
    : U1 C5 Y) Y! Q7 e" j
  897.   # ● 后退一个字符, [; d6 Y8 `6 m' I4 a/ F
  898.   #--------------------------------------------------------------------------8 @3 E; j: \& B  ~: H
  899.   def process_back
    - M* k6 }1 ^. q
  900.     Sound.play_cancel
    & d/ C, t$ w+ U+ J& M7 E& x
  901.     place = 10  (@digits_max - 1 - @old_window_index)
    6 i2 a$ B5 _& f# ^" u  ^
  902.     n = (@number  place) % 10
    - b( k; A7 s0 P! h
  903.     @number -= n  place6 K+ V- a' r8 j0 m* X
  904.     @number_proc.call(@number)+ j) T/ Z+ p& S( r0 V
  905.     @old_window_index -= 1 if @old_window_index  0
    3 O$ ^4 p6 C* j- U& z) v
  906.     @index_proc.call(@old_window_index)
    ' K8 a# k: w* v4 F9 O9 n
  907.     @refresh_proc.call
    8 }# @6 j! `& _& ?0 F; I4 k
  908.   end5 T8 b! F1 M1 D+ y, i' z. d
  909.   #--------------------------------------------------------------------------  b+ ?0 x1 Q  E1 a6 {+ f* m. q! e) H
  910.   # ● 按下确定键时的处理
    % L- i/ K& f1 @* `3 _
  911.   #--------------------------------------------------------------------------" h" N) \% {5 ^% R
  912.   def process_ok; m4 W! z5 ]) d" j  Q
  913.     if get_number
    ) m, s3 Z$ Y1 V( F/ I; I: h( O3 B9 U
  914.       Sound.play_cursor
    ) D) Q  P* I* J
  915.       place = 10  (@digits_max - 1 - @old_window_index)2 P* ^$ [5 u& O2 k6 w. O; Z
  916.       n = get_number - (@number  place) % 101 k* m* a/ ~' C! b- U
  917.       @number += n  place8 `2 N; Z7 B" ^2 Q  R7 l4 q0 ^
  918.       @number_proc.call(@number)
    $ f8 I; v3 Y# b, ]+ V4 v
  919.       @old_window_index += 1 if @old_window_index  @digits_max - 1. w9 g3 G" L- W) S# \
  920.       @index_proc.call(@old_window_index)* Y0 b; Z4 V, ]5 ]: ^( e1 o, G
  921.       @refresh_proc.call
    9 W* U' `5 F* ?1 |
  922.     elsif is_delete
    ) K" e. f! N- }& g/ }5 f! B* o
  923.       process_back- I4 `( }# [- n0 C4 p# Y
  924.     elsif is_ok6 C* H. i0 g9 s+ f. O9 n- f
  925.       on_input_ok
    9 K! i; E1 |& L8 U6 a
  926.     end
    9 N7 D* E" E" T0 @
  927.   end
    ; ?* c/ @& Q( [) O9 z* W; t6 }
  928.   #--------------------------------------------------------------------------& }  y2 `1 }% }6 D! j) ?$ Y
  929.   # ● 确定
    0 g6 b' A0 j0 h" c8 f! K" _$ S; B
  930.   #--------------------------------------------------------------------------( h: @3 a) Z  U1 H7 u) {/ d
  931.   def on_input_ok, x6 y1 X6 S/ k* r. T1 }: G# V  D
  932.     @index = 0( `5 X6 @8 z& e
  933.     @old_window_index = 0: t7 r: m) @9 s+ W, M6 k
  934.     $game_variables[@variable_id] = @number
    * z1 _) V  h6 |7 H; u$ e, i+ I
  935.     Sound.play_ok! ]6 Y$ \8 \0 Z7 U1 ]* u
  936.     @close_proc.call; v, t4 ^& m2 K1 @
  937.   end: ~3 Q! M) s5 M
  938.   #--------------------------------------------------------------------------  `/ c7 K8 H  ^$ d/ E+ D$ F7 R
  939.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ! }) \% Q  b/ m4 N/ X
  940.   #--------------------------------------------------------------------------3 B% _% [$ z$ J* h
  941.   def set_mouse_pos- g& T/ j* |( @9 `( K/ D
  942.     if viewport.nil # necessary!( {& u) i( i, E4 R
  943.       vp_x, vp_y = 0, 0* |) x. B4 r3 e
  944.     else/ [& D  Y3 Q' t# ^! P1 y: m
  945.       vp_x = viewport.rect.x - viewport.ox
    7 h/ p/ \7 @* a9 G5 Y" L5 e
  946.       vp_y = viewport.rect.y - viewport.oy
    5 O, n' i1 _2 m2 C
  947.     end" O# j: N0 G. |9 x( `, w1 V) s( f
  948.     item_x1 = vp_x + x + standard_padding
    1 W. a  Z4 U7 w
  949.     item_y1 = vp_y + y + standard_padding
    ) L' e! q, c- G' {; `" {/ T
  950.     get_index = @index  0  0  @index
    , ^' K1 h' q; {9 y, q/ h4 V2 B6 k) C
  951.     new_x = item_x1 + 32  (get_index % 3 + 0.5)
    5 `0 G! k" _0 i' a# d: j. b( j
  952.     new_y = item_y1 + 24  (get_index  3 + 0.5)) U' Q! d9 j4 u4 O2 f+ o* S
  953.     Mouse.set_mouse_pos(new_x, new_y)
    # ~5 s  {% k/ R* e/ C
  954.   end+ p3 t7 y" w6 I6 Y  Y
  955. end9 r" \6 d. G; j
  956. - f2 G; t, `+ u8 N8 R' C$ @
  957. #==============================================================================! M: R3 I! C& F( S+ N' W% V4 R
  958. # ■ Window_Message
    0 Q# Q% s$ M, Z9 x/ W) q
  959. #------------------------------------------------------------------------------6 z' [: h# }! Q; h% z$ |& Z' C
  960. #  显示文字信息的窗口。
    , c- _* }+ M4 c6 d8 E
  961. #==============================================================================* v5 }+ \* D& ^  X$ H  p
  962. class Window_Message  Window_Base
      g" B; ~9 ]8 M% c
  963.   #--------------------------------------------------------------------------, s+ v, \. D5 w
  964.   # ● 处理数值的输入(覆盖原方法)
    7 Z3 z4 W5 O0 P: P! n7 {0 g7 s! F
  965.   #--------------------------------------------------------------------------2 ~4 A. C9 o! R* H1 _' O3 Q4 i
  966.   def input_number
    8 ]7 v" S% o! @) U- q. D- J
  967.     @number_window.start
    4 D9 R7 g" l/ l# [0 H) Y# A
  968.     Fiber.yield while @number_window.extra_window.active- Y7 T8 P, {& @8 j! G* B' k7 p% v
  969.   end1 i/ x3 i) N1 h! f8 B
  970. end9 d; T; S( \/ d2 V

  971. 9 g% r6 J8 r+ l# a4 E7 z
  972. #==============================================================================( T8 c1 v1 }& N, N
  973. # ■ Window_PartyCommand: z( V% @: K2 q" O  |: C+ O# {
  974. #------------------------------------------------------------------------------; p* _5 {" j' R; q
  975. #  战斗画面中,选择“战斗/撤退”的窗口。% F: Y5 K+ {. `/ {! F) T, B) y8 W
  976. #==============================================================================, i' `1 z" l- `4 k
  977. class Window_PartyCommand  Window_Command0 j) A1 G" D0 L" z
  978.   #--------------------------------------------------------------------------% u2 M# n) l2 M( l" R
  979.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    % }) M; V: q, ^& r9 |! @# s  S
  980.   #--------------------------------------------------------------------------
    0 V2 w; f, |3 H9 G
  981.   def set_mouse_pos
    ! q( `* V; S$ W
  982.     if viewport.nil1 @+ a5 k9 p. n+ _, z, p5 H
  983.       vp_x, vp_y = 0, 0
    ! A1 b" d+ v0 l) D( @
  984.     else
    & ]7 v6 `0 w9 ]+ g
  985.       #vp_x = viewport.rect.x - viewport.ox
    6 z* }0 U9 t# S8 D7 e: y- G  o( X
  986.       vp_y = viewport.rect.y - viewport.oy" h8 Y. ^& a6 u; ~, w
  987.     end) |6 q1 e" w. F' I& F  E
  988.     item_x1 = x + standard_padding
    # ^3 Q! u' D; l  Z7 ^1 x
  989.     item_y1 = vp_y + y + standard_padding
    . X9 k8 U  M$ h7 A7 w
  990.     get_index = @index  0  0  @index
    ) o) ~/ o$ i1 i3 U/ f* J0 N
  991.     row = get_index  col_max - top_row1 N! H7 o+ i' V2 t8 ^
  992.     col = get_index % col_max
    ; ~9 |# c4 G8 s6 `, f) y0 l
  993.     new_x = item_x1 + item_width  (col + 0.5)7 `! m, [& h+ T2 k1 j
  994.     new_y = item_y1 + item_height  (row + 0.5)
    8 u5 ?# j! W+ g2 V1 @$ q
  995.     Mouse.set_mouse_pos(new_x, new_y)
    " X  }  o  ^+ p: b; d
  996.   end
    3 Z; i$ ]& b- I4 ?% H7 k
  997. end$ d) v( V6 U$ _  W# X
  998. ) a% {+ a6 m: X0 g; M
  999. #==============================================================================
    2 U, |  c( h4 v, {* {
  1000. # ■ Window_ActorCommand
    ) i; A. M9 b( R
  1001. #------------------------------------------------------------------------------+ K, h7 }) f1 J0 x, Z
  1002. #  战斗画面中,选择角色行动的窗口。2 |! u) E4 Z, l. O& A" x
  1003. #==============================================================================
    4 L: d: b: k1 @
  1004. class Window_ActorCommand  Window_Command+ S6 |$ z/ s0 {% h% c0 [" E1 M  K/ g
  1005.   #--------------------------------------------------------------------------, t! ]" s# l9 Q$ e' \
  1006.   # ● 方向键移动光标时将鼠标移动到对应的光标位置; G# x, i7 Y1 f$ v% P5 N
  1007.   #--------------------------------------------------------------------------( r7 i8 x9 {0 t4 W
  1008.   def set_mouse_pos! ~4 M  b  [1 h. N9 s  A* f4 `
  1009.     if viewport.nil/ ^/ a  f/ ]6 o( u
  1010.       vp_x, vp_y = 0, 0
    ( Q. h% e! i/ G7 J
  1011.     else* e' s0 G+ d4 k8 j
  1012.       #vp_x = viewport.rect.x - viewport.ox
    & A! c9 g: P. |0 W: B& @
  1013.       vp_y = viewport.rect.y - viewport.oy
    9 V  r1 r( G) C" b5 v* D# F7 N2 `' l% G+ F
  1014.     end: x) E/ R8 k( k4 {/ J. _( Y' P
  1015.     item_x1 = Graphics.width - width + standard_padding
    ; i, q& B% j9 p8 M; A# }
  1016.     item_y1 = vp_y + y + standard_padding  [9 o7 Q& W1 @/ Y( M: W
  1017.     get_index = @index  0  0  @index
    3 U+ e1 B0 S9 K- s
  1018.     row = get_index  col_max - top_row# C) c7 W% U: Q- ]3 ?) P
  1019.     col = get_index % col_max% M# m& ^5 v0 L4 n
  1020.     new_x = item_x1 + item_width  (col + 0.5)
    3 R( P, `& S0 D+ N1 T! ?0 f
  1021.     new_y = item_y1 + item_height  (row + 0.5)( ~" q2 \$ N+ b2 u5 R* g- E% y" P
  1022.     Mouse.set_mouse_pos(new_x, new_y)$ o7 [% t" E' B% V
  1023.   end
    . S- i! l) P6 y1 u' ^9 F2 x
  1024. end3 K( |5 g2 R5 {; W/ v( X  c( p# X

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

  2145. 2 b  W2 e! z4 I
  2146. #==============================================================================+ ~1 D) H1 C9 A  ?
  2147. # ■ Game_Map$ x7 V3 {: K# g  W
  2148. #------------------------------------------------------------------------------
      A( f) Z% A: _/ S/ \3 C- w, L
  2149. #  管理地图的类。拥有卷动地图以及判断通行度的功能。$ U& |0 k4 I. A1 T: s
  2150. #   本类的实例请参考 $game_map 。
    3 g' p! V+ A" s+ E
  2151. #==============================================================================
    : H3 d' L3 S5 @8 k4 A
  2152. class Game_Map
    8 j7 F; L% Y: c2 U
  2153.   #--------------------------------------------------------------------------
    + R9 `; i5 s6 n0 [" H6 f
  2154.   # ● 定义实例变量
    ; ~1 P/ R1 L0 Y8 m1 ?
  2155.   #--------------------------------------------------------------------------
    * a. {+ r: C% D: H
  2156.   attr_reader mouse_map_x # 使用前需先使用 get_mouse_map_xy 方法来更新数据
    5 y: x! Z! l, x$ J+ I& @9 p6 ?
  2157.   attr_reader mouse_map_y # 同上
    3 s2 T  T7 `) f$ [  U
  2158.   #--------------------------------------------------------------------------+ E$ f6 N$ q) H( j
  2159.   # ● 初始化对象! u" T' _# ~" y, ~8 A3 ^
  2160.   #--------------------------------------------------------------------------
    + I: D4 K, C4 ?+ l6 C
  2161.   alias sion_mouse_initialize initialize
    6 h0 {- z9 y* _6 |1 ~8 U
  2162.   def initialize
    , R( X* S" o( I, r4 o4 ]; s8 E. w
  2163.     sion_mouse_initialize6 j' f* y2 J  f+ r
  2164.     creat_move_sign  ###
    8 W! J; C6 {# p; j. c; c
  2165.     set_constants
    : L% V& c5 f0 n+ |& M
  2166.   end  ^( C8 O- h8 o) v2 f0 J$ t  f0 s+ I, U4 I
  2167.   #--------------------------------------------------------------------------" \# z, O) }& ]( K. ~+ h7 H; l
  2168.   # ● 更新画面
    # F4 }3 F- \4 j! E: u# `. }. S
  2169.   #     main  事件解释器更新的标志
    ) E8 k; U  K: ^( D
  2170.   #--------------------------------------------------------------------------
    6 V9 i. |0 R( E) n: Y
  2171.   alias sion_mouse_update update* m! o' \8 ?, t% L9 y! p
  2172.   def update(main = false)
    - n/ f5 c6 k: n# _* Y
  2173.     sion_mouse_update(main)( o! X0 K, b1 D
  2174.     update_move_sign" f" M  h& T4 C! @6 Y" O/ J4 {
  2175.   end
    3 `6 B9 g/ \: [% q+ L: q
  2176.   #--------------------------------------------------------------------------' W8 O6 O( ~0 b; Y7 _/ d
  2177.   # ● 创建显示路径点的事件
    3 f9 U, V7 `' h5 z% a- [
  2178.   #--------------------------------------------------------------------------
    % v  D$ C9 O. d( M' A
  2179.   def creat_move_sign
    # s( z( S) `6 p9 S
  2180.     $mouse_move_sign = Move_Sign.new4 e7 F) K# V: f1 O* {+ h: [' P! b
  2181.   end% j% I/ [6 R, b( F  j
  2182.   #--------------------------------------------------------------------------- b- Y5 U1 c8 H5 V" U" C* [. ~
  2183.   # ● 更新显示路径点的事件
    3 G' \8 _+ R# k" z6 ?" z" \
  2184.   #--------------------------------------------------------------------------
    1 e5 L: E* h0 O* h% g% m/ x/ L
  2185.   def set_constants6 V% [( u% ~0 R( y& U' K3 b
  2186.     @mouse_pos_setted = true4 }) T. ]% i7 Q* G3 h9 `  G
  2187.     @set_pos_prepared = false
    - ?1 W: }" o) R, A* ^7 E
  2188.     @mouse_old_x = 0
    # C+ V: ]5 t3 K" u& [
  2189.     @mouse_old_y = 06 s1 y  N: T1 X. N  t4 ?3 v
  2190.   end# z  H7 P/ P/ w
  2191.   #--------------------------------------------------------------------------* N& i# ~. a  b2 f+ _. D  h
  2192.   # ● 更新显示路径点的事件
    " G4 e5 l( n$ L, b
  2193.   #--------------------------------------------------------------------------
    1 p4 Q4 h3 q0 P
  2194.   def update_move_sign) ?4 o3 C2 n2 |: }+ l
  2195.     $mouse_move_sign.update
    : k# d: y4 y% V" H/ R
  2196.   end8 k9 b, P+ P2 F1 s; I
  2197.   #--------------------------------------------------------------------------
    ' s/ n5 {* d  k8 T( a5 l
  2198.   # ● 获取鼠标位于的地图块的x、y坐标
    9 }1 B, o! ~: @0 }. ~8 C. b8 a
  2199.   #--------------------------------------------------------------------------
      }9 Z1 E4 N8 _, N4 g
  2200.   def get_mouse_map_xy; B' ?& B) L" N3 T( }5 s. ]8 q
  2201.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y- k: `. ~* `6 U1 m) _/ ]+ |& Q& E
  2202.     @mouse_map_x = round_x((@display_x + mouse_x  32.0).to_i)
    1 l' I- S! y9 ~- T$ _$ }
  2203.     @mouse_map_y = round_y((@display_y + mouse_y  32.0).to_i)
    7 y5 J% u) M. h8 c* J  y
  2204.   end1 a# l7 U- [! s3 z  A
  2205.   #--------------------------------------------------------------------------7 b, K9 {! l' x; u) n& N0 v+ \$ c
  2206.   # ● 返回地图画面时重设鼠标坐标: i- [* p* V( e+ h: r0 f2 D
  2207.   #--------------------------------------------------------------------------
    2 m5 J! p' i( n: X! U7 u
  2208.   def reset_mouse_pos2 i; B$ D4 G3 F7 x* o
  2209.     return if @mouse_pos_setted
    ( {0 K$ U* O0 T& x' i
  2210.     Mouse.set_mouse_pos(@mouse_old_x, @mouse_old_y)  }! z8 R( D, Z. D. k% ~" g2 C
  2211.     @mouse_pos_setted = true  o6 N, N7 f) o
  2212.     @set_pos_prepared = false
      H4 v+ \- c! C  O3 u  q
  2213.   end7 G9 Y4 \. }9 k, J
  2214.   #--------------------------------------------------------------------------$ R& y7 ]8 o; G
  2215.   # ● 重设鼠标的坐标
    7 d- `/ v+ J/ T$ @  {. ]% l3 k
  2216.   #--------------------------------------------------------------------------3 ~( A8 u7 Q1 j+ c- c' @0 r
  2217.   def prepare_reset_mouse_pos: z8 J& ~% t5 B
  2218.     return if @set_pos_prepared9 i* N. o, x9 k. Y& t
  2219.     @mouse_pos_setted = false
    $ k0 Q  o0 e4 i( z; z9 N
  2220.     @mouse_old_x = Mouse.mouse_x: z  F9 v4 D, {8 Q/ ?
  2221.     @mouse_old_y = Mouse.mouse_y
    ; Z% g4 E$ [% C3 z  @$ `0 i
  2222.     @set_pos_prepared = true8 M( r. E3 }. i6 O3 [" L/ y& _0 ]& z3 l
  2223.   end
    ) v, p9 C6 H" n6 x1 m
  2224. end4 \3 H: w0 p* z7 i( j, w
  2225. 1 y* n* H9 p* B5 \, z3 u8 U% z
  2226. #==============================================================================) {+ h& i+ |+ ~1 \4 n
  2227. # ■ Spriteset_Map
    0 ]$ P8 W$ \, [0 }. F
  2228. #------------------------------------------------------------------------------$ C  a# r+ |! J+ z" B8 o% W/ n5 I
  2229. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。# d; ~4 S6 k; e. B5 f  n
  2230. #==============================================================================6 O) p4 h0 e, v* J1 _9 v
  2231. class Spriteset_Map
    5 {6 a. w8 y4 L- w8 _$ ]
  2232.   #--------------------------------------------------------------------------- j0 w& n6 f1 r+ }' m- u. f+ ~' {! e3 y
  2233.   # ● 生成路径点精灵: t2 H! d8 J" A2 I+ H8 h
  2234.   #--------------------------------------------------------------------------
    % Z' ^& P( j% t7 g4 @, v) @
  2235.   alias sion_mouse_create_characters create_characters0 I8 u- R) ?2 \) }
  2236.   def create_characters
    # n% ]* V9 m9 v  k. Q. D
  2237.     sion_mouse_create_characters
      D. R- z* s/ k2 A9 Q
  2238.     @character_sprites.push(Sprite_Character.new(@viewport1, $mouse_move_sign))
    ! v" d" N4 N- i2 r+ W
  2239.   end
    ( Q# }# l) [- i! J8 {
  2240. end, w5 H1 K; P2 n$ ?9 n' C

  2241. 4 g0 p9 v" n4 s
  2242. #==============================================================================
    % y: ?$ i; V; a! t$ }/ I  J
  2243. # ■ Scene_Map- `; @: G( ~  `( v2 i9 V2 R
  2244. #------------------------------------------------------------------------------6 ~( T/ f' Z" p+ Q
  2245. #  地图画面
    : v# M- e, B3 [- U& @
  2246. #==============================================================================- T5 F& _6 O+ M% H. l# ]
  2247. class Scene_Map  Scene_Base
    % B. p8 q) H* J: N* }' a
  2248.   #--------------------------------------------------------------------------
    9 C! q9 M* i0 k% i2 c5 t: T
  2249.   # ● 画面更新5 [& n5 F, X- X9 U0 P
  2250.   #--------------------------------------------------------------------------
    . z! K7 d' l7 G4 X+ B* A
  2251.   alias sion_mouse_update_scene update_scene
    # ~9 V3 c4 e( w/ y$ J
  2252.   def update_scene) N8 `3 y8 T( A
  2253.     sion_mouse_update_scene% p$ X" H# j, L; f0 m+ T
  2254.     update_mouse_action unless scene_changing
    , G! U# k- n4 M2 W- m* M
  2255.   end, B) g& ?% @# U) g' G9 x+ m- a
  2256.   #--------------------------------------------------------------------------
    9 x4 z( e* j% M
  2257.   # ● 场所移动前的处理% L  @: B' n5 U( z2 t# [( x
  2258.   #--------------------------------------------------------------------------9 [5 y4 h9 u% ^7 l( X3 o
  2259.   alias sion_mouse_pre_transfer pre_transfer3 [3 i! W4 \; r6 L% C( a8 M
  2260.   def pre_transfer
    7 U8 o* e6 C) K. X
  2261.     $game_player.reset_move_path
    . j- L/ F! [, N/ l
  2262.     sion_mouse_pre_transfer) ?$ T6 V# V* \
  2263.   end. E' C; c( ]  `
  2264.   #--------------------------------------------------------------------------3 c+ K3 u, }* P* R! f- t- O
  2265.   # ● 监听鼠标左键的按下9 q, }7 S4 p$ N. A; V
  2266.   #--------------------------------------------------------------------------; I! T( L9 Z  N! I* t2 T+ o9 t  Y
  2267.   def update_mouse_action- d- t( Q+ ^% t2 @- j
  2268.     $game_player.left_button_action if Mouse.press(0x01)' d: o1 G$ X) K, A) X' {
  2269.   end  _% \  V% r7 w- H* u
  2270. end  v4 O, y( j- |! z: |
  2271. + r, j! J0 I8 R" X9 L9 l% ~" k
  2272. #==============================================================================
    % o- F1 E+ c5 e1 K2 c
  2273. # ■ Scene_File# J% I" Z3 x% Y
  2274. #------------------------------------------------------------------------------  t. R, a" ~. i
  2275. #  存档画面和读档画面共同的父类
    ; `0 r% L! e" g  w
  2276. #==============================================================================+ R* k/ H, B4 `& u7 E; v. w
  2277. class Scene_File  Scene_MenuBase* C) {0 J( ?( y+ X/ A/ `: x; q
  2278.   #--------------------------------------------------------------------------9 ^1 z+ \* y6 z* f4 M
  2279.   # ● 开始处理' F6 l; d# ^- U! c1 X% ^4 _5 z! M0 t$ i
  2280.   #--------------------------------------------------------------------------. w8 H0 ~$ g. H! f# p$ [
  2281.   alias sion_mouse_start start
    & K9 q% ~% n3 R+ B9 R, A  [6 F5 M8 A. [. N. |
  2282.   def start
    3 x( P  v- r$ ~# c2 _# R0 n
  2283.     sion_mouse_start
    . F; A8 u0 ~  M, G
  2284.     @move_state = 0
    / j, v" u6 U. b
  2285.     set_mouse_pos" O7 C9 q3 T, `9 w
  2286.   end
    % v, ]. `7 L9 L" ?
  2287.   #--------------------------------------------------------------------------
    : M5 s) K2 \$ F7 x
  2288.   # ● 更新画面
    ) k& v( }7 t: |+ a
  2289.   #--------------------------------------------------------------------------3 {5 b' C. k3 \5 p8 }4 T, U
  2290.   alias sion_mouse_update update1 e. W- e. t9 L* g) B
  2291.   def update" x6 L  \' C% e
  2292.     sion_mouse_update
    1 d" Q3 [6 q& [" g& L
  2293.     Input.dir4.zero  set_cursor  set_mouse_pos
    " y' w( l, _0 Y9 e: b7 D
  2294.   end
    + S2 i4 X* I4 q) d" R9 X
  2295.   #--------------------------------------------------------------------------: f* L$ N- q3 l+ _
  2296.   # ● 更新光标
    / S  `! X2 [) m" c! ?; H5 g# b
  2297.   #--------------------------------------------------------------------------
    ( f( n9 X- k  B' n
  2298.   def set_cursor7 T1 D* a0 r3 ]' o6 j
  2299.     @move_state += 1
    3 k3 i" N: P( R* t
  2300.     last_index = @index$ d6 ]0 A$ B) R% q5 y- h/ U/ h' p
  2301.     if mouse_which_window == -2) Q5 N& l* e" Q5 C
  2302.       if (@move_state - 1) % 6 == 07 q  i9 H# l. w
  2303.         @index = (@index + 1) % item_max if @index  item_max - 1- v9 J. g5 ~- o9 F% H
  2304.       end
    , Z3 T9 V4 ~7 v5 z. Q
  2305.     elsif mouse_which_window == -13 J7 x2 h. I! b! t. q/ J: ?& x
  2306.       if (@move_state - 1) % 6 == 0
    & d% D$ n8 G/ G# p0 d
  2307.         @index = (@index - 1 + item_max) % item_max if @index  0
    * M& R. N% z3 Z) c0 Y
  2308.       end- P, E( b- ]4 `% _4 z# T8 }
  2309.     else7 \: C2 r( K4 I& U
  2310.       @move_state = 0
    ' g- z+ f- i, M* n# n+ T# Z. L
  2311.       @index = top_index + mouse_which_window7 C/ S7 v' v  h
  2312.     end6 U1 h; L& ?9 ]! U3 y: Z+ C
  2313.     ensure_cursor_visible
    5 y: B' E) u/ G, n' X
  2314.     if @index != last_index& ?% D& K4 k8 {$ r# }/ g+ e, z  c
  2315.       @savefile_windows[last_index].selected = false% x& z8 E$ l; @6 U
  2316.       @savefile_windows[@index].selected = true
    4 x) p, r6 S, e
  2317.     end
    9 q7 @) W: u3 f* O: m: Y
  2318.   end( M- x9 j# W* `% T
  2319.   #--------------------------------------------------------------------------
    % T$ l$ L& i* @) M
  2320.   # ● 判断鼠标位于哪个窗口
    + M9 ~2 _; `8 |3 @* a* k) u& x
  2321.   #--------------------------------------------------------------------------
    9 f. Q1 k; R  d  D& s
  2322.   def mouse_which_window2 T, F2 [8 E4 M! f) A( t7 O
  2323.     mouse_x, mouse_y = Mouse.mouse_x, Mouse.mouse_y
    6 l! C3 C$ q: ]5 J
  2324.     if mouse_y  @help_window.height + 14& g/ K/ Z: W$ B3 r4 p
  2325.       mouse_row = -1
    3 L+ u) d( y5 T
  2326.     elsif mouse_y  Graphics.height - 14/ B: ], y# H& E& R  ~
  2327.       mouse_row = -2, t8 U7 h6 ]1 m* U" S+ a
  2328.     else. @+ C1 A& `! u; i. I
  2329.       mouse_row = 4  (mouse_y - @help_window.height)
    : z4 K' I6 \) \( r: ?/ R) v8 q
  2330.         (Graphics.height - @help_window.height)
    $ n9 e8 U7 C( _1 g: A7 a7 O
  2331.     end
    4 e$ [# o& A0 z9 ~( ~
  2332.     return mouse_row: o7 A+ C6 X( l- Y
  2333.   end  G# |' R) h9 _" A. O& W) O3 K
  2334.   #--------------------------------------------------------------------------, l3 L# }4 K$ b
  2335.   # ● 方向键移动光标时将鼠标移动到对应的光标位置
    ( Q' [/ _; K3 ?6 W
  2336.   #--------------------------------------------------------------------------; e7 ~- a( `( m1 @8 H
  2337.   def set_mouse_pos
    # s! L* Z; o& c# `' [5 D- ]& G! B5 B
  2338.     new_x = 40
    2 ^3 v9 M: q# I
  2339.     new_y = @help_window.height + savefile_height  (@index - top_index) + 24% g" G6 g" b& A" V9 e1 O
  2340.     Mouse.set_mouse_pos(new_x, new_y)' R: `/ {7 b8 M0 N4 }% H& `
  2341.   end! |5 E; E) L  ~8 h5 G5 |9 Z& [
  2342. end
    2 F" ]4 O$ ?4 C
  2343. 6 N& X* x/ s/ B* {( B9 J& b8 L
  2344. #==============================================================================( ]2 ?' |: a3 c* x% z) m. G; G1 l
  2345. # ■ Game_Event
    9 E9 T- M' F, {9 k3 b, d6 n  m$ W
  2346. #------------------------------------------------------------------------------
    0 p2 I& H& N. X0 D( s
  2347. #  处理事件的类。拥有条件判断、事件页的切换、并行处理、执行事件等功能。
    . G3 O6 |1 l0 M* w/ P' H8 N
  2348. #   在 Game_Map 类的内部使用。4 w/ p/ m" H: s
  2349. #==============================================================================3 s9 a( m  X& o2 X0 |3 W1 d
  2350. class Game_Event  Game_Character4 K' c7 a9 g# H& E$ n1 U$ m& z5 J6 ]
  2351.   #--------------------------------------------------------------------------8 I/ P/ K, ~  r0 g2 h( d
  2352.   # ● 事件启动/ f' y! H1 `8 {, n# ], R+ `
  2353.   #--------------------------------------------------------------------------
    , t( Q+ d, b1 ^: n' h- r! b
  2354.   alias sion_mouse_start start( w8 v+ X7 y6 ~; @
  2355.   def start
    # q" V3 X5 w$ v! X! B
  2356.     return if mouse_start && !Mouse.press(0x01)8 z4 }/ O9 q0 _  i
  2357.     sion_mouse_start
    9 C) D  l/ b- A9 [! @7 L1 y' U1 s
  2358.   end
    ( R& F: x% Q6 R$ Y# g  |
  2359.   #--------------------------------------------------------------------------
    6 b! n0 h% t/ \  N9 G
  2360.   # ● 判断事件是否由鼠标启动2 u  E7 d+ O3 V# j3 z2 z
  2361.   #--------------------------------------------------------------------------- j6 X+ G, V- I
  2362.   def mouse_start
    ) U( f+ X. \" F# X- _5 r
  2363.     return false if empty
    ( j; g2 k* y- f, v& ]5 f8 _% h
  2364.     @list.each do index+ j2 A5 A( @( Z% u* k5 F" j& w+ h
  2365.       return true if (index.code == 108  index.code == 408) &&
    - ?7 n, K' r7 G8 I
  2366.         index.parameters[0].include('鼠标启动')5 Y  Q% v+ h3 g9 e: I6 D
  2367.     end9 u; G' V" Q' a* d
  2368.     return false
    % K9 R4 G, b: B  ]1 v
  2369.   end! s5 H. u; ]# s5 Y  c3 \
  2370. end- O' ?+ p7 c/ Q# ?  u# P

  2371. . j' L& T" ]: R  `) G/ [
  2372. ####泥煤的height
    * T; U- A# t2 ^
  2373. # @height = height
    5 x' x9 \8 n5 z% a9 K; J7 X" J

  2374. 7 n4 ~# Q% |+ \1 I0 D/ q
  2375. class Area_Response
    # L5 v, e/ T' p+ v9 j: t: v
  2376.   attr_accessor type$ m  U( H, H; R+ w+ A$ r2 e. x' Q8 \
  2377.   attr_reader ox  n5 }* B( l& T+ V$ X  W
  2378.   attr_reader oy( @, G9 D4 |9 C& w5 ]6 L$ O
  2379.   attr_reader width
    ; g: N3 {- V' U
  2380.   attr_reader height3 V0 U4 w7 y* X- {! l1 [
  2381.   attr_reader switch_id
    $ t( Q1 g' X/ `
  2382.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)5 f) F) N" }6 h" p
  2383.     @type = type
    / b9 w" o% c0 ~9 X+ G% q6 m1 c
  2384.     @ox = ox
    $ O) v+ {' ~$ g7 {  n
  2385.     @oy = oy" R# P+ y% X7 R- u+ J2 `
  2386.     @width = width
    5 k2 y& Z- z  C/ F! s$ a
  2387.     @height = height
    # R9 U& q: U* U- n
  2388.     @switch_id = switch_id
    - q8 t: [* E3 k, y
  2389.   end6 j  o8 g. J; L
  2390. end8 v% {% c5 o9 |$ t) Y
  2391. , d, R. |. u2 o
  2392. $area_responses = []3 L; F, d9 M! m& U& g

  2393. - v5 f: B6 q+ G' _6 t/ o& s7 R
  2394. class Scene_Map1 P3 ^# m3 @* `
  2395.   alias update_mouse_2013421 update_mouse_action/ e- ?3 _$ h2 y( B  R
  2396.   def update_mouse_action5 E" w* x# i. x. s% F+ @  }$ K
  2397.     update_area_response  O* L, E4 f1 B) ?3 e# C
  2398.     update_mouse_2013421& `# V. w3 A+ B
  2399.   end* p' g. w. j8 p/ s: I2 F' D
  2400.   def update_area_response
    * L5 J5 t: s; C8 l( U+ E
  2401.     responses = $area_responses& v+ V! m! J" Y: {; i$ _3 F
  2402.     responses.each {response% R$ Y2 J0 W& a4 ~
  2403.       ox = response.ox
    * F( a% v9 C+ y) C; M+ Q: w
  2404.       oy = response.oy$ U4 r& n! g3 @; x8 Q
  2405.       width = response.width7 @3 M0 K! C  v7 Z, j# N/ i
  2406.       height = response.height1 m2 \" _8 l6 D( J+ F( x: b
  2407.       switch_id = response.switch_id2 c$ H* d6 n' s- Y
  2408.       case response.type
    ' _& A- g  c& Z. N) Z
  2409.       when 0
    # {0 a5 f' B* \  b8 f* {' I, C; ~
  2410.         if mouse_in_area(ox, oy, width, height)
    + a3 o/ U4 G5 B0 U+ g9 g6 [
  2411.           $game_switches[switch_id] = true! Z$ E+ P+ R/ h9 L
  2412.           $area_responses.delete(response)
    / _7 u  O& t/ B; e" T( V$ ^0 l
  2413.         end
    / w! `* V/ B' I6 \1 q  ]$ G6 |* A
  2414.       when 1
    # v7 t# V* j! [/ y* A% `3 c9 P
  2415.         if mouse_in_area(ox, oy, width, height) && Mouse.trigger(0x01)6 p) Y' p/ e' K( r. ~
  2416.           $game_switches[switch_id] = true2 {- J* V' {( p7 o) s% K; z
  2417.           $area_responses.delete(response)
    7 ?, |' S5 W5 }+ U5 c7 E2 j& _! m
  2418.         end
    . Z- g9 e4 s+ [8 A4 T% |
  2419.       when 2
    , Q# J/ U+ g- X. ]
  2420.         if mouse_in_area(ox, oy, width, height)' s- Z0 d, r5 Y
  2421.           $game_switches[switch_id] = true3 a0 ~1 R" Q8 i2 ~1 ]
  2422.         else
    * x) I$ Q- ^& f4 {/ N# C' _. s! M
  2423.           $game_switches[switch_id] = false. n) M6 h/ `5 M3 g  C" Q, o! F
  2424.         end
    * M, u3 z* V3 E. {
  2425.       when 3
    % t; H  E' G. g: M2 _4 [
  2426.         if mouse_in_area((ox - $game_map.display_x)  32 ,
    : x4 O* @; w/ e
  2427.             (oy - $game_map.display_y)  32, width, height)+ ?+ B0 |% n/ e
  2428.           $game_map.events_xy(ox, oy).each {event
    0 a$ v/ y  N/ y
  2429.           event.start$ m3 O: a5 ~/ ]3 t  a" K6 {8 N
  2430.           $area_responses.delete(response)0 `3 d/ G: ?8 e/ {+ i
  2431.           return' U5 z2 W) X. r4 e
  2432.           } 0 f; Q0 V* S3 V* w
  2433.         end
    % m- R4 ^- Q0 M' g+ E9 P: x
  2434.       when 4
    # y- V, `: Z# U& ?5 x
  2435.         if mouse_in_area((ox - $game_map.display_x)  32,5 ?6 {' B, s, V0 v
  2436.             (oy - $game_map.display_y)  32, width, height)1 q3 t7 B1 V, ^  d+ D. |4 l
  2437.           $game_map.events_xy(ox, oy).each {event
    $ i9 N6 [* S# G' u( f
  2438.             event.start
    1 V) q: X% E- K3 K1 z" k6 T2 J/ q0 r
  2439.             return
    ; l, q' b; F* ]9 ~- ~
  2440.           } 9 y$ w/ s: w/ ~" @/ R8 Q1 d
  2441.         end
      G& n# T/ _$ ]
  2442.       end
    5 v  O* _8 [+ V$ [
  2443.     }
      g! q% ]9 h; I1 e' T5 L2 L
  2444.   end
    0 u8 T$ [6 a1 q0 S
  2445.   def mouse_in_area(ox, oy, width, height)' f9 z/ J0 ~% m1 m
  2446.     Mouse.mouse_x = ox && Mouse.mouse_x = ox + width &&
    5 l9 o+ [3 i# L
  2447.     Mouse.mouse_y = oy && Mouse.mouse_y = oy + height- B9 @' I6 p& _2 R$ |
  2448.   end$ `; D2 v5 _8 H
  2449. end: v4 V# D" x7 `! s, `
  2450. class Game_Interpreter$ D+ h( [7 R2 G
  2451.   def area_response(arg)
    + p* g& z! h; \3 w
  2452.     $area_responses.push(Area_Response.new(arg))  O0 V0 ^7 L% U8 g) I* L/ N
  2453.   end- K; U. {0 O4 y, G
  2454. end2 r7 J+ F) h$ K7 x; H4 ~! ]
复制代码

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

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

GMT+8, 2024-9-21 01:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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