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);
        }
Ejemplo n.º 2
0
        static public ColObjManager getInstance()
        {
            if (Instance == null)
            {
                Instance = new ColObjManager();
                return(Instance);
            }

            return(Instance);
        }
        public Alien CreateAliens(Rectangle inRect, SpriteName inSName, NodeName inColGrName, int score)
        {
            TextureSprite Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, inSName);
            ColObj        _colobj = new ColObj(inRect, ColObjName.Crab, SpriteName.BBox);
            Alien         Obj     = new Alien(GameObjName.Alien, _colobj, new Vector2(inRect.X, inRect.Y), Text, score);

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

            return(Obj);
        }
        public Column CreateColumns(Vector2 Position, GameObjName inName, NodeName inColGrName)
        {
            ColObj _colobj = new ColObj(new Rectangle((int)Position.X, (int)Position.Y, 0, 0), ColObjName.Column, SpriteName.BBox);
            Column Obj     = new Column(inName, _colobj, Position);

            ColObjManager.getInstance().Add(_colobj);

            Obj.Create(inColGrName);

            return(Obj);
        }
        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;
            }
        }
        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;
        }
        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);
        }
        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);
        }
        public void KillObject(GameObj inObj, SpriteBatchName inSpName)
        {
            GameSprite _gameSprite = inObj.getGameSprite();

            if (_gameSprite != null)
            {
                SpriteBatchManager.getInstance().Kill(_gameSprite, inSpName);
            }

            ColObj _colObj = inObj.getColObj();

            if (_colObj != null)
            {
                ColObjManager.getInstance().Kill(_colObj);
            }

            ColGroup _ColGroup = ColGroupManager.getInstance().find(inObj.TempColGroupName);

            _ColGroup.Kill(inObj);

            Kill(inObj);
        }
        public Bomb CreateBomb(Rectangle inRect)
        {
            TextureSprite Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Bomb);
            ColObj        _colobj = new ColObj(inRect, ColObjName.Missile, SpriteName.BBox);
            Bomb          Obj     = new Bomb(GameObjName.Missile, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Bomb);

            ColGroup X = ColGroupManager.getInstance().find(Obj.TempColGroupName);

            if (X == null)
            {
                ColGroupManager.getInstance().find(ColGroupName.Bomb);
            }

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

            ColGroupManager.getInstance().find(Obj.TempColGroupName).Add(Obj);

            GameObjMananger.getInstance().Add(Obj);

            return(Obj);
        }
        public Missile CreateMissile(Rectangle inRect)
        {
            TextureSprite Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Missile);
            ColObj        _colobj = new ColObj(inRect, ColObjName.Missile, SpriteName.BBox);
            Missile       Obj     = new Missile(GameObjName.Missile, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Missile);

            ColGroup X = ColGroupManager.getInstance().find(Obj.TempColGroupName);

            if (X == null)
            {
                ColGroupManager.getInstance().find(ColGroupName.Missile);
            }

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

            ColGroupManager.getInstance().find(Obj.TempColGroupName).Add(Obj);

            GameObjMananger.getInstance().Add(Obj);
            Obj.setStatus(false);
            ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).setMissile(Obj);

            return(Obj);
        }
        public Wall CreateLevel(GraphicsDevice Graph)
        {
            //////////////////////////////////////////Walls
            ColGroup Walls = ColGroupManager.getInstance().find(ColGroupName.Wall);

            //Left Wall
            ColObj _colobj = new ColObj(new Rectangle(15, 100, 5, Graph.Viewport.Height - 145), ColObjName.Wall, SpriteName.BBox);
            Wall   Obj     = new Wall(GameObjName.Wall, _colobj, new Vector2(15, 100));

            ColObjManager.getInstance().Add(_colobj);
            ColGroupManager.getInstance().find(ColGroupName.Wall).Add(Obj);
            GameObjMananger.getInstance().Add(Obj);

            //Right Wall
            _colobj = new ColObj(new Rectangle(Graph.Viewport.Width - 15, 100, 5, Graph.Viewport.Height - 145), ColObjName.Wall, SpriteName.BBox);
            Obj     = new Wall(GameObjName.Wall, _colobj, new Vector2(Graph.Viewport.Width - 15, 100));
            ColObjManager.getInstance().Add(_colobj);
            ColGroupManager.getInstance().find(ColGroupName.Wall).Add(Obj);
            GameObjMananger.getInstance().Add(Obj);

            //Top Wall
            _colobj = new ColObj(new Rectangle(15, 100, Graph.Viewport.Width - 25, 5), ColObjName.Wall, SpriteName.BBox);
            Obj     = new Wall(GameObjName.Wall, _colobj, new Vector2(15, 100));
            ColObjManager.getInstance().Add(_colobj);
            ColGroupManager.getInstance().find(ColGroupName.Wall).Add(Obj);
            GameObjMananger.getInstance().Add(Obj);

            //Bottom Wall
            _colobj = new ColObj(new Rectangle(15, Graph.Viewport.Height - 50, Graph.Viewport.Width - 25, 5), ColObjName.Wall, SpriteName.BBox);
            Obj     = new Wall(GameObjName.Wall, _colobj, new Vector2(15, Graph.Viewport.Height - 50));
            ColObjManager.getInstance().Add(_colobj);
            ColGroupManager.getInstance().find(ColGroupName.Wall).Add(Obj);
            GameObjMananger.getInstance().Add(Obj);

            return(Obj);
        }
        public Shield CreateShield()
        {
            ColGroup  Shields = ColGroupManager.getInstance().find(ColGroupName.Shield);
            Rectangle inRect  = new Rectangle(150, 600, 100, 100);
            Rectangle inRectparts;

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

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

            inRectparts = new Rectangle(inRect.X, inRect.Y, 10, 10);
            Obj.Create(inRectparts);

            GameObjMananger.getInstance().Add(Obj);


            inRect = new Rectangle(350, 600, 100, 100);
            //Shield 2
            Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Shield);
            _colobj = new ColObj(inRect, ColObjName.Shield, SpriteName.BBox);
            Obj     = new Shield(GameObjName.Shield, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Shield);
            ColObjManager.getInstance().Add(_colobj);
            // SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Text);
            ColGroupManager.getInstance().find(ColGroupName.Shield).Add(Obj);

            inRectparts = new Rectangle(inRect.X, inRect.Y, 10, 10);
            Obj.Create(inRectparts);

            GameObjMananger.getInstance().Add(Obj);

            inRect = new Rectangle(550, 600, 100, 100);
            //Shield 3
            Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Shield);
            _colobj = new ColObj(inRect, ColObjName.Shield, SpriteName.BBox);
            Obj     = new Shield(GameObjName.Shield, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Shield);
            ColObjManager.getInstance().Add(_colobj);
            ColGroupManager.getInstance().find(ColGroupName.Shield).Add(Obj);

            inRectparts = new Rectangle(inRect.X, inRect.Y, 10, 10);
            Obj.Create(inRectparts);

            GameObjMananger.getInstance().Add(Obj);

            inRect = new Rectangle(750, 600, 100, 100);
            //Shield 4
            Text    = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Shield);
            _colobj = new ColObj(inRect, ColObjName.Shield, SpriteName.BBox);
            Obj     = new Shield(GameObjName.Shield, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Shield);
            ColObjManager.getInstance().Add(_colobj);
            ColGroupManager.getInstance().find(ColGroupName.Shield).Add(Obj);

            inRectparts = new Rectangle(inRect.X, inRect.Y, 10, 10);
            Obj.Create(inRectparts);

            GameObjMananger.getInstance().Add(Obj);

            return(Obj);
        }