using System; using System.Diagnostics; namespace SpaceInvaders { public class SpriteBoxMan : Manager { //------------------------------------------------------------------- // FIELDS //------------------------------------------------------------------- private SpriteBox poCompare; private static SpriteBoxMan poInstance = null; //------------------------------------------------------------------- // PRIVATE CONSTRUCTION //------------------------------------------------------------------- private SpriteBoxMan(int initialReserve = 3, int growReserve = 1) : base(new DLinkMan(), new DLinkMan(), initialReserve, growReserve) { //LTN: owned by Sprite Box Man this.poCompare = new SpriteBox(); Debug.Assert(this.poCompare != null); } //------------------------------------------------------------------- // PUBLIC METHODS //------------------------------------------------------------------- public static void Create(int initialReserve = 3, int growReserve = 2) { //LTN: owned by Sprite Box Man //Debug.Assert(pInstance == null); if(SpriteBoxMan.poInstance == null) { SpriteBoxMan.poInstance = new SpriteBoxMan(initialReserve, growReserve); Debug.Assert(SpriteBoxMan.poInstance != null); } SpriteBox pSpriteBox = SpriteBoxMan.AddBox(SpriteBox.SpriteBoxName.NullObject, 0.0f, 0.0f, 0.0f, 0.0f); Debug.Assert(pSpriteBox != null); } public static void Destroy() { } public static SpriteBox AddBox(SpriteBox.SpriteBoxName name, float x, float y, float sx, float sy, Azul.Color pColor = null) { SpriteBoxMan pManager = SpriteBoxMan.GetInstance(); Debug.Assert(pManager != null); SpriteBox pBox = (SpriteBox)pManager.AddToFront(); Debug.Assert(pBox != null); pBox.SetBox(name, x, y, sx, sy, pColor); return pBox; } public static SpriteBox FindBox(SpriteBox.SpriteBoxName name) { SpriteBoxMan pManager = SpriteBoxMan.GetInstance(); Debug.Assert(pManager != null); pManager.poCompare.name = name; SpriteBox pBox = (SpriteBox)pManager.Find(pManager.poCompare); return pBox; } public static void RemoveBox(SpriteBox pBox) { Debug.Assert(pBox != null); SpriteBoxMan pManager = SpriteBoxMan.GetInstance(); Debug.Assert(pManager != null); pManager.Remove(pBox); } public static void PrintBox() { SpriteBoxMan pManager = SpriteBoxMan.GetInstance(); Debug.Assert(pManager != null); pManager.PrintStats(); } //------------------------------------------------------------------- // PROTECTED METHODS //------------------------------------------------------------------- protected override Node derivedCreate() { //LTN: owned by Sprite Node Man Node pNode = new SpriteBox(); Debug.Assert(pNode != null); return pNode; } //------------------------------------------------------------------- // PRIVATE METHODS //------------------------------------------------------------------- private static SpriteBoxMan GetInstance() { Debug.Assert(SpriteBoxMan.poInstance != null); return SpriteBoxMan.poInstance; } } //end class } //end namespace