예제 #1
0
        public override void DropBomb()
        {
            //get the total time passed

            //get a random existing column;
            //needs to create a new random every time to
            //keep up with current number of columns;
            Random r = new Random();
            int    randomColumnIndex = r.Next(0, this.numColumns);

            ////check that the child exists - can't drop a bomb if no columns/aliens!
            //Debug.Assert(randomChildColumn != null);
            ////cast to an alien object;
            //AlienType randomColumn = (AlienType)randomChildColumn;
            //todo Clean this up - remove if-else special case for first column bomb drop - without this first column never drops a bomb
            if (randomColumnIndex != 0)
            {
                AlienType randomColumn = privGetRandomColumn(randomColumnIndex);
                Debug.Assert(randomColumn != null);
                //drop the bomb from the appropriate spot;
                //call passed through this->column->alien
                randomColumn.DropBomb();
            }
            else
            {
                GameObject firstColumnObj = (GameObject)this.pChild;
                AlienType  firstColumn    = (AlienType)firstColumnObj;

                Debug.Assert(firstColumn != null);
                firstColumn.DropBomb();
            }
        }
예제 #2
0
        //todo: FIX THE LINKS WHEN THE ALIEN COLUMN IS REMOVED!!!!
        private AlienType privGetRandomColumn(int columnIndex)
        {
            GameObject randomChildColumn = (GameObject)this.pChild;

            //check that the child exists - can't drop a bomb if no columns/aliens!
            Debug.Assert(randomChildColumn != null);

            GameObject pNext = (GameObject)randomChildColumn.pSibling;

            //null check for early out
            if (pNext != null)
            {
                //iterate through siblings of child column until at index of random child;
                for (int i = 0; i < columnIndex - 1; i++)
                {
                    //set next as sibling
                    pNext = (GameObject)pNext.pSibling;
                }

                //set the random child as the last column selected
                AlienType result = (AlienType)pNext;
                Debug.Assert(result != null);
                return(result);
            }
            else
            {
                //no siblings - only one column
                AlienType result = (AlienType)randomChildColumn;
                Debug.Assert(result != null);
                return(result);
            }
        }
예제 #3
0
 public Explosion(GameObjectName goName, SpriteBaseName sName, AlienType alienType, GameObject go, ColorName color, int idx)
     : base(goName, sName, alienType, idx)
 {
     this.x = go.x;
     this.y = go.y;
     this.pProxySprite.x = x;
     this.pProxySprite.y = y;
     this.pProxySprite.pSprite.SetColor(ColorFactory.Create(color).pAzulColor);
 }
예제 #4
0
        //called from column ( (GameObject)this.pParent );
        //passed to lowest alien ( (GameObject)this.pChild );
        public override void DropBomb()
        {
            //get the lowest alien - in PCS tree structure that's the child of this column;
            GameObject childAlien = (GameObject)this.pChild;

            //cast to an alien object;
            AlienType lowAlien = (AlienType)childAlien;

            //drop the bomb from the appropriate spot;
            lowAlien.DropBomb();
        }
예제 #5
0
        private void privTestAlienColumnBombDrop()
        {
            //TEST - drop bomb on trigger;

            //get the grid as a game object
            GameObject gridGameObj = GameObjectManager.Find(GameObject.Name.Grid);
            //cast to an alien to drop the bomb
            AlienType alienGrid = (AlienType)gridGameObj;

            //drop the bomb - function cascades to first child of first column
            alienGrid.DropBomb();
        }
