コード例 #1
0
        public void associateBombs()
        {
            UFO ufo = (UFO)FactoryManager.getUfoFactry().cParent.pChild;

            if (ufo.launch)
            {
                if (ufo.x > 50)
                {
                    Random random = new Random(DateTime.UtcNow.Millisecond);
                    int    number = random.Next(1, 3);

                    if (number == 2)
                    {
                        Bomb bomb = getActivatedBomb();
                        bomb.x     = ufo.x;
                        bomb.y     = ufo.y;
                        associated = true;
                    }
                }
            }
            if (!associated)
            {
                int colCount = FactoryManager.getAlienFactry().columnCount;
                if (colCount > 0)
                {
                    Random     random        = new Random(DateTime.UtcNow.Millisecond);
                    int        number        = random.Next(1, colCount);
                    PCSTree    columnPcsTree = FactoryManager.getAlienFactry().cPCSTree;
                    GameObject column        = (GameObject)columnPcsTree.getRoot().pChild;

                    while (column != null)
                    {
                        number--;
                        if (number == 0)
                        {
                            GameObject alien = (GameObject)column.pChild;

                            if (bomb == null)
                            {
                                Bomb bomb = getActivatedBomb();
                                //bomb = (Bomb)GhostManager.find(GameObject.GameObjectName.Bomb);

                                //GhostManager.remove(bomb);
                                //BombFactory bombF = FactoryManager.getBombFactry();
                                //bombF.activate(bomb);
                                if (bomb == null)
                                {
                                    Debug.WriteLine("bomb null");
                                }
                            }
                            bomb.x = alien.x;
                            bomb.y = alien.y;
                            break;
                        }
                        column = (GameObject)column.pSibling;
                    }
                }
            }
            associated = false;
        }
コード例 #2
0
        public override void VisitUFO(UFO u)
        {
            ColPair cp = ColPairMan.GetActiveColPair();

            cp.SetCollision(u, this);
            cp.NotifyListeners();
        }
コード例 #3
0
        public override void Draw(Game pGame)
        {
            FontManager.DrawString("PLAY", 400.0f, 800.0f);
            FontManager.DrawString("SPACE INVADERS", 320.0f, 700.0f);
            FontManager.DrawString("*SCORE ADVANCE TABLE*", 250.0F, 500.0f);
            FontManager.DrawString("= ??? MYSTERY", 380.0f, 440.0f);
            FontManager.DrawString("= 30 POINTS", 380.0f, 365.0f);
            FontManager.DrawString("= 20 POINTS", 380.0f, 290.0f);
            FontManager.DrawString("= 10 POINTS", 380.0f, 215.0f);
            Alien pUFO = new UFO(GameObjectName.UFO, SpriteBaseName.UFO, null, 325.0f, 440.0f);

            pUFO.pProxySprite.x = 325.0f;
            pUFO.pProxySprite.y = 440.0f;
            pUFO.pProxySprite.Render();
            pUFO.pProxySprite.Update();
            Alien pSquid = new Squid(GameObjectName.Squid, SpriteBaseName.Squid, 325.0f, 375.0f, 0);

            pSquid.pProxySprite.x = 325.0f;
            pSquid.pProxySprite.y = 375.0f;
            pSquid.pProxySprite.Render();
            pSquid.pProxySprite.Update();
            Alien pCrab = new Crab(GameObjectName.Crab, SpriteBaseName.Crab, 325.0f, 300.0f, 0);

            pCrab.pProxySprite.x = 325.0f;
            pCrab.pProxySprite.y = 300.0f;
            pCrab.pProxySprite.Render();
            pCrab.pProxySprite.Update();
            Alien pOctopus = new Octopus(GameObjectName.Octopus, SpriteBaseName.Octopus, 325.0f, 225.0f, 0);

            pOctopus.pProxySprite.x = 325.0f;
            pOctopus.pProxySprite.y = 225.0f;
            pOctopus.pProxySprite.Render();
            pOctopus.pProxySprite.Update();
        }
