using System;
using Microsoft.DirectX.DirectDraw;
using Global;
using Global.GlobalClass;
using KillerInstinct.DirectX;
namespace KillerInstinct.Sprites{
public class ShotAlternativClass : SpriteClass
{
public const int RANGE = 200;
// shot types
public enum AltShotTypes
{
None = 69, // should produce an error if accessing an array, file, etc.
AltBasic = 10,
AltL2 = 11,
AltL3 = 12,
AltL4 = 13
}
private AltShotTypes m_shotType = AltShotTypes.AltBasic;
private float m_x, m_y;
public float speedCount;
public int damage = 0;
public int range = 0;
private byte m_colorkey = CONST.COLORKEY_WHITE;
// returns type of SECONDARY (alternative) shot
public AltShotTypes ShotType
{
get
{ return m_shotType; }
}
public ShotAlternativClass(AltShotTypes shotType, float x, float y, ulong parentId)
{
this.parentId = parentId;
// sprite attributes
frame.Width = 5;
frame.Height = 5;
framesCount = 1;
framesPerRow = 1;
// starting direction
whichFrame = 0;
m_x = x;
m_y = y;
// staring speed
speed = 3f;
// collisionType
collisionType = CollisionType.NoCollision;
// to be in range
speedCount = speed;
range = 200;
m_shotType = shotType;
layer = LAYER_SHOT;
// determine other shot type specific information
switch (shotType)
{
// alternate basic shot
case AltShotTypes.AltBasic:
range = 175;
speed = 3f;
break;
// alternate shot level 2
case AltShotTypes.AltL2:
range = 200;
speed = 4f;
break;
// alternate shot level 3
case AltShotTypes.AltL3:
range = 250;
speed = 5f;
break;
// alternate shot level 4
case AltShotTypes.AltL4:
frame.Width = 15;
frame.Height = 15;
framesCount = 3;
framesPerRow = 3;
range = 350;
speed = 2.5f;
m_colorkey = CONST.COLORKEY_BLACK;
break;
default:
global.dbg.Out(Debug.ERR, "AltShotClass undefined shot type: [" + shotType + "].");
break;
}
Init(CONST.BMP_SHOT + (int)shotType + ".bmp", m_colorkey, x, y);
}
public override void Update()
{
posX = posX + speed * (float)Math.Cos(direction*Math.PI/180);
posY = posY + speed * (float)Math.Sin(direction*Math.PI/180);
speedCount += speed;
if ((posX<0) || (posX>global.options.SCR_WIDTH-frame.Width) ||
(posY<0) || (posY>global.options.SCR_HEIGHT-frame.Height) ||
(speedCount > range))
global.spriteList.Delete(this);
if ((Math.Abs(m_x-posX)>35) || (Math.Abs(m_y-posY)>35))
collisionType = CollisionType.BoundingBox;
// glowing red shot
if (ShotType == AltShotTypes.AltL4)
{
if (whichFrame < framesCount-1) whichFrame++;
else whichFrame = 0;
}
}
public override void ReactToCollision(SpriteClass s)
{
// if one of the sprites _IS_ the other persons parent...
//if (this.globalId != s.parentId && this.parentId != s.globalId)
//
if (this.parentId != s.globalId)
{
global.dbg.Out(Debug.DBG2, "ShotAlternativClass.ReactToCollision called [" + s + "]");
if (s.collisionType != CollisionType.NoCollision)
{
global.spriteList.Delete(this);
global.SC.Play(SoundClass.SOUND_ALTHIT, false);
}
//TODO:??else if (s.GetType() == typeof())
{
}
}
}
}
}
|