using System;
using Microsoft.DirectX.DirectDraw;
using Global;
using Global.GlobalClass;
using KillerInstinct.DirectX;
namespace KillerInstinct.Sprites{
public class PowerupClass : SpriteClass
{
public const int MAX_POWERUP_TYPES = 3;
public enum PowerupType
{
Energy = 0,
Shield = 1,
Weapon = 2,
Ammo = 3
}
private PowerupType m_powerup = 0; // which power-up
private int m_amount = 0; // how much of a power-up, e.g. +10 energy, -5 shields, +5 ammo, etc.
private ShotClass.ShotTypes m_weapon = 0; // for weapon and ammo power-ups, this is which weapon applies
public int Amount
{
get
{ return m_amount; }
}
public PowerupType Powerup
{
get
{ return m_powerup; }
}
public ShotClass.ShotTypes Weapon
{
get
{ return m_weapon; }
}
public PowerupClass(float x, float y, PowerupType powerup, int amount, ShotClass.ShotTypes weapon, int deleteTime)
{
global.dbg.Out(Debug.DBG2, "PowerupClass called, x=[" + x + "] y=[" + y + "] powerup=[" + powerup + "] amount=[" + amount + "] weapon=[" + weapon + "] delTime=[" + deleteTime + "]");
byte colorkey = CONST.COLORKEY_WHITE;
// sprite attributes
frame.Width = 12;
frame.Height = 12;
framesCount = 1;
framesPerRow = 1;
whichFrame = 0;
m_powerup = powerup;
m_amount = amount;
m_weapon = weapon;
layer = LAYER_POWERUP;
//TODO: need new collision type that allows tank to collide, but shots NOT to collide
collisionType = CollisionType.BoundingBox;
string powerupFile = "";
switch (powerup)
{
case PowerupType.Energy:
{
powerupFile = CONST.BMP_POWERUP + "0.bmp";
break;
}
case PowerupType.Shield:
{
int rShield = global.random(0, CONST.MAX_POWERUP_SHIELDS);
powerupFile = CONST.BMP_POWERUP_SHIELD + rShield + ".bmp";
frame.Width = 13;
frame.Height= 14;
break;
}
case PowerupType.Weapon:
{
int rWeapon = global.random(0, CONST.MAX_POWERUP_WEAPONS);
powerupFile = CONST.BMP_POWERUP_WEAPON + rWeapon + ".bmp";
colorkey = CONST.COLORKEY_BLACK;
frame.Width = 13;
frame.Height= 13;
break;
}
case PowerupType.Ammo:
{
powerupFile = CONST.BMP_POWERUP + "3.bmp";
break;
}
default:
{
global.dbg.Out(Debug.ERR, "PowerupClass unknown powerup type: " + powerup);
break;
}
}
//TODO: don't draw ABOVE trees, etc.
//TODO: don't draw on top of other existing objects (except terrain objects?)
Init(powerupFile, colorkey, x, y, deleteTime);
}
public override void Update()
{
}
public override void ReactToCollision(SpriteClass s)
{
//global.dbg.Out(Debug.DBG2, "PowerupClass.ReactToCollision called, [" + s + "]");
if (s.GetType() == typeof(TankClass))
{
global.spriteList.Delete(this);
global.SC.Play(SoundClass.SOUND_POWERUP + "0.wav", false);
}
}
}
}
|