コード例 #1
0
        public bool ShootMissile()
        {
            if (_missile == null)
            {
                Rectangle inRect = ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).getRectangle();
                _missile = GameObjMananger.getInstance().CreateMissile(new Rectangle(inRect.X + inRect.Width / 2 - 10 / 2, inRect.Y, 10, 16));
                _missile.setStatus(false);

                Sound Effect = SoundManager.getInstance().Find(SoundName.Missile);
                Effect.PlaySound();

                return(true);
            }
            else
            {
                if (!_missile.getStatus())
                {
                    _missile.Position.Y = Position.Y - 2;
                    _missile.setStatus(true);


                    Sound Effect = SoundManager.getInstance().Find(SoundName.Missile);
                    Effect.PlaySound();

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
 public override void VisitShield(Shield inShield)
 {
     if (inShield.CheckParts(this))
     {
         ((Super)(GameObjMananger.getInstance().Find(GameObjName.Super))).ReloadBomb(this);
     }
 }
コード例 #3
0
        public Super CreateSuper()
        {
            Super temp = ((Super)(Find(GameObjName.Super)));

            if (temp != null)
            {
                ((Super)(Find(GameObjName.Super))).Purge();
            }

            ColObj _colobj = new ColObj(Rectangle.Empty, ColObjName.Super, SpriteName.BBox);

            ColObjManager.getInstance().Add(_colobj);
            Super Obj;

            if (temp != null)
            {
                Obj          = temp;
                Obj.BombPool = temp.BombPool;
            }
            else
            {
                Obj          = new Super(GameObjName.Super, _colobj, new Vector2(0, 0));
                Obj.BombPool = new BombReserve();

                ColGroup Invaders = ColGroupManager.getInstance().find(ColGroupName.Alien);
                Invaders.Add(Obj);

                GameObjMananger.getInstance().Add(Obj);
            }

            Obj.Create();


            return(Obj);
        }
コード例 #4
0
 public override void VisitSuper(Super inSuper)
 {
     if (inSuper.CheckColumns(this))
     {
         ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).ReloadMissile();
     }
 }
コード例 #5
0
 public override void VisitShield(Shield inShield)
 {
     if (inShield.CheckParts(this))
     {
         ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).ReloadMissile();
     }
 }
コード例 #6
0
 public void Create()
 {
     for (int i = 0; i < bufferSize; ++i)
     {
         Bombs.Add(GameObjMananger.getInstance().CreateBomb(new Rectangle(-1, -1, 0, 0)));
     }
 }
コード例 #7
0
        public bool CheckColumns(Missile inObj)
        {
            ListNode ptr = (ListNode)Columns.getActiveHead();

            while (ptr != null)
            {
                Column temp = (Column)ptr.getData();

                if (temp.iSCollide(inObj.getCollisionObjRectangle()))
                {
                    bool Hit = temp.CheckAliens(inObj);

                    if (((Column)ptr.getData()).isEmpty())
                    {
                        Columns.Remove(ptr);
                        GameObjMananger.getInstance().KillObject((Column)ptr.getData(), SpriteBatchName.Scene);
                    }

                    Rectangle X = UpdateSize();

                    if (X.Equals(Rectangle.Empty))
                    {
                        GameManager.getInstance().NextLevel();
                    }

                    return(Hit);
                }

                ptr = (ListNode)ptr.pNext;
            }

            return(false);
        }
コード例 #8
0
        public void ReCreate(NodeName PName)
        {
            Rectangle Rect = new Rectangle((int)Position.X, (int)Position.Y, 25, 25);
            Alien     Obj  = null;

            for (int i = 0; i < 5; ++i)
            {
                if (i == 0)
                {
                    Obj = GameObjMananger.getInstance().CreateAliens(Rect, SpriteName.Squid, PName, 30);
                }
                else if (i <= 2)
                {
                    Obj = GameObjMananger.getInstance().CreateAliens(Rect, SpriteName.Crab, PName, 20);
                }
                else if (i > 2)
                {
                    Obj = GameObjMananger.getInstance().CreateAliens(Rect, SpriteName.Octopus, PName, 10);
                }

                Aliens.Add(Obj);
                Obj = null;

                Rect.Y += (5 + Rect.Height);
            }
        }
