Beispiel #1
0
        //---------------------------------------------------------
        // Override abstract methods
        //---------------------------------------------------------
        public override void notify()
        {
            //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            AlienGroup   pGird = (AlienGroup)this.pSubject.pObjA;
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetCategoryType() == WallCategory.Type.Right && pGird.getMoveForward())
            {
                pGird.setMoveForward(false);
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left && !pGird.getMoveForward())
            {
                pGird.setMoveForward(true);
            }
            //else
            //{
            //    Debug.Assert(false);
            //}

            if (pGird.poCollisionObject.pCollisionSprite.y >= 450.0f)
            {
                pGird.setGoingDown(true);
            }
        }
Beispiel #2
0
        public override void Notify()
        {
            Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // OK do some magic
            AlienGrid pGrid = (AlienGrid)this.pSubject.pObjA;

            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                if (pGrid.flag == true)
                {
                    pGrid.SetDelta(-20.0f);
                    pGrid.MoveDownGrid();
                    pGrid.flag = false;
                }
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                if (pGrid.flag == false)
                {
                    pGrid.SetDelta(20.0f);
                    pGrid.MoveDownGrid();
                    pGrid.flag = true;
                }
            }
            else
            {
                Debug.Assert(false);
            }
        }
Beispiel #3
0
        public override void Notify()
        {
            //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // OK do some alphabetic magic
            AlienGrid    pGrid = (AlienGrid)this.pSubject.pObjA;
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;


            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                // Was set true in the collision

                if (pGrid.GetIsOnWall())
                {
                    Debug.WriteLine("---- Hiding : Wall Hit");
                    TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO(pGrid), pGrid.movementTimeInterval);
                }
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                // Was set true in the collision

                if (pGrid.GetIsOnWall())
                {
                    Debug.WriteLine("---- Hiding : Wall Hit");
                    TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO(pGrid), pGrid.movementTimeInterval);
                }
            }

            else
            {
                Debug.Assert(false);
            }
        }
Beispiel #4
0
        //Grid Observer only worryies about moving the grid back and forth and down
        public override void Notify()
        {
            float movement;
            //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            AlienGroup pGrid = (AlienGroup)this.pSubject.pObjA;

            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                //BAD HACK FIX LATER
                movement = pGrid.GetDeltaMove() * -1.0f;
                pGrid.SetDeltaMove(movement);
                pGrid.MoveAcross();
                pGrid.MoveDown();
            }

            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                movement = pGrid.GetDeltaMove() * -1.0f;
                pGrid.SetDeltaMove(movement);
                pGrid.MoveAcross();
                pGrid.MoveDown();
            }

            else
            {
                //Bottom Wall hit, move aliens up and reset Waves before Game Over
                SpaceInvaders pGame  = GameMan.GetGame();
                GameState     pState = pGame.GetCurrentState();

                if (pState.GetStateName() == GameMan.State.InGame)
                {
                    InGameState pLvl1 = (InGameState)pState;
                    pLvl1.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 2.0f);
                }

                else if (pState.GetStateName() == GameMan.State.LVL2)
                {
                    InGameStateLV2 pLvl2 = (InGameStateLV2)pState;
                    pLvl2.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 2.0f);
                }
            }
        }
        public override void Notify()
        {
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;
            //Debug.WriteLine("Ship hits " + pWall.name);

            Ship pShip = ShipMan.GetShip();

            if (pWall.name == GameObject.Name.WallRight)
            {
                pShip.SetState(ShipMan.State.NotMovingRight);
            }
            else if (pWall.name == GameObject.Name.WallLeft)
            {
                pShip.SetState(ShipMan.State.NotMovingLeft);
            }
        }
Beispiel #6
0
        public override void Notify()
        {
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetCategoryType() == WallCategory.Type.Right && this.flag == true)
            {
                this.flag = false;
                MoveDonw();
                AlienGroup.ChangeDirection(-1);
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left && this.flag == false)
            {
                this.flag = true;
                MoveDonw();
                AlienGroup.ChangeDirection(1);
            }
        }
Beispiel #7
0
        public override void Notify()
        {
            AlienGrid pGrid = (AlienGrid)this.pSubject.pObjA;

            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                pGrid.SetDelta(-2.0f);
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                pGrid.SetDelta(2.0f);
            }
            else
            {
                Debug.Assert(false);
            }
        }
Beispiel #8
0
        public override void Notify()
        {
            //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // OK do some magic
            AlienGrid pGrid = (AlienGrid)this.pSubject.pObjA;

            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                pGrid.SetDelta(-20.0f);
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                pGrid.SetDelta(20.0f);
            }

            pGrid.SetYDelta(-35.0f);
        }
Beispiel #9
0
        public override void Notify()
        {
            //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // OK do some alphabetic magic
            AlienGrid    pGrid = (AlienGrid)this.pSubject.pObjA;
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;


            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                // Was set true in the collision
                if (pGrid.GetIsOnWall())
                {
                    pGrid.SetDelta(-1.0f);
                    // Only add the drop command once
                    TimerManager.Add(TimeEvent.Name.DropGrid, new DropGrid(pGrid), pGrid.movementTimeInterval);
                    // Move off the wall
                    pGrid.MoveGrid();
                }
            }
            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                // Was set true in the collision

                if (pGrid.GetIsOnWall())
                {
                    pGrid.SetDelta(1.0f);
                    // Only add the drop command once
                    TimerManager.Add(TimeEvent.Name.DropGrid, new DropGrid(pGrid), pGrid.movementTimeInterval);
                    // Move off the wall
                    pGrid.MoveGrid();
                }
            }

            else
            {
                Debug.Assert(false);
            }
        }
Beispiel #10
0
        public override void Notify()
        {
            Debug.WriteLine("GridObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // OK do some magic
            Grid pGrid = (Grid)this.pSubject.pObjA;

            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetWallType() == WallCategory.Type.Right)
            {
                pGrid.SetDelta(-2.0f);
            }
            else if (pWall.GetWallType() == WallCategory.Type.Left)
            {
                pGrid.SetDelta(2.0f);
            }
            else
            {
                Debug.Assert(false);
            }
        }