コード例 #4
0
        public void CheckCollision(List <Alien> aliens, UFO ufo)
        {
            if (!bullet.dead)
            {
                foreach (Alien alien in aliens)
                {
                    if (Collision(bullet, alien))
                    {
                        player.Stop();
                        player.Play();
                        bullet.dead = true;
                        bullet.X   -= 10;
                        score      += 600;
                        alien.dead  = true;
                        return;
                    }
                }

                if (Collision(bullet, ufo))
                {
                    player.Stop();
                    player.Play();
                    ufo.die();
                    bullet.dead = true;
                    bullet.X   -= 10;
                    score      += 3000;
                }
            }

            if (enemyManager.getBullets().RemoveAll(bullet => Collision(mainShip, bullet)) > 0)
            {
                PlayerHit();
            }
        }
コード例 #5
0
 private UFOManager()
 {
     this.pUFO            = null;
     this.pBomb           = null;
     this.isUFOActive     = false;
     this.isUFOBombActive = false;
 }
コード例 #6
0
        public static void ChangeSceneInternal(GameObject pGameObject)
        {
            ForwardIterator pFor = new ForwardIterator(pGameObject);

            Component pNode = pFor.First();

            pFor.Next();
            if (pFor.IsDone())
            {
                GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);
                UFO        pUFO     = (UFO)Iterator.GetChild(pUFORoot);
                pUFO.StopSound();

                int mode      = SceneStateGame.GetPlayMode();
                int currLevel = SceneStateGame.GetCurrLevel();

                String pScore1 = Int32.Parse(FontMan.Find(Font.Name.Score1).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore1(pScore1);

                String pScore2 = Int32.Parse(FontMan.Find(Font.Name.Score2).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore2(pScore2);

                String pScoreHigh = Int32.Parse(FontMan.Find(Font.Name.ScoreHigh).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScoreHigh(pScoreHigh);

                SceneStateGame.SetStay(true);

                int currPlayer = SceneStateGame.GetCurrPlayer();

                if (currLevel == 1)
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 2);
                    SceneStateGame.SetBaseY(450.0f);
                    SceneStateGame.SetMoveRate(1.0f);
                }
                else
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 1);
                    SceneStateGame.SetBaseY(600.0f);
                    SceneStateGame.SetMoveRate(1.5f);
                    //no need to change to the next player, when finish level 2, same player, back to level 1
                    //SceneStateGame.SetCurrPlayer(currPlayer == mode ? 1 : 2);
                }

                //currLevel = SceneStateGame.GetCurrLevel();
                //if (currLevel == 1)
                //{
                //    SceneStateGame.SetBaseY(600.0f);
                //    SceneStateGame.SetMoveRate(1.5f);
                //}
                //else
                //{
                //    SceneStateGame.SetBaseY(450.0f);
                //    SceneStateGame.SetMoveRate(1.0f);
                //}

                Scene pScene = SceneMan.GetScene();
                pScene.Unload();
            }
        }
コード例 #7
0
 public virtual void VisitUFO(UFO u)
 {
     //shouldn't call this
     //need to implement in concrete class
     Debug.WriteLine("Visit by UFORoot not implemented");
     Debug.Assert(false);
 }
コード例 #8
0
        override public void Execute(float deltaTime)
        {
            float value = pRandom.Next(10, 60);
            UFO   pUFO  = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 100, 515);

            ColPair pColPair = ColPairMan.Add(ColPair.Name.UFO_WallLeft, pUFO, this.pWallLeft);

            pColPair.Attach(new UFOWallLeftObserver());

            pColPair = ColPairMan.Add(ColPair.Name.UFO_WallRight, pUFO, this.pWallRight);
            pColPair.Attach(new UFOWallRightObserver());

            MissileGroup pMissile = (MissileGroup)GameObjectMan.Find(GameObject.Name.MissileGroup);

            pColPair = ColPairMan.Add(ColPair.Name.UFOMissile, pUFO, pMissile);
            pColPair.Attach(new RemoveUFOObserver());

            pUFO.ActivateCollisionSprite(this.pSB_Boxes);
            pUFO.ActivateGameSprite(this.pSB_Aliens);
            GameObjectMan.Attach(pUFO);

            Sound.Name pSoundName = Sound.Name.Uninitialized;
            switch (pRandom.Next(0, 1))
            {
            case (0):
                pSoundName = Sound.Name.UFOLow;
                break;

            case (1):
                pSoundName = Sound.Name.UFOHigh;
                break;
            }
            SoundMan.PlaySound(pSoundName);
            TimerMan.Add(TimeEvent.Name.UFO, this, value);
        }
