using System; using System.Diagnostics; namespace SpaceInvaders { public class Texture : DLink { //------------------------------------------------------------------- // FIELDS //------------------------------------------------------------------- public enum TextureName { Aliens, Shield, Consolas20pt, Consolas36pt, HotPink, Null_Texture, Uninitialized } public Texture.TextureName name; private readonly Azul.Texture poAzulTexture; //------------------------------------------------------------------- // CONSTRUCTION //------------------------------------------------------------------- public Texture() { //create and load texture this.poAzulTexture = new Azul.Texture(); //LTN: owned by texture Debug.Assert(this.poAzulTexture != null); this.name = TextureName.Uninitialized; } //------------------------------------------------------------------ // PUBLIC METHODS //------------------------------------------------------------------ public void SetTexture(TextureName name, string filename) { Debug.Assert(filename != null); Debug.Assert(this.poAzulTexture != null); this.poAzulTexture.Set(filename, Azul.Texture_Filter.NEAREST, Azul.Texture_Filter.NEAREST); this.name = name; } public Azul.Texture GetAzulTexture() { return this.poAzulTexture; } public override bool Compare(Node pNode) { //cant compare null Debug.Assert(pNode != null); Texture pTexture = (Texture)pNode; if(this.name == pTexture.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(" Azul Texture: {0}", this.poAzulTexture.GetHashCode()); base.PrintStats(); } //------------------------------------------------------------------ // PRIVATE METHODS //------------------------------------------------------------------ private void Clear() { //check texture isn't null Debug.Assert(this.poAzulTexture != null); this.poAzulTexture.Set("HotPink.tga", Azul.Texture_Filter.NEAREST, Azul.Texture_Filter.NEAREST); this.name = TextureName.Uninitialized; } } //end class } // end namespace