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

Project1

 找回密码
 注册会员
搜索
Project1 查看内容

烛光系统 (共4种不同的版本)

2007-10-8 23:35| 发布者: 柳柳| 查看: 5452| 评论: 0|原作者: 亿万星辰,柳柳,蓝蓝小雪

摘要:   作者 亿万星辰,柳柳,蓝蓝小雪 版本 相关网址 点此进入讨论贴1 点击进入讨论贴2 点击进入讨论贴3 范例工程  见上面的汇或具体内容   具体内容    教学1
 

作者

亿万星辰,柳柳,蓝蓝小雪

版本

相关网址

点此进入讨论贴1

点击进入讨论贴2

点击进入讨论贴3

范例工程

 见上面的汇或具体内容


 

具体内容

 

 教学1:Astory 漆黑世界


素材包:http://bbs.66rpg.com/UP_PIC/200710/AStory_Torch_Res.rar

首先把素材包中的图片放到Graphics\Pictures\System中,然后插入以下脚本,注意修改其中43为火把物品编号。以后进入漆黑世界只要用事件-脚本:
$game_system.dark_place=true
$game_system.torch_icon=false
$game_system.torch_keep=false
就可以了,退出漆黑模式,只需用事件-脚本:
$game_system.dark_place=false
$scene=Scene_Map.new
再加上一个更改画面色调(0,0,0,0,@10)就可以了。

主脚本:
#==============================================================================
# 66RPG 制作 AStory 的漆黑世界效果 by 蓝蓝小雪 sunnyboy8888888#163.com
# 以下脚本来自于 AStory,但已经经过蓝蓝小雪的 N (N>100) 处修改,请尊重他人的劳动成果。
#==============================================================================

#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
#  在没有存档的情况下,处理临时数据的类。这个类的实例请参考
# $game_temp 。
#==============================================================================

class Game_Temp
 attr_accessor :torch_help_demo          # ★ たいまつ説明中フラグ
 attr_accessor :torch_help_icon          # ★ たいまつ説明用アイコンフラグ
 attr_accessor :torch_transition         # ★ たいまつトランジション用フラグ
 attr_accessor :torch_setup              # ★ たいまつセットアップフラグ
 attr_accessor :torch_icon_flash         # ★ たいまつアイコンフラッシュフラグ
 alias torch_initialize initialize
 def initialize
   torch_initialize
   @torch_help_demo = 0
   @torch_help_icon = 0
   @torch_transition = false
   @torch_setup = false
   @torch_icon_flash = 0
 end
end

#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
#  处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
# $game_system 。
#==============================================================================

class Game_System
 attr_accessor :torch_help_flags         # ★ たいまつ説明完了フラグ
 attr_accessor :torch_count              # ★ たいまつカウント
 attr_accessor :torch_brightness         # ★ たいまつ明るさ
 attr_accessor :torch_keep               # ★ たいまつ明るさ保持フラグ
 attr_accessor :dark_place
 attr_accessor :torch_event
 attr_accessor :torch_icon
 alias torch_initialize initialize
 def initialize
   torch_initialize
   @torch_help_flags = true
   @torch_count = 0
   @torch_brightness = 0
   @torch_keep = false
   @dark_place = false
   @torch_event = false
   @torch_icon = false
 end
end

#==============================================================================
# ■ Sprite_Torch
#------------------------------------------------------------------------------
#  たいまつの処理を行うクラスです。
#==============================================================================

