public static float GetCurrTime() { // Get the instance TimerEventManager pTimerEventManager = TimerEventManager.privGetInstance(); // return time return(pTimerEventManager.currTime); }
public static void DumpLists() { TimerEventManager pMan = TimerEventManager.privGetInstance(); Debug.Assert(pMan != null); Debug.WriteLine("------ TimerEvent Manager Lists ------"); pMan.baseDumpLists(); }
public static void Remove(TimerEvent pNode) { TimerEventManager pMan = TimerEventManager.privGetInstance(); Debug.Assert(pMan != null); Debug.Assert(pNode != null); pMan.baseRemoveNode(pNode); }
//----------------------------------------------------------------------------- // Game::Update() // Called once per frame, update data, tranformations, etc // Use this function to control process order // Input, AI, Physics, Animation, and Graphics //----------------------------------------------------------------------------- public override void Update() { //check time; //Debug.WriteLine("Simulation.GetTimeStep() = {0}", Simulation.GetTimeStep()); //Debug.WriteLine("Simulation.GetTotalTime() = {0}", Simulation.GetTotalTime()); //Update game simulation // Single Step, Free running... Simulation.Update(this.GetTime()); //always update input asap InputManager.Update(); // Run based on simulation stepping if (Simulation.GetTimeStep() > 0.0f) { // Fire off the timer events //with simulator timer TimerEventManager.Update(Simulation.GetTotalTime()); ////no simulator timer //TimerEventManager.Update(this.GetTime()); // Do the collision checks ColPairManager.Process(); //GameObjectManager updates ALL game objects and sprite positions // remember each game object has a proxy sprite attached GameObjectManager.Update(); GridManager.UpdateBombDrop(); } ////Original, No Simulation --------------------------------------------------- ////always update input asap //InputMan.Update(); //// Fire off the timer events //TimerMan.Update(this.GetTime()); //// Do the collision checks //ColPairMan.Process(); ////GameObjectManager updates ALL game objects and sprite positions //// remember each game object has a proxy sprite attached //// walk through all objects and push to flyweight //GameObjectMan.Update(); //// Delete any objects here... //DelayedObjectMan.Process(); }
public void Set(Name eventName, Command pCommand, float deltaTimeToTrigger) { Debug.Assert(pCommand != null); this.name = eventName; this.pCommand = pCommand; this.deltaTime = deltaTimeToTrigger; // set the trigger time this.triggerTime = TimerEventManager.GetCurrTime() + deltaTimeToTrigger; }
//----------------------------------------------------------------------------- // Game::UnLoadContent() // unload content (resources loaded above) // unload all content that was loaded before the Engine Loop started //----------------------------------------------------------------------------- public override void UnLoadContent() { TextureManager.Destroy(); ImageManager.Destroy(); GameSpriteManager.Destroy(); BoxSpriteManager.Destroy(); SpriteBatchManager.Destroy(); ProxySpriteManager.Destroy(); TimerEventManager.Destroy(); DeathManager.Destroy(); }
public static void Destroy() { // Get the instance TimerEventManager pMan = TimerEventManager.privGetInstance(); Debug.WriteLine("--->TimerMan.Destroy()"); pMan.baseDestroy(); #if (TRACK_DESTRUCTOR) Debug.WriteLine(" {0} ({1})", TimerMan.pTimerEventRef, TimerMan.pTimerEventRef.GetHashCode()); Debug.WriteLine(" {0} ({1})", TimerMan.pInstance, TimerMan.pInstance.GetHashCode()); #endif TimerEventManager.pTimerEventRef = null; TimerEventManager.pInstance = null; }
public static void Create(int startReserveSize = 3, int refillSize = 1) { // make sure values are ressonable Debug.Assert(startReserveSize > 0); Debug.Assert(refillSize > 0); // initialize the singleton here Debug.Assert(pInstance == null); // Do the initialization if (pInstance == null) { pInstance = new TimerEventManager(startReserveSize, refillSize); } Debug.WriteLine("------TimerEvent Manager Initialized-------"); }
public static TimerEvent Find(TimerEvent.Name name) { TimerEventManager pMan = TimerEventManager.privGetInstance(); Debug.Assert(pMan != null); // Compare functions only compares two Nodes // So: Use a reference node // fill in the needed data // use in the Compare() function Debug.Assert(pTimerEventRef != null); pTimerEventRef.Wash(); pTimerEventRef.SetName(name); TimerEvent pData = (TimerEvent)pMan.baseFindNode(pTimerEventRef); return(pData); }
public static void LoadAlienAnimations() { //---------------------- //Animated Sprite (Attached to TimerManager //Each animation is a TimerEvent following command pattern; // Create alien animation sprites AnimationSprite pAnim_Squid = new AnimationSprite(GameSprite.Name.Squid); AnimationSprite pAnim_Crab = new AnimationSprite(GameSprite.Name.Crab); AnimationSprite pAnim_Octo = new AnimationSprite(GameSprite.Name.Octopus); //explosion animation AnimationSprite pAnim_AlienExplosion_Pop = new AnimationSprite(GameSprite.Name.AlienExplosion); // attach to death manager for garbage collection management DeathManager.Attach(pAnim_Squid); DeathManager.Attach(pAnim_Crab); DeathManager.Attach(pAnim_Octo); DeathManager.Attach(pAnim_AlienExplosion_Pop); // attach alternating images to animation cycle pAnim_Squid.Attach(Image.Name.SquidClosed); pAnim_Squid.Attach(Image.Name.SquidOpen); pAnim_Crab.Attach(Image.Name.CrabClosed); pAnim_Crab.Attach(Image.Name.CrabOpen); pAnim_Octo.Attach(Image.Name.OctopusClosed); pAnim_Octo.Attach(Image.Name.OctopusOpen); // add AnimationSprite to timer //set the interval between events and add sprite animation event objects to timer manager; float animInterval = 1.0f; TimerEventManager.Add(TimerEvent.Name.SpriteAnimation, pAnim_Squid, animInterval); TimerEventManager.Add(TimerEvent.Name.SpriteAnimation, pAnim_Crab, animInterval); TimerEventManager.Add(TimerEvent.Name.SpriteAnimation, pAnim_Octo, animInterval); }
public override void Execute(float deltaTime) { // advance to next image ImageHolder pImageHolder = (ImageHolder)this.pCurrImage.pSNext; // if at end of list, set to first if (pImageHolder == null) { pImageHolder = (ImageHolder)poFirstImage; } // squirrel away for next timer event this.pCurrImage = pImageHolder; // change image this.pSprite.ChangeImage(pImageHolder.pImage); // Add itself back to timer TimerEventManager.Add(TimerEvent.Name.SpriteAnimation, this, deltaTime); }
//---------------------------------------------------------------------- // Methods //---------------------------------------------------------------------- public static TimerEvent Add(TimerEvent.Name timeName, Command pCommand, float deltaTimeToTrigger) { TimerEventManager pMan = TimerEventManager.privGetInstance(); Debug.Assert(pMan != null); //pull a resereved node TimerEvent pNode = (TimerEvent)pMan.basePopReserve(); Debug.Assert(pNode != null); Debug.Assert(pCommand != null); Debug.Assert(deltaTimeToTrigger >= 0.0f); //set the data pNode.Set(timeName, pCommand, deltaTimeToTrigger); //add the newly set timer event node to the list in sorted order pMan.baseAddSorted(pNode); return(pNode); }
public static void Update(float totalTime) { // Get the instance TimerEventManager pTimerEventManager = TimerEventManager.privGetInstance(); // store the current time pTimerEventManager.currTime = totalTime; // walk the event list TimerEvent pEvent = (TimerEvent)pTimerEventManager.baseGetActive(); TimerEvent nextEvent = null; // Walk the list until currTime is greater than timeEvent triggerTime while (pEvent != null) { // get the next event early in case this event executes and is removed nextEvent = (TimerEvent)pEvent.pMNext; if (pTimerEventManager.currTime >= pEvent.triggerTime) { //Debug.WriteLine("{0} Event Triggered!", pEvent.GetName()); //Debug.WriteLine("Trigger Time:{0}", pTimerEventManager.currTime); // execute the event pEvent.Process(); // remove event from list after execution pTimerEventManager.baseRemoveNode(pEvent); } else { // early out, since the list is sorted break; } // advance the pointer pEvent = nextEvent; } }
public static void LoadBombAnimations() { //----------------- // Create bomb animation sprites AnimationSprite pAnim_CrossAlienBomb = new AnimationSprite(GameSprite.Name.CrossAlienBomb); AnimationSprite pAnim_ZigZagAlienBomb = new AnimationSprite(GameSprite.Name.ZigZagAlienBomb); AnimationSprite pAnim_RollingAlienBomb = new AnimationSprite(GameSprite.Name.RollingAlienBomb); // attach to death manager for garbage collection management DeathManager.Attach(pAnim_CrossAlienBomb); DeathManager.Attach(pAnim_ZigZagAlienBomb); DeathManager.Attach(pAnim_RollingAlienBomb); // attach alternating images to animation cycle pAnim_CrossAlienBomb.Attach(Image.Name.AlienBombCross_Two); pAnim_CrossAlienBomb.Attach(Image.Name.AlienBombCross_Three); pAnim_CrossAlienBomb.Attach(Image.Name.AlienBombCross_Four); pAnim_CrossAlienBomb.Attach(Image.Name.AlienBombCross_One); pAnim_ZigZagAlienBomb.Attach(Image.Name.AlienBombZigZag_Two); pAnim_ZigZagAlienBomb.Attach(Image.Name.AlienBombZigZag_Three); pAnim_ZigZagAlienBomb.Attach(Image.Name.AlienBombZigZag_Four); pAnim_ZigZagAlienBomb.Attach(Image.Name.AlienBombZigZag_One); pAnim_RollingAlienBomb.Attach(Image.Name.AlienBombRolling_Three); pAnim_RollingAlienBomb.Attach(Image.Name.AlienBombRolling_Two); //set the interval between events and add sprite animation event objects to timer manager; float animInterval = 0.01f; TimerEventManager.Add(TimerEvent.Name.BombAnimation, pAnim_CrossAlienBomb, animInterval); TimerEventManager.Add(TimerEvent.Name.BombAnimation, pAnim_ZigZagAlienBomb, animInterval); TimerEventManager.Add(TimerEvent.Name.BombAnimation, pAnim_RollingAlienBomb, animInterval); }
//----------------------------------------------------------------------------- // Game::LoadContent() // Allows you to load all content needed for your engine, // such as objects, graphics, etc. //----------------------------------------------------------------------------- public override void LoadContent() { Debug.WriteLine("----------------------------------"); Debug.WriteLine("Load Content"); Debug.WriteLine("----------------------------------\n"); //----------------------------------------------- //Create Game Simulation instance Simulation.Create(); //----------------------------------------------- //Manager Load //------------------------------ //Texture Manager Create TextureManager.Create(); //------------------------------ //Image Manager Create ImageManager.Create(); //------------------------------ //Game/Box Sprite Manager Create GameSpriteManager.Create(5, 2); BoxSpriteManager.Create(); //------------------------------ //SpriteBatch Manager Create SpriteBatchManager.Create(); //------------------------------ //ProxySprite Manager Create ProxySpriteManager.Create(10, 1); //------------------------------ //GameObject Manager Create GameObjectManager.Create(); //------------------------------ //CollisionPair Manager Create ColPairManager.Create(); //------------------------------ //TimerEvent Manager Create TimerEventManager.Create(); //------------------------------ //Glyph/Font Manager Create/Load GlyphManager.Create(); FontManager.Create(); //------------------------------ //Death/Ghost Manager Create DeathManager.Create(1, 1); GhostManager.Create(1, 1); //----------------------------------------------- // Input Manager - Key Observer Load InputManager.LoadKeyInputObservers(); //----------------------------------------------- //Print some initial stats TextureManager.DumpStats(); ImageManager.DumpStats(); GameSpriteManager.DumpStats(); BoxSpriteManager.DumpStats(); SpriteBatchManager.DumpStats(); ProxySpriteManager.DumpStats(); TimerEventManager.DumpStats(); GameObjectManager.DumpStats(); DeathManager.DumpStats(); GhostManager.DumpStats(); ColPairManager.DumpStats(); GlyphManager.DumpStats(); //------------------------------ //Asset Loading //Texture/Image/Font Load TextureManager.LoadTextures(); ImageManager.LoadImages(); FontManager.LoadFonts(); //----------------------------------------------- //Sprite Batch /Sprite Load SpriteBatch pSB_GameSprites = SpriteBatchManager.Add(SpriteBatch.Name.GameSprites); SpriteBatch pShields = SpriteBatchManager.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Boxes = SpriteBatchManager.Add(SpriteBatch.Name.SpriteBoxes); SpriteBatch pSB_Texts = SpriteBatchManager.Add(SpriteBatch.Name.TextLetters); //----------------------------------------------- //Sprites/BoxSprites Load //NOTE that the following coordinates will not matter //once proxy sprites are used! //35w x 35h for all sprites; float const_AlienSpriteSize = 30.0f; //render dimensions/coordinates float squid_sX = 400.0f; float squid_sY = 400.0f; float crab_sX = 400.0f; float crab_sY = 350.0f; float octo_sX = 400.0f; float octo_sY = 300.0f; float missileSpriteWidth = 4.0f; float missileSpriteHeight = 8.0f; float alienBombSpriteWidth = 6.0f; float alienBombSpriteHeight = 12.0f; float shipSpriteWidth = 55.0f; float shipSpriteHeight = 25.0f; float verticalWallWidth = 678.0f; float verticalWallHeight = 10.0f; float horizontalWallWidth = 678.0f; float horizontalWallHeight = 10.0f; //---------------------- //aliens (initial sprites only) //note that the alien grid and alien column are game sprites for box sprite rendering, //but will pass a null image since they don't have anything to render GameSpriteManager.Add(GameSprite.Name.AlienGrid, Image.Name.NullObject, 0, 0, 0, 0); GameSpriteManager.Add(GameSprite.Name.AlienColumn, Image.Name.NullObject, 0, 0, 0, 0); //squid game sprite GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidOpen, squid_sX, squid_sY, const_AlienSpriteSize, const_AlienSpriteSize); //crab game sprite GameSpriteManager.Add(GameSprite.Name.Crab, Image.Name.CrabOpen, crab_sX, crab_sY, const_AlienSpriteSize, const_AlienSpriteSize); //octopus game sprite GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusOpen, octo_sX, octo_sY, const_AlienSpriteSize, const_AlienSpriteSize); //alien explosion (for explosion animation after alien is destroyed) GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosionPop, 0, 0, const_AlienSpriteSize, const_AlienSpriteSize); //---------------------- //alien bombs (initial sprites only) //zigzag bomb GameSpriteManager.Add(GameSprite.Name.ZigZagAlienBomb, Image.Name.AlienBombZigZag_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight); //cross bomb GameSpriteManager.Add(GameSprite.Name.CrossAlienBomb, Image.Name.AlienBombCross_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight); //rolling bomb GameSpriteManager.Add(GameSprite.Name.RollingAlienBomb, Image.Name.AlienBombRolling_Two, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight); //---------------------- //hero ship GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 640.0f, 440.0f, shipSpriteWidth, shipSpriteHeight); //hero missile GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, missileSpriteWidth, missileSpriteHeight); //---------------------- //walls (2: top/bottom, left/right) //note screen w = 672px wide by 768px GameSpriteManager.Add(GameSprite.Name.VerticalWall, Image.Name.NullObject, 0, 0, verticalWallWidth, verticalWallHeight); GameSpriteManager.Add(GameSprite.Name.HorizontalWall, Image.Name.NullObject, 0, 0, horizontalWallWidth, horizontalWallHeight); //---------------------- //shield bricks (6) float brickSpriteWidth = 15.0f; float brickSpriteHeight = 10.0f; GameSpriteManager.Add(GameSprite.Name.ShieldBrick, Image.Name.ShieldBrick, 0.0f, 0.0f, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickLeft_Top, Image.Name.ShieldBrickLeft_Top, 0.0f, 0.0f, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickRight_Top, Image.Name.ShieldBrickRight_Top, 0, 0, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickMidLeft_Bottom, Image.Name.ShieldBrickMidLeft_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickMid_Bottom, Image.Name.ShieldBrickMid_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickMidRight_Bottom, Image.Name.ShieldBrickMidRight_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight); //---------------------- //alien UFO ship float ufoSpriteWidth = 30.0f; float ufoSpriteHeight = 10.0f; GameSpriteManager.Add(GameSprite.Name.AlienUFO, Image.Name.AlienUFO, 0, 0, ufoSpriteWidth, ufoSpriteHeight); //---------------------- //BoxSprites are added in the CollisionObject constructor depending on the sprite! //----------------------------------------------- //Load the Animations (TimerEvents) TimerEventManager.LoadAlienAnimations(); TimerEventManager.LoadBombAnimations(); //----------------------------------------------- //Set the Game Simulation State; Simulation.SetState(Simulation.State.Realtime); //----------------------------------------------- //GameObject Load (Factory) //get the PCSRootTree that was created by GameObjectManager PCSTree rootGamObjTree = GameObjectManager.GetRootTree(); //make sure root tree and root have been created; Debug.Assert(rootGamObjTree != null); Debug.Assert(rootGamObjTree.GetRoot() != null); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Create Missile Tree MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); rootGamObjTree.Insert(pMissileRoot, null); //pMissileRoot.ActivateCollisionSprite(pSB_Boxes); //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree); GameObjectManager.AttachTree(pMissileRoot); //TEST------------------ //PCSTree missileTree = new PCSTree(); //MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); //missileTree.Insert(pMissileRoot, null); //pMissileRoot.ActivateCollisionSprite(pSB_Boxes); //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree); //rootGamObjTree.Insert(pMissileRoot, rootGamObjTree.GetRoot()); //------------------------------------------------ // Create Ship Tree ShipRoot shipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); DeathManager.Attach(shipRoot); //check the tree rootGamObjTree.DumpTree(); //attach the shipRoot to the rootGameObjTree, with the gamObjRoot as parent rootGamObjTree.Insert(shipRoot, null); //check the tree rootGamObjTree.DumpTree(); //attach the shipRoot to the root game object tree //GameObjectManager.AttachTree(shipRoot, rootGamObjTree); GameObjectManager.AttachTree(shipRoot); //create the ship manager that handles all the ship's states ShipManager.CreateShipManager(); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Create an Alien Tree //AlienRoot alienRoot = new AlienRoot(GameObject.Name.AlienRoot, GameSprite.SpriteName.Null_Object, 0, 0.0f, 0.0f); //create the PCS tree that will hold all alien game objects PCSTree pAlienTree = new PCSTree(); DeathManager.Attach(pAlienTree); //create the alien game object factory with pAlienTree as the factory's tree //factory will attach all alien game objects to pAlienTree AlienFactory pAlienFactory = new AlienFactory(SpriteBatch.Name.GameSprites, pAlienTree); DeathManager.Attach(pAlienFactory); //attach grid as a child of game object root; grid will be parent of all alien game objects Grid pGrid = (Grid)pAlienFactory.Create(AlienType.Type.AlienGrid, GameObject.Name.Grid); // set the grid as the root parent to attach all aliens to; pAlienFactory.SetParent(pGrid); //Build the grid (builder pattern) int numberOfColumns = 11; //numberOfColumns = 1; AlienFactory.BuildAlienGrid(pAlienFactory, pGrid, numberOfColumns); //check the tree rootGamObjTree.DumpTree(); //GameObjectManager.AttachTree(pGrid, rootGamObjTree); GameObjectManager.AttachTree(pGrid); //------------------------------------------------ // Create Alien Bomb tree //create the root BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); //insert root into the bomb tree rootGamObjTree.Insert(pBombRoot, null); //pBombRoot.ActivateCollisionSprite(pSB_Boxes); //add the bombtree to the root tree //GameObjectManager.AttachTree(pBombRoot, rootGamObjTree); GameObjectManager.AttachTree(pBombRoot); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Associate and Create Walls //note screen = 672px wide by 768px WallRoot pWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); rootGamObjTree.Insert(pWallRoot, null); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.HorizontalWall, 0, 336.0f, 728.0f, 612.0f, 10.0f); rootGamObjTree.Insert(pWallTop, pWallRoot); pWallTop.ActivateCollisionSprite(pSB_Boxes); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.HorizontalWall, 0, 336.0f, 40.0f, 612.0f, 10.0f); rootGamObjTree.Insert(pWallBottom, pWallRoot); pWallBottom.ActivateCollisionSprite(pSB_Boxes); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.HorizontalWall, 0, 652.0f, 384.0f, 10.0f, 693.0f); rootGamObjTree.Insert(pWallRight, pWallRoot); pWallRight.ActivateCollisionSprite(pSB_Boxes); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.HorizontalWall, 0, 20.0f, 384.0f, 10.0f, 693.0f); rootGamObjTree.Insert(pWallLeft, pWallRoot); pWallLeft.ActivateCollisionSprite(pSB_Boxes); //now that it's fully created, attach the newly created wall tree to the main game object tree //GameObjectManager.AttachTree(pWallRoot, rootGamObjTree); GameObjectManager.AttachTree(pWallRoot); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- //create the root ShieldRoot pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); rootGamObjTree.Insert(pShieldRoot, null); //attach to game object tree GameObjectManager.AttachTree(pShieldRoot); // create the factory ShieldFactory shieldFactory = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Shields, rootGamObjTree); // set the parent for hierarchy inside the factory, grid is root, so parent is null //shieldFactory.setParent(pShieldRoot); // create and attach grid to Root //ShieldGrid pShieldGrid = (ShieldGrid)shieldFactory.Create(ShieldCategory.Type.ShieldGrid, GameObject.Name.ShieldGrid); float startPos_X = 50.0f; float startPos_y = 100.0f; //shield 1 - far left shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //move to the right startPos_X = 210.0f; shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //move to the right startPos_X = 370.0f; shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //move to the right startPos_X = 520.0f; shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Associate and Create Collision Pairs ColPair pColPair = null; // IMPORTANT: At LEAST two steps when establishing the collision pairs // 1) associate object roots in a collision pair, // 2) then attach all relevent Observer objects that will execute their specified response to collision //todo create an observerObject manager that pools all of these observer objects! //--------------------------------------------------------------------------------------------- //Missile CollisionPairs //Missile vs Wall (Top) Collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Missile_Wall, pMissileRoot, pWallRoot); //attach all observers that will react to collision pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ShipRemoveMissileObserver()); //-------------------- // Missile vs Shield collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Misslie_Shield, pMissileRoot, pShieldRoot); //attach all observers that will react to this collision pColPair.Attach(new RemoveMissileObserver()); //pColPair.Attach(new DegradeBrickSpriteObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver()); //-------------------- //Missile vs AlienGrid collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Alien_Missile, pMissileRoot, pGrid); //attach all observers that will react to collision pColPair.Attach(new RemoveMissileObserver()); //todo alien explosion animation isn't working pColPair.Attach(new AnimateAlienExplosionObserver()); pColPair.Attach(new RemoveAlienObserver()); //pColPair.Attach(new AlienDeathSoundObserver()); //pColPair.Attach(new AlienScoreUpdateObserver()); pColPair.Attach(new ShipReadyObserver()); //--------------------------------------------------------------------------------------------- //Bomb CollisionPairs //Bomb vs Wall (Bottom) Collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallRoot); //attach all observers that will react to collision //pColPair.Attach(new BombObserver()); pColPair.Attach(new RemoveBombObserver()); //todo broken collision - fix //-------------------- //Bomb vs Shield Collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); //attach all observers that will react to collision pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveBrickObserver()); //todo need to implement collision reaction for bomb v ship ////-------------------- ////Bomb vs Ship Collision //// associate object roots in a collision pair //pColPair = ColPairManager.Add(ColPair.Name.Bomb_Ship, pBombRoot, shipRoot); ////attach all observers that will react to collision //pColPair.Attach(new RemoveBombObserver()); ////pColPair.Attach(new ShipExplosionSoundObserver()); ////pColPair.Attach(new TriggerGameOverStateObserver()); //todo need to implement collision reaction for grid v wall, grid vs shield; //--------------------------------------------------------------------------------------------- //AlienGrid/Column CollisionPairs ////AlienGrid vs Walls //// associate object roots in a collision pair //pColPair = ColPairManager.Add(ColPair.Name.Alien_Wall, pGrid, pWallRoot); ////attach all observers that will react to collision //pColPair.Attach(new AlienGridPivotObserver()); //-------------------- //AlienColumn vs Shield Collision //// associate object roots in a collision pair //pColPair = ColPairManager.Add(ColPair.Name.Alien_Shield, pGrid, pShieldRoot); ////attach all observers that will react to collision //pColPair.Attach(new RemoveShieldBrickObserver()); //--------------------------------------------------------------------------------------------- //Ship CollisionPairs Debug.WriteLine("\n\n\n\n\n"); GameObjectManager.DumpAll(); Debug.WriteLine("\n\nLoad Content Complete\n----------------------------------\n"); //----------------------------------------------- //Data Dump; TextureManager.DumpStats(); ImageManager.DumpStats(); GameSpriteManager.DumpStats(); BoxSpriteManager.DumpStats(); SpriteBatchManager.DumpStats(); ProxySpriteManager.DumpStats(); TimerEventManager.DumpStats(); GameObjectManager.DumpStats(); DeathManager.DumpStats(); GhostManager.DumpStats(); ColPairManager.DumpStats(); GlyphManager.DumpStats(); //TextureManager.DumpLists(); //ImageManager.DumpLists(); //GameSpriteManager.DumpLists(); BoxSpriteManager.DumpLists(); //SpriteBatchManager.DumpLists(); //ProxySpriteManager.DumpLists(); //TimerEventManager.DumpLists(); //GameObjectManager.DumpLists(); //DeathManager.DumpLists(); //GhostManager.DumpLists(); //ColPairManager.DumpLists(); //GlyphManager.DumpLists(); //TextureManager.DumpAll(); //ImageManager.DumpAll(); //GameSpriteManager.DumpAll(); //BoxSpriteManager.DumpAll(); //SpriteBatchManager.DumpAll(); //ProxySpriteManager.DumpAll(); //TimerEventManager.DumpAll(); //GameObjectManager.DumpAll(); //DeathManager.DumpAll(); //GhostManager.DumpAll(); //ColPairManager.DumpAll(); //GlyphManager.DumpAll(); }