Exemplo n.º 1
0
        public override void VisitAlien(AlienCategory a)
        {
            //now Alien Column v. ShieldRoot
            GameObject pGameObject = (GameObject)Iterator.GetChild(this);

            ColPair.Collide(a, pGameObject);
        }
Exemplo n.º 2
0
        override public void Execute(float deltaTime)
        {
            int pFreq = pRandom.Next(1, 10) / this.nCurrLevel;

            AlienGrid     pGrid  = (AlienGrid)GameObjectMan.Find(GameObject.Name.AlienGrid);
            AlienCategory pAlien = pGrid.GetRandomAlien();

            // HACK don't crash pleease
            if (pAlien == null)
            {
                TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
                return;
            }

            int          type          = pRandom.Next(0, 2);
            FallStrategy pFallStrategy = null;

            switch (type)
            {
            case (0):
                pFallStrategy = new FallZigZag();
                break;

            case (1):
                pFallStrategy = new FallDagger();
                break;

            case (2):
                pFallStrategy = new FallStraight();
                break;
            }
            type = pRandom.Next(0, 2);
            GameSprite.Name pGameSpriteName = GameSprite.Name.Uninitialized;
            switch (type)
            {
            case (0):
                pGameSpriteName = GameSprite.Name.BombZigZag;
                break;

            case (1):
                pGameSpriteName = GameSprite.Name.BombDagger;
                break;

            case (2):
                pGameSpriteName = GameSprite.Name.BombStraight;
                break;
            }

            Bomb pBomb = new Bomb(GameObject.Name.Bomb, pGameSpriteName, pFallStrategy, pAlien.x, pAlien.y);

            pBomb.ActivateCollisionSprite(this.pSB_Boxes);
            pBomb.ActivateGameSprite(this.pSB_Bombs);

            GameObject pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            pBombRoot.Add(pBomb);
            TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
        }
Exemplo n.º 3
0
        public void dropBomb()
        {
            AlienColumn pAlienColumn = (AlienColumn)this.poHead;

            while (pAlienColumn != null)
            {
                if (this.randNum.Next(10) >= 10 - this.level)
                {
                    AlienCategory pAlien = (AlienCategory)pAlienColumn.poHead;

                    if (pAlien != null)
                    {
                        // get last alien of column
                        while (pAlien.pNext != null)
                        {
                            pAlien = (AlienCategory)pAlien.pNext;
                        }

                        pAlien.dropBomb();
                    }
                }

                pAlienColumn = (AlienColumn)pAlienColumn.pNext;
            }
        }
Exemplo n.º 4
0
        public override void VisitAlien(AlienCategory a)
        {
            //Alien v ShipRoot
            //now check ship
            GameObject pGameObject = (GameObject)Iterator.GetChild(this);

            ColPair.Collide(a, pGameObject);
        }
Exemplo n.º 5
0
        public override void VisitAlien(AlienCategory a)
        {
            //Alien v Shield Column
            //now check its children(bricks)
            GameObject pGameObject = (GameObject)Iterator.GetChild(this);

            ColPair.Collide(a, pGameObject);
        }
Exemplo n.º 6
0
        public override void VisitAlien(AlienCategory a)
        {
            //Alien v Shield Brick
            ColPair pColPair = ColPairMan.GetActiveColPair();

            pColPair.SetCollision(a, this);
            pColPair.NotifyListeners();
        }
Exemplo n.º 7
0
        public override void DropBomb(AlienCategory pAlien)
        {
            Bomb pBomb = AlienMan.ActivateBomb(pAlien);

            pBomb.SetPos(pAlien.x + 10 * AlienGroup.GetXDirection(), pAlien.y - 15);

            // switch states
            this.Handle(pAlien);
        }
Exemplo n.º 8
0
        public override void dropBomb(AlienCategory pAlien)
        {
            Bomb pBomb = BombMan.ActiveBomb();

            pBomb.setPos(pAlien.x + 5, pAlien.y - 40);
            pBomb.setShooter(pAlien);

            // switch states
            this.handle(pAlien);
        }