コード例 #9
0
        public UFO createUFO(UFO.UFOType mUfoType, GameObject.GameObjectName gameName, int index = 0, float mX = 0.0f, float mY = 0.0f)
        {
            UFO ufo = null;

            switch (mUfoType)
            {
            case UFO.UFOType.UFORoot:
                ufo = new UFORoot(gameName, Sprite.SpriteName.NullObject, index, mX, mY, UFO.UFOType.UFORoot);
                GameObjectNodeManager.add(ufo, cPCSTree);
                break;

            case UFO.UFOType.AlienUFO:
                ufo = new AlienUFO(gameName, Sprite.SpriteName.AlienUFO, index, mX, mY, UFO.UFOType.AlienUFO);
                break;

            case UFO.UFOType.Uninitilized:
                Debug.WriteLine("ufo Type is Uninitilized");
                break;
            }

            this.cPCSTree.Insert(ufo, this.cParent);
            ufo.addSpriteToBatch(this.cSpriteBatch);
            ufo.addCollisionToBatch(SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes));
            return(ufo);
        }
コード例 #10
0
        public override void notify()
        {
            Debug.WriteLine("Action after the Alien and Missile hits goes here");
            Debug.WriteLine("UFOMissileObserver Observer: {0} {1}", this.colSubject.gameObjA.cGameObjectName, this.colSubject.gameObjB.cGameObjectName);

            Missile missile = (Missile)this.colSubject.gameObjA;

            UFO ufo = (UFO)this.colSubject.gameObjB;


            missile.remove();
            ufo.explode(Sprite.SpriteName.AlienExplosion);
            //ufo.removeFromGameManager();
            //ufo.markForDeath();

            //Update Score
            PlayerManager.getCurrentPlayer().addScore(Unit.ufoScore);

            ufo.launch = false;
            UFODeathAnimation deathAni = new UFODeathAnimation(ufo);

            TimerManager.sortedAdd(TimerEvent.TimerEventName.DeathAnimation, deathAni, Unit.ufoDeathAnimationTime);

            Random      random = new Random(DateTime.UtcNow.Millisecond);
            int         number = random.Next(Unit.UFOLaunchMin, Unit.UFOLaunchMax);
            UFOActivate ufoAct = new UFOActivate(ufo);

            TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateUFO, ufoAct, number);
        }
