using System; using System.Diagnostics; namespace SpaceInvaders { public class Image : DLink { //------------------------------------------------------------------- // FIELDS //------------------------------------------------------------------- public enum ImageName { Crab_Open, Crab_Closed, Squid_Open, Squid_Closed, Octopus_Open, Octopus_Closed, Alien_Explosion, UFO, Bomb_Straight, Bomb_Zigzag0, Bomb_Zigzag1, Bomb_Zigzag2, Bomb_Zigzag3, Bomb_Cross, Ship, Missile, Brick, BrickLeft_Top0, BrickLeft_Top1, BrickLeft_Bottom, BrickRight_Top0, BrickRight_Top1, BrickRight_Bottom, HotPink, Uninitialized } public Image.ImageName name; private Texture pTexture; private Azul.Rect poRect; //------------------------------------------------------------------- // PUBLIC METHODS //------------------------------------------------------------------- public Image() { this.name = ImageName.Uninitialized; this.pTexture = null; //LTN: owner: each img has associated rect this.poRect = new Azul.Rect(); } //------------------------------------------------------------------- // PUBLIC METHODS //------------------------------------------------------------------- public void SetImage(ImageName name, Texture pTexture, float x, float y, float sx, float sy) { Debug.Assert(pTexture != null); Debug.Assert(poRect != null); this.name = name; this.pTexture = pTexture; this.poRect.Set(x, y, sx, sy); } public Azul.Texture GetAzulTexture() { return this.pTexture.GetAzulTexture(); } public Azul.Rect GetAzulRect() { return this.poRect; } //------------------------------------------------------------------- // OVERRIDDEN METHODS //------------------------------------------------------------------- public override bool Compare(Node pNode) { //check incoming Debug.Assert(pNode != null); Image pImageB = (Image)pNode; if(this.name == pImageB.name) { return true; } return false; } public override object GetName() { return this.name; } public override void Reset() { this.Clear(); } public override void PrintStats() { Debug.WriteLine("Name: {0} --> {1}", this.name, this.GetHashCode()); Debug.WriteLine("Rect: [ x-{0} y-{1} sx-{2} sy-{3} ]", this.poRect.x, this.poRect.y, this.poRect.width, this.poRect.height); Debug.WriteLine("Rect: {0}", poRect.GetHashCode()); base.PrintStats(); } //------------------------------------------------------------------- // PRIVATE METHODS //------------------------------------------------------------------- private void Clear() { Debug.Assert(this.poRect != null); this.name = ImageName.Uninitialized; this.pTexture = null; this.poRect.Clear(); } } //end class } //end namespace