Exemplo n.º 9
0
        public static Bomb ActivateBomb(AlienCategory pAlien)
        {
            AlienMan pAlienMan = AlienMan.PrivInstance();

            Debug.Assert(pAlienMan != null);

            // copy over safe copy
            byte[] buffer = Guid.NewGuid().ToByteArray();
            int    iSeed  = BitConverter.ToInt32(buffer, 0);
            Random random = new Random(iSeed);

            Bomb pBombObj = null;
            int  randint  = random.Next(0, 4);

            switch (randint)
            {
            case 0:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombDagger, new FallDagger(), pAlien.x, pAlien.y, pAlien);
                break;

            case 1:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombRolling, new FallRolling(), pAlien.x, pAlien.y, pAlien);
                break;

            case 2:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombZigZag, new FallZigZag(), pAlien.x, pAlien.y, pAlien);
                break;

            case 3:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombStraight, new FallStraight(), pAlien.x, pAlien.y, pAlien);
                break;

            default:
                Debug.Assert(false);
                break;
            }

            pAlienMan.pBomb = pBombObj;

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Box    = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pBombObj.ActivateCollisionSprite(pSB_Box);
            pBombObj.ActivateGameSprite(pSB_Aliens);

            // Attach the missile to the missile root
            GameObject pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pBombRoot.Add(pAlienMan.pBomb);

            return(pAlienMan.pBomb);
        }
Exemplo n.º 10
0
        public override void VisitAlien(AlienCategory a)
        {
            Debug.WriteLine("         collide:  {0} <-> {1}", a.GetName(), this.GetName());

            Debug.WriteLine("-------> BOOM!  <--------");

            ColPair pColPair = ColPairMan.GetActiveColPair();

            pColPair.SetCollision(a, this);
            pColPair.NotifyListeners();
        }
Exemplo n.º 11
0
        public void DropBomb(GameObject pGameObj)
        {
            AlienCategory pAlienceCategory = (AlienCategory)pGameObj;

            if (pGameObj.pNext == null)
            {
                byte[] buffer = Guid.NewGuid().ToByteArray();
                int    iSeed  = BitConverter.ToInt32(buffer, 0);
                Random random = new Random(iSeed);

                int dropPossibility = random.Next(0, 100);
                if (dropPossibility < 5)
                {
                    pAlienceCategory.DropBomb();
                }
            }
        }
Exemplo n.º 12
0
        public GameObject Create(GameObject.Name name, AlienCategory.Type type, GameObject pContainer = null, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pGameObj = null;

            switch (type)
            {
            case AlienCategory.Type.Squid:
                pGameObj = new Squid(GameObject.Name.Squid, GameSprite.Name.Squid, posX, posY);
                AlienCategory pAlienCategory = (AlienCategory)pGameObj;
                pAlienCategory.SetState(AlienMan.State.Ready);
                break;

            case AlienCategory.Type.Crab:
                pGameObj       = new Crab(GameObject.Name.Crab, GameSprite.Name.Crab, posX, posY);
                pAlienCategory = (AlienCategory)pGameObj;
                pAlienCategory.SetState(AlienMan.State.Ready);
                break;

            case AlienCategory.Type.Octopus:
                pGameObj       = new Octopus(GameObject.Name.Octopus, GameSprite.Name.Octopus, posX, posY);
                pAlienCategory = (AlienCategory)pGameObj;
                pAlienCategory.SetState(AlienMan.State.Ready);
                break;

            case AlienCategory.Type.Group:
                pGameObj = new AlienGroup(name, GameSprite.Name.NullObject, posX, posY);
                break;

            case AlienCategory.Type.Column:
                pGameObj = new AlienColumn(name, GameSprite.Name.NullObject, posX, posY);
                break;

            default:
                Debug.Assert(false);
                break;
            }

            // Attached to Group
            this.AttachTo(pGameObj, pContainer);
            return(pGameObj);
        }
Exemplo n.º 13
0
        public AlienCategory GetRandomAlien()
        {
            AlienCategory   pAlien = null;
            ForwardIterator pFor   = new ForwardIterator(this);
            Component       pNode  = pFor.First();
            int             pCount = pRandom.Next(1, this.nTotalAliens - 1);
            int             x      = 0;

            while (!pFor.IsDone())
            {
                GameObject pGameObj = (GameObject)pNode;
                if (!pGameObj.bMarkForDeath && x >= pCount && pGameObj is AlienCategory)
                {
                    pAlien = (AlienCategory)pGameObj;
                    break;
                }
                pNode = pFor.Next();
                x++;
            }
            return(pAlien);
        }
