Advertisement
KingGerar

Kingdom Age of Empires HUD

Oct 25th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.26 KB | None | 0 0
  1. #===============================================================================
  2. #                        Kingdom Age of Empires HUD
  3. #                             Por King Gerar
  4. #-------------------------------------------------------------------------------
  5. # Este script permite a visalização de uma HUD na tela mediante a ativação de
  6. # uma switch. Essa HUD permite mostrar 5 valores, com ícones e nome.
  7. # Este script foi baseado no sistema de matéria-prima de Age of Empires e no
  8. # script "HUD com Variáveis Estilo Age of Empires 1" de autoria de Alucard_2.
  9. #===============================================================================
  10. module KAoE_HUD_Config
  11.   Swch_Eneable = 1                     # ID da Switch que ativa/desativa a HUD.
  12.  
  13.   Wdw_Default = "Window"               # Gráfico da window utilizada.
  14.  
  15.   SystemFont = "Bauhaus"               # Fonte do menu.
  16.   FontSize = 17                        # Tamanho da fonte.
  17.  
  18.   Icon_Gold = 360                      # Ícone do ouro.
  19.   Icon_Wood = 331                      # Ícone da madeira.
  20.   Icon_Stone = 350                     # Ícone da pedra.
  21.   Icon_Metal = 342                     # Ícone do metal.
  22.   Icon_Pop = 121                       # Ícone da população.
  23.  
  24.   Txt_Gold = "Ouro:"                   # Texto do ouro.
  25.   Txt_Wood = "Madeira:"                # Texto da madeira.
  26.   Txt_Stone = "Pedra:"                 # Texto da pedra.
  27.   Txt_Metal = "Cristal:"               # Texto do metal.
  28.   Txt_Pop = "População:"               # Texto da população.
  29.   #-----------------------------------------------------------------------------
  30.   # Defina as variáveis utilizadas. Coloque o ID.
  31.   #-----------------------------------------------------------------------------
  32.   Var_Gold = 10                        # Ouro.
  33.   Var_Wood = 11                        # Madeira.
  34.   Var_Stone = 12                       # Pedra.
  35.   Var_Metal = 13                       # Metal.
  36.   Var_Pop = 14                         # População.
  37.   Var_MaxPop = 15                      # População máxima.
  38.   #-----------------------------------------------------------------------------
  39.   # Defina a cor das escritas.
  40.   #-----------------------------------------------------------------------------
  41.   Clr_Main = Color.new(255, 255, 0, 255)
  42.   #-----------------------------------------------------------------------------
  43.   # A opção abaixo define a posição da HUD na tela.
  44.   # 0 = Horizontal superior       1 = Horizontal inferior
  45.   # 2 = Vertical esquerda         3 = Vertical direita
  46.   #-----------------------------------------------------------------------------
  47.   Position = 3
  48. end
  49.  
  50. #===============================================================================
  51. # Window_KingdomAoEHUD
  52. #-------------------------------------------------------------------------------
  53. # Esta classe exibe uma HUD no mapa com a quantidade das matérias-primas em
  54. # posse.
  55. #===============================================================================
  56. class Window_KingdomAoEHUD < Window_Base
  57.   include KAoE_HUD_Config
  58.   #-----------------------------------------------------------------------------
  59.   # Inicialização do processo.
  60.   #-----------------------------------------------------------------------------
  61.   def initialize
  62.   super(0, 0, Graphics.width, 80) if Position == 0
  63.   super(0, 336, Graphics.width, 80) if Position == 1
  64.   super(0, 0, 96, Graphics.height) if Position == 2
  65.   super(448, 0, 96, Graphics.height) if Position == 3
  66.   self.windowskin = Cache.system(Wdw_Default)
  67.     self.contents.font.name = SystemFont
  68.     self.contents.font.size = FontSize
  69.   self.visible = $game_switches[Swch_Eneable]
  70.   update
  71.   end
  72.   #-----------------------------------------------------------------------------
  73.   # Criação das informações.
  74.   #-----------------------------------------------------------------------------
  75.   def draw_contents
  76.   @materia = Array.new(5)
  77.   @text = [Txt_Gold, Txt_Wood, Txt_Stone, Txt_Metal, Txt_Pop]
  78.   @icon = [Icon_Gold, Icon_Wood, Icon_Stone, Icon_Metal, Icon_Pop]
  79.   @value = [Var_Gold, Var_Wood, Var_Stone, Var_Metal, Var_Pop]
  80.   if Position == 0 or Position == 1
  81.     for n in 0...@materia.size
  82.     change_color(Clr_Main)
  83.     draw_text(n * 104, 0, 96, line_height, @text[n], 0)
  84.     change_color(normal_color)
  85.     draw_icon(@icon[n], n * 104, line_height)
  86.     draw_text((n * 104) + 26, line_height, 60, line_height, $game_variables[@value[n]].to_s, 0)
  87.     draw_text(474, line_height, 16, line_height, "/", 1)
  88.     draw_text(490, line_height, 32, line_height, $game_variables[Var_MaxPop].to_s, 0)
  89.     end
  90.   end
  91.   if Position == 2 or Position == 3
  92.       for n in 0...@materia.size
  93.     change_color(Clr_Main)
  94.       draw_text(0, n * 80, 72, line_height, @text[n], 1)
  95.       change_color(normal_color)
  96.       draw_icon(@icon[n], 0, (n * 80) + line_height)
  97.       draw_text(26, (n * 80) + line_height, 38, line_height, $game_variables[@value[n]].to_s, 0)
  98.       draw_text(28, 344, 38, line_height, "/", 1)
  99.       draw_text(50, 344, 18, line_height, $game_variables[Var_MaxPop].to_s, 0)
  100.       end
  101.   end
  102.   end
  103.   #-----------------------------------------------------------------------------
  104.   # Condição de atualização das informações.
  105.   #-----------------------------------------------------------------------------    
  106.   def update
  107.   super
  108.   self.visible = $game_switches[Swch_Eneable]
  109.   if Var_Gold != $game_variables[Var_Gold] or Var_Wood != $game_variables[Var_Wood] or
  110.     Var_Stone != $game_variables[Var_Stone] or Var_Metal != $game_variables[Var_Metal] or
  111.     Var_Pop != $game_variables[Var_Pop] or Var_MaxPop != $game_variables[Var_MaxPop]
  112.   contents.clear
  113.   draw_contents
  114.   end
  115.   end
  116. end
  117. #===============================================================================
  118. # Scene_Map
  119. #-------------------------------------------------------------------------------
  120. # Esta classe executa o processamento da tela de mapa.
  121. #===============================================================================
  122. class Scene_Map < Scene_Base
  123.   alias start_window start
  124.   alias term_window terminate
  125.   alias update_window update
  126.  
  127.   def start
  128.     start_window
  129.     @materia_hud = Window_KingdomAoEHUD.new
  130.     update
  131.   end
  132.  
  133.   def terminate
  134.     @materia_hud.dispose
  135.     term_window
  136.   end
  137.  
  138.   def update
  139.     update_window
  140.     @materia_hud.update
  141.   end
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement