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);
}
}
}
}
}
|