Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # • Variable Popup
- #==============================================================================
- # Autor: Dax
- # Versão: 1.0
- # Site: [email protected]
- # Requerimento: Dax Core
- #==============================================================================
- # • Descrição:
- #------------------------------------------------------------------------------
- # [Mostra o valor duma variável em cima do player ou de um evento.]
- #==============================================================================
- # • Como usar : NO COMANDO 'CHAMAR SCRIPT'
- #------------------------------------------------------------------------------
- # var_player(variable_id, type) | Para usar no jogador;
- # * variable_id : ID da variável, que irá mostrar o dano.
- # * type : Cor do dano. Por padrão e branco, em tal não precisa espeficar.
- # :normal : Cor normal(Pode mudar)
- # :critical : Cor vermelho(Pode mudar)
- # :recover : Cor verde(Pode mudar)
- # :special : Cor azul(Pode mudar)
- # var_event(id, variable_id, type) | Para usar no evento;
- # * id : ID do Evento no mapa.
- # * variable_id : ID da variável, que irá mostrar o dano.
- # * type : Cor do dano. Por padrão e branco, em tal não precisa espeficar.
- # :normal : Cor normal(Pode mudar)
- # :critical : Cor vermelho(Pode mudar)
- # :recover : Cor verde(Pode mudar)
- # :special : Cor azul(Pode mudar)
- #==============================================================================
- Dax.register(:variable_popup)
- #==============================================================================
- # • Variable Popup
- #==============================================================================
- module Rpg::Variable_Popup
- #----------------------------------------------------------------------------
- # • Função do módulo.
- #----------------------------------------------------------------------------
- module_function
- @variable_popup = []
- #----------------------------------------------------------------------------
- # • Configuração.
- #----------------------------------------------------------------------------
- def configure
- return {
- # Configuração da propriedade no mapa.
- z: 200,
- # Cor normal do texto.;
- normal: ColorBasic.hex("ffffff"),
- # Cor critical do texto.
- critical: ColorBasic.hex("c51414"),
- # Cor recover do texto.
- recover: ColorBasic.hex("31d329"),
- # Cor special do texto.
- special: ColorBasic.hex("63b8df"),
- # Nome da fonte do texto.
- name: "Bell MT",
- # Tamanho da fonte do texto.
- size: 20,
- # Usar negrito na fonte do texto.
- bold: true,
- # Usar borda na fonte do texto.
- outline: false,
- # Usar sombra da fonte do texto.
- shadow: true,
- # Cor da borda da fonte do texto.
- out_color: ColorBasic.hex("000000"),
- # Posição adicional.
- x_add: 0,
- # Posição adicional.
- y_add: 0,
- # Velocidade para sumir do mapa.
- opacity: 3,
- }
- end
- #----------------------------------------------------------------------------
- # • Popup da variável no personagem.
- #----------------------------------------------------------------------------
- def player(id, type=:normal)
- @variable_popup << Variable_Popup_Player.new(id, type)
- end
- #----------------------------------------------------------------------------
- # • Popup da variável no evento.
- #----------------------------------------------------------------------------
- def event(id, vid, type=:normal)
- @variable_popup << Variable_Popup_Event.new(id, vid, type)
- end
- #----------------------------------------------------------------------------
- # • Atualização.
- #----------------------------------------------------------------------------
- def update
- return if @variable_popup.nil?
- @variable_popup.each_with_index do |var, index|
- unless var.nil?
- var.update
- unless var.visible
- var.dispose
- @variable_popup.delete_at(index)
- end
- end
- end
- end
- #----------------------------------------------------------------------------
- # • Limpar todas.
- #----------------------------------------------------------------------------
- def clear
- @variable_popup.clear
- end
- end
- #==============================================================================
- # • Rpg::Variable_Popup::Player
- #==============================================================================
- class Variable_Popup_Player < Sprite
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #----------------------------------------------------------------------------
- def initialize(id, type=:normal)
- super([64, Rpg::Variable_Popup.configure[:size]+2])
- self.x = ($game_player.screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
- self.y = ($game_player.screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
- ["name", "size", "bold", "outline", "shadow", "out_color"].each { |i|
- eval("self.bitmap.font.#{i} = Rpg::Variable_Popup.configure[:#{i}]")
- }
- self.bitmap.font.color = Rpg::Variable_Popup.configure[type]
- @opacity = Rpg::Variable_Popup.configure[:opacity]
- self.bitmap.draw_text_rect($game_variables[id].to_s, 1)
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose
- super
- end
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- def update
- super
- self.x = ($game_player.screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
- self.y = ($game_player.screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
- self.opacity -= @opacity
- self.visible = false if self.opacity <= 0
- end
- end
- #==============================================================================
- # • Rpg::Variable_Popup::Event
- #==============================================================================
- class Variable_Popup_Event < Sprite
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #----------------------------------------------------------------------------
- def initialize(id, vid, type=:normal)
- super([64, Rpg::Variable_Popup.configure[:size]+2])
- self.x = ($game_map.events[id].screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
- self.y = ($game_map.events[id].screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
- ["name", "size", "bold", "outline", "shadow", "out_color"].each { |i|
- eval("self.bitmap.font.#{i} = Rpg::Variable_Popup.configure[:#{i}]")
- }
- self.bitmap.font.color = Rpg::Variable_Popup.configure[type]
- @opacity = Rpg::Variable_Popup.configure[:opacity]
- self.bitmap.draw_text_rect($game_variables[vid].to_s, 1)
- @id = id
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose
- super
- end
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- def update
- super
- self.x = ($game_map.events[@id].screen_x - (self.width/2)) + Rpg::Variable_Popup.configure[:x_add]
- self.y = ($game_map.events[@id].screen_y - self.height) - (26 + Rpg::Variable_Popup.configure[:y_add])
- self.opacity -= @opacity
- self.visible = false if self.opacity <= 0
- end
- end
- #==============================================================================
- # • Spriteset_Map
- #==============================================================================
- class Spriteset_Map
- alias :variable_popup_update :update
- def update
- variable_popup_update
- Rpg::Variable_Popup.update
- end
- end
- #==============================================================================
- # • Interpretador;
- #==============================================================================
- class Game_Interpreter
- #----------------------------------------------------------------------------
- # • No Jogador.
- #----------------------------------------------------------------------------
- def var_player(*args)
- Rpg::Variable_Popup.player(*args)
- end
- #----------------------------------------------------------------------------
- # • No Evento.
- #----------------------------------------------------------------------------
- def var_event(*args)
- Rpg::Variable_Popup.event(*args)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment