public override void Notify()
        {
            GameObject pObject = this.pSubject.pObjA;

            this.pShip = (Ship)this.pSubject.pObjB;
            Debug.Assert(pShip != null);

            if (pShip.bMarkForDeath == false)
            {
                this.pShip.bMarkForDeath = true;

                //had initially tried to use the reference "this" ship
                //did not work FYI, needed to get the ship from manager
                Ship pShip = ShipMan.GetShip();

                pShip.SetShootState(ShipMan.ShootState.End);
                pShip.SetMoveState(ShipMan.MoveState.NoMove);


                HitShipObserver pObserver = new HitShipObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }

            //very wierd not sure how i feel about it
            if (pObject.GetName() == GameObject.Name.Octopus || pObject.GetName() == GameObject.Name.Squid || pObject.GetName() == GameObject.Name.Crab)
            {
                //we want to reset the grids location
                AlienGroup pGrid = (AlienGroup)GONodeMan.Find(GameObject.Name.AlienGrid);
                pGrid.MoveUp();
            }
        }
Esempio n. 2
0
        public static void DumpNodes()
        {
            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            Debug.Assert(pGraveyard != null);

            GameObject pNode = pGraveyard.poHead;

            if (pNode == null)
            {
                Debug.WriteLine("-----------------------------");
                Debug.WriteLine("Graveyard Empty");
                Debug.WriteLine("-----------------------------");
            }
            else
            {
                int i = 0;
                while (pNode != null)
                {
                    Debug.WriteLine("");
                    Debug.WriteLine("{0})----------", i);
                    Debug.WriteLine("{0} ({1})", pNode.GetName(), pNode.GetHashCode());
                    Debug.WriteLine("Parent: {0} X:{1}, Y:{2}", pNode.pParent, pNode.x, pNode.y);

                    pNode = (GameObject)pNode.pNext;
                    i++;
                }
            }
        }
        public override void Notify()
        {
            this.pShip = (Ship)this.pSubject.pObjA;
            Debug.Assert(this.pShip != null);


            this.pWall = (WallCategory)this.pSubject.pObjB;
            Debug.Assert(this.pWall != null);

            if (pWall.GetName() == GameObject.Name.LeftWall)
            {
                this.pShip.SetMoveState(ShipMan.MoveState.NoLeft);
            }

            if (pWall.GetName() == GameObject.Name.RightWall)
            {
                this.pShip.SetMoveState(ShipMan.MoveState.NoRight);
            }
        }
Esempio n. 4
0
        public override void Notify()
        {
            // It is very important to know the data type of pObjA and pObjB
            AlienGroup pAlien = (AlienGroup)this.pSubject.pObjA;
            GameObject pWall  = (GameObject)this.pSubject.pObjB;

            if (pWall.GetName() == GameObject.Name.WallRight)
            {
                if (!pAlien.isInWall)
                {
                    pAlien.isInWall = true;
                    pAlien.ChangeState(AlienGridMoveState.MoveState.GridHitRightWall);
                }
            }
            else if (pWall.GetName() == GameObject.Name.WallLeft)
            {
                if (!pAlien.isInWall)
                {
                    pAlien.isInWall = true;
                    pAlien.ChangeState(AlienGridMoveState.MoveState.GridHitLeftWall);
                }
            }
        }
