InfoBarClass.cs :  » Game » Killer-Instinct » KillerInstinct » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » Killer Instinct 
Killer Instinct » KillerInstinct » InfoBarClass.cs
using System;
using System.Drawing;
using KillerInstinct.DirectX;
using KillerInstinct.Sprites;
using Global;
using Global.GlobalClass;

namespace KillerInstinct{
  public class InfoBarClass
  {
    // constants
    public  static int BAR_HEIGHT    = 40;
    private static int AMMO_WIDTH    = 75;
    private static int AMMO_HEIGHT    = BAR_HEIGHT-1;
    private static int ALTAMMO_OFFSET  = 3;
    private static int ALTAMMO_WIDTH  = AMMO_WIDTH-ALTAMMO_OFFSET*2;
    private static int ALTAMMO_HEIGHT  = 10;
    private const  int BASE_ALTAMMO_IDX  = (int)ShotClass.ShotTypes.AltBasic;
    // ...
    private TankClass      m_playerTank  = null;
    private ProgressBarClass[]  m_ammoBars    = new ProgressBarClass[4];  // how much ammunition left for PRIMARY weapons
    private ProgressBarClass[]  m_altAmmoBars  = new ProgressBarClass[4];  // how much ammunition left for SECONDARY weapons
    private Sprites.DigitClass  m_energyText  = null;
    //private ProgressBarClass[] m_ammoBars = new ProgressBarClass[ShotClass.MAX_SHOT_TYPES];  // how much ammunition left per weapon
    public InfoBarClass(Sprites.TankClass playerTank)
    {
      m_playerTank = playerTank;
      // create energy text
      m_energyText = new Sprites.DigitClass(CONST.BMP_DIGIT, global.options.SCR_WIDTH-100, 4);
      // create ammunition bar for each weapon
      for(int i=0; i < m_ammoBars.Length; ++i)
      {
        m_ammoBars[i] = new ProgressBarClass(
          AMMO_WIDTH,
          AMMO_HEIGHT,
          m_playerTank.GetAmmoCount(i),
          m_playerTank.GetAmmoMax(i),
          Color.White,
          m_playerTank.GetWeaponColor(i),
          Color.Black);
      }
      // create ammunition bar for alternative weapons, though only the active one will be drawn
      for(int i=0; i < m_altAmmoBars.Length; ++i)
      {
        m_altAmmoBars[i] = new ProgressBarClass(
          ALTAMMO_WIDTH,
          ALTAMMO_HEIGHT,
          m_playerTank.GetAmmoCount(i+BASE_ALTAMMO_IDX),
          m_playerTank.GetAmmoMax(i+BASE_ALTAMMO_IDX),
          Color.Gray,
          Color.FloralWhite,
          Color.Black);
      }
    }
    public void Draw()
    {
      // draw black box where information is written
      global.DC.DrawBox(0, 0, global.options.SCR_WIDTH, BAR_HEIGHT, Color.Black, Color.Black);
      // draw divider bar
      global.DC.DrawBox(0, BAR_HEIGHT, global.options.SCR_WIDTH, 3, Color.DimGray, Color.Gold);
      // draw our remaining energy
      m_energyText.Draw(global.DC.Back, 3, global.Tank.Energy, "Energy", Color.Black, CONST.SCR_WIDTH-50, 40);
      // draw ammunition remaining for each weapon
      for(int i=0; i < m_ammoBars.Length; ++i)
      {
        Color barColor = m_playerTank.GetWeaponColor(i);
        // draw all other weapons greyed-out
        if (i != (int)m_playerTank.ShotType)
        {
          barColor = Color.FromArgb(35, 35, 55);
        }
        m_ammoBars[i].Draw(AMMO_WIDTH*i, 0, m_playerTank.GetAmmoCount(i), barColor);
        // write how much ammo remaining
        global.DC.DrawText(
          AMMO_WIDTH*i+3,
          2,
          m_playerTank.GetAmmoCount(i).ToString() + " / " + m_playerTank.GetAmmoMax(i).ToString(),
          Color.MintCream);
      }
      // draw remaining ammunition for currently selected SECONDARY weapon
      for(int i=0; i < m_altAmmoBars.Length; ++i)
      {
        // only draw selected SECONDARY weapon's remaining ammunition
        if (i+BASE_ALTAMMO_IDX == (int)m_playerTank.AltShotType)
        {
          // draw currently selected alternative shot count on bottom of corresponding primary weapon column
          int xPos = (AMMO_WIDTH*((int)m_playerTank.AltShotType-BASE_ALTAMMO_IDX))+ALTAMMO_OFFSET;
          m_altAmmoBars[i].Draw(xPos-1, BAR_HEIGHT-ALTAMMO_HEIGHT-2, m_playerTank.AltAmmoCount);
        }
      }
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.