コード例 #9
0
        public bool CheckParts(GameObj inObj)
        {
            ListNode ptr = (ListNode)ShieldParts.getActiveHead();

            while (ptr != null)
            {
                ShieldPart temp = (ShieldPart)ptr.getData();

                if (temp.iSCollide(inObj.getCollisionObjRectangle()))
                {
                    temp.Health--;
                    switch (temp.Health)
                    {
                    case 3:
                        temp.FlipSprite(SpriteName.ShieldPart2);
                        break;

                    case 2:
                        temp.FlipSprite(SpriteName.ShieldPart3);
                        break;

                    default:
                        ShieldParts.Remove(ptr);
                        GameObjMananger.getInstance().KillObject((ShieldPart)ptr.getData(), SpriteBatchName.Shields);

                        UpdateSize();
                        break;
                    }
                    return(true);
                }

                ptr = (ListNode)ptr.pNext;
            }
            return(false);
        }
コード例 #10
0
        public void Reset()
        {
            this.FlipSprite(SpriteName.Ufo);
            isDying = false;

            this.direction.X = 0;
            this.Position.X  = -70;

            Random X = new Random();
            int    s = X.Next(3);

            switch (s)
            {
            case 0:
                score = 50;
                break;

            case 1:
                score = 100;
                break;

            case 2:
                score = 150;
                break;
            }

            Sound Effect = SoundManager.getInstance().Find(SoundName.UFOMove);

            Effect.PauseSoundLooped();

            TimeSpan FrameInterval = new TimeSpan(0, 0, 20);
            UFO      ufo           = (UFO)GameObjMananger.getInstance().Find(GameObjName.UFO);

            TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, ufo, delegate { Actions.Act(ufo); });
        }
コード例 #11
0
        public void Action()
        {
            Step = true;
            int count = 0;

            UpdateMovement(ref count);

            Random R      = new Random();
            int    Chosen = R.Next(count);
            Column inCol  = (Column)Columns.getDatabyIndex(Chosen);

            BombPool.Update(inCol);

            Rectangle tempRect = UpdateSize();

            UpdateCollisionObject(tempRect);
            UpdateAnimStep();

            if (this.getCollisionObjRectangle().Y + this.getCollisionObjRectangle().Height >= 715)
            {
                ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).Status = playerStatus.Dead;
                GameManager.getInstance().Hit();
                GameManager.getInstance().Hit();
                GameManager.getInstance().Hit();
            }
        }
コード例 #12
0
        public void GAMEOVER()
        {
            ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).score = currentPlayerScore;
            currentPlayerScore = 0;

            ScreenManager.Instance().CurrentScreen = Screen.GameOver;
            ScreenManager.Instance().switchScreen();
        }
コード例 #13
0
        public void Reset()
        {
            Status = playerStatus.Live;
            lives  = 2;
            score  = 0;

            ((UI)(GameObjMananger.getInstance().Find(GameObjName.LivesUI))).ChangeText(lives);
        }
コード例 #14
0
        public void UpdateHIScore()
        {
            if (currentPlayerScore > currentHiScore)
            {
                currentHiScore = currentPlayerScore;

                ((UI)(GameObjMananger.getInstance().Find(GameObjName.HiScore))).ChangeText(currentHiScore);
            }
        }
コード例 #15
0
        public override void VisitBomb(Bomb inBomb)
        {
            ((Super)(GameObjMananger.getInstance().Find(GameObjName.Super))).ReloadBomb(inBomb);

            if (Status == playerStatus.Live)
            {
                TimeSpan  FrameInterval = new TimeSpan(0);
                Animation An            = AnimationManager.getInstance().Find(AnimName.ShipDeath);
                TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, An, delegate { Actions.Animate(An, this); });
            }
        }
コード例 #16
0
        public void StartTimedEvents()
        {
            TimeSpan FrameInterval = new TimeSpan(5750000);
            Super    Super         = (Super)GameObjMananger.getInstance().Find(GameObjName.Super);

            TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, Super, delegate { Actions.Act(Super); });

            FrameInterval = new TimeSpan(0, 0, 15);
            UFO ufo = (UFO)GameObjMananger.getInstance().Find(GameObjName.UFO);

            TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, ufo, delegate { Actions.Act(ufo); });
        }
コード例 #17
0
        public void NextLevel()
        {
            CurrLevel++;
            Difficulty = CurrLevel * 50;
            if (Difficulty > 200)
            {
                Difficulty = 200;
            }

            Super temp = GameObjMananger.getInstance().CreateSuper();

            temp.direction.Y = 50;
        }
コード例 #18
0
        public void ReloadBomb(Bomb inBomb)
        {
            usedBomb--;
            Column temp = ((Column)(GameObjMananger.getInstance().Find(inBomb.ColumnName)));

            if (temp != null)
            {
                temp.Bomb_Active = false;
            }

            inBomb.setStatus(false);
            Add(inBomb);
        }
