356 lines
13 KiB
Ruby
356 lines
13 KiB
Ruby
#==============================================================================
|
||
# ■ 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
|