コード例 #11
0
        // Should be called at some point after enter a new state
        public override void Initialize(GameManager pGameManager)
        {
            //Debug.WriteLine("Initializing the Attract Screen");
            //---------------------------------------------------------------------------------------------------------
            // Create Header Fonts
            //---------------------------------------------------------------------------------------------------------

            FontManager.Add(Font.Name.Play, SpriteBatch.Name.Texts, "PLAY", Glyph.Name.Consolas36pt, 400, 800);
            FontManager.Add(Font.Name.SpaceInvader, SpriteBatch.Name.Texts, "SPACE    INVADERS", Glyph.Name.Consolas36pt, 300, 700);
            FontManager.Add(Font.Name.ScoringTable, SpriteBatch.Name.Texts, "*SCORING ADVANCE TABLE*", Glyph.Name.Consolas36pt, 220, 600);
            FontManager.Add(Font.Name.ScoreMystery, SpriteBatch.Name.Texts, "= ? Mystery", Glyph.Name.Consolas36pt, 400, 550);
            FontManager.Add(Font.Name.ScoreSmInvader, SpriteBatch.Name.Texts, "= 30 POINTS", Glyph.Name.Consolas36pt, 400, 500);
            FontManager.Add(Font.Name.ScoreMedInvader, SpriteBatch.Name.Texts, "= 20 POINTS", Glyph.Name.Consolas36pt, 400, 450);
            FontManager.Add(Font.Name.ScoreLgInvader, SpriteBatch.Name.Texts, "= 10 POINTS", Glyph.Name.Consolas36pt, 400, 400);
            FontManager.Add(Font.Name.PressSpace, SpriteBatch.Name.Texts, "<PRESS SPACE TO CONTINUE>", Glyph.Name.Consolas36pt, 200, 200);

            InvaderFactory rootLevelIF = new InvaderFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes);
            UFO            pUFO        = (UFO)rootLevelIF.ActiveCreate(GameObject.Type.UFO, 350, 550);

            pUFO.speedX = 0;
            rootLevelIF.ActiveCreate(GameObject.Type.SmallInvader, 350, 500);
            rootLevelIF.ActiveCreate(GameObject.Type.MediumInvader, 350, 450);
            rootLevelIF.ActiveCreate(GameObject.Type.LargeInvader, 350, 400);

            InputSubject pInputSubject = InputManager.GetSpaceSubject();

            pInputSubject.Attach(new AdvanceGameStateObserver());
        }
コード例 #12
0
 public static UFO create(UFO.Side side)
 {
     UFO ufo;
     if (side.Equals(UFO.Side.Left))
     {
         if (Instance.ufo == null)
         {
             ufo = new UFO(side, 0f, Constants.SCREEN_HEIGHT * .87f);
         }
         else
         {
             ufo = Instance.ufo;
             ufo.set(side, 0f, Constants.SCREEN_HEIGHT * .87f);
         }
     }
     else
     {
         if (Instance.ufo == null)
         {
             ufo = new UFO(side, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT * .87f);
         }
         else
         {
             ufo = Instance.ufo;
             ufo.set(side, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT * .87f);
         }
     }
     Instance.batch.attach(ufo.Spr);
     SpriteBatchManager.attachToGroup(ufo.ColObj.Spr, BatchGroup.BatchType.Collisions);
     GameObjectManager.insert(ufo, Instance.ufoTree);
     return ufo;
 }
コード例 #13
0
        public override void VisitUFO(UFO u)
        {
            // Bomb vs WallRoot
            GameObject pGameObj = (GameObject)Iterator.GetChild(this);

            ColPair.Collide(u, pGameObj);
        }
コード例 #14
0
        public static void DropBomb()
        {
            UFOManager ufoMan  = UFOManager.GetInstance();
            UFO        ufo     = ufoMan.pUFO;
            PCSTree    pcsTree = GameObjectManager.GetRootTree();

            Debug.Assert(pcsTree != null);

            Bomb pBomb = new Bomb(GameObjectName.UFOBomb, SpriteBaseName.UFOBomb, new FallStraight(), ufo.x, ufo.y, 0);

            pBomb.pProxySprite.pSprite.SetColor(ColorFactory.Create(ColorName.Red).pAzulColor);
            ufoMan.pBomb = pBomb;

            SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes  = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            pBomb.ActivateCollisionSprite(sbBoxes);
            pBomb.ActivateGameSprite(sbAliens);

            GameObject pBombRoot = GameObjectManager.Find(GameObjectName.BombRoot);

            Debug.Assert(pBombRoot != null);

            pcsTree.Insert(ufoMan.pBomb, pBombRoot);
            SetUFOBombActive(true);
            Debug.WriteLine("UFO Bomb dropped!");
        }
