Advertisement
LiTTleDRAgo

[RGSS] Automatic Door

Nov 6th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.40 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # [Xp] Automatic Door
  3. # Version: 1.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #==============================================================================
  7. # ■ Game_Event
  8. #------------------------------------------------------------------------------
  9. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  10. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  11. #==============================================================================
  12. class Game_Event < Game_Character
  13.  
  14.   attr_reader :name
  15.   #--------------------------------------------------------------------------
  16.   # ● initialize
  17.   #--------------------------------------------------------------------------
  18.   alias drago_event_auto_initialize initialize
  19.   def initialize(map_id, event)
  20.     @name = event.name
  21.     drago_event_auto_initialize(map_id, event)    
  22.   end      
  23.   #--------------------------------------------------------------------------
  24.   # ● フレーム更新
  25.   #--------------------------------------------------------------------------
  26.   alias :update_autodoor :update
  27.   def update
  28.     update_autodoor
  29.     about_door
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● ドアの全て
  33.   #--------------------------------------------------------------------------  
  34.   def about_door
  35.     if @name[/Door(\d+)/] and @page.through and
  36.       $game_system.map_interpreter.running? == false
  37.       distance = ($game_player.x-@x).abs+($game_player.y-@y).abs
  38.       case distance
  39.       when 0...1
  40.         return if @direction == 8
  41.         door_se($1.to_i * 2) if @direction == 2
  42.         turn_up
  43.         @wait_count = 6
  44.       when 1...2
  45.         return if @direction == 6
  46.         if @direction > 6 and @wait_count > 0
  47.           @wait_count -= 1
  48.         elsif @direction == 8
  49.           turn_right
  50.           @wait_count = 6
  51.         else
  52.           door_se($1.to_i * 2) if @direction == 2
  53.           turn_right
  54.           @wait_count = 6
  55.         end
  56.       when 2...3 #
  57.         return if @direction == 4
  58.         if @direction > 4 and @wait_count > 0
  59.           @wait_count -= 1
  60.         elsif @direction == 8
  61.           turn_right
  62.           @wait_count = 6
  63.         elsif @direction == 6
  64.           turn_left
  65.           @wait_count = 6
  66.         else
  67.           door_se($1.to_i * 2) if @direction == 2
  68.           turn_left
  69.           @wait_count = 6
  70.         end
  71.       else
  72.         return if @direction == 2
  73.         if @direction > 2 and @wait_count > 0
  74.           @wait_count -= 1
  75.         elsif @direction == 8
  76.           turn_right
  77.           @wait_count = 6
  78.         elsif @direction == 6
  79.           turn_left
  80.           @wait_count = 6
  81.         elsif @direction == 4
  82.           door_se($1.to_i * 2 + 1)
  83.           turn_down
  84.         end
  85.       end
  86.     end
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● ドアの SE 設定
  90.   #--------------------------------------------------------------------------
  91.   def door_se(type)
  92.     case type
  93.     when 2 then Audio.se_play("Audio/SE/Door_01", 90, 100) rescue nil
  94.     when 3 then Audio.se_play("Audio/SE/Door_02", 90, 100) rescue nil
  95.     end
  96.   end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement