Ejemplo n.º 1
0
        public static InvaderCategory GetRandomBombDropper(InvaderGrid pGrid)
        {
            InvaderGridManager pMan = InvaderGridManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            InvaderCategory pTmpInvader = null;

            // Find a random bottom row invader to drop the bomb
            int           numColumns        = pGrid.GetNumChildren();
            int           randomColumnIndex = pMan.pRandom.Next(numColumns);
            InvaderColumn pColumn           = (InvaderColumn)pGrid.GetChild(randomColumnIndex);

            pTmpInvader = (InvaderCategory)pColumn.GetChild(0);

            // Check to see if the invader drop the bomb, if not go find another invader

            InvaderCategory pInvader = null;

            for (int i = 0; i < numColumns; i++)
            {
                randomColumnIndex = pMan.pRandom.Next(numColumns);
                pColumn           = (InvaderColumn)pGrid.GetChild(randomColumnIndex);
                pTmpInvader       = (InvaderCategory)pColumn.GetChild(0);
                if (pTmpInvader.canLaunchBomb)
                {
                    pInvader = pTmpInvader;
                    break;
                }
            }

            return(pInvader);
        }
Ejemplo n.º 2
0
        public static GridState GetState(InvaderGridManager.State state)
        {
            InvaderGridManager pMan = InvaderGridManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            GridState pGridState = null;

            switch (state)
            {
            case InvaderGridManager.State.NotCollingWithWall:
                pGridState = pMan.pNotCollingState;
                break;

            case InvaderGridManager.State.CollidingLeftWall:
                pGridState = pMan.pCollidingLeft;
                break;

            case InvaderGridManager.State.CollidingRightWall:
                pGridState = pMan.pCollidingRight;
                break;
            }

            return(pGridState);
        }