コード例 #19
0
        public void Create(Rectangle inRect)
        {
            Rectangle tempRect = inRect;
            bool      toDraw   = false;;

            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (i != 7 && i != 8 && i != 9)
                    {
                        toDraw = true;
                    }
                    else
                    if (j != 3 && j != 4 && j != 5 && j != 6)
                    {
                        toDraw = true;
                    }

                    if ((i == 0 && j == 0) || (i == 0 && j == 9))
                    {
                        toDraw = false;
                    }
                    if ((i == 0 && j == 1) || (i == 0 && j == 8))
                    {
                        toDraw = false;
                    }
                    if ((i == 1 && j == 0) || (i == 1 && j == 9))
                    {
                        toDraw = false;
                    }

                    if (toDraw)
                    {
                        TextureSprite inSprite = new TextureSprite(tempRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.ShieldPart);
                        ColObj        _colobj  = new ColObj(tempRect, ColObjName.ShieldPart, SpriteName.BBox);
                        ShieldPart    Obj      = new ShieldPart(GameObjName.ShieldPart, _colobj, new Vector2(tempRect.X, tempRect.Y), inSprite);
                        ColObjManager.getInstance().Add(_colobj);
                        SpriteBatchManager.getInstance().Find(SpriteBatchName.Shields).Add(inSprite);
                        GameObjMananger.getInstance().Add(Obj);

                        ShieldParts.Add(Obj);
                    }

                    tempRect.X += 10;
                    toDraw      = false;
                }
                tempRect.X  = inRect.X;
                tempRect.Y += 10;
            }
        }
コード例 #20
0
        public void Reset()
        {
            Sound Effect = SoundManager.getInstance().Find(SoundName.UFOMove);

            Effect.PauseSoundLooped();

            CurrLevel  = 0;
            Difficulty = CurrLevel * 2;

            ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).Reset();
            ((UI)(GameObjMananger.getInstance().Find(GameObjName.Score))).ChangeText(0);
            getCurrentPlayerData();
            GameObjMananger.getInstance().ResetLevel();
        }
コード例 #21
0
        public void Initialize(GraphicsDeviceManager graphics, SpriteBatch spritebatch)
        {
            TextureManager.getInstance().Initialize();
            TextureManager.getInstance().CreateGameTextures();

            SoundManager.getInstance().Initialize();
            SoundManager.getInstance().CreateSounds();

            ImageManager.getInstance().Initialize();
            ImageManager.getInstance().CreateGameImages();

            SpriteManager.getInstance().Initialize();
            SpriteManager.getInstance().CreateAllSprites();

            AnimationManager.getInstance().Initialize();
            AnimationManager.getInstance().CreateAnimations();

            SpriteBatchManager.getInstance().Initialize();
            SpriteBatchManager.getInstance().CreateAllSpriteBatches(graphics.GraphicsDevice);
            SpriteBatchManager.getInstance().CreateMenu(graphics.GraphicsDevice);

            ColObjManager.getInstance().Initialize();
            GameObjMananger.getInstance().Initialize();

            ColGroupManager.getInstance().Initialize();
            ColGroupManager.getInstance().Create();

            ColPairManager.getInstance().Initialize();
            ColPairManager.getInstance().CreateCollisionPairs();

            GameObjMananger.getInstance().CreateSuper();
            GameObjMananger.getInstance().CreateLevel(graphics.GraphicsDevice);
            GameObjMananger.getInstance().CreateShield();
            GameObjMananger.getInstance().CreateShip();
            GameObjMananger.getInstance().CreateUI();
            GameObjMananger.getInstance().CreateUfo();

            InputManager.Instance().Initialize();
            TimeEventManager.getInstance().Initialize();
            TimeEventManager.getInstance().StartTimedEvents();

            ScreenManager.Instance().CurrentScreen = Screen.MainMenu;
            ScreenManager.Instance().switchScreen();

            getCurrentPlayerData();

            CurrLevel  = 0;
            Difficulty = CurrLevel * 2;
        }
コード例 #22
0
        public void Hit()
        {
            currentPlayerLives--;

            if (currentPlayerLives >= 0)
            {
                ((UI)(GameObjMananger.getInstance().Find(GameObjName.LivesUI))).ChangeText(currentPlayerLives);

                Lives l = (Lives)GameObjMananger.getInstance().Find(GameObjName.Life);
                if (l != null)
                {
                    GameObjMananger.getInstance().KillObject(l, SpriteBatchName.Scene);
                }
            }
        }
コード例 #23
0
        public void reCreate()
        {
            Vector2     ColumnPos  = new Vector2(50, 200);
            NodeName    PName      = NodeName.Col1;
            GameObjName ColumnName = GameObjName.Column1;

            for (int i = 0; i < 5; ++i)
            {
                Column Obj = GameObjMananger.getInstance().CreateColumns(new Vector2(ColumnPos.X, ColumnPos.Y), ColumnName, PName);
                Columns.Add(Obj);
                ColumnPos.X += 50;
                PName++;
                ColumnName++;
            }
        }