Exemplo n.º 14
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);
                }
            }
        }
Exemplo n.º 15
0
        //rebuilds the Alien Group Tree
        public static void RaiseDead()
        {
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Boxes  = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);
            GameObject  pRoot      = GONodeMan.Find(GameObject.Name.AlienGrid);

            GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance();

            GameObject pSafety = pGraveyard.poHead;

            GameObject pNode = pSafety;

            GameObject pNextNode = null;

            //search for the columns
            while (pNode != null)
            {
                //save this to iterate, because we will possibly remove the next pointer
                pNextNode = (GameObject)pNode.pNext;

                //we still have the parent reference on the objects
                if (pRoot == pNode.pParent)
                {
                    //dettach from list then add it to tree
                    pGraveyard.PrivDetach(pNode, ref pGraveyard.poHead);

                    pNode.Clear();

                    pRoot.Add(pNode);
                    pNode.ActivateGameSprite(pSB_Aliens);
                    pNode.ActivateCollisionSprite(pSB_Boxes);
                }

                pNode = pNextNode;
            }

            //random check
            //check to see if AlienGroup has a column
            Debug.Assert(pRoot.GetFirstChild() != null);

            GameObject pColumn = (GameObject)pRoot.GetFirstChild();

            //iterate through the column siblings
            while (pColumn != null)
            {
                //iterate through the graveyard
                pNode = pGraveyard.poHead;
                while (pNode != null)
                {
                    //save this to iterate, because we will possibly remove the next pointer it
                    pNextNode = (GameObject)pNode.pNext;

                    //check the parent reference to the column
                    if (pColumn == pNode.pParent)
                    {
                        //dettach from list then add it to tree
                        pGraveyard.PrivDetach(pNode, ref pGraveyard.poHead);

                        AlienCategory pAlien = (AlienCategory)pNode;
                        pAlien.x             = pAlien.OrigX();
                        pAlien.y             = pAlien.OrigY() - 100.0f;
                        pAlien.bMarkForDeath = false;

                        pNode.Clear();

                        pColumn.Add(pNode);
                        pNode.ActivateGameSprite(pSB_Aliens);
                        pNode.ActivateCollisionSprite(pSB_Boxes);
                    }

                    pNode = pNextNode;
                }


                pColumn = (GameObject)pColumn.pNext;
            }
        }
Exemplo n.º 16
0
 public override void Handle(AlienCategory pAlien)
 {
     pAlien.SetState(AlienMan.State.BombFlying);
 }
Exemplo n.º 17
0
 public virtual void VisitAlien(AlienCategory a)
 {
     Debug.WriteLine("Visit by octo not implemented");
     Debug.Assert(false);
 }
Exemplo n.º 18
0
 public override void LoadBomb(AlienCategory pAlien)
 {
 }
Exemplo n.º 19
0
 public override void Handle(AlienCategory pAlien)
 {
 }
Exemplo n.º 20
0
 public override void DropBomb(AlienCategory pAlien)
 {
 }
Exemplo n.º 21
0
 //---------------------------------------------------------
 // Override abstract methods
 //---------------------------------------------------------
 public override void handle(AlienCategory pAlien)
 {
     pAlien.setState(AlienMan.State.BombDroping);
 }
Exemplo n.º 22
0
 public virtual void dropBomb(AlienCategory pAlien)
 {
 }
Exemplo n.º 23
0
 //---------------------------------------------------------
 // Abstract class
 //---------------------------------------------------------
 // state()
 public abstract void handle(AlienCategory pAlien);
Exemplo n.º 24
0
 public RemoveAlienCommand(AlienCategory alien)
 {
     this.alien = null;
 }
Exemplo n.º 25
0
 public void setShooter(AlienCategory pAlien)
 {
     this.pShooter = pAlien;
 }
Exemplo n.º 26
0
 // strategy()
 public abstract void LoadBomb(AlienCategory pAlien);
Exemplo n.º 27
0
 public abstract void DropBomb(AlienCategory pAlien);