Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        public override void VisitAlienGrid(AlienGrid ag)
        {
            // AlienGrid vs Wall-Right
            //Debug.WriteLine("\ncollide: {0} with {1}", this, ag);
            //Debug.WriteLine("               --->DONE<----");

            // Set a new direction : Positive means go right -->
            ag.SetDelta(-1.0f);
            ag.SetIsOnWall(true);

            CollPair pCollPair = CollPairManager.GetActiveCollPair();

            Debug.Assert(pCollPair != null);

            // Register collisiton and notify the observers
            pCollPair.SetCollision(ag, this);
            pCollPair.NotifyListeners();
        }