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

Project1

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

[已经过期] 鼠标点击显示高光

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3186
在线时间
1863 小时
注册时间
2010-6-19
帖子
1205
跳转到指定楼层
1
发表于 2022-4-12 16:12:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
下面这段脚本,鼠标点击NPC的时候会显示一个图片,如何在添加上一个光高效果,就是点击NPC的话显示图片,人物还会发亮的那种~~

  1. #==============================================================================
  2. # ■ 完整鼠标系统(八方向)
  3. #------------------------------------------------------------------------------
  4. #  使用时务必配合专用寻路算法
  5. #   By whbm
  6. #==============================================================================
  7. #下面做一下介绍与使用说明:
  8. #    在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
  9. #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
  10. #后果了吧)
  11. #    在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
  12. #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
  13. #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
  14. #点,那时在单击NPC即可。
  15. #    当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
  16. #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
  17. #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
  18. #那两个注释。
  19. #    当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
  20. #==============================================================================
  21. class Game_Event
  22.   attr_accessor :flag
  23. end

  24. #==============================================================================
  25. # ■ Game_Map
  26. #------------------------------------------------------------------------------
  27. #  处理地图的类。包含卷动以及可以通行的判断功能。
  28. # 本类的实例请参考 $game_map 。
  29. #==============================================================================

  30. class Game_Map
  31.   #--------------------------------------------------------------------------
  32.   # ● 检查鼠标处是否有自定义的事件并返回类型
  33.   #--------------------------------------------------------------------------
  34.   def check_event_custom(mouse_x, mouse_y)
  35.     for event in $game_map.events.values #循环所有事件检查
  36.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数
  37.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 8
  38.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  39.         for i in 0...event.list.size
  40.           if event.list[i].parameters[0] == "Item" #类型判断
  41.             event.flag = 1
  42.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  43.             event.flag = 2
  44.           else
  45.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  46.           end
  47.           return event.flag #返回事件类型标志
  48.         end
  49.       end
  50.     end
  51.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  52.     return $mouse_icon_id #使鼠标图不变化
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 检查鼠标处是否有事件可以开启
  56.   #--------------------------------------------------------------------------
  57.   def check_event_custom_start(mouse_x, mouse_y)
  58.     for event in $game_map.events.values #循环所有事件检查
  59.       #事件角色图片宽度、高度
  60.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数
  61.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 8
  62.       #判断是否鼠标在事件上
  63.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  64.         way_x = $game_player.x - event.x
  65.         way_y = $game_player.y - event.y
  66.         if [1,0,-1].include?($game_player.x-event.x) and [1,0,-1].include?($game_player.y-event.y)
  67.           for i in 0...event.list.size
  68.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  69.               #判断主角朝向
  70.               if way_x == -1
  71.                 p_direction = 3 if way_y == -1
  72.                 p_direction = 6 if way_y == 0
  73.                 p_direction = 9 if way_y == 1
  74.               elsif way_x == 0
  75.                 p_direction = 2 if way_y == -1
  76.                 p_direction = 8 if way_y == 1
  77.               else
  78.                 p_direction = 1 if way_y == -1
  79.                 p_direction = 4 if way_y == 0
  80.                 p_direction = 7 if way_y == 1
  81.               end
  82.               event.start #开启事件
  83.               return 1, p_direction #返回即将开启事件以及角色朝向
  84.             end
  85.           end
  86.         end
  87.       end
  88.     end
  89.     return 0, 5 #返回不会开启事件以及角色朝向不变
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  93.   #--------------------------------------------------------------------------
  94.   def check_event_custom_exist(mouse_x, mouse_y)
  95.     for event in $game_map.events.values #循环所有事件检查
  96.       #事件角色图片宽度、高度
  97.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数
  98.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 8
  99.       if mouse_x > event.screen_x - event_width / 2 and mouse_x < event.screen_x + event_width / 2 and mouse_y + 32 > event.screen_y + 32 - event_height and mouse_y + 32 < event.screen_y + 32
  100.         for i in 0...event.list.size
  101.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  102.         end
  103.       end
  104.     end
  105.     return 0, event #返回不存在自定义事件,以及事件体
  106.   end
  107. end
  108. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  109. $敌人选框扩大 = 20
  110. $角色选框扩大 = 30


  111. #==============================================================================
  112. # ● API调用
  113. #==============================================================================
  114. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  115. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  116. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  117. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  118. $Window_HWND = $GetActiveWindow.call
  119. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  120. module Mouse  
  121. LEFT = 0x01
  122. RIGHT = 0x02

  123. def self.init(sprite = nil)
  124.    $ShowCursor.call(0)
  125.    
  126.    @show_cursor = false
  127.    
  128.    @mouse_sprite = Sprite.new
  129.    @mouse_sprite.z = 99999
  130.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/001-Weapon01.png')

  131.    @left_press = false
  132.    @right_press = false
  133.    @left_trigger = false
  134.    @right_trigger = false
  135.    @left_repeat = false
  136.    @right_repeat = false
  137.    @click_lock = false
  138.    
  139.    update
  140. end
  141. def self.exit
  142.    @mouse_sprite.bitmap.dispose
  143.    @mouse_sprite.dispose
  144.    @show_cursor = true
  145.    $ShowCursor.call(1)
  146. end
  147. def self.mouse_debug
  148.    return @mouse_debug.bitmap
  149. end
  150. def self.update
  151.    left_down = $GetKeyState.call(0x01)
  152.    right_down = $GetKeyState.call(0x02)
  153.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  154.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  155.      @a = !@a
  156.    end
  157.    if $scene.is_a?(Scene_Map) == false
  158.      $mouse_icon_id = 0
  159.    end
  160.    if $mouse_icon_id != $mouse_icon_id_last
  161.      case $mouse_icon_id
  162.      when 1
  163.        if @a
  164.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem1')
  165.        else
  166.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/GetItem2')
  167.        end
  168.      when 2
  169.        if @a
  170.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo1')
  171.        else
  172.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/TalkTo2')
  173.        end
  174.      when 11
  175.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_LEFT')
  176.      when 12
  177.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_DOWN')
  178.      when 13
  179.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LOWER_RIGHT')
  180.      when 14
  181.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_LEFT')
  182.      when 16
  183.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_RIGHT')
  184.      when 17
  185.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_LEFT')
  186.      when 18
  187.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UP')
  188.      when 19
  189.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/Mouse_UPPER_RIGHT')
  190.      when 0
  191.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/木剑')
  192.      end
  193.      $mouse_icon_id_last = $mouse_icon_id
  194.    end
  195.    @click_lock = false
  196.    mouse_x, mouse_y = self.get_mouse_pos
  197.    if @mouse_sprite != nil
  198.      @mouse_sprite.x = mouse_x
  199.      @mouse_sprite.y = mouse_y
  200.    end
  201.    if left_down[7] == 1
  202.      @left_repeat = (not @left_repeat)
  203.      @left_trigger = (not @left_press)
  204.      @left_press = true
  205.    else
  206.      @left_press = false
  207.      @left_trigger = false
  208.      @left_repeat = false
  209.    end
  210.    if right_down[7] == 1
  211.      @right_repeat = (not @right_repeat)
  212.      @right_trigger = (not @right_press)
  213.      @right_press = true
  214.    else
  215.      @right_press = false
  216.      @right_trigger = false
  217.      @right_repeat = false
  218.    end
  219. end
  220. def self.get_mouse_pos
  221.    point_var = [0, 0].pack('ll')
  222.    if $GetCursorPos.call(point_var) != 0
  223.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  224.        x, y = point_var.unpack('ll')
  225.        if (x < 0) or (x > 10000) then x = 0 end
  226.        if (y < 0) or (y > 10000) then y = 0 end
  227.        if x > 640 then x = 640 end
  228.        if y > 480 then y = 480 end
  229.        return x, y
  230.      else
  231.        return 0, 0
  232.      end
  233.    else
  234.      return 0, 0
  235.    end
  236. end
  237. def self.press?(mouse_code)
  238.    if mouse_code == LEFT
  239.      if @click_lock
  240.        return false
  241.      else
  242.        return @left_press
  243.      end
  244.    elsif mouse_code == RIGHT
  245.      return @right_press
  246.    else
  247.      return false
  248.    end
  249. end
  250. def self.trigger?(mouse_code)
  251.    if mouse_code == LEFT
  252.      if @click_lock
  253.        return false
  254.      else
  255.        return @left_trigger
  256.      end
  257.    elsif mouse_code == RIGHT
  258.      return @right_trigger
  259.    else
  260.      return false
  261.    end
  262. end
  263. def self.repeat?(mouse_code)
  264.    if mouse_code == LEFT
  265.      if @click_lock
  266.        return false
  267.      else
  268.        return @left_repeat
  269.      end
  270.    elsif mouse_code == RIGHT
  271.      return @right_repeat
  272.    else
  273.      return false
  274.    end
  275. end
  276. def self.click_lock?
  277.    return @click_lock
  278. end
  279. def self.click_lock
  280.    @click_lock = true
  281. end
  282. def self.click_unlock
  283.    @click_lock = false
  284. end
  285. end
  286. module Input
  287. if @self_update == nil
  288.    @self_update = method('update')
  289.    @self_press = method('press?')
  290.    @self_trigger = method('trigger?')
  291.    @self_repeat = method('repeat?')
  292. end
  293. def self.update
  294.    @self_update.call
  295.    Mouse.update
  296. end
  297. def self.press?(key_code)
  298.    if @self_press.call(key_code)
  299.      return true
  300.    end
  301.    if key_code == C
  302.      return Mouse.press?(Mouse::LEFT)
  303.    elsif key_code == B
  304.      return Mouse.press?(Mouse::RIGHT)
  305.    else
  306.      return @self_press.call(key_code)
  307.    end
  308. end
  309. def self.trigger?(key_code)
  310.    if @self_trigger.call(key_code)
  311.      return true
  312.    end
  313.    if key_code == C
  314.      return Mouse.trigger?(Mouse::LEFT)
  315.    elsif key_code == B
  316.      return Mouse.trigger?(Mouse::RIGHT)
  317.    else
  318.      return @self_trigger.call(key_code)
  319.    end
  320. end
  321. def self.repeat?(key_code)
  322.    if @self_repeat.call(key_code)
  323.      return true
  324.    end
  325.    if key_code == C
  326.      return Mouse.repeat?(Mouse::LEFT)
  327.    elsif key_code == B
  328.      return Mouse.repeat?(Mouse::RIGHT)
  329.    else
  330.      return @self_repeat.call(key_code)
  331.    end
  332. end
  333. end
  334. class Window_Selectable
  335. if @self_alias == nil
  336.    alias self_update update
  337.    @self_alias = true
  338. end
  339. def update
  340.    self_update
  341.    if self.active and @item_max > 0
  342.      index_var = @index
  343.      tp_index = @index
  344.      mouse_x, mouse_y = Mouse.get_mouse_pos
  345.      mouse_not_in_rect = true
  346.      for i in 0...@item_max
  347.        @index = i
  348.        update_cursor_rect
  349.        top_x = self.cursor_rect.x + self.x + 16
  350.        top_y = self.cursor_rect.y + self.y + 16
  351.        bottom_x = top_x + self.cursor_rect.width
  352.        bottom_y = top_y + self.cursor_rect.height
  353.        if (mouse_x > top_x) and (mouse_y > top_y) and
  354.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  355.          mouse_not_in_rect = false
  356.          if tp_index != @index
  357.            tp_index = @index
  358.            $game_system.se_play($data_system.cursor_se)
  359.          end
  360.          break
  361.        end
  362.      end
  363.      if mouse_not_in_rect
  364.        @index = index_var
  365.        update_cursor_rect
  366.        Mouse.click_lock
  367.      else
  368.        Mouse.click_unlock               
  369.      end
  370.    end
  371. end
  372. end
  373. class Window_NameInput
  374. if @self_alias == nil
  375.    alias self_update update
  376.    @self_alias = true
  377. end
  378. def update
  379.    self_update
  380.    if self.active
  381.      index_var = @index
  382.      mouse_x, mouse_y = Mouse.get_mouse_pos
  383.      mouse_not_in_rect = true
  384.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  385.        @index = i
  386.        update_cursor_rect
  387.        top_x = self.cursor_rect.x + self.x + 16
  388.        top_y = self.cursor_rect.y + self.y + 16
  389.        bottom_x = top_x + self.cursor_rect.width
  390.        bottom_y = top_y + self.cursor_rect.height
  391.        if (mouse_x > top_x) and (mouse_y > top_y) and
  392.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  393.          mouse_not_in_rect = false
  394.          break
  395.        end
  396.      end
  397.      if mouse_not_in_rect
  398.        @index = index_var
  399.        update_cursor_rect
  400.        Mouse.click_lock
  401.      else
  402.        Mouse.click_unlock
  403.      end
  404.    end
  405. end
  406. end
  407. class Window_InputNumber
  408. if @self_alias == nil
  409.    alias self_update update
  410.    @self_alias = true
  411. end
  412. def update
  413.    self_update
  414.    mouse_x, mouse_y = Mouse.get_mouse_pos
  415.    if self.active and @digits_max > 0
  416.      index_var = @index
  417.      mouse_not_in_rect = true
  418.      for i in 0...@digits_max
  419.        @index = i
  420.        update_cursor_rect
  421.        top_x = self.cursor_rect.x + self.x + 16
  422.        bottom_x = top_x + self.cursor_rect.width
  423.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  424.          mouse_not_in_rect = false
  425.          break
  426.        end
  427.      end
  428.      if mouse_not_in_rect
  429.        @index = index_var
  430.        update_cursor_rect
  431.        Mouse.click_lock
  432.      else
  433.        Mouse.click_unlock
  434.      end
  435.    end
  436.    if @last_mouse_y == nil
  437.      @last_mouse_y = mouse_y
  438.    end
  439.    check_pos = (@last_mouse_y - mouse_y).abs
  440.    if check_pos > 10
  441.      $game_system.se_play($data_system.cursor_se)
  442.      place = 10 ** (@digits_max - 1 - @index)
  443.      n = @number / place % 10
  444.      @number -= n * place
  445.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  446.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  447.      @number += n * place
  448.      refresh
  449.      @last_mouse_y = mouse_y
  450.    end
  451. end
  452. end
  453. class Scene_File
  454. if @self_alias == nil
  455.    alias self_update update
  456.    @self_alias = true
  457. end
  458. def update
  459.    mouse_x, mouse_y = Mouse.get_mouse_pos
  460.    Mouse.click_lock
  461.    idx = 0
  462.    for i in @savefile_windows
  463.      top_x = i.x + 16
  464.      top_y = i.y + 16
  465.      bottom_x = top_x + i.width
  466.      bottom_y = top_y + i.height
  467.      if (mouse_x > top_x) and (mouse_y > top_y) and
  468.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  469.        i.selected = true
  470.        if @file_index != idx
  471.          @file_index = idx
  472.          $game_system.se_play($data_system.cursor_se)
  473.        end            
  474.        Mouse.click_unlock
  475.      else
  476.        i.selected = false
  477.      end
  478.      idx += 1
  479.    end
  480.    self_update
  481. end
  482. end
  483. class Arrow_Enemy
  484. if @self_alias == nil
  485.    alias self_update update
  486.    @self_alias = true
  487. end
  488. def update
  489.    mouse_x, mouse_y = Mouse.get_mouse_pos
  490.    idx = 0
  491.    for i in $game_troop.enemies do
  492.      if i.exist?
  493.        top_x = i.screen_x - self.ox
  494.        top_y = i.screen_y - self.oy
  495.        bottom_x = top_x + self.src_rect.width
  496.        bottom_y = top_y + self.src_rect.height
  497.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大) and
  498.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大)
  499.          if @index != idx
  500.            $game_system.se_play($data_system.cursor_se)
  501.            @index = idx
  502.          end
  503.        end
  504.      end
  505.      idx += 1
  506.    end
  507.    self_update
  508. end
  509. end
  510. class Arrow_Actor
  511. if @self_alias == nil
  512.    alias self_update update
  513.    @self_alias = true
  514. end
  515. def update
  516.    mouse_x, mouse_y = Mouse.get_mouse_pos
  517.    idx = 0
  518.    for i in $game_party.actors do
  519.      if i.exist?
  520.        top_x = i.screen_x - self.ox
  521.        top_y = i.screen_y - self.oy
  522.        bottom_x = top_x + self.src_rect.width
  523.        bottom_y = top_y + self.src_rect.height
  524.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大) and
  525.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大)
  526.          if @index != idx
  527.            $game_system.se_play($data_system.cursor_se)
  528.            @index = idx
  529.          end
  530.        end
  531.      end
  532.      idx += 1
  533.    end
  534.    self_update
  535. end
  536. end
  537. #==============================================================================
  538. # ■ Game_Player
  539. #------------------------------------------------------------------------------
  540. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  541. # 本类的实例请参考 $game_player。
  542. #   鼠标控制角色的主程序
  543. #==============================================================================
  544. class Game_Player
  545. if @self_alias == nil
  546.    alias self_update update
  547.    @self_alias = true
  548. end
  549. #--------------------------------------------------------------------------
  550. # ● 得到鼠标的状态
  551. #--------------------------------------------------------------------------
  552. def get_mouse_sta
  553.    return @mouse_sta
  554. end
  555. #--------------------------------------------------------------------------
  556. # ● 完整鼠标系统
  557. #--------------------------------------------------------------------------
  558. def update
  559.    mouse_x, mouse_y = Mouse.get_mouse_pos
  560.    @mtp_x = mouse_x
  561.    @mtp_y = mouse_y
  562.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  563.      #得到鼠标图标方向
  564.      $mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y)  if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
  565.    else
  566.      #令鼠标图标为正常
  567.      $mouse_icon_id = 0 if @mouse_sta != 2
  568.    end
  569.    
  570.    #单击鼠标时进行判断寻路或跟随
  571.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  572.      unless $game_system.map_interpreter.running? or
  573.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  574.        #初始化
  575.        @mouse_sta = 1
  576.        p_direction = 5
  577.        #检查鼠标处能否开启事件
  578.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  579.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  580.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  581.        if @mouse_sta != 2
  582.          #鼠标状态不为跟随状态则取数据并初始化路径
  583.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  584.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  585.          @paths = []
  586.          @paths_id = 0
  587.          if event_start == 0 #若不能开启事件
  588.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  589.              find_path = Find_Path.new
  590.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  591.            end
  592.          else #若能开启事件则改变角色朝向
  593.            @direction = p_direction
  594.          end
  595.        end
  596.      end
  597.    end

  598.    #开始移动
  599.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  600.      unless moving? or $game_system.map_interpreter.running? or
  601.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  602.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  603.          case @paths[@paths_id] #判断路径
  604.          when 6
  605.            @last_move_x = true
  606.            move_right
  607.            @paths_id += 1
  608.            @direction = 6
  609.          when 4
  610.            @last_move_x = true
  611.            move_left
  612.            @paths_id += 1
  613.            @direction = 4
  614.          when 2
  615.            @last_move_x = false
  616.            move_down
  617.            @direction = 2
  618.            @paths_id += 1
  619.          when 8
  620.            @last_move_x = false
  621.            move_up
  622.            @direction = 8
  623.            @paths_id += 1
  624.          #斜四方向
  625.          when 1
  626.            @last_move_x = false
  627.            move_lower_left
  628.            @direction = 1
  629.            @paths_id += 1
  630.          when 3
  631.            @last_move_x = false
  632.            move_lower_right
  633.            @direction = 3
  634.            @paths_id += 1
  635.          when 7
  636.            @last_move_x = false
  637.            move_upper_left
  638.            @direction = 7
  639.            @paths_id += 1
  640.          when 9
  641.            @last_move_x = false
  642.            move_upper_right
  643.            @direction = 9
  644.            @paths_id += 1
  645.          end
  646.        end
  647.      end
  648.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  649.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  650.        unless moving? or $game_system.map_interpreter.running? or
  651.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  652.          #跟随方向判断并跟随
  653.          if @mtp_x > self.screen_x
  654.            if @mtp_y - self.screen_y > - 0.4 * ( @mtp_x - self.screen_x ) and
  655.               @mtp_y - self.screen_y < 0.4 * ( @mtp_x - self.screen_x )
  656.              move_right
  657.              $mouse_icon_id = 16
  658.              @direction = 6
  659.            end
  660.            if @mtp_y - self.screen_y > 0.4 * ( @mtp_x - self.screen_x ) and
  661.              @mtp_y - self.screen_y < 2.4 * ( @mtp_x - self.screen_x )
  662.              move_lower_right
  663.              $mouse_icon_id = 13
  664.              @direction = 3
  665.            end
  666.            if @mtp_y - self.screen_y < - 0.4 * ( @mtp_x - self.screen_x ) and
  667.              @mtp_y - self.screen_y > - 2.4 * ( @mtp_x - self.screen_x )
  668.              move_upper_right
  669.              $mouse_icon_id = 19
  670.              @direction = 9
  671.            end
  672.            if @mtp_y - self.screen_y > 2.4 * ( @mtp_x - self.screen_x )
  673.              move_down
  674.              $mouse_icon_id = 12
  675.              @direction = 2
  676.            end
  677.            if @mtp_y - self.screen_y < - 2.4 * ( @mtp_x - self.screen_x )
  678.              move_up
  679.              $mouse_icon_id = 18
  680.              @direction = 8
  681.            end
  682.          end
  683.        if @mtp_x < self.screen_x
  684.          if @mtp_y - self.screen_y > - 0.4 * ( self.screen_x - @mtp_x ) and
  685.             @mtp_y - self.screen_y < 0.4 * ( self.screen_x - @mtp_x )
  686.            move_left
  687.            $mouse_icon_id = 14
  688.            @direction = 4
  689.          end
  690.          if @mtp_y - self.screen_y > 0.4 * ( self.screen_x - @mtp_x ) and
  691.            @mtp_y - self.screen_y < 2.4 * ( self.screen_x - @mtp_x )
  692.            move_lower_left
  693.            $mouse_icon_id = 11
  694.            @direction = 1
  695.          end
  696.          if @mtp_y - self.screen_y < - 0.4 * ( self.screen_x - @mtp_x ) and
  697.            @mtp_y - self.screen_y > - 2.4 * ( self.screen_x - @mtp_x )
  698.            move_upper_left
  699.            $mouse_icon_id = 17
  700.            @direction = 7
  701.          end
  702.          if @mtp_y - self.screen_y > 2.4 * ( self.screen_x - @mtp_x )
  703.            move_down
  704.            $mouse_icon_id = 12
  705.            @direction = 2
  706.          end
  707.          if @mtp_y - self.screen_y < - 2.4 * ( self.screen_x - @mtp_x )
  708.            move_up
  709.            $mouse_icon_id = 18
  710.            @direction = 8
  711.          end
  712.        end
  713.      end
  714.    else #没状态的情况
  715.      $mouse_icon_id = 0
  716.      @mouse_sta = 0
  717.      @paths_id = @paths.size #终止寻路移动
  718.    end
  719. end
  720. self_update
  721. end
  722. end
  723. Mouse.init
  724. END { Mouse.exit }
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-4-28 16:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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