class Sprite_Torch < Sprite
 #--------------------------------------------------------------------------
 # ● オブジェクト初期化
 #     viewport : ビューポート
 #--------------------------------------------------------------------------
 def initialize(viewport)
   super(viewport)
   @light = Sprite.new
   @light.bitmap = RPG::Cache.picture("System/Torch-Base02")
   @light.opacity = 0
   @light.visible = false
   @base = Sprite.new
   @base.bitmap = RPG::Cache.picture("System/Torch-Base01")
   @base.visible = false
   @opacity = [0, 128, 144, 160, 192]
   @counts = [0, 600, 1200, 1800]
   @count = $game_system.torch_count
   @brightness = $game_system.torch_brightness
   @turn = 0
   @fade = false
   @start = false
   @reset = false
   if $game_system.dark_place and $game_system.torch_keep
     unless $game_system.torch_event
       setup_torch
     end
     @light.opacity = @opacity[@brightness]
     $game_system.torch_keep = false
   end
 end
 #--------------------------------------------------------------------------
 # ● 解放
 #--------------------------------------------------------------------------
 def dispose
   @light.dispose
   @base.dispose
   super
 end
 #--------------------------------------------------------------------------
 # ● フレーム更新
 #--------------------------------------------------------------------------
 def update
   super
   if $game_system.dark_place
     # イベント用たいまつモード
     if $game_system.torch_event
       transition
       unless @start
         reset_torch
         setup_event
         @start = true
       end
       @turn += 1
       if @turn < 5
         @light.zoom_x -= 0.3
         @light.zoom_y -= 0.3
       elsif @turn >= 5 and @turn < 10
         @light.zoom_x += 0.3
         @light.zoom_y += 0.3
       else
         @light.zoom_x = 12
         @light.zoom_y = 12
         @turn = 0
       end
     @light.x = 320 - 80 * @light.zoom_x
     @light.y = 240 - 80 * @light.zoom_y
     # 通常たいまつモード
     else
       transition
       unless @start
         @start = true
         @base.visible = true
         @light.visible = true
       end
       if $game_temp.torch_setup
         $game_temp.torch_setup = false
         tone_change
         setup_torch
       end
       # 説明デモ
       if @count == @counts[0] or $game_temp.torch_help_demo == 4
         @brightness = 0
         tone_change
         @fade = true
       elsif @count == @counts[1] or $game_temp.torch_help_demo == 3
         @brightness = 1
         tone_change
         @fade = true
       elsif @count == @counts[2] or $game_temp.torch_help_demo == 2
         @brightness = 2
         tone_change
         @fade = true
       elsif @count == @counts[3] or $game_temp.torch_help_demo == 1
         @brightness = 3
         tone_change
         @fade = true
       end
       # 場所移動時のフェードアウト
       unless @start or $game_temp.transition_processing
         @start = true
         $game_screen.start_tone_change(Tone.new(-96, -96, -96), 0)
       end
       # カウント進行
       unless $game_system.torch_keep or $game_system.torch_icon or
             $game_temp.message_window_showing or $game_temp.torch_transition
         @count -= 1
       end
       # 揺らぎ処理
       if @light.opacity > @opacity[@brightness]
         @light.opacity -= 4
       end
       if @fade
         brightness_change
       else
         @turn += 1
         if @turn < 5
           @light.zoom_x -= @brightness * 0.1
           @light.zoom_y -= @brightness * 0.1
         elsif @turn >= 5 and @turn < 10
           @light.zoom_x += @brightness * 0.1
           @light.zoom_y += @brightness * 0.1
         else
           @light.zoom_x = zoom * 2
           @light.zoom_y = zoom * 2
           @turn = 0
         end
       end
       @base.x = $game_player.screen_x - 640 * @base.zoom_x
       @base.y = $game_player.screen_y - 16 - 480 * @base.zoom_y
       @light.x = $game_player.screen_x - 80 * @light.zoom_x
       @light.y = $game_player.screen_y - 16 - 80 * @light.zoom_y
       # カウント・明るさを記憶
       $game_system.torch_count = @count
       $game_system.torch_brightness = @brightness
     end
   # 通常マップ
   else
     # カウント・明るさをリセット
     if not @reset
       reset_torch
     end
   end
 end
 #--------------------------------------------------------------------------
 # ● 拡大率
 #--------------------------------------------------------------------------
 def zoom
   return @brightness + 1
 end
 #--------------------------------------------------------------------------
 # ● 場所移動時のフェード調整
 #--------------------------------------------------------------------------
 def transition
   if $game_temp.torch_transition
     @light.opacity -= 8 if @light.opacity > 0
   else
     @light.opacity += 8 if @light.opacity < @opacity[@brightness]
   end
 end
 #--------------------------------------------------------------------------
 # ● イベントたいまつセットアップ
 #--------------------------------------------------------------------------
 def setup_event
   @brightness = 4
   $game_system.torch_brightness = @brightness
   @light.zoom_x = 12
   @light.zoom_y = 12
   @light.x = 320 - 80 * @light.zoom_x
   @light.y = 240 - 80 * @light.zoom_y
   @base.zoom_x = 6
   @base.zoom_y = 6
   @base.x = 320 - 640 * @base.zoom_x
   @base.y = 240 - 480 * @base.zoom_y
   @base.visible = true
   @light.visible = true
   tone_change
   @turn = 0
 end
 #--------------------------------------------------------------------------
 # ● 画面切り替えからの復帰
 #--------------------------------------------------------------------------
 def setup_torch
   @base.zoom_x = zoom
   @base.zoom_y = zoom
   @light.zoom_x = zoom * 2
   @light.zoom_y = zoom * 2
   @base.visible = true
   @light.visible = true
   tone_change
   @turn = 0
 end
 #--------------------------------------------------------------------------
 # ● たいまつリセット
 #--------------------------------------------------------------------------
 def reset_torch
   $game_system.torch_count = 0
   $game_system.torch_brightness = 0
   @count = 0
   @brightness = 0
   @turn = 0
   @start = false
   @reset = true
 end
 #--------------------------------------------------------------------------
 # ● 画面色調切り替え
 #--------------------------------------------------------------------------
 def tone_change
   time = $game_system.torch_keep ? 0 : 15
   case @brightness
   when 0
     $game_screen.start_tone_change(Tone.new(-96, -96, -96), time)
   when 1
     $game_screen.start_tone_change(Tone.new(-64, -64, -64), time)
   when 2
     $game_screen.start_tone_change(Tone.new(-48, -48, -48), time)
   else
     $game_screen.start_tone_change(Tone.new(-32, -32, -32), time)
   end
   $game_temp.torch_transition = false
 end
 #--------------------------------------------------------------------------
 # ● 明るさ切り替え
 #--------------------------------------------------------------------------
 def brightness_change
   if @brightness == 0
     @base.zoom_x -= zoom * 0.02
     @base.zoom_y -= zoom * 0.02
     @light.zoom_x -= zoom * 0.04
     @light.zoom_y -= zoom * 0.04
     if @base.zoom_x <= zoom and @base.zoom_y <= zoom and
         @light.zoom_x <= zoom * 2 and @light.zoom_y <= zoom * 2
       @base.zoom_x = zoom
       @base.zoom_y = zoom
       @light.zoom_x = zoom * 2
       @light.zoom_y = zoom * 2
       @light.opacity = 0
       @fade = false
     end
   elsif @brightness < 3
     @base.zoom_x -= zoom * 0.01
     @base.zoom_y -= zoom * 0.01
     @light.zoom_x -= zoom * 0.02
     @light.zoom_y -= zoom * 0.02
     if @base.zoom_x <= zoom and @base.zoom_y <= zoom and
         @light.zoom_x <= zoom * 2 and @light.zoom_y <= zoom * 2
       @base.zoom_x = zoom
       @base.zoom_y = zoom
       @light.zoom_x = zoom * 2
       @light.zoom_y = zoom * 2
       @fade = false
     end
   else
     @base.zoom_x += zoom * 0.025
     @base.zoom_y += zoom * 0.025
     @light.zoom_x += zoom * 0.05
     @light.zoom_y += zoom * 0.05
     if @base.zoom_x >= zoom and @base.zoom_y >= zoom and
         @light.zoom_x >= zoom * 2 and @light.zoom_y >= zoom * 2
       @base.zoom_x = zoom
       @base.zoom_y = zoom
       @light.zoom_x = zoom * 2
       @light.zoom_y = zoom * 2
       @turn = 0
       @fade = false
     end
   end
 end
 #--------------------------------------------------------------------------
 # ● たいまつ使用
 #--------------------------------------------------------------------------
 def torch_set
   @brightness = 3
   @count = @counts[@brightness]
   tone_change
   @fade = true
 end