예제 #6
0
        public AlienType Create(AlienType.Type type, GameObject.Name gameObjectName, int index = 0, float posX = 0.0f, float posY = 0.0f)
        {
            AlienType pAlien = null;

            switch (type)
            {
            case AlienType.Type.Crab:
                pAlien = new Crab(gameObjectName, GameSprite.Name.Crab, index, posX, posY);
                break;

            case AlienType.Type.Squid:
                pAlien = new Squid(gameObjectName, GameSprite.Name.Squid, index, posX, posY);
                break;

            case AlienType.Type.Octopus:
                pAlien = new Octopus(gameObjectName, GameSprite.Name.Octopus, index, posX, posY);
                break;


            case AlienType.Type.AlienGrid:
                //note that the grid HAS a sprite to determine color of the sprite box
                //it will not render a sprite since the image is a null image object
                pAlien = new Grid(gameObjectName, GameSprite.Name.AlienGrid, index, posX, posY);
                //GameObjectManager.AttachTree(pAlien);
                //todo refactor GridManager to handle at least two grids;
                GridManager.CreateGridManager((Grid)pAlien);
                break;

            case AlienType.Type.AlienGridColumn:
                pAlien = new Column(gameObjectName, GameSprite.Name.AlienColumn, index, posX, posY);
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }


            //insert alien into the PCSTree Hierarchy;
            this.pTree.Insert(pAlien, this.pParent);

            //Activate the GameSprite by attaching the
            //new alien's proxy sprite to the alien sprite batch;
            //also attach a collision box associated with this sprite;
            pAlien.ActivateGameSprite(this.pSpriteBatch);
            pAlien.ActivateCollisionSprite(this.pSpriteBatch);

            return(pAlien);
        }
예제 #7
0
        public Alien Create(AlienType alienType, float x, float y)
        {
            Alien pAlien = null;

            switch (alienType)
            {
            case AlienType.Crab:
                pAlien = new Crab(GameObjectName.Crab, SpriteBaseName.Crab, x, y);
                break;

            case AlienType.Squid:
                pAlien = new Squid(GameObjectName.Squid, SpriteBaseName.Squid, x, y);
                break;

            case AlienType.Octopus:
                pAlien = new Octopus(GameObjectName.Octopus, SpriteBaseName.Octopus, x, y);
                break;

            case AlienType.Hierarchy:
                pAlien = new Grid();
                break;

            case AlienType.Ship:
                pAlien = new Ship(GameObjectName.Ship, SpriteBaseName.Ship, x, y);
                break;

            default:
                Debug.Assert(pAlien != null);
                break;
            }
            GameObjectManager.Add(pAlien);
            //this.pTree.dumpTree();
            if (alienType != AlienType.Ship)
            {
                this.pTree.Insert(pAlien, this.pParent);
            }
            //this.pTree.dumpTree();
            this.pSpriteBatch.Attach(pAlien.pProxySprite);
            this.pSpriteBoxBatch.Attach(pAlien.pCollisionObject.pCollisionSpriteBox);
            return(pAlien);
        }
예제 #8
0
        public Alien Create(AlienType alienType, GameObjectName goName, int goIdx = 0, float x = 0.0f, float y = 0.0f)
        {
            Alien pAlien = null;

            switch (alienType)
            {
            case AlienType.Crab:
                pAlien = new Crab(goName, SpriteBaseName.Crab, x, y, goIdx);
                break;

            case AlienType.Squid:
                pAlien = new Squid(goName, SpriteBaseName.Squid, x, y, goIdx);
                break;

            case AlienType.Octopus:
                pAlien = new Octopus(goName, SpriteBaseName.Octopus, x, y, goIdx);
                break;

            case AlienType.Grid:
                pAlien = new Grid(goName, SpriteBaseName.Null, x, y, goIdx);
                GameObjectManager.AttachTree(pAlien);
                break;

            case AlienType.Column:
                pAlien = new Column(goName, SpriteBaseName.Null, x, y, goIdx, this.pRandom);
                break;

            default:
                Debug.Assert(pAlien != null);
                break;
            }
            this.pTree.Insert(pAlien, this.pParent);
            pAlien.ActivateGameSprite(this.pSpriteBatch);
            pAlien.ActivateCollisionSprite(this.pSpriteBatch);
            return(pAlien);
        }
예제 #9
0
파일: Alien.cs 프로젝트: ccaunca/Projects
 public Alien(GameObjectName goName, SpriteBaseName spriteName, AlienType alienType, int idx)
     : base(goName, spriteName, idx)
 {
     this.alienType = alienType;
 }
예제 #10
0
파일: Alien.cs 프로젝트: ccaunca/Projects
 public Alien(GameObjectName goName, SpriteBaseName spriteName, AlienType alienType, float x, float y)
     : base(goName, GameObjectType.Alien, spriteName, x, y)
 {
     this.alienType = alienType;
 }