Esempio n. 5
0
        public override void Notify()
        {
            //remove alien
            //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            //a little tricky ObjA is the missile, we are not alphabetical
            //because of how the missile observer is set up
            this.pAlien = (AlienCategory)this.pSubject.pObjB;
            Debug.Assert(this.pAlien != null);



            if (pAlien.bMarkForDeath == false)
            {
                pAlien.bMarkForDeath = true;

                if (pAlien.GetName() == GameObject.Name.Squid)
                {
                    PlayerMan.SetP1Score(30);
                }

                else if (pAlien.GetName() == GameObject.Name.Crab)
                {
                    PlayerMan.SetP1Score(40);
                }

                else
                {
                    PlayerMan.SetP1Score(50);
                }

                //pass brick reference to manager thats executes/removes objects later
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }
Esempio n. 6
0
        public static void Remove(GameObject pGameObject)
        {
            //get the singleton
            GhostManager pMan = privGetInstance();

            Debug.Assert(pMan != null);

            // Compare functions only compares two Nodes
            pMan.pRefNode.pGameObj.SetName(pGameObject.GetName());
            GhostNode pData = (GhostNode)pMan.baseFindNode(pMan.pRefNode);

            // release the resource
            pData.pGameObj = null;
            pMan.baseRemoveNode(pData);
        }
Esempio n. 7
0
        //public static GameObject Find(GameObject.Name name)
        //{
        //    //get the singleton
        //    GameObjectManager pMan = privGetInstance();

        //    // Compare functions only compares two Nodes
        //    GameObjectManager.pRefNode.pGameObj.SetName(name);

        //    GameObjectNode pNode = (GameObjectNode)pMan.baseFindNode(GameObjectManager.pRefNode);
        //    Debug.Assert(pNode != null);

        //    return pNode.pGameObj;
        //}
        public static GameObject Find(GameObject.Name name, int index = 0)
        {
            GameObjectManager pMan = GameObjectManager.privGetInstance();

            // Compare functions only compares two Nodes
            GameObjectManager.pRefNode.pGameObj.SetName(name);
            GameObjectManager.pRefNode.pGameObj.index = index;

            GameObjectNode pRoot    = (GameObjectNode)pMan.baseGetActive();
            GameObject     pGameObj = null;

            bool found = false;

            while (pRoot != null && found == false)
            {
                // OK at this point, I have a Root tree,
                // need to walk the tree completely before moving to next tree
                //forward navigation
                PCSTreeForwardIterator pIterator = new PCSTreeForwardIterator(pRoot.pGameObj);

                // Initialize
                pGameObj = (GameObject)pIterator.First();
                //while (pGameObj != null)
                while (!pIterator.IsDone())
                {
                    //check for both matching name and index
                    if (pGameObj.GetName() == GameObjectManager.pRefNode.pGameObj.GetName() &&
                        pGameObj.index == GameObjectManager.pRefNode.pGameObj.index)
                    {
                        found = true;
                        break;
                    }

                    // Advance
                    pGameObj = (GameObject)pIterator.Next();
                }

                // Goto Next tree
                pRoot = (GameObjectNode)pRoot.pMNext;
            }

            return(pGameObj);
        }
Esempio n. 8
0
        public override void Notify()
        {
            //Debug.WriteLine("BombObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);
            GameObject placeObject;

            if (this.p == 1)
            {
                placeObject = this.pSubject.pObjA;
            }
            else
            {
                placeObject = this.pSubject.pObjB;
            }

            Bomb pBomb = (Bomb)placeObject;

            GameObject pGameObj = pBomb.getOwned();

            Debug.Assert(pGameObj != null);
            if (pGameObj.GetName() == GameObject.Name.UFO)
            {
                if (pGameObj.bMarkForDeath == false)
                {
                    UFO pUFO = (UFO)pGameObj;
                    pUFO.SetState(UFOMan.State.Flying);
                }
            }
            else
            {
                if (pGameObj.bMarkForDeath == false)
                {
                    AlienCategory pAlien = (AlienCategory)pGameObj;
                    pAlien.SetState(AlienMan.State.Ready);
                }
            }
        }
Esempio n. 9
0
        //execute the Alien Removal - and potentially the removal of a column and the alien grid object
        public override void Execute()
        {
            //if the alien that was removed was the last one in the column, delete the column it was assigned to!
            //Debug.WriteLine("alien {0} parentColumn {1}", this.pAlien, this.pAlien.pParent);

            GameObject targetAlien  = (GameObject)this.pAlienObj;
            GameObject parentColumn = (GameObject)targetAlien.pParent;

            //make sure the parent is a column;
            Debug.Assert(parentColumn.GetName() == GameObject.Name.Column);

            Debug.WriteLine("removing alien {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", targetAlien.pProxySprite.pSprite.GetName(),
                            targetAlien.pProxySprite.x,
                            targetAlien.pProxySprite.y,
                            targetAlien.pProxySprite.sx,
                            targetAlien.pProxySprite.sy
                            );

            //hold the x, y coordinates of the target alien;
            //float target_X = targetAlien.pProxySprite.x;
            //float target_Y = targetAlien.pProxySprite.y;

            //remove the alien
            targetAlien.Remove();

            //gameobject and proxysprite gone;
            //after alien removal, place an explosion sprite in the last location of its proxy sprite;

            //GameSprite pExplodeSprite = GameSpriteManager.Find(GameSprite.Name.AlienExplosion);

            //pExplodeSprite.x = target_X;
            //pExplodeSprite.y = target_Y;
            //pExplodeSprite.sx = 1.0f;
            //pExplodeSprite.sy = 1.0f;



            //pExplodeSprite.Update();
            //pExplodeSprite.Draw();


            ////find the AlienGrid game object to increase the march speed;
            //GameObject pAlienGridObj = GameObjectManager.Find()
            //alienGrid.IncreaseAlienMarchSpeed();
            //Debug.WriteLine("Increased Alien Grid March Speed");
            //Debug.WriteLine("Current MarchSpeed: {0}", AlienGrid.marchSpeed);

            //Grid.liveAlienCount--;
            //Grid.deadAlienCount++;

            //Debug.WriteLine("Live AlienCount: {0}", AlienGrid.liveAlienCount);
            //Debug.WriteLine("Dead AlienCount: {0}", AlienGrid.deadAlienCount);


            //TODO: Need a better way to check if this is last alien in column/last column in grid;
            //check if last alien in the column
            if (privIsLastChildOf(parentColumn) == true)
            {
                //if so, remove the parent column;

                //get the grid pointer before removing the column (in case this is the last column)
                GameObject parentAlienGrid = (GameObject)parentColumn.pParent;
                parentColumn.Remove();

                //double check that parentAlienGrid is actually an alien grid
                Debug.Assert(parentAlienGrid.GetName() == GameObject.Name.Grid);

                //cast to a grid object and decrement the number of columns;
                Grid alienGrid = (Grid)parentAlienGrid;
                alienGrid.DecrementColumnCount();


                //check if the last column in the grid
                if (privIsLastChildOf(parentAlienGrid) == true)
                {
                    //todo - place a next level reload or reward for beating the level here!!!
                    //if so, remove the grid and trigger a reaction
                    parentAlienGrid.Remove();
                }
            }
        }