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

Project1

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

[已经过期] 请懂英语的帮忙看一下脚本怎么用

[复制链接]

Lv2.观梦者

梦石
0
星屑
812
在线时间
121 小时
注册时间
2013-10-2
帖子
33
跳转到指定楼层
1
发表于 2015-11-14 11:10:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 VIPArcher 于 2015-11-14 13:35 编辑

从一个什么网上找到了一段代码,看起来效果不错。可是就是不知道怎么用啊,请各位帮忙看一下,万分感谢。
代码:
RUBY 代码复制
  1. #==============================================================================
  2. # ** Victor Engine - Light Effects
  3. #------------------------------------------------------------------------------
  4. # Author : Victor Sant
  5. #
  6. # Version History:
  7. #  v 1.00 - 2011.12.21 > First release
  8. #  v 1.01 - 2011.12.23 > Compatibility with Diagonal Movement
  9. #  v 1.02 - 2011.12.24 > Better checks for images bigger than screen
  10. #  v 1.03 - 2011.12.27 > Fixed bug when teleporting to same map
  11. #  v 1.04 - 2011.12.30 > Faster Regular Expressions
  12. #  v 1.05 - 2012.01.04 > Fixed lantern direction bug
  13. #                      > Fixed load fail when lights ON
  14. #  v 1.06 - 2012.01.07 > Fixed light opacity change not updating
  15. #  v 1.07 - 2012.01.13 > Fixed update delay when exiting the menu
  16. #  v 1.08 - 2012.01.15 > Fixed the positive sign on some Regular Expressions
  17. #                      > Fixed the Regular Expressions problem with "" and “”
  18. #  v 1.09 - 2012.05.21 > Compatibility with Map Turn Battle
  19. #  v 1.10 - 2012.07.24 > Compatibility with Moving Platform
  20. #                      > Changed actor indexing for lantern (now start at 1)
  21. #  v 1.11 - 2012.08.02 > Compatibility with Basic Module 1.27
  22. #  v 1.12 - 2013.01.07 > Fixed issue with actor lantern and map transfer
  23. #------------------------------------------------------------------------------
  24. #  This scripts allow to add varied light effects to the maps. But it works
  25. # different from other scripts with this function.
  26. # Normally, light effect scripts add images above the events, and then the
  27. # screen is tone is changed, with the images staying bellow the darker layer.
  28. # This script add an new darkened layer, and apply the light effect images
  29. # on this layer.
  30. #------------------------------------------------------------------------------
  31. # Compatibility
  32. #   Requires the script 'Victor Engine - Basic Module' v 1.27 or higher
  33. #
  34. # * Alias methods
  35. #   class Game_Map
  36. #     def setup(map_id)
  37. #
  38. #  class Game_CharacterBase
  39. #     def init_public_members
  40. #     def update
  41. #
  42. #   class Game_Event < Game_Character
  43. #     def clear_starting_flag
  44. #
  45. #   class Spriteset_Map
  46. #     def initialize
  47. #     def update
  48. #     def dispose
  49. #
  50. #   class Scene_Map
  51. #     def pre_transfer
  52. #
  53. #   class Game_Interpreter
  54. #     def comment_call
  55. #
  56. #------------------------------------------------------------------------------
  57. # Instructions:
  58. #  To instal the script, open you script editor and paste this script on
  59. #  a new section bellow the Materials section. This script must also
  60. #  be bellow the script 'Victor Engine - Basic'
  61. #  The lights must be placed on the folder "Graphics/Lights". Create a folder
  62. #  named "Lights" on the Graphics folder.
  63. #
  64. #------------------------------------------------------------------------------
  65. # Comment calls note tags:
  66. #  Tags to be used in events comment box, works like a script call.
  67. #
  68. #  <create shade>
  69. #  setting
  70. #  </create shade>
  71. #   Create a shade effect on the map, add the following values to the setting.
  72. #     opacity: x : opacity (0-255)
  73. #     red: x     : red tone   (0-255, can be negative)
  74. #     green: x   : green tone (0-255, can be negative)
  75. #     blue: x    : blue tone  (0-255, can be negative)
  76. #     blend: x   : fog blend type (0: normal, 1: add, 2: subtract)
  77. #
  78. #  <actor light>      <event light>      <vehicle light>
  79. #  setting            setting            setting
  80. #  </actor light>     </event light>     </vehicle light>
  81. #   Create a light effect on actor, event or vehicle, add the following
  82. #   values to the info. The ID, index and name must be added, other values
  83. #   are optional.
  84. #     id: x      : ligh effect ID
  85. #     name: "x"  : ligh effect graphic filename ("filename")
  86. #     index: x   : actor index, event id or (0: boat, 1: ship, 2: airship)
  87. #     opacity: x : light opacity (0-255)
  88. #     pos x: x   : coordinate X adjust
  89. #     pos y: x   : coordinate Y adjust
  90. #     var: x     : light opacity variation
  91. #     speed: x   : light variation speed
  92. #     zoom: x    : ligh effect zoom (100 = default size)
  93. #
  94. #  <map light>
  95. #  setting
  96. #  </map light>
  97. #   Create a light effect on a specific map postion, add the following
  98. #   values to the info. The ID, map_x, map_y and name must be added, other
  99. #   values are optional.
  100. #     id: x      : ligh effect ID
  101. #     name: "x"  : ligh effect graphic filename ("filename")
  102. #     map x: x   : map X coordinate
  103. #     map y: x   : map Y coordinate
  104. #     opacity: x : light opacity (0-255)
  105. #     pos x: x   : coordinate X adjust
  106. #     pos y: x   : coordinate Y adjust
  107. #     var: x     : light opacity variation
  108. #     speed: x   : light variation speed
  109. #     zoom: x    : ligh effect zoom (100 = default size)
  110. #   
  111. #  <actor lantern i: o>
  112. #  <event lantern i: o>
  113. #  <vehicle lantern i: o>
  114. #   Call a lantern on the target character, lanterns are effets that
  115. #   lights the front of the character
  116. #     i : actor index, event id or (0: boat, 1: ship, 2: airship)
  117. #     o : light opacity (0-255)
  118. #
  119. #  <light opacity id: o, d>
  120. #   This tag allows to change the light opacity gradually
  121. #     i : light effect ID
  122. #     o : new opacity (0-255)
  123. #     d : wait until complete change (60 frames = 1 second)
  124. #
  125. #  <shade opacity: o, d>
  126. #   This tag allows to change the shade opacity gradually
  127. #     o : new opacity (0-255)
  128. #     d : wait until complete change (60 frames = 1 second)
  129. #
  130. #  <shade tone: r, g, b, d>
  131. #   This tag allows to change the shade opacity gradually
  132. #     r : red tone   (0-255, can be negative)
  133. #     g : green tone (0-255, can be negative)
  134. #     b : blue tone  (0-255, can be negative)
  135. #     d : wait until complete change (60 frames = 1 second)
  136. #
  137. #  <remove light: id>
  138. #   This tag allows remove a light effect
  139. #     id: ligh effect ID
  140. #
  141. #------------------------------------------------------------------------------
  142. # Maps note tags:
  143. #   Tags to be used on the Maps note box in the database
  144. #
  145. #  <create shade>
  146. #  setting
  147. #  </create shade>
  148. #   Create a shade effect on the map, add the following values to the setting.
  149. #    opacity: x : opacity (0-255)
  150. #    red: x     : red tone   (0-255, can be negative)
  151. #    green: x   : green tone (0-255, can be negative)
  152. #    blue: x    : blue tone  (0-255, can be negative)
  153. #    blend: x   : fog blend type (0: normal, 1: add, 2: subtract)
  154. #
  155. #  <actor light>      <event light>      <vehicle light>
  156. #  setting            setting            setting
  157. #  </actor light>     </event light>     </vehicle ligth>
  158. #   Create a light effect on actor, event or vehicle, add the following
  159. #   values to the info. The ID, index and name must be added, other values
  160. #   are optional.
  161. #     id: x      : ligh effect ID
  162. #     name: "x"  : ligh effect graphic filename ("filename")
  163. #     index: x   : actor index, event id or (0: boat, 1: ship, 2: airship)
  164. #     opacity: x : light opacity (0-255)
  165. #     pos x: x   : coordinate X adjust
  166. #     pos y: x   : coordinate Y adjust
  167. #     var: x     : light opacity variation
  168. #     speed: x   : light variation speed
  169. #     zoom: x    : ligh effect zoom (100 = default size)
  170. #
  171. #  <map light>
  172. #  setting
  173. #  </map light>
  174. #   Create a light effect on a specific map postion, add the following
  175. #   values to the info. The ID, map_x, map_y and name must be added, other
  176. #   values are optional.
  177. #     id: x      : ligh effect ID
  178. #     name: "x"  : ligh effect graphic filename ("filename")
  179. #     map x: x   : map X coordinate
  180. #     map y: x   : map Y coordinate
  181. #     opacity: x : light opacity (0-255)
  182. #     pos x: x   : coordinate X adjust
  183. #     pos y: x   : coordinate Y adjust
  184. #     var: x     : light opacity variation
  185. #     speed: x   : light variation speed
  186. #     zoom: x    : ligh effect zoom (100 = default size)
  187. #
  188. #  <actor lantern i: o>
  189. #  <event lantern i: o>
  190. #  <vehicle lantern i: o>
  191. #   Call a lantern on the target character, lanterns are effets that
  192. #   lights the front of the character
  193. #     i : actor index, event id or (0: boat, 1: ship, 2: airship)
  194. #     o : light opacity (0-255)
  195. #
  196. #------------------------------------------------------------------------------
  197. # Comment boxes note tags:
  198. #   Tags to be used on events Comment boxes. They're different from the
  199. #   comment call, they're called always the even refresh.
  200. #
  201. #  <custom light>
  202. #  settings
  203. #  </custom light>
  204. #   Create a custom light effect on actor, event or vehicle, add the following
  205. #   values to the settings. The name must be added, other values
  206. #   are optional.
  207. #     name: "x"  : ligh effect graphic filename ("filename")
  208. #     opacity: x : light opacity (0-255)
  209. #     pos x: x   : coordinate X adjust
  210. #     pos y: x   : coordinate Y adjust
  211. #     var: x     : light opacity variation
  212. #     speed: x   : light variation speed
  213. #     zoom: x    : ligh effect zoom (100 = default size)
  214. #
  215. #  <simple light: o>
  216. #  <simple lamp: o>
  217. #  <simple torch: o>
  218. #  <simple window 1: o>
  219. #  <simple window 2: o>
  220. #   Simple light shortcuts
  221. #     o : new opacity (0-255)
  222. #
  223. #  <flash light: o>
  224. #  <flash lamp: o>
  225. #  <flash torch: o>
  226. #  <flash window 1: o>
  227. #  <flash window 2: o>
  228. #   Flashing light shortcuts
  229. #     o : new opacity (0-255)
  230. #
  231. #  <lantern: o>
  232. #   Lanterns shortcut
  233. #     o : new opacity (0-255)
  234. #
  235. #------------------------------------------------------------------------------
  236. # Additional instructions:
  237. #
  238. #  The lights are placed on the shade, so you *must* create a shade in order
  239. #  to display the lights. No shade, no lights.
  240. #
  241. #  The IDs of the light effects are used as identifiers. Don't use the
  242. #  same value for different light spots, if you do so, one light will
  243. #  replace the other. Also the IDs are used as referece to when
  244. #  removing lights and changing light opacity.
  245. #
  246. #  The actor lanter use the actor position in the party, NOT the actor ID.
  247. #  So the if you want a lantern for the first character, use
  248. #  <actor lantern 1: o> (o = opacity)
  249. #
  250. #  About the error on line 1062: this is a USER error made by BAD setup.
  251. #  this happen when you assign a light effect to a event id that don't exist
  252. #  at the map. So please: DON'T REPORT IT ANYMORE.
  253. #
  254. #==============================================================================
  255.  
  256. #==============================================================================
  257. # ** Victor Engine
  258. #------------------------------------------------------------------------------
  259. #   Setting module for the Victor Engine
  260. #==============================================================================
  261.  
  262. module Victor_Engine
  263.   #--------------------------------------------------------------------------
  264.   # * required
  265.   #   This method checks for the existance of the basic module and other
  266.   #   VE scripts required for this script to work, don't edit this
  267.   #--------------------------------------------------------------------------
  268.   def self.required(name, req, version, type = nil)
  269.     if !$imported[:ve_basic_module]
  270.       msg = "The script '%s' requires the script\n"
  271.       msg += "'VE - Basic Module' v%s or higher above it to work properly\n"
  272.       msg += "Go to [url]http://victorscripts.wordpress.com/[/url] to download this script."
  273.       msgbox(sprintf(msg, self.script_name(name), version))
  274.       exit
  275.     else
  276.       self.required_script(name, req, version, type)
  277.     end
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # * script_name
  281.   #   Get the script name base on the imported value, don't edit this
  282.   #--------------------------------------------------------------------------
  283.   def self.script_name(name, ext = "VE")
  284.     name = name.to_s.gsub("_", " ").upcase.split
  285.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  286.     name.join(" ")
  287.   end
  288. end
  289.  
  290. $imported ||= {}
  291. $imported[:ve_light_effects] = 1.11
  292. Victor_Engine.required(:ve_light_effects, :ve_basic_module, 1.27, :above)
  293. Victor_Engine.required(:ve_light_effects, :ve_map_battle, 1.00, :bellow)
  294.  
  295. #==============================================================================
  296. # ** Cache
  297. #------------------------------------------------------------------------------
  298. #  This module loads each of graphics, creates a Bitmap object, and retains it.
  299. # To speed up load times and conserve memory, this module holds the created
  300. # Bitmap object in the internal hash, allowing the program to return
  301. # preexisting objects when the same bitmap is requested again.
  302. #==============================================================================
  303.  
  304. module Cache
  305.   #--------------------------------------------------------------------------
  306.   # * New method: lights
  307.   #--------------------------------------------------------------------------
  308.   def self.lights(filename)
  309.     self.load_bitmap('Graphics/Lights/', filename)
  310.   end
  311. end
  312.  
  313. #==============================================================================
  314. # ** Game_Screen
  315. #------------------------------------------------------------------------------
  316. #  This class handles screen maintenance data, such as change in color tone,
  317. # flashes, etc. It's used within the Game_Map and Game_Troop classes.
  318. #==============================================================================
  319.  
  320. class Game_Screen
  321.   #--------------------------------------------------------------------------
  322.   # * Public Instance Variables
  323.   #--------------------------------------------------------------------------
  324.   attr_reader   :lights
  325.   attr_reader   :shade
  326.   attr_accessor :remove_light
  327.   #--------------------------------------------------------------------------
  328.   # * Alias method: clear
  329.   #--------------------------------------------------------------------------
  330.   alias :clear_ve_light_effects :clear
  331.   def clear
  332.     clear_ve_light_effects
  333.     clear_lights
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # * New method: clear_lights
  337.   #--------------------------------------------------------------------------
  338.   def clear_lights
  339.     [url=home.php?mod=space&uid=22478]@lights[/url] = {}
  340.     @remove_light = []
  341.     [url=home.php?mod=space&uid=475349]@shade[/url] = Game_ShadeEffect.new
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # * New method: lights
  345.   #--------------------------------------------------------------------------
  346.   def lights
  347.     @lights ||= {}
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # * New method: remove_light
  351.   #--------------------------------------------------------------------------
  352.   def remove_light
  353.     @remove_light ||= []
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # * New method: shade
  357.   #--------------------------------------------------------------------------
  358.   def shade
  359.     @shade ||= Game_ShadeEffect.new
  360.   end
  361. end
  362.  
  363. #==============================================================================
  364. # ** Game_Map
  365. #------------------------------------------------------------------------------
  366. #  This class handles maps. It includes scrolling and passage determination
  367. # functions. The instance of this class is referenced by $game_map.
  368. #==============================================================================
  369.  
  370. class Game_Map
  371.   #--------------------------------------------------------------------------
  372.   # * Alias method: setup
  373.   #--------------------------------------------------------------------------
  374.   alias :setup_ve_light_effects :setup
  375.   def setup(map_id)
  376.     setup_ve_light_effects(map_id)
  377.     setup_lights_effect
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # * New method: setup_lights_effect
  381.   #--------------------------------------------------------------------------
  382.   def setup_lights_effect
  383.     setup_map_shade(note)
  384.     setup_map_lights(:actor, note)
  385.     setup_map_lights(:event, note)
  386.     setup_map_lights(:vehicle, note)
  387.     setup_map_lights(:map, note)
  388.     setup_map_lantern(:actor, note)
  389.     setup_map_lantern(:event, note)
  390.     setup_map_lantern(:vehicle, note)
  391.   end
  392.   #--------------------------------------------------------------------------
  393.   # * New method: setup_map_shade
  394.   #--------------------------------------------------------------------------
  395.   def setup_map_shade(text)
  396.     if text =~ get_all_values("CREATE SHADE")
  397.       info  = $1.dup
  398.       shade = @screen.shade
  399.       shade.show
  400.       shade.opacity = info =~ /OPACITY: (\d+)/i ? $1.to_i : 192
  401.       shade.blend   = info =~ /BLEND: (\d+)/i   ? $1.to_i : 2
  402.       red   = info =~ /RED: (\d+)/i   ? $1.to_i : 0
  403.       green = info =~ /GREEN: (\d+)/i ? $1.to_i : 0
  404.       blue  = info =~ /BLUE: (\d+)/i  ? $1.to_i : 0
  405.       shade.set_color(red, green, blue)
  406.     end
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # * New method: setup_map_lights
  410.   #--------------------------------------------------------------------------
  411.   def setup_map_lights(type, text)
  412.     value  = get_regexp_value(type)
  413.     text.scan(get_all_values("#{value} LIGHT")) do
  414.       light = setup_light($1.dup, type)
  415.       @screen.lights[light.id] = light if light.id
  416.     end
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # * New method: setup_map_lantern
  420.   #--------------------------------------------------------------------------
  421.   def setup_map_lantern(type, text)
  422.     value  = get_regexp_value(type)
  423.     regexp = /<#{value} LANTERN (\d+): (\d+)>/i  
  424.     text.scan(regexp) do |index, opacity|
  425.       target = get_font(type, index.to_i)
  426.       next unless target
  427.       target.lantern = opacity.to_i
  428.       target.update_lantern
  429.     end
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # * New method: get_regexp_value
  433.   #--------------------------------------------------------------------------
  434.   def get_regexp_value(type)
  435.     case type
  436.     when :actor   then "ACTOR"
  437.     when :event   then "EVENT"
  438.     when :vehicle then "VEHICLE"
  439.     when :map     then "MAP"
  440.     end
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # * New method: setup_light
  444.   #--------------------------------------------------------------------------
  445.   def setup_light(info, type)
  446.     light = Game_LightEffect.new
  447.     light.name     = info =~ /NAME: #{get_filename}/i ? $1.dup : ""
  448.     light.id       = info =~ /ID: (\w+)/i         ? $1.to_s : 0
  449.     light.id       = info =~ /ID: (\d+)/i         ? $1.to_i : light.id
  450.     light.x        = info =~ /POS X: ([+-]?\d+)/i ? $1.to_i : 0
  451.     light.y        = info =~ /POS Y: ([+-]?\d+)/i ? $1.to_i : 0
  452.     light.speed    = info =~ /SPEED: (\d+)/i      ? $1.to_i : 0
  453.     light.zoom     = info =~ /ZOOM: (\d+)/i       ? $1.to_f : 100.0
  454.     light.opacity  = info =~ /OPACITY: (\d+)/i    ? $1.to_i : 192
  455.     light.variance = info =~ /VAR: (\d+)/i        ? $1.to_i : 0
  456.     if type == :map
  457.       map_x = info =~ /MAP X: (\d+)/i ? $1.to_i : 0
  458.       map_y = info =~ /MAP Y: (\d+)/i ? $1.to_i : 0
  459.       light.info = {x: map_x, y: map_y}
  460.     else
  461.       index = info =~ /INDEX: (\d+)/i ? $1.to_i : 0
  462.       light.info = {type => index}
  463.     end
  464.     light
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # * New method: set_light
  468.   #--------------------------------------------------------------------------
  469.   def set_light(id, name, info, op = 0, x = 0, y = 0, v = 0, s = 0, z = 100)
  470.     light = Game_LightEffect.new
  471.     light.id       = id
  472.     light.name     = name
  473.     light.info     = info
  474.     light.opacity  = op.to_i
  475.     light.x        = x.to_i
  476.     light.y        = y.to_i
  477.     light.variance = v.to_i
  478.     light.speed    = s.to_i
  479.     light.zoom     = z.to_f
  480.     light
  481.   end
  482.   #--------------------------------------------------------------------------
  483.   # * New method: get_font
  484.   #--------------------------------------------------------------------------
  485.   def get_font(type, i)
  486.     case type
  487.     when :actor   then actors[i - 1]
  488.     when :event   then events[i]
  489.     when :vehicle then vehicles[i]  
  490.     end
  491.   end
  492. end
  493.  
  494. #==============================================================================
  495. # ** Game_CharacterBase
  496. #------------------------------------------------------------------------------
  497. #  This class deals with characters. Common to all characters, stores basic
  498. # data, such as coordinates and graphics. It's used as a superclass of the
  499. # Game_Character class.
  500. #==============================================================================
  501.  
  502. class Game_CharacterBase
  503.   #--------------------------------------------------------------------------
  504.   # * Public Instance Variables
  505.   #--------------------------------------------------------------------------
  506.   attr_accessor :lantern
  507.   #--------------------------------------------------------------------------
  508.   # * Alias method: init_public_members
  509.   #--------------------------------------------------------------------------
  510.   alias :init_public_members_ve_light_effects :init_public_members
  511.   def init_public_members
  512.     init_public_members_ve_light_effects
  513.     @lantern = 0
  514.   end
  515.   #--------------------------------------------------------------------------
  516.   # * Alias method: update
  517.   #--------------------------------------------------------------------------
  518.   alias :update_ve_light_effects :update
  519.   def update
  520.     update_ve_light_effects
  521.     update_lantern
  522.   end
  523.   #--------------------------------------------------------------------------
  524.   # * New method: update_lantern
  525.   #--------------------------------------------------------------------------
  526.   def update_lantern(forced = false)
  527.     diag = $imported[:ve_diagonal_move] && diagonal?
  528.     if @lantern != 0 && ((!diag && @lantern_direction != @direction) ||
  529.        (diag && @lantern_direction != @diagonal) || forced)
  530.       @lantern_direction = (diag ? @diagonal : @direction)
  531.       light = setup_lantern
  532.       $game_map.screen.lights[light.id] = light
  533.     elsif @lantern == 0 && @lantern_direction
  534.       id = event? ? "EL#{@id}" : "AL#{@id}"
  535.       $game_map.screen.remove_light.push(id) if $game_map.screen.remove_light
  536.       @lantern_direction = nil
  537.     end
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # * New method: setup_lantern
  541.   #--------------------------------------------------------------------------
  542.   def setup_lantern
  543.     id   = event? ? "EL#{@id}" : "AL#{@id}"
  544.     type = event? ? :event : :actor
  545.     case @lantern_direction
  546.     when 1
  547.       name  = 'lantern_downleft'
  548.       value = [id, name, {type => @id}, @lantern, -48, 48]
  549.     when 3
  550.       name  = 'lantern_downright'
  551.       value = [id, name, {type => @id}, @lantern, 48, 48]
  552.     when 2
  553.       name  = 'lantern_down'
  554.       value = [id, name, {type => @id}, @lantern, 0, 64]
  555.     when 4
  556.       name  = 'lantern_left'
  557.       value = [id, name, {type => @id}, @lantern, -64, 0]
  558.     when 6
  559.       name  = 'lantern_right'
  560.       value = [id, name, {type => @id}, @lantern, 64, 0]
  561.     when 7
  562.       name  = 'lantern_upleft'
  563.       value = [id, name, {type => @id}, @lantern, -48, -48]
  564.     when 8
  565.       name  = 'lantern_up'
  566.       value = [id, name, {type => @id}, @lantern, 0, -64,]
  567.     when 9
  568.       name  = 'lantern_upright'
  569.       value = [id, name, {type => @id}, @lantern, 48, -48]
  570.     end
  571.     $game_map.set_light(*value)
  572.   end  
  573. end
  574.  
  575. #==============================================================================
  576. # ** Game_Event
  577. #------------------------------------------------------------------------------
  578. #  This class deals with events. It handles functions including event page
  579. # switching via condition determinants, and running parallel process events.
  580. # It's used within the Game_Map class.
  581. #==============================================================================
  582.  
  583. class Game_Event < Game_Character
  584.   #--------------------------------------------------------------------------
  585.   # * Alias method: clear_starting_flag
  586.   #--------------------------------------------------------------------------
  587.   alias :clear_starting_flag_ve_light_effects :clear_starting_flag
  588.   def clear_starting_flag
  589.     clear_starting_flag_ve_light_effects
  590.     @lantern = 0
  591.     $game_map.screen.remove_light.push("EV#{@id}")
  592.     refresh_lights if @page
  593.   end
  594.   #--------------------------------------------------------------------------
  595.   # * New method: refresh_lights
  596.   #--------------------------------------------------------------------------
  597.   def refresh_lights
  598.     case note
  599.     when /<SIMPLE LIGHT: (\d+)?>/i
  600.       set_light("EV#{@id}", "light", $1 ? $1 : 255)
  601.     when /<SIMPLE LAMP: (\d+)?>/i
  602.       set_light("EV#{@id}", "lamp", $1 ? $1 : 255)
  603.     when /<SIMPLE TORCH: (\d+)?>/i
  604.       set_light("EV#{@id}", "torch", $1)
  605.     when /<SIMPLE WINDOW (\d+): (\d+)?>/i
  606.       adj = $1 == "1" ? 0 : 14
  607.       set_light("EV#{@id}", "window", $2 ? $2 : 255, 0, 0, 0, adj)
  608.     when /<FLASH LIGHT: (\d+)?>/i
  609.       set_light("EV#{@id}", "light", $1 ? $1 : 255, 30, 1)
  610.     when /<FLASH LAMP: (\d+)?>/i
  611.       set_light("EV#{@id}", "lamp", $1 ? $1 : 255, 30, 1)
  612.     when /<FLASH TORCH: (\d+)?>/i
  613.       set_light("EV#{@id}", "torch", $1 ? $1 : 255, 30, 1)
  614.     when /<FLASH WINDOW (\d+): (\d+)?>/i
  615.       adj = $1 == "1" ? 0 : 14
  616.       set_light("EV#{@id}", "window", $2 ? $2 : 255, 30, 1, 0, adj)        
  617.     when get_all_values("CUSTOM LIGHT")
  618.       info = $1.dup
  619.       n = info =~ /NAME: #{get_filename}/i ? $1.dup : ""
  620.       x = info =~ /POS X: ([+-]?\d+)/i  ? $1.to_i : 0
  621.       y = info =~ /POS Y: ([+-]?\d+)/i  ? $1.to_i : 0
  622.       s = info =~ /SPEED: (\d+)/i       ? $1.to_i : 0
  623.       z = info =~ /ZOOM: (\d+)/i        ? $1.to_f : 100.0
  624.       o = info =~ /OPACITY: (\d+)/i     ? $1.to_i : 192
  625.       v = info =~ /VAR: (\d+)/i         ? $1.to_i : 0
  626.       set_light("EV#{@id}", n, o, v, s, x, y, z)      
  627.     when /<LANTERN(?:: (\d+))?>/i
  628.       @lantern = ($1 ? $1.to_i : 255)
  629.     end
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # * New method: set_light
  633.   #--------------------------------------------------------------------------
  634.   def set_light(id, name, op = 255, v = 0, s = 0, x = 0, y = 0, z = 100)
  635.     value = [id, name, {:event => @id}, op, x, y, v, s, z].compact
  636.     $game_map.screen.lights[id] = $game_map.set_light(*value)
  637.     $game_map.screen.remove_light.delete(id)
  638.   end  
  639. end
  640.  
  641. #==============================================================================
  642. # ** Game_Interpreter
  643. #------------------------------------------------------------------------------
  644. #  An interpreter for executing event commands. This class is used within the
  645. # Game_Map, Game_Troop, and Game_Event classes.
  646. #==============================================================================
  647.  
  648. class Game_Interpreter
  649.   #--------------------------------------------------------------------------
  650.   # * Alias method: comment_call
  651.   #--------------------------------------------------------------------------
  652.   alias :comment_call_ve_light_effects :comment_call
  653.   def comment_call
  654.     call_create_lights
  655.     call_change_shade_opacity
  656.     call_change_shade_tone
  657.     call_change_light_opacity
  658.     call_remove_light
  659.     comment_call_ve_light_effects
  660.   end
  661.   #--------------------------------------------------------------------------
  662.   # * New method: create_lights
  663.   #--------------------------------------------------------------------------
  664.   def call_create_lights
  665.     $game_map.setup_map_shade(note)
  666.     $game_map.setup_map_lights(:actor, note)
  667.     $game_map.setup_map_lights(:event, note)
  668.     $game_map.setup_map_lights(:vehicle, note)
  669.     $game_map.setup_map_lights(:map, note)
  670.     $game_map.setup_map_lantern(:actor, note)
  671.     $game_map.setup_map_lantern(:event, note)
  672.     $game_map.setup_map_lantern(:vehicle, note)
  673.   end
  674.   #--------------------------------------------------------------------------
  675.   # * New method: call_change_shade_opacity
  676.   #--------------------------------------------------------------------------
  677.   def call_change_shade_opacity
  678.     return if !$game_map.screen.shade.visible
  679.     note.scan(/<SHADE OPACITY: ((?:\d+,? *){2})>/i) do
  680.       if $1 =~ /(\d+) *,? *(\d+)?/i
  681.         duration = $2 ? $2.to_i : 0
  682.         $game_map.screen.shade.change_opacity($1.to_i, duration)
  683.       end
  684.     end
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # * New method: call_change_shade_tone
  688.   #--------------------------------------------------------------------------
  689.   def call_change_shade_tone
  690.     return if !$game_map.screen.shade.visible
  691.     note.scan(/<SHADE TONE: ((?:\d+,? *){4})>/i) do
  692.       if $1 =~ /(\d+) *, *(\d+) *, *(\d+) *, *(\d+)/i
  693.         $game_map.screen.shade.change_color($1.to_i, $2.to_i, $3.to_i, $4.to_i)
  694.       end
  695.     end
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # * New method: call_change_light_opacity
  699.   #--------------------------------------------------------------------------
  700.   def call_change_light_opacity
  701.     return if !$game_map.screen.shade.visible
  702.     note.scan(/<LIGHT OPACITY (\d+): ((?:\d+,? *){2})>/i) do
  703.       light = $game_map.screen.lights[$1.to_i]
  704.       if light && $2 =~ /(\d+) *,? *(\d+)?/i
  705.         duration = $2 ? $2.to_i : 0
  706.         light.change_opacity($1.to_i, duration)
  707.       end
  708.     end
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # * New method: call_remove_light
  712.   #--------------------------------------------------------------------------
  713.   def call_remove_light
  714.     note.scan(/<REMOVE LIGHT: (\d+)>/i) do
  715.       $game_map.screen.remove_light.push($1.to_i)
  716.     end
  717.   end
  718. end
  719.  
  720. #==============================================================================
  721. # ** Spriteset_Map
  722. #------------------------------------------------------------------------------
  723. #  This class brings together map screen sprites, tilemaps, etc. It's used
  724. # within the Scene_Map class.
  725. #==============================================================================
  726.  
  727. class Spriteset_Map
  728.   #--------------------------------------------------------------------------
  729.   # * Alias method: initialize
  730.   #--------------------------------------------------------------------------
  731.   alias :initialize_ve_light_effects :initialize
  732.   def initialize
  733.     initialize_ve_light_effects
  734.     2.times { update_light(true) }
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # * Alias method: update
  738.   #--------------------------------------------------------------------------
  739.   alias :update_ve_light_effects :update
  740.   def update
  741.     update_ve_light_effects
  742.     update_light
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   # * Alias method: dispose
  746.   #--------------------------------------------------------------------------
  747.   alias :dispose_ve_light_effects :dispose
  748.   def dispose
  749.     dispose_ve_light_effects
  750.     dispose_light unless SceneManager.scene_is?(Scene_Map)
  751.   end
  752.   #--------------------------------------------------------------------------
  753.   # * New method: update_light
  754.   #--------------------------------------------------------------------------
  755.   def update_light(forced = false)
  756.     return unless Graphics.frame_count % 2 == 0 || forced
  757.     update_shade
  758.     update_effects
  759.   end
  760.   #--------------------------------------------------------------------------
  761.   # * New method: dispose_light
  762.   #--------------------------------------------------------------------------
  763.   def dispose_light
  764.     if @light_effect
  765.       @light_effect.dispose
  766.       @light_effect = nil
  767.       @screen_shade = nil
  768.     end
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # * New method: update_shade
  772.   #--------------------------------------------------------------------------
  773.   def update_shade
  774.     if !@light_effect && $game_map.screen.shade.visible
  775.       refresh_lights
  776.     elsif $game_map.screen.shade.visible && @light_effect
  777.       @light_effect.update
  778.     elsif @light_effect && !$game_map.screen.shade.visible
  779.       dispose_light
  780.     end
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # * New method: refresh_lights
  784.   #--------------------------------------------------------------------------
  785.   def refresh_lights
  786.     @light_effect.dispose if @light_effect
  787.     @screen_shade = $game_map.screen.shade
  788.     @light_effect = Sprite_Light.new(@screen_shade, @viewport2)
  789.     $game_map.event_list.each {|event| event.refresh_lights }
  790.     @light_effect.update
  791.   end  
  792.   #--------------------------------------------------------------------------
  793.   # * New method: update_effects
  794.   #--------------------------------------------------------------------------
  795.   def update_effects
  796.     return if !@light_effect || $game_map.screen.lights.empty?
  797.     $game_map.screen.lights.keys.each {|key| create_light(key) }
  798.     $game_map.screen.remove_light.clear
  799.   end
  800.   #--------------------------------------------------------------------------
  801.   # * New method: create_light
  802.   #--------------------------------------------------------------------------
  803.   def create_light(key)
  804.     effect = @light_effect.lights[key]
  805.     return if remove_light(key)
  806.     return if effect && effect.light == $game_map.screen.lights[key]
  807.     @light_effect.create_light($game_map.screen.lights[key])
  808.   end
  809.   #--------------------------------------------------------------------------
  810.   # * New method: remove_light
  811.   #--------------------------------------------------------------------------
  812.   def remove_light(key)
  813.     return false if !$game_map.screen.remove_light.include?(key)
  814.     @light_effect.remove_light(key)
  815.     $game_map.screen.lights.delete(key)
  816.     return true
  817.   end
  818. end
  819.  
  820. #==============================================================================
  821. # ** Scene_Map
  822. #------------------------------------------------------------------------------
  823. #  This class performs the map screen processing.
  824. #==============================================================================
  825.  
  826. class Scene_Map
  827.   #--------------------------------------------------------------------------
  828.   # * Alias method: pre_transfer
  829.   #--------------------------------------------------------------------------
  830.   alias :pre_transfer_ve_light_effects :pre_transfer
  831.   def pre_transfer
  832.     pre_transfer_ve_light_effects
  833.     if $game_player.new_map_id !=  $game_map.map_id
  834.       @spriteset.dispose_light
  835.       $game_map.screen.clear_lights
  836.     end
  837.   end
  838.   #--------------------------------------------------------------------------
  839.   # * Alias method: post_transfer
  840.   #--------------------------------------------------------------------------
  841.   alias :post_transfer_ve_light_effects :post_transfer
  842.   def post_transfer
  843.     $game_map.actors.each {|actor| actor.update_lantern(true) }
  844.     post_transfer_ve_light_effects
  845.   end
  846. end
  847.  
  848. #==============================================================================
  849. # ** Game_ShadeEffect
  850. #------------------------------------------------------------------------------
  851. #  This class handles the shade layer data
  852. #==============================================================================
  853.  
  854. class Game_ShadeEffect
  855.   #--------------------------------------------------------------------------
  856.   # * Public Instance Variables
  857.   #--------------------------------------------------------------------------
  858.   attr_reader   :visible
  859.   attr_reader   :color
  860.   attr_accessor :blend
  861.   attr_accessor :opacity
  862.   #--------------------------------------------------------------------------
  863.   # * initialize
  864.   #--------------------------------------------------------------------------
  865.   def initialize
  866.     init_opacity
  867.     init_color
  868.   end
  869.   #--------------------------------------------------------------------------
  870.   # * init_opacity
  871.   #--------------------------------------------------------------------------
  872.   def init_opacity
  873.     @visible = false
  874.     @opacity = 0
  875.     @opacity_target   = 0
  876.     @opacity_duration = 0
  877.   end
  878.   #--------------------------------------------------------------------------
  879.   # * init_color
  880.   #--------------------------------------------------------------------------
  881.   def init_color
  882.     @blend = 0
  883.     [url=home.php?mod=space&uid=10453]@color[/url] = Color.new(0, 0, 0, 0)
  884.     @color_duration = 0
  885.     @color_target   = Color.new(0, 0, 0, 0)
  886.   end
  887.   #--------------------------------------------------------------------------
  888.   # * show
  889.   #--------------------------------------------------------------------------
  890.   def show
  891.     @visible = true
  892.   end
  893.   #--------------------------------------------------------------------------
  894.   # * hide
  895.   #--------------------------------------------------------------------------
  896.   def hide
  897.     @visible = false
  898.   end
  899.   #--------------------------------------------------------------------------
  900.   # * set_color
  901.   #--------------------------------------------------------------------------
  902.   def set_color(r = 0, g = 0, b = 0)
  903.     @color        = get_colors(r, g, b)
  904.     @color_target = @color.clone
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # * change_opacity
  908.   #--------------------------------------------------------------------------
  909.   def change_opacity(op, d)
  910.     @opacity_target   = op
  911.     @opacity_duration = [d, 0].max
  912.     @opacity = @opacity_target if @opacity_duration == 0
  913.   end
  914.   #--------------------------------------------------------------------------
  915.   # * change_color
  916.   #--------------------------------------------------------------------------
  917.   def change_color(r, g, b, d)
  918.     @color_target   = get_colors(r, g, b)
  919.     @color_duration = [d, 0].max
  920.     @color = @color_target.clone if @color_duration == 0
  921.   end
  922.   #--------------------------------------------------------------------------
  923.   # * get_colors
  924.   #--------------------------------------------------------------------------
  925.   def get_colors(r, g, b)
  926.     color = Color.new(255 - r, 255 - g, 255 - b, 255) if @blend == 2
  927.     color = Color.new(r, g, b, 255) if @blend != 2
  928.     color
  929.   end
  930.   #--------------------------------------------------------------------------
  931.   # * update
  932.   #--------------------------------------------------------------------------
  933.   def update
  934.     update_opacity
  935.     update_color
  936.   end
  937.   #--------------------------------------------------------------------------
  938.   # * update_opacity
  939.   #--------------------------------------------------------------------------
  940.   def update_opacity
  941.     return if @opacity_duration == 0
  942.     d = @opacity_duration
  943.     @opacity = (@opacity * (d - 1) + @opacity_target) / d
  944.     @opacity_duration -= 1
  945.   end
  946.   #--------------------------------------------------------------------------
  947.   # * update_color
  948.   #--------------------------------------------------------------------------
  949.   def update_color
  950.     return if @color_duration == 0
  951.     d = @color_duration
  952.     @color.red   = (@color.red   * (d - 1) + @color_target.red)   / d
  953.     @color.green = (@color.green * (d - 1) + @color_target.green) / d
  954.     @color.blue  = (@color.blue  * (d - 1) + @color_target.blue)  / d
  955.     @color_duration -= 1
  956.   end
  957. end
  958.  
  959. #==============================================================================
  960. # ** Game_LightEffect
  961. #------------------------------------------------------------------------------
  962. #  This class handles the light sprite data
  963. #==============================================================================
  964.  
  965. class Game_LightEffect
  966.   #--------------------------------------------------------------------------
  967.   # * Public Instance Variables
  968.   #--------------------------------------------------------------------------
  969.   attr_accessor :id
  970.   attr_accessor :name
  971.   attr_accessor :info
  972.   attr_accessor :opacity
  973.   attr_accessor :x
  974.   attr_accessor :y
  975.   attr_accessor :variance
  976.   attr_accessor :speed
  977.   attr_accessor :zoom
  978.   attr_accessor :opacity_target
  979.   attr_accessor :opacity_duration
  980.   #--------------------------------------------------------------------------
  981.   # * change_opacity
  982.   #--------------------------------------------------------------------------
  983.   def change_opacity(op, d)
  984.     @opacity_target   = op
  985.     @opacity_duration = [d, 0].max
  986.     @opacity = @opacity_target if @opacity_duration == 0
  987.   end
  988. end
  989.  
  990. #==============================================================================
  991. # ** Game_LightBitmap
  992. #------------------------------------------------------------------------------
  993. #  This class handles the bitmpas of each light spot
  994. #==============================================================================
  995.  
  996. class Game_LightBitmap
  997.   #--------------------------------------------------------------------------
  998.   # * Public Instance Variables
  999.   #--------------------------------------------------------------------------
  1000.   attr_reader   :light
  1001.   attr_reader   :bitmap
  1002.   attr_reader   :opacity
  1003.   attr_reader   :x
  1004.   attr_reader   :y
  1005.   #--------------------------------------------------------------------------
  1006.   # * initialize
  1007.   #--------------------------------------------------------------------------
  1008.   def initialize(light)
  1009.     [url=home.php?mod=space&uid=22469]@light[/url] = light
  1010.     init_basic
  1011.     update
  1012.   end
  1013.   #--------------------------------------------------------------------------
  1014.   # * init_basic
  1015.   #--------------------------------------------------------------------------
  1016.   def init_basic
  1017.     @bitmap   = Cache.lights(@light.name)
  1018.     @target   = set_target
  1019.     @opacity  = @light.opacity
  1020.     @speed    = @light.speed
  1021.     @variance = 0.0
  1022.     @light.opacity_duration = 0
  1023.     @light.opacity_target   = 0
  1024.   end
  1025.   #--------------------------------------------------------------------------
  1026.   # * width
  1027.   #--------------------------------------------------------------------------
  1028.   def width
  1029.     @bitmap.width * @light.zoom / 100.0
  1030.   end
  1031.   #--------------------------------------------------------------------------
  1032.   # * height
  1033.   #--------------------------------------------------------------------------
  1034.   def height
  1035.     @bitmap.height * @light.zoom / 100.0
  1036.   end
  1037.   #--------------------------------------------------------------------------
  1038.   # * update
  1039.   #--------------------------------------------------------------------------
  1040.   def update
  1041.     update_position
  1042.     update_opacity
  1043.     update_variance
  1044.   end
  1045.   #--------------------------------------------------------------------------
  1046.   # * update_position
  1047.   #--------------------------------------------------------------------------
  1048.   def update_position
  1049.     @target.is_a?(Game_Character) ? character_position : map_position
  1050.   end
  1051.   #--------------------------------------------------------------------------
  1052.   # * character_position
  1053.   #--------------------------------------------------------------------------
  1054.   def character_position
  1055.     @x = $game_map.adjust_x(@target.real_x) * 32  - width / 2  + @light.x + 16
  1056.     @y = $game_map.adjust_y(@target.real_y) * 32  - height / 2 + @light.y + 16
  1057.   end
  1058.   #--------------------------------------------------------------------------
  1059.   # * map_position
  1060.   #--------------------------------------------------------------------------
  1061.   def map_position
  1062.     @x = $game_map.adjust_x(@target[:x]) * 32 - width / 2  + @light.x + 16
  1063.     @y = $game_map.adjust_y(@target[:y]) * 32 - height / 2 + @light.y + 16
  1064.   end
  1065.   #--------------------------------------------------------------------------
  1066.   # * change_opacity
  1067.   #--------------------------------------------------------------------------
  1068.   def change_opacity(op, d)
  1069.     @light.opacity_target   = op
  1070.     @light.opacity_duration = [d, 0].max
  1071.     @light.opacity = @light.opacity_target if @light.opacity_duration == 0
  1072.   end
  1073.   #--------------------------------------------------------------------------
  1074.   # * update_opacity
  1075.   #--------------------------------------------------------------------------
  1076.   def update_opacity
  1077.     return if @light.opacity_duration == 0
  1078.     d = @light.opacity_duration
  1079.     @light.opacity = (@light.opacity * (d - 1) + @light.opacity_target) / d
  1080.     @light.opacity_duration -= 1
  1081.   end
  1082.   #--------------------------------------------------------------------------
  1083.   # * update_variance
  1084.   #--------------------------------------------------------------------------
  1085.   def update_variance
  1086.     @variance += @speed
  1087.     @speed *= -1 if @variance.abs > @light.variance.abs
  1088.     @opacity = [[@light.opacity + @variance, 0].max, 255].min
  1089.   end
  1090.   #--------------------------------------------------------------------------
  1091.   # * dispose
  1092.   #--------------------------------------------------------------------------
  1093.   def dispose
  1094.     @bitmap.dispose
  1095.   end
  1096.   #--------------------------------------------------------------------------
  1097.   # * set_target
  1098.   #--------------------------------------------------------------------------
  1099.   def set_target
  1100.     if @light.info.keys.include?(:actor)
  1101.       target = $game_map.actors[@light.info[:actor] - 1]
  1102.     elsif @light.info.keys.include?(:event)
  1103.       target = $game_map.events[@light.info[:event]]
  1104.     elsif @light.info.keys.include?(:vehicle)
  1105.       target = $game_map.vehicles[@light.info[:vehicle]]
  1106.     else
  1107.       target = @light.info
  1108.     end
  1109.     target
  1110.   end
  1111. end
  1112.  
  1113. #==============================================================================
  1114. # ** Sprite_Light
  1115. #------------------------------------------------------------------------------
  1116. #  This sprite is used to display the light effects
  1117. #==============================================================================
  1118.  
  1119. class Sprite_Light < Sprite_Base
  1120.   #--------------------------------------------------------------------------
  1121.   # * Public Instance Variables
  1122.   #--------------------------------------------------------------------------
  1123.   attr_reader :lights
  1124.   #--------------------------------------------------------------------------
  1125.   # * initialize
  1126.   #--------------------------------------------------------------------------
  1127.   def initialize(shade, viewport)
  1128.     super(viewport)
  1129.     @shade = shade
  1130.     self.bitmap     = Bitmap.new(Graphics.width, Graphics.height)
  1131.     self.blend_type = @shade.blend
  1132.     self.opacity    = @shade.opacity
  1133.     self.z = 100
  1134.     @lights = {}
  1135.   end
  1136.   #--------------------------------------------------------------------------
  1137.   # * map_x
  1138.   #--------------------------------------------------------------------------
  1139.   def map_x
  1140.     $game_map.adjust_x($game_map.display_x)
  1141.   end
  1142.   #--------------------------------------------------------------------------
  1143.   # * map_y
  1144.   #--------------------------------------------------------------------------
  1145.   def map_y
  1146.     $game_map.adjust_y($game_map.display_y)
  1147.   end
  1148.   #--------------------------------------------------------------------------
  1149.   # * update
  1150.   #--------------------------------------------------------------------------
  1151.   def update
  1152.     super
  1153.     self.ox = map_x
  1154.     self.oy = map_y
  1155.     update_opacity
  1156.     update_lights
  1157.   end
  1158.   #--------------------------------------------------------------------------
  1159.   # * update lights
  1160.   #--------------------------------------------------------------------------
  1161.   def update_lights
  1162.     rect = Rect.new(map_x, map_y, Graphics.width, Graphics.height)
  1163.     self.bitmap.fill_rect(rect, color)
  1164.     draw_light_effects
  1165.   end
  1166.   #--------------------------------------------------------------------------
  1167.   # * color
  1168.   #--------------------------------------------------------------------------
  1169.   def color
  1170.     @shade.color
  1171.   end
  1172.   #--------------------------------------------------------------------------
  1173.   # * draw_light_effects
  1174.   #--------------------------------------------------------------------------
  1175.   def draw_light_effects
  1176.     @lights.values.each do |light|
  1177.       light.update
  1178.       next if !on_screen?(light)
  1179.       draw_light(light)
  1180.     end
  1181.   end
  1182.   #--------------------------------------------------------------------------
  1183.   # * on_sceen?
  1184.   #--------------------------------------------------------------------------
  1185.   def on_screen?(light)
  1186.     ax1 = light.x
  1187.     ay1 = light.y
  1188.     ax2 = light.x + light.width
  1189.     ay2 = light.y + light.height
  1190.     bx1 = map_x
  1191.     by1 = map_y
  1192.     bx2 = map_x + Graphics.width
  1193.     by2 = map_y + Graphics.height
  1194.     check1 = ax1.between?(bx1, bx2) || ax2.between?(bx1, bx2) ||
  1195.              ax1 < bx1 && ax2 > bx2
  1196.     check2 = ay1.between?(by1, by2) || ay2.between?(by1, by2) ||
  1197.              ay1 < by1 && ay2 > by2
  1198.     check1 && check2
  1199.   end
  1200.   #--------------------------------------------------------------------------
  1201.   # * draw_light
  1202.   #--------------------------------------------------------------------------
  1203.   def draw_light(light)
  1204.     img  = light.bitmap
  1205.     rect = Rect.new(light.x, light.y, light.width, light.height)
  1206.     self.bitmap.stretch_blt(rect, img, img.rect, light.opacity)
  1207.   end
  1208.   #--------------------------------------------------------------------------
  1209.   # * update_opacity
  1210.   #--------------------------------------------------------------------------
  1211.   def update_opacity
  1212.     @shade.update
  1213.     self.opacity    = @shade.opacity
  1214.     self.blend_type = @shade.blend
  1215.   end
  1216.   #--------------------------------------------------------------------------
  1217.   # * create_light
  1218.   #--------------------------------------------------------------------------
  1219.   def create_light(light)
  1220.     remove_light(light.id)
  1221.     @lights[light.id] = Game_LightBitmap.new(light)
  1222.   end
  1223.   #--------------------------------------------------------------------------
  1224.   # * remove_light
  1225.   #--------------------------------------------------------------------------
  1226.   def remove_light(id)
  1227.     @lights.delete(id) if @lights[id]
  1228.   end
  1229.   #--------------------------------------------------------------------------
  1230.   # * dispose
  1231.   #--------------------------------------------------------------------------
  1232.   def dispose
  1233.     super
  1234.     @lights.values.each {|light| light.dispose unless light.bitmap.disposed? }
  1235.   end
  1236. end
plutrie7
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-17 00:00

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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