コード例 #15
0
        public static UFO ActivateUFO(bool isCollisionBoxActive)
        {
            Debug.WriteLine("UFO has been activated!");
            UFOManager ufoMan = UFOManager.GetInstance();

            PCSTree pcsTree = GameObjectManager.GetRootTree();

            Debug.Assert(pcsTree != null);

            UFOStrategy strat = new UFOMoveRight();
            float       x     = -10.0f;

            if (pRandom.Next(0, 2) == 0)
            {
                strat = new UFOMoveLeft();
                x     = 915.0f;
            }

            UFO pUFO = new UFO(GameObjectName.UFO, SpriteBaseName.UFO, strat, x, 905.0f);

            ufoMan.pUFO = pUFO;

            UFORoot     pUFORoot = (UFORoot)GameObjectManager.Find(GameObjectName.UFORoot);
            SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes  = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            if (isCollisionBoxActive)
            {
                pUFO.ActivateCollisionSprite(sbBoxes);
            }
            pUFO.ActivateGameSprite(sbAliens);
            pcsTree.Insert(ufoMan.pUFO, pUFORoot);
            SetUFOActive(true);
            return(ufoMan.pUFO);
        }
コード例 #16
0
ファイル: UFOSpawnEvent.cs プロジェクト: ccaunca/Projects
        private void SpawnUFO()
        {
            int random = UFOManager.GetRandom().Next(7, 10);

            this.pUFO = UFOManager.ActivateUFO(GameManager.GetCollisionBoxes());
            TimerManager.Add(TimerEventName.PlayUFOSound, TimerManager.GetCurrentTime() + 0.2f, 0.2f, new StartUFOSoundCommand());
            TimerManager.Add(TimerEventName.UFOSpawnBomb, TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), new UFOBombSpawnEvent());
        }
コード例 #17
0
 public RandomlySpawnUFO(float timeRange, Missile pMissile, WallManager pWallMan)
     : base(timeRange)
 {
     this.poUfo    = null;
     this.poUfoIF  = new InvaderFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes);
     this.pMissile = pMissile;
     this.pWallMan = pWallMan;
 }
コード例 #18
0
        public static void MoveUFO(float x, float y)
        {
            UFO pUFO = GetUFO();

            pUFO.x = x;
            pUFO.y = y;
            pUFO.Update();
        }
コード例 #19
0
        public override void VisitUFO(UFO u)
        {
            ColPair pColPair = ColPairMan.GetActiveColPair();

            Debug.Assert(pColPair != null);

            pColPair.SetCollision(u, this);
            pColPair.NotifyListeners();
        }
コード例 #20
0
ファイル: WallRight.cs プロジェクト: abergie5b/SpaceInvaders
        public override void VisitUFO(UFO m)
        {
            // Missile vs WallTop
            //Debug.WriteLine(" ---> Done");
            ColPair pColPair = ColPairMan.GetActiveColPair();

            pColPair.SetCollision(m, this);
            pColPair.NotifyListeners();
        }
コード例 #21
0
        public override void Update()
        {
            UFO pUFO = (UFO)this.pSubject.goB;

            if (pUFO != null)
            {
                ScoreManager.UpdateScore(pUFO);
            }
        }
コード例 #22
0
ファイル: UfOBomb.cs プロジェクト: AlfredYan/Space_Invaders
        public override void execute(float deltaTime)
        {
            UFO pUFO = UFOMan.getUFO();

            if (pUFO != null)
            {
                pUFO.dropBomb();
            }
        }
コード例 #23
0
ファイル: UFOMan.cs プロジェクト: Carsonq/SpaceInvaders
        private UFOMan()
        {
            this.pStateReady    = new UFOStateReady();
            this.pStateFlying   = new UFOStateFlying();
            this.pStateEnd      = new UFOStateEnd();
            this.pStateDropping = new UFOStateDropping();

            this.pUFO = null;
        }