end

#==============================================================================
# ■ Window_Icon
#------------------------------------------------------------------------------
#  システムアイコンを表示するウィンドウです。
#  関連セクション:Scene_Map
#==============================================================================

class Window_Icon < Window_Base
 #--------------------------------------------------------------------------
 # ● オブジェクト初期化
 #--------------------------------------------------------------------------
 def initialize
   super(400-16, 0-16, 240, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.visible = false
   self.opacity=0
   self.back_opacity =255
   self.z = 500
   refresh
 end
 #--------------------------------------------------------------------------
 # ● リフレッシュ
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   if $game_system.dark_place
     # マジックトーチ
     @number = $game_party.item_number(43)
     @opacity = @number > 0 ? 255 : 160
     @icon1 = RPG::Cache.picture("System/Torch-Icon-Normal")
     if $game_party.item_number(43) > 0
       if $game_temp.torch_icon_flash > 0
         #@icon2 = RPG::Cache.picture("System/Torch-Icon-Flash02")
       else
         #@icon2 = RPG::Cache.picture("System/Torch-Icon-Command")
       end
     else
       if $game_temp.torch_icon_flash > 0
         #@icon2 = RPG::Cache.picture("System/Torch-Icon-Flash01")
       else
         @icon2 = nil
       end
     end
     icon_blt
     torch_number
   end
 end
 #--------------------------------------------------------------------------
 # ● アイコン画像表示
 #--------------------------------------------------------------------------
 def icon_blt
   if @icon1 != nil
     @icon1_rect = Rect.new(0, 0, @icon1.width, @icon1.height)
     self.contents.blt(self.width - @icon1.width - 32, 0, @icon1, @icon1_rect, @opacity)
   end
   if @icon2 != nil
     @icon2_rect = Rect.new(0, 0, @icon2.width, @icon2.height)
     self.contents.blt(self.width - @icon2.width - 32, 0, @icon2, @icon2_rect)
   end
 end
 #--------------------------------------------------------------------------
 # ● たいまつ個数表示
 #--------------------------------------------------------------------------
 def torch_number
   self.contents.font.size = 12
   self.contents.font.color = @number > 0 ? normal_color : disabled_color
   self.contents.draw_text(118, 28, 26, 24, @number.to_s, 1)
 end
 #--------------------------------------------------------------------------
 # ● たいまつ使用時
 #--------------------------------------------------------------------------
 def icon_flash
   $game_temp.torch_icon_flash = 10
   refresh
 end
 #--------------------------------------------------------------------------
 # ● フレーム更新
 #--------------------------------------------------------------------------
 def update
   super
   if $game_system.dark_place
     if $game_temp.torch_transition
       self.visible = false
     else
       self.visible = true
       refresh
     end
     if $game_system.torch_event or
         $game_system.torch_icon or $game_system.torch_keep
       self.visible = false
     end
   end
 end
end

#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  处理地图画面的类。(火把专用)
#==============================================================================

class Scene_Map
 attr_accessor :spriteset
 def initialize
   @torch_index = 0
 end
 def main
   # スプライトセットを作成
   @spriteset = Spriteset_Map.new
   # メッセージウィンドウを作成
   @message_window = Window_Message.new
   # ★ アイコンウィンドウを作成
   @icon_window = Window_Icon.new
   # トランジション実行
   Graphics.transition
   # メインループ
   loop do
     # ゲーム画面を更新
     Graphics.update
     # 入力情報を更新
     Input.update
     # フレーム更新
     update
     # 画面が切り替わったらループを中断
     if $scene != self
       # ★ たいまつカウントストップフラグを設定
       $game_system.torch_keep = true
       break
     end
   end
   # トランジション準備
   Graphics.freeze
   # スプライトセットを解放
   @spriteset.dispose
   # ★ アイコンウィンドウを解放
   @icon_window.dispose
   # メッセージウィンドウを解放
   @message_window.dispose
   # タイトル画面に切り替え中の場合
   if $scene.is_a?(Scene_Title)
     # 画面をフェードアウト
     Graphics.transition
     Graphics.freeze
   end
 end
 def update
   # 循环
   loop do
     # 按照地图、实例、主角的顺序刷新
     # (本更新顺序不会在的满足事件的执行条件下成为给予角色瞬间移动
     #  的机会的重要因素)
     $game_map.update
     $game_system.map_interpreter.update
     $game_player.update
     # 系统 (计时器)、画面刷新
     $game_system.update
     $game_screen.update
     # 如果主角在场所移动中就中断循环
     unless $game_temp.player_transferring
       break
     end
     # 执行场所移动
     transfer_player
     # 处理过渡中的情况下、中断循环
     if $game_temp.transition_processing
       break
     end
   end
   # 刷新活动块
   @spriteset.update
   if $game_system.dark_place
     @icon_window.update
   end
   # 刷新信息窗口
   @message_window.update
   # 游戏结束的情况下
   if $game_temp.gameover
     # 切换的游戏结束画面
     $scene = Scene_Gameover.new
     return
   end
   # 返回标题画面的情况下
   if $game_temp.to_title
     # 切换到标题画面
     $scene = Scene_Title.new
     return
   end
   # 处理过渡中的情况下
   if $game_temp.transition_processing
     # 清除过渡处理中标志
     $game_temp.transition_processing = false
     # 执行过渡
     if $game_temp.transition_name == ""
       Graphics.transition(20)
     else
       Graphics.transition(40, "Graphics/Transitions/" +
         $game_temp.transition_name)
     end
   end
   # 显示信息窗口中的情况下
   if $game_temp.message_window_showing
     return
   end
   # 遇敌计数为 0 且、且遇敌列表不为空的情况下
   if $game_player.encounter_count == 0 and $game_map.encounter_list != []
     # 不是在事件执行中或者禁止遇敌中
     unless $game_system.map_interpreter.running? or
            $game_system.encounter_disabled
       # 确定队伍
       n = rand($game_map.encounter_list.size)
       troop_id = $game_map.encounter_list[n]
       # 队伍有效的话
       if $data_troops[troop_id] != nil
         # 设置调用战斗标志
         $game_temp.battle_calling = true
         $game_temp.battle_troop_id = troop_id
         $game_temp.battle_can_escape = true
         $game_temp.battle_can_lose = false
         $game_temp.battle_proc = nil
       end
     end
   end
   if $game_system.dark_place and $game_system.torch_help_flags
     unless $game_temp.message_window_showing or
           $game_system.torch_event
       update_torch
     end
   end
   # 按下 B 键的情况下
   if Input.trigger?(Input::B)
     # 不是在事件执行中或菜单禁止中
     unless $game_system.map_interpreter.running? or
            $game_system.menu_disabled
       # 设置菜单调用标志以及 SE 演奏
       $game_temp.menu_calling = true
       $game_temp.menu_beep = true
     end
   end
   # 调试模式为 ON 并且按下 F9 键的情况下
   if $DEBUG and Input.press?(Input::F9)
     # 设置调用调试标志
     $game_temp.debug_calling = true
   end
   # 不在主角移动中的情况下
   unless $game_player.moving?
     # 执行各种画面的调用
     if $game_temp.battle_calling
       call_battle
     elsif $game_temp.shop_calling
       call_shop
     elsif $game_temp.name_calling
       call_name
     elsif $game_temp.menu_calling
       call_menu
     elsif $game_temp.save_calling
       call_save
     elsif $game_temp.debug_calling
       call_debug
     end
   end
 end
 #--------------------------------------------------------------------------
 # ★ フレーム更新(たいまつ使用マップ)
 #--------------------------------------------------------------------------
 def update_torch
   # ★ たいまつアイコンのフラッシュ解除
   if $game_temp.torch_icon_flash > 1
     $game_temp.torch_icon_flash -= 1
   elsif $game_temp.torch_icon_flash == 1
     $game_temp.torch_icon_flash = 0
     @icon


鲜花

刚表态过的朋友 (0 人)

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