赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 2 |
经验 | 925 |
最后登录 | 2019-6-10 |
在线时间 | 14 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 180
- 在线时间
- 14 小时
- 注册时间
- 2017-6-9
- 帖子
- 29
|
8楼
楼主 |
发表于 2017-7-3 20:54:33
|
只看该作者
■ Damage Sprite
#==============================================================================
class Damage_Sprite < Sprite
include MOG_DAMAGEPOPUP
attr_accessor :duration
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil , x,y, value ,index,index_max,target)
super(viewport)
dispose_damage ; setup_base(value,x,y,index,index_max,target) ; create_sprites
end
#--------------------------------------------------------------------------
# ● Setup Base
#--------------------------------------------------------------------------
def setup_base(value,x,y,index,index_max,target)
@target = target ; y2 = 0
if @target.bitmap != nil ; y2 = SceneManager.scene_is?(Scene_Battle) ? @target.bitmap.height / 2 : 0 ; end
@animation_type = 0 ; @index = index ; @index_max = index_max + 1
@image = $game_temp.pre_cache_damage ; self.z = index + DAMAGE_Z
@cw = @image[0].width / 10 ; @ch = @image[0].height / 2 ; @cw2 = 0
@x = x ; @y = y - y2 ; @value = value[0] ; @type = value[1] ; @ch2 = 0
@critical = (value[2] and @value.to_i >= 0) ? true : false; self.opacity = 0
@state_index = value[3] ; @oxy = [0,0,0,0] ; @org_xy = [0,0] ; @spxy = [0,0]
@duration = 92 ; @org_oxy = [0,0,0,0]
self.visible = false ;set_initial_position(index,nil)
end
#--------------------------------------------------------------------------
# ● Set Duration
#--------------------------------------------------------------------------
def set_duration(index,pre_index = nil)
return if @duration != 0
@duration = 82 + (2 * index) if @animation_type == 0
end
#--------------------------------------------------------------------------
# ● Set Initial Position
#--------------------------------------------------------------------------
def set_initial_position(index,old_duration)
@org_xy = [@x,@y]
self.zoom_y = self.zoom_x
end
#--------------------------------------------------------------------------
# ● Dispose Damage
#--------------------------------------------------------------------------
def dispose_damage
(self.bitmap.dispose ; self.bitmap = nil) if self.bitmap
(@sup_sprite.bitmap.dispose ; @sup_sprite.dispose) if @sup_sprite
@duration = -1
end
#--------------------------------------------------------------------------
# ● Create Sprites
#--------------------------------------------------------------------------
def create_sprites
if @value.is_a?(Numeric)
create_number
elsif ["Missed","Evaded","Level UP","Counter","Reflection"].include?(@value.to_s)
create_miss
else
create_string
end
set_damage_position
end
#--------------------------------------------------------------------------
# ● Set Damage Position
#--------------------------------------------------------------------------
def set_damage_position
return if self.bitmap == nil
self.ox = (self.bitmap.width - @cw2) / 2
self.oy = self.bitmap.height / 2 ; self.x = @x ; self.y = @y
@org_oxy[0] = self.ox
@org_oxy[1] = self.oy
set_animation_type
if @sup_sprite
@sup_sprite.ox = self.bitmap.width / 2 ;
@sup_sprite.oy = self.bitmap.height / 2
@org_oxy[2] = @sup_sprite.ox
@org_oxy[3] = @sup_sprite.oy
if @critical
@sup_sprite.x = @x - (@sup_sprite.bitmap.width / 2) + ((@cw / 2) * @number_value.size)
@sup_sprite.y = self.y
end
update_sup_position(@index_max - @index)
end
end
#--------------------------------------------------------------------------
# ● Set Damage Position
#--------------------------------------------------------------------------
def set_animation_type
s = rand(2) ; s2 = (rand(10) * 0.1).round(2)
@oxy[2] = s == 1 ? s2 : -s2
end
#--------------------------------------------------------------------------
# ● Create Number
#--------------------------------------------------------------------------
def create_number
case @type
when "MP"
number_image = @image[11] ;h = @value >= 0 ? 0 : @ch ; create_sup_sprite
when "TP"
#number_image = @image[12] ;h = @value >= 0 ? 0 : @ch ; create_sup_sprite
#when "Exp"
#number_image = @image[13] ;h = 0 ; create_sup_sprite
#when "Gold"
number_image = @image[13] ;h = @ch ; create_sup_sprite
else
number_image = @image[0] ; h = @value >= 0 ? 0 : @ch
end
@number_value = @value.abs.truncate.to_s.split(//)
self.bitmap = Bitmap.new(@cw * @number_value.size, @ch)
for r in 0...@number_value.size
number_value_abs = @number_value[r].to_i
src_rect = Rect.new(@cw * number_value_abs, h, @cw, @ch)
self.bitmap.blt(@cw * r, 0, number_image, src_rect)
end
create_sup_sprite if @critical
end
#--------------------------------------------------------------------------
# ● Create Sup Sprite
#--------------------------------------------------------------------------
def create_sup_sprite
return if @sup_sprite != nil
@sup_sprite = Sprite.new ; @sup_sprite.visible = false ; fy = 0 ; sp = [0,0]
if @type == "MP" ; @sup_sprite.bitmap = @image[1].dup
elsif @type == "TP" ; @sup_sprite.bitmap = @image[2].dup
elsif @critical
@sup_sprite.bitmap = @image[5].dup
@cw2 = 0 ; @ch2 = @sup_sprite.bitmap.height
return
elsif @type == "Exp"
@sup_sprite.bitmap = @image[6].dup ; fy = @ch ; sp[1] = 1.0
elsif @type == "Gold"
@sup_sprite.bitmap = @image[7].dup ; fy = (@ch * 2) ; sp[1] = 0.5
end
fy = 0 if !SceneManager.scene_is?(Scene_Battle)
@y += fy ; @org_xy[1] += 0
@cw2 = @sup_sprite.bitmap.width + @cw
@spxy = [sp[0],sp[1]]
end
#--------------------------------------------------------------------------
# ● Update Sup Position
#--------------------------------------------------------------------------
def update_sup_position(dif_y)
@sup_sprite.x = self.x - @cw unless @critical
@sup_sprite.y = @critical ? self.y - @ch2 : self.y
@sup_sprite.opacity = self.opacity ; @sup_sprite.angle = self.angle
@sup_sprite.zoom_x = self.zoom_x ; @sup_sprite.zoom_y = self.zoom_y
@sup_sprite.z = self.z ; @sup_sprite.viewport = self.viewport
@sup_sprite.visible = self.visible
end
#--------------------------------------------------------------------------
# ● Create Miss
#--------------------------------------------------------------------------
def create_miss
self.bitmap = @image[3].dup if @value == "Missed"
self.bitmap = @image[4].dup if @value == "Evaded"
self.bitmap = @image[8].dup if @value == "Level UP"
self.bitmap = @image[9].dup if @value == "Counter"
self.bitmap = @image[10].dup if @value == "Reflection"
end
#--------------------------------------------------------------------------
# ● Create Spring
#--------------------------------------------------------------------------
def create_string
string_size = @value.to_s.split(//) ; fsize = FONT_SIZE > 10 ? FONT_SIZE : 10
@stg_size = string_size.size > 0 ? ((1 + string_size.size ) * ((fsize / 2) - 2)) : 32
self.bitmap = Bitmap.new(@stg_size,32)
self.bitmap.font.color = FONT_COLOR
self.bitmap.font.size = fsize ; self.bitmap.font.bold = FONT_BOLD
self.bitmap.font.italic = FONT_ITALIC
if @type == "Item"
self.bitmap.font.color = FONT_COLOR_ITEM
elsif @type == "States Plus"
self.bitmap.font.color = FONT_COLOR_STATUS_PLUS
elsif @type == "States Minus"
self.bitmap.font.color = FONT_COLOR_STATUS_MINUS
end
self.bitmap.draw_text(0, 0, self.bitmap.width, self.bitmap.height, @value.to_s,0)
draw_states if @state_index != nil
end
#--------------------------------------------------------------------------
# ● Draw States
#--------------------------------------------------------------------------
def draw_states
@sup_sprite = Sprite.new ; @sup_sprite.bitmap = Bitmap.new(24,24)
rect = Rect.new(@state_index % 16 * 24, @state_index / 16 * 24, 24, 24)
@image[14] = Cache.system("Iconset") if @image[14]== nil or @image[14].disposed?
@sup_sprite.bitmap.blt(0, 0, @image[14].dup, rect)
(@org_xy[1] += (@ch + 5) ; @y += (@ch + 5)) unless !SceneManager.is_a?(Scene_Battle)
@cw2 = @sup_sprite.bitmap.width + @cw / 2 ; @sup_sprite.visible = false
end
#--------------------------------------------------------------------------
# ● Update Damage
#--------------------------------------------------------------------------
def update_damage(index_max,index,battler)
@index_max = index_max ; @index = index
return if self.bitmap == nil or self.bitmap.disposed?
@duration -= 1
self.visible = @duration > 90 ? false : true
return if !self.visible
dif_y = (@index_max - @index)
update_animation(dif_y)
update_sprite_position(dif_y,battler)
update_sup_position(dif_y) if @sup_sprite
dispose_damage if @duration <= 0
end
#--------------------------------------------------------------------------
# ● Update Sprite Position
#--------------------------------------------------------------------------
def update_sprite_position(dif_y,battler)
execute_move(0,self,@org_xy[0] + @oxy[0])
execute_move(1,self,@org_xy[1] + @oxy[1] - (dif_y * Y_SPACE))
self.zoom_y = self.zoom_x
update_battle_camera if oxy_camera?(battler)
end
#--------------------------------------------------------------------------
# ● Update Battle Camera
#--------------------------------------------------------------------------
def update_battle_camera
self.ox = $game_temp.viewport_oxy[0] + @org_oxy[0]
self.oy = $game_temp.viewport_oxy[1] + @org_oxy[1]
@sup_sprite.ox = $game_temp.viewport_oxy[0] + @org_oxy[2] if @sup_sprite != nil
@sup_sprite.oy = $game_temp.viewport_oxy[1] + @org_oxy[3] if @sup_sprite != nil
end
#--------------------------------------------------------------------------
# ● OXY_CAMERA
#--------------------------------------------------------------------------
def oxy_camera?(battler)
return false if $imported[:mog_battle_camera] == nil
if battler.is_a?(Game_Actor)
return false if $imported[:mog_battle_hud_ex] and SceneManager.face_battler?
end
return true
end
#--------------------------------------------------------------------------
# ● Execute Move
#--------------------------------------------------------------------------
def execute_move(type,sprite,np)
cp = type == 0 ? sprite.x : sprite.y
sp = 1 + ((cp - np).abs / 10)
sp = 1 if @duration < 60
if cp > np ; cp -= sp ; cp = np if cp < np
elsif cp < np ; cp += sp ; cp = np if cp > np
end
sprite.x = cp if type == 0 ; sprite.y = cp if type == 1
end
#--------------------------------------------------------------------------
# ● Update Animation
#--------------------------------------------------------------------------
def update_animation(dif_y)
@oxy[1] -= 1
case @duration
when 60..90 ; self.opacity += 15
when 30..60 ; self.opacity = 255
when 0..30 ; self.opacity -= 9
end
end
end
#==============================================================================
# ■ Sprite Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● Update Collapse
#--------------------------------------------------------------------------
alias mog_damage_pop_update_collapse update_collapse
def update_collapse
mog_damage_pop_update_collapse
execute_exp_pop
end
#--------------------------------------------------------------------------
# ● Update Instant Collapse
#--------------------------------------------------------------------------
alias mog_damage_pop_update_instant_collapse update_instant_collapse
def update_instant_collapse
mog_damage_pop_update_instant_collapse
execute_exp_pop
end
#--------------------------------------------------------------------------
# ● Update Boss Collapse
#--------------------------------------------------------------------------
alias mog_damage_pop_update_boss_collapse update_boss_collapse
def update_boss_collapse
mog_damage_pop_update_boss_collapse
execute_exp_pop
end
#--------------------------------------------------------------------------
# ● Execute Exp Pop
#--------------------------------------------------------------------------
def execute_exp_pop
return if !MOG_DAMAGEPOPUP::EXP_GOLD_POPUP_BATTLE or @dam_exp != nil
return if @battler == nil or @battler.is_a?(Game_Actor)
@dam_exp = true
if $imported[:mog_active_bonus_gauge] != nil
real_exp = $game_troop.bonus_exp? ? @battler.exp * 2 : @battler.exp
real_gold = $game_troop.bonus_gold? ? @battler.gold * 2 : @battler.gold
else
real_exp = @battler.exp ; real_gold = @battler.gold
end
@battler.damage.push([real_exp,"Exp"]) if @battler.exp > 0
@battler.damage.push([real_gold,"Gold"]) if @battler.gold > 0
end
end
咋改 |
|