コード例 #24
0
        public override void loadContent(Scene pScene)
        {
            SpriteBatchMan.Add(SpriteBatch.Name.SelectWindowTexts);

            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "SCORE<1>", Glyph.Name.Consolas36pt, 20, 1000);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "HI-SCORE", Glyph.Name.Consolas36pt, 370, 1000);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "SCORE<2>", Glyph.Name.Consolas36pt, 700, 1000);
            FontMan.Add(Font.Name.ScoreOne, SpriteBatch.Name.SelectWindowTexts, pScene.getScoreOne().ToString("D4"), Glyph.Name.Consolas36pt, 50, 960);
            FontMan.Add(Font.Name.HighestScore, SpriteBatch.Name.SelectWindowTexts, pScene.getHighestScore().ToString("D4"), Glyph.Name.Consolas36pt, 400, 960);
            FontMan.Add(Font.Name.ScoreTwo, SpriteBatch.Name.SelectWindowTexts, pScene.getScoreTwo().ToString("D4"), Glyph.Name.Consolas36pt, 730, 960);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "CREDIT", Glyph.Name.Consolas36pt, 700, 25);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "00", Glyph.Name.Consolas36pt, 830, 25);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "SPACE    INVADERS", Glyph.Name.Consolas36pt, 300, 750);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "PUSH <1> OR <2> PLAYERS BUTTON", Glyph.Name.Consolas36pt, 160, 700);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "*SCORE  ADVANCE  TABLE*", Glyph.Name.Consolas36pt, 240, 650);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 200 POINTS", Glyph.Name.Consolas36pt, 380, 600);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 30 POINTS", Glyph.Name.Consolas36pt, 380, 550);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 20 POINTS", Glyph.Name.Consolas36pt, 380, 500);
            FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 10 POINTS", Glyph.Name.Consolas36pt, 380, 450);

            SpriteBatch   pSB_StartWindowSprites = SpriteBatchMan.Add(SpriteBatch.Name.StartWindowSprites);
            ShipLifeGroup pStartWindow           = new ShipLifeGroup(GameObject.Name.ShipLifeGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pStartWindow.activateGameSprite(pSB_StartWindowSprites);

            UFO pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 320, 600, true);

            pUFO.activateGameSprite(pSB_StartWindowSprites);
            pStartWindow.add(pUFO);

            Squid pSquid = new Squid(GameObject.Name.Squid, GameSprite.Name.Squid, 320, 550);

            pSquid.activateGameSprite(pSB_StartWindowSprites);
            pStartWindow.add(pSquid);

            Crab pCrab = new Crab(GameObject.Name.Crab, GameSprite.Name.Crab, 320, 500);

            pCrab.activateGameSprite(pSB_StartWindowSprites);
            pStartWindow.add(pCrab);

            Octopus pOctopus = new Octopus(GameObject.Name.Octopus, GameSprite.Name.Octopus, 320, 450);

            pOctopus.activateGameSprite(pSB_StartWindowSprites);
            pStartWindow.add(pOctopus);

            GameObjectMan.Attach(pStartWindow);

            InputSubject pInputSubject;

            pInputSubject = InputMan.GetKey1Subject();
            pInputSubject.attach(new OnePlayerObserver());

            pInputSubject = InputMan.GetKey2Subject();
            pInputSubject.attach(new TwoPlayerObserver());
        }
コード例 #25
0
ファイル: RightWall.cs プロジェクト: ramjam1215/SpaceInvaders
        public override void VisitUFO(UFO u)
        {
            //Debug.WriteLine("         collide:  {0} <-> {1}", u.GetName(), this.GetName());

            //missile hit wall(keep it alsphabetical)
            //Debug.WriteLine("-------> Missed It!  <--------");
            ColPair pColPair = ColPairMan.GetActiveColPair();

            pColPair.SetCollision(u, this);
            pColPair.NotifyListeners();
        }
