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

Project1

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

[已经过期] 完整鼠标系统取消自动寻路

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
24 小时
注册时间
2012-8-29
帖子
48
跳转到指定楼层
1
发表于 2012-11-23 18:51:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 Chen。 于 2012-11-23 18:53 编辑
  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 / 4
  37.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height / 4
  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/4
  61.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  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, -1].include?($game_player.x-event.x) and $game_player.y-event.y == 0) or ([1, -1].include?($game_player.y-event.y) and $game_player.x-event.x == 0)
  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 = 6 if way_y == 0
  72.               elsif way_x == 0
  73.                 p_direction = 2 if way_y == -1
  74.                 p_direction = 8 if way_y == 1
  75.               else
  76.                 p_direction = 4 if way_y == 0
  77.               end
  78.               event.start #开启事件
  79.               return 1, p_direction #返回即将开启事件以及角色朝向
  80.             end
  81.           end
  82.         end
  83.       end
  84.     end
  85.     return 0, 5 #返回不会开启事件以及角色朝向不变
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  89.   #--------------------------------------------------------------------------
  90.   def check_event_custom_exist(mouse_x, mouse_y)
  91.     for event in $game_map.events.values #循环所有事件检查
  92.       #事件角色图片宽度、高度
  93.       event_width = RPG::Cache.character(event.character_name,event.character_hue).width/4
  94.       event_height = RPG::Cache.character(event.character_name,event.character_hue).height/4
  95.       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
  96.         for i in 0...event.list.size
  97.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  98.         end
  99.       end
  100.     end
  101.     return 0, event #返回不存在自定义事件,以及事件体
  102.   end
  103. end


  104. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  105. $敌人选框扩大 = 20
  106. $角色选框扩大 = 30


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

  119. def self.init(sprite = nil)
  120.    $ShowCursor.call(0)
  121.    
  122.    @show_cursor = false
  123.    
  124.    @mouse_sprite = Sprite.new
  125.    @mouse_sprite.z = 99999
  126.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标.png')

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

  594.    #开始移动
  595.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  596.      unless moving? or $game_system.map_interpreter.running? or
  597.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  598.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  599.          case @paths[@paths_id] #判断路径
  600.          when 6
  601.            @last_move_x = true
  602.            move_right
  603.            @paths_id += 1
  604.            @direction = 6
  605.          when 4
  606.            @last_move_x = true
  607.            move_left
  608.            @paths_id += 1
  609.            @direction = 4
  610.          when 2
  611.            @last_move_x = false
  612.            move_down
  613.            @direction = 2
  614.            @paths_id += 1
  615.          when 8
  616.            @last_move_x = false
  617.            move_up
  618.            @direction = 8
  619.            @paths_id += 1
  620.          end
  621.        end
  622.      end
  623.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  624.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  625.        unless moving? or $game_system.map_interpreter.running? or
  626.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  627.          #跟随方向判断并跟随
  628.          if @mtp_x > self.screen_x
  629.            if @mtp_y - self.screen_y > - ( @mtp_x - self.screen_x ) and
  630.               @mtp_y - self.screen_y < @mtp_x - self.screen_x
  631.              move_right
  632.              $mouse_icon_id = 16
  633.              @direction = 6
  634.            end
  635.            if @mtp_y - self.screen_y > @mtp_x - self.screen_x
  636.              move_down
  637.              $mouse_icon_id = 12
  638.              @direction = 2
  639.            end
  640.            if @mtp_y - self.screen_y < - ( @mtp_x - self.screen_x )
  641.              move_up
  642.              $mouse_icon_id = 18
  643.              @direction = 8
  644.            end
  645.          end
  646.          if @mtp_x < self.screen_x
  647.            if @mtp_y - self.screen_y > - ( self.screen_x - @mtp_x ) and
  648.               @mtp_y - self.screen_y < self.screen_x - @mtp_x
  649.              move_left
  650.              $mouse_icon_id = 14
  651.              @direction = 4
  652.            end
  653.            if @mtp_y - self.screen_y > self.screen_x - @mtp_x
  654.              move_down
  655.              $mouse_icon_id = 12
  656.              @direction = 2
  657.            end
  658.            if @mtp_y - self.screen_y < - ( self.screen_x - @mtp_x )
  659.              move_up
  660.              $mouse_icon_id = 18
  661.              @direction = 8
  662.            end
  663.          end
  664.        end
  665.      else #没状态的情况
  666.        $mouse_icon_id = 0
  667.        @mouse_sta = 0
  668.        @paths_id = @paths.size #终止寻路移动
  669.      end
  670.    end
  671. self_update
  672. end
  673. end
  674. Mouse.init
  675. END { Mouse.exit }
复制代码
我的完整鼠标系统怎么取消自动寻路,改成点击事件就对话。求大神解决
[

Lv2.观梦者

梦石
0
星屑
946
在线时间
61 小时
注册时间
2019-12-10
帖子
97
2
发表于 2021-6-26 21:51:43 | 只看该作者
这个还有错误
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-4-25 14:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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