コード例 #24
0
        public void Purge()
        {
            ListNode ptr = null;

            do
            {
                ptr = (ListNode)Aliens.getActiveHead();

                if (ptr != null)
                {
                    Alien temp = (Alien)ptr.getData();
                    Aliens.Remove(ptr);
                    GameObjMananger.getInstance().KillObject(temp, SpriteBatchName.Scene);
                }
            } while (ptr != null);
        }
コード例 #25
0
        public Ship CreateShip()
        {
            Rectangle inRect = new Rectangle(476, 715, 58, 32);

            TextureSprite Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ship);
            ColObj        _colobj = new ColObj(inRect, ColObjName.Ship, SpriteName.BBox);
            Ship          Obj     = new Ship(GameObjName.Ship, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Ship);

            ColObjManager.getInstance().Add(_colobj);
            SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Text);
            ColGroupManager.getInstance().find(ColGroupName.Ship).Add(Obj);

            GameObjMananger.getInstance().Add(Obj);

            this.CreateMissile(new Rectangle(inRect.X + inRect.Width / 2 - 10 / 2, inRect.Y - 2, 10, 16));

            return(Obj);
        }
コード例 #26
0
        public Lives CreateLives()
        {
            Rectangle     inRect = new Rectangle(0, 0, 48, 32);
            TextureSprite Life   = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ship);
            Lives         _Lives = new Lives(GameObjName.Life, new Vector2(75, 760), Life);

            SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Life);

            GameObjMananger.getInstance().Add(_Lives);

            inRect = new Rectangle(0, 0, 48, 32);
            Life   = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ship);
            _Lives = new Lives(GameObjName.Life, new Vector2(145, 760), Life);
            SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Life);

            GameObjMananger.getInstance().Add(_Lives);

            return(_Lives);
        }
コード例 #27
0
        public bool CheckAliens(ShieldPart inObj)
        {
            ListNode ptr = (ListNode)Aliens.getActiveHead();

            while (ptr != null)
            {
                Alien temp = (Alien)ptr.getData();

                if (temp.iSCollide(inObj.getCollisionObjRectangle()))
                {
                    GameObjMananger.getInstance().KillObject(inObj, SpriteBatchName.Shields);
                    return(true);
                }

                ptr = (ListNode)ptr.pNext;
            }

            return(false);
        }
コード例 #28
0
        public UFO CreateUfo()
        {
            Rectangle inRect = new Rectangle(-70, 120, 95 / 2, 46 / 2);

            TextureSprite Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ufo);
            ColObj        _colobj = new ColObj(inRect, ColObjName.UFO, SpriteName.BBox);

            ColObjManager.getInstance().Add(_colobj);
            UFO Obj = new UFO(GameObjName.UFO, _colobj, new Vector2(inRect.X, inRect.Y), Text, 100);

            SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Text);

            ColGroup Invaders = ColGroupManager.getInstance().find(ColGroupName.Ufo);

            Invaders.Add(Obj);

            GameObjMananger.getInstance().Add(Obj);

            return(Obj);
        }
コード例 #29
0
        public static void Animate(Animation Anim, UFO Ufo)
        {
            if (!Ufo.isDying)
            {
                Ufo.FlipSprite(Anim.getNextFrame());
                TimeSpan FrameInterval = new TimeSpan(1750000);
                TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, Anim, delegate { Actions.Animate(Anim, Ufo); });
                Ufo.isDying = true;

                Sound Effect = SoundManager.getInstance().Find(SoundName.UFOKill);
                Effect.PlaySound();
            }
            else
            {
                Ufo.Reset();
                GameManager.getInstance().ScoreUp(Ufo.getScore());
                UI Score = (UI)GameObjMananger.getInstance().Find(GameObjName.Score);
                Score.ChangeText(GameManager.getInstance().getCurrentScore());
            }
        }
コード例 #30
0
        public void Update(GameTime gameTime)
        {
            currentPlayerStatus = ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).Status;

            InputManager.Instance().Update(ScreenManager.Instance().CurrentScreen);

            if (currentPlayerStatus != playerStatus.Dead && ScreenManager.Instance().CurrentScreen == Screen.Game)
            {
                ColPairManager.getInstance().Collide();
                GameObjMananger.getInstance().Update(gameTime);
                TimeEventManager.getInstance().Update(gameTime);
                AnimationManager.getInstance().Update(gameTime);
                UpdateHIScore();
            }

            if (currentPlayerStatus == playerStatus.Dead && ScreenManager.Instance().CurrentScreen == Screen.Game)
            {
                GAMEOVER();
            }
        }