コード例 #26
0
        // Creates invader And adds it to Batches or gameobject manager
        public GameObject ActiveCreate(GameObject.Type type, float posX, float posY)
        {
            GameObject pGameObj = null;

            switch (type)
            {
            case GameObject.Type.SmallInvader:
                pGameObj = new SmallInvader(GameObject.Name.SmallInvader, Sprite.Name.SmallInvader, BoxSprite.Name.SmallInvaderBox, posX, posY);
                break;

            case GameObject.Type.MediumInvader:
                pGameObj = new MediumInvader(GameObject.Name.MediumInvader, Sprite.Name.MediumInvader, BoxSprite.Name.MediumInvaderBox, posX, posY);
                break;

            case GameObject.Type.LargeInvader:
                pGameObj = new LargeInvader(GameObject.Name.LargeInvader, Sprite.Name.LargeInvader, BoxSprite.Name.LargeInvaderBox, posX, posY);
                break;

            case GameObject.Type.UFO:
                pGameObj = new UFO(GameObject.Name.UFO, Sprite.Name.UFO, BoxSprite.Name.UFOBox, posX, posY);
                break;

            case GameObject.Type.InvaderColumn:
                pGameObj = new InvaderColumn(GameObject.Name.InvaderColumn, BoxSprite.Name.InvaderColumnBox);
                break;

            case GameObject.Type.InvaderGrid:
                pGameObj = new InvaderGrid(GameObject.Name.InvaderGrid, BoxSprite.Name.InvaderGridBox);
                break;

            default:
                // something is wrong
                Debug.Assert(false, "GameObject type not supported by this factory");
                break;
            }

            // add it to the gameObjectManager
            Debug.Assert(pGameObj != null);
            GameObjectManager.Attach(pGameObj);

            if (pGOComposite != null)
            {
                // add to grouping
                pGOComposite.Add(pGameObj);
            }

            // Attached to Batches
            this.pBoxSpriteBatch.Attach(pGameObj.poColObj.pColSprite);
            this.pSpriteBatch.Attach(pGameObj.pProxySprite);
            return(pGameObj);
        }
コード例 #27
0
        public override void Move(UFO pUFO)
        {
            byte[] buffer = Guid.NewGuid().ToByteArray();
            int    iSeed  = BitConverter.ToInt32(buffer, 0);
            Random random = new Random(iSeed);

            int movePossibility = random.Next(0, 200);

            if (movePossibility == 5)
            {
                this.Handle(pUFO);
                pUFO.PlaySound();
            }
        }
コード例 #28
0
        public void loadUFO()
        {
            UFOFactory ufoFactory = FactoryManager.getUfoFactry();
            UFORoot    ufoRoot    = (UFORoot)ufoFactory.createUFO(UFO.UFOType.UFORoot, GameObject.GameObjectName.UFORoot, 0, 0, 0);

            ufoFactory.setParent(ufoRoot);

            UFO         ufo    = ufoFactory.createUFO(UFO.UFOType.AlienUFO, GameObject.GameObjectName.AlienUFO, 1, Unit.ufoPosX, Unit.ufoPosY);
            Random      random = new Random(DateTime.UtcNow.Millisecond);
            int         number = random.Next(1, 40);
            UFOActivate ufoAct = new UFOActivate(ufo);

            TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateUFO, ufoAct, number);
        }
コード例 #29
0
        public override void notify()
        {
            TimerManager.addDelta(delta);
            FactoryManager.getBombFactry().removeChildren();
            UFO ufo = (UFO)FactoryManager.getUfoFactry().cParent.pChild;

            if (ufo.launch)
            {
                ufo.reset();
                Random      random = new Random(DateTime.UtcNow.Millisecond);
                int         number = random.Next(1, 40);
                UFOActivate ufoAct = new UFOActivate(ufo);
                TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateUFO, ufoAct, number);
            }
            //   Game.freezeGame();
        }
