lunariafantasia/Scripts/_.147.rb
2024-01-12 03:12:38 -06:00

356 lines
13 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#==============================================================================
# ■ Sprite_Timer
#------------------------------------------------------------------------------
#  タイマー表示用のスプライトです。$game_timer を監視し、スプライトの状態を
# 自動的に変化させます。
#==============================================================================
class Sprite_Count < Sprite
#--------------------------------------------------------------------------
# オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
create_bitmap
update
end
#--------------------------------------------------------------------------
# 解放
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# ビットマップの作成
#--------------------------------------------------------------------------
def create_bitmap
self.bitmap = Bitmap.new(128, 48)
self.bitmap.font.size = 32
self.bitmap.font.color.set(255, 255, 255)
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
def update
super
update_bitmap
update_position
update_visibility
end
#--------------------------------------------------------------------------
# 転送元ビットマップの更新
#--------------------------------------------------------------------------
def update_bitmap
if $game_temp.counter? && $game_variables[19] != $game_temp.before_count
$game_temp.before_count = $game_variables[19]
redraw
end
end
#--------------------------------------------------------------------------
# 再描画
#--------------------------------------------------------------------------
def redraw
self.bitmap.clear
color = Color.new(0, 0, 0, 192)
ad = 4
self.bitmap.fill_rect(ad, ad, self.bitmap.width - ad * 2, self.bitmap.height - ad * 2, color)
self.bitmap.draw_text(self.bitmap.rect, count_text, 1)
end
#--------------------------------------------------------------------------
# 描画用テキストの作成
#--------------------------------------------------------------------------
def count_text
sprintf("注文 %02d/%02d", $game_variables[19], $game_temp.counter)
end
#--------------------------------------------------------------------------
# 位置の更新
#--------------------------------------------------------------------------
def update_position
self.x = 0 #Graphics.width - self.bitmap.width
self.y = 0
self.z = 200
end
#--------------------------------------------------------------------------
# 可視状態の更新
#--------------------------------------------------------------------------
def update_visibility
self.visible = ($game_temp.counter? && !$game_system.h_event)
end
end
#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
#  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
# スタンスは $game_temp で参照されます。
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :counter #
attr_accessor :before_count #
attr_accessor :shot_counter #
attr_accessor :before_shot_count #
attr_accessor :final_shot #
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias excount_initialize initialize
def initialize
excount_initialize
counter_init
shot_init
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def counter?
@counter > 0
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def counter_init
@counter = 0
@before_count = 0
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def counter_start(c)
@counter = c
@before_count = -1
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def shot_counter?
@shot_counter > 0
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def shot_init
@shot_counter = 0
@before_shot_count = 0
@final_shot = false
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def shot_counter_start(c, flag = true)
@shot_counter = c + 1
@before_shot_count = 0
@final_shot = flag
end
end
#==============================================================================
# ■ Sprite_Timer
#------------------------------------------------------------------------------
#  タイマー表示用のスプライトです。$game_timer を監視し、スプライトの状態を
# 自動的に変化させます。
#==============================================================================
class Sprite_ShotCount < Sprite
#--------------------------------------------------------------------------
# オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(window)
super(window.viewport)
@message_window = window
create_bitmap
update
end
#--------------------------------------------------------------------------
# 解放
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# ビットマップの作成
#--------------------------------------------------------------------------
def create_bitmap
self.bitmap = Bitmap.new(64, 32)
self.bitmap.font.size = 24
self.bitmap.font.color.set(255, 255, 255)
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
def font_color_set
if $game_temp.final_shot
self.bitmap.font.color.set(255, 204, 0)
else
self.bitmap.font.color.set(255, 255, 255)
end
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
def update
super
update_bitmap
update_position
update_visibility
end
#--------------------------------------------------------------------------
# 転送元ビットマップの更新
#--------------------------------------------------------------------------
def update_bitmap
if $game_temp.shot_counter? && $game_temp.shot_counter != $game_temp.before_shot_count
$game_temp.before_shot_count = $game_temp.shot_counter
redraw
end
end
#--------------------------------------------------------------------------
# 再描画
#--------------------------------------------------------------------------
def redraw
self.bitmap.clear
op = [32 * ($game_variables[Option::H_Opacity] - 1), 255].min
color = Color.new(0, 0, 0, op)
ad = 4
font_color_set
self.bitmap.fill_rect(ad, ad, self.bitmap.width - ad * 2, self.bitmap.height - ad * 2, color)
self.bitmap.draw_text(self.bitmap.rect, count_text, 1)
end
#--------------------------------------------------------------------------
# 描画用テキストの作成
#--------------------------------------------------------------------------
def count_text
sprintf(" %02d ", $game_temp.shot_counter)
end
#--------------------------------------------------------------------------
# 位置の更新
#--------------------------------------------------------------------------
def update_position
self.x = @message_window.width - self.bitmap.width - 4
self.y = @message_window.y - self.bitmap.height
self.z = @message_window.z + 1
end
#--------------------------------------------------------------------------
# 可視状態の更新
#--------------------------------------------------------------------------
def update_visibility
self.visible = $game_temp.shot_counter? && sprite_visibility && $game_system.h_event && visible_window
end
#--------------------------------------------------------------------------
# 可視状態の更新
#--------------------------------------------------------------------------
def sprite_visibility
$game_temp.shot_counter < $game_variables[Option::EXH_SHOT]
=begin
case $game_variables[Option::EXH_SHOT]
when 1 ; $game_temp.shot_counter < 9
when 2 ; $game_temp.shot_counter < 6
when 3 ; $game_temp.shot_counter < 4
else ; false
end
=end
end
#--------------------------------------------------------------------------
# 可視状態の更新
#--------------------------------------------------------------------------
def visible_window
@message_window.count_sprite_visible
end
end
#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
#  マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは
# Scene_Map クラスの内部で使用されます。
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● タイマースプライトの作成
#--------------------------------------------------------------------------
alias count_plus_create_timer create_timer
def create_timer
count_plus_create_timer
@counter_sprite = Sprite_Count.new(@viewport2)
#@shot_sprite = Sprite_ShotCount.new(@viewport2)
end
#--------------------------------------------------------------------------
# ● タイマースプライトの解放
#--------------------------------------------------------------------------
alias count_plus_dispose_timer dispose_timer
def dispose_timer
count_plus_dispose_timer
@counter_sprite.dispose
#@shot_sprite.dispose
end
#--------------------------------------------------------------------------
# ● タイマースプライトの更新
#--------------------------------------------------------------------------
alias count_plus_update_timer update_timer
def update_timer
count_plus_update_timer
@counter_sprite.update
#@shot_sprite.update
end
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
#  文章表示に使うメッセージウィンドウです。
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# オブジェクト初期化
#--------------------------------------------------------------------------
alias count_initialize initialize
def initialize
count_initialize
@count_sprite = Sprite_ShotCount.new(self)
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
alias count_update update
def update
count_update
@count_sprite.update
end
#--------------------------------------------------------------------------
#
#--------------------------------------------------------------------------
alias count_dispose dispose
def dispose
@count_sprite.dispose
count_dispose
end
#--------------------------------------------------------------------------
# スプライトの可視状態
#--------------------------------------------------------------------------
def count_sprite_visible
visible && open?
end
#--------------------------------------------------------------------------
# 改ページ処理
#--------------------------------------------------------------------------
alias count_new_page new_page
def new_page(text, pos)
count_new_page(text, pos)
$game_temp.shot_counter -= 1 if $game_temp.shot_counter? && $game_system.h_event
end
end