コード例 #30
0
        protected override void DoAction()
        {
            //Debug.WriteLine("Attempting to Spawen an Alien!!!");
            if (this.poUfo == null || this.poUfo.bMarkForDeath == true)
            {
                int UfoDirection = this.pRandom.Next(0, 2);
                //Debug.WriteLine("Random direction is: " + UfoDirection);
                this.poUfo = (UFO)this.poUfoIF.ActiveCreate(GameObject.Type.UFO, Constants.UFOPosXPos, Constants.UFOYPos);
                if (UfoDirection == 0)
                {
                    this.poUfo.speedX *= -1.0f;
                    this.poUfo.x       = Constants.UFONegXPos;
                }
                IrrKlang.ISound pHardwareSound = SoundManager.PlaySound(Sound.Name.UFOLowPitch, true);

                ColPair pMissile_UFOColPair = ColPairManager.Add(ColPair.Name.Missile_UFO, this.pMissile, this.poUfo);
                Debug.Assert(pMissile_UFOColPair != null);

                ColPair pUFO_WallLeftColPair = ColPairManager.Add(ColPair.Name.UFO_WallLeft, this.poUfo, this.pWallMan.GetWallLeft());
                Debug.Assert(pUFO_WallLeftColPair != null);

                ColPair pUFO_WallRightColPair = ColPairManager.Add(ColPair.Name.UFO_WallRight, this.poUfo, this.pWallMan.GetWallRight());
                Debug.Assert(pUFO_WallRightColPair != null);

                // Set up missile UFO collsions
                pMissile_UFOColPair.Attach(new RemoveCollisionPairObserver(pMissile_UFOColPair));
                pMissile_UFOColPair.Attach(new RemoveCollisionPairObserver(pUFO_WallLeftColPair));
                pMissile_UFOColPair.Attach(new RemoveCollisionPairObserver(pUFO_WallRightColPair));
                pMissile_UFOColPair.Attach(new ShipMissileReadyObserver());
                pMissile_UFOColPair.Attach(new ShipRemoveMissileObserver());
                pMissile_UFOColPair.Attach(new RemoveUFOObserver(pHardwareSound));
                pMissile_UFOColPair.Attach(new AwardPointsObserver());

                // Set up UFO left wall collision
                pUFO_WallLeftColPair.Attach(new RemoveCollisionPairObserver(pUFO_WallLeftColPair));
                pUFO_WallLeftColPair.Attach(new RemoveCollisionPairObserver(pUFO_WallRightColPair));
                pUFO_WallLeftColPair.Attach(new RemoveCollisionPairObserver(pMissile_UFOColPair));
                pUFO_WallLeftColPair.Attach(new RemoveUFOObserver(pHardwareSound));

                // Set up UFO Right wall collision
                pUFO_WallRightColPair.Attach(new RemoveCollisionPairObserver(pUFO_WallRightColPair));
                pUFO_WallRightColPair.Attach(new RemoveCollisionPairObserver(pUFO_WallLeftColPair));
                pUFO_WallRightColPair.Attach(new RemoveCollisionPairObserver(pMissile_UFOColPair));
                pUFO_WallRightColPair.Attach(new RemoveUFOObserver(pHardwareSound));
            }
        }
コード例 #31
0
        public static UFO ActiveUFO()
        {
            UFOMan pUFOMan = UFOMan.GetInstance();

            Debug.Assert(pUFOMan != null);

            UFO pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 10.0f, 925.0f);

            pUFOMan.pUFO = pUFO;
            pUFOMan.pUFO.activateGameSprite(SpriteBatchMan.Find(SpriteBatch.Name.UFO));
            pUFOMan.pUFO.activateCollisionSprite(SpriteBatchMan.Find(SpriteBatch.Name.Boxes));
            GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);

            pUFORoot.add(pUFOMan.pUFO);

            return(pUFOMan.pUFO);
        }
コード例 #32
0
ファイル: WallNode.cs プロジェクト: frobro98/School-Projects
 public override void visitUFO(UFO u, CollisionPair p)
 {
     p.collision(u, (GameObject)this.Child);
 }
コード例 #33
0
ファイル: RemoveUFO.cs プロジェクト: frobro98/School-Projects
 public RemoveUFO(UFO ufo)
 {
     this.ufo = ufo;
 }
コード例 #34
0
 public static void receiveUFO(UFO ufo)
 {
     Instance.ufo = ufo;
 }
コード例 #35
0
 private UFOFactory()
 {
     this.ufo = null;
 }
コード例 #36
0
 public override void visitUFO(UFO v, CollisionPair p)
 {
     p.collision(v, (GameObject)this.child);
 }
コード例 #37
0
ファイル: Missile.cs プロジェクト: frobro98/School-Projects
 public override void visitUFO(UFO v, CollisionPair p)
 {
     //p.notify(v, this);
 }
コード例 #38
0
ファイル: Visitor.cs プロジェクト: frobro98/School-Projects
 public virtual void visitUFO(UFO v, CollisionPair p)
 {
     Debug.Assert(false, "Shouldn't have been called");
 }