Ejemplo n.º 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            if (!IsActive)
            {
                return;
            }

            if (state == gameState.lobby)
            {
                DrawLobby();
            }
            else if (state == gameState.winner)
            {
                DrawEndScreen();
            }
            // If we are in a network session, draw it.

            else if (networkSession == null && state == gameState.ready)
            {
                DrawMenuScreen();
            }

            else if (state == gameState.game && networkSession != null)
            {
                SpriteBatchManager.Instance().process();
                DrawNetworkSession();
            }
            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
        public XmasHell()
#endif
        {
            Graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

#if ANDROID
            Graphics.SupportedOrientations = DisplayOrientation.Portrait;
            _activity = activity;

            // Used for bloom effect
            Graphics.PreferredDepthStencilFormat = DepthFormat.Depth16;

            Graphics.IsFullScreen = true;
            Graphics.ApplyChanges();
#else
            Graphics.IsFullScreen    = false;
            Window.AllowUserResizing = true;
            IsMouseVisible           = true;
            //Graphics.PreferredBackBufferWidth = GameConfig.VirtualResolution.X;
            //Graphics.PreferredBackBufferHeight = GameConfig.VirtualResolution.Y;

            Graphics.PreferredBackBufferWidth  = 480;
            Graphics.PreferredBackBufferHeight = 853;

            // Unlock FPS
            //IsFixedTimeStep = false;
            //Graphics.SynchronizeWithVerticalRetrace = false;
#endif

            GameManager        = new GameManager(this);
            SpriteBatchManager = new SpriteBatchManager(this);
            PerformanceManager = new PerformanceManager(this);
        }
        //
        // Constructors
        //

        public Scene()
        {
            // Make all the managers
            this.manAnimationFlip   = new AnimationFlipManager(2, 1);
            this.manAnimationFrame  = new AnimationFrameManager(4, 1);
            this.manAnimationMotion = new AnimationMotionManager(1, 1);
            this.manCollisionPair   = new CollisonPairManager(13, 1);
            this.manGameObject      = new GameObjectManager(50, 10);
            this.manSpriteBatch     = new SpriteBatchManager(7, 1);
            this.manSpriteProxy     = new SpriteProxyManager(50, 10);
            this.manSpriteColProxy  = new SpriteCollisonProxyManager(50, 10);
            this.manTimedEvent      = new TimedEventManager(10, 1, SceneManager.Self.AzulClockTime);

            // Make all the other containers
            this.gameData                 = new GameSessionData();
            this.hudDisplay               = this.CreateHud();
            this.collisionBatch           = this.manSpriteBatch.Find(SpriteBatch.Name.SpriteCollisions);
            this.collisionBatch.IsEnabled = false;

            // Set scene data
            this.name                   = Name.UNINITIALIZED;
            this.lastAzulTime           = 0.0f;
            this.alienCoordinatorId     = 0u;
            this.ufoId                  = 0u;
            this.isLoaded               = false;
            this.isPaused               = false;
            this.isMarkedForSceneChange = false;
            this.isMarkedForRemoval     = false;
        }
Ejemplo n.º 4
0
        private void createBomb(PlayerID _id, Ship s)
        {
            BombData data = BombManager.Instance().getNextBomb(_id);

            bombID = data.ID;

            bombsprite = data.sprite;
            spriteRef  = new Sprite_Proxy(bombsprite, (int)s.spriteRef.pos.X, (int)s.spriteRef.pos.Y, 0.5f, Color.White);

            SBNode bombBatch = SpriteBatchManager.Instance().getBatch(batchEnum.bomb);

            bombBatch.addDisplayObject(spriteRef);

            orgPos = spriteRef.pos;


            if (_id == PlayerID.one)
            {
                image1 = ImageManager.Instance().getImage(ImageEnum.bluebomb1);
                image2 = ImageManager.Instance().getImage(ImageEnum.bluebomb2);
            }
            else
            {
                image1 = ImageManager.Instance().getImage(ImageEnum.greenbomb1);
                image2 = ImageManager.Instance().getImage(ImageEnum.greenbomb2);
            }

            spriteRef.sprite.image = image1;

            curImage = 0;

            state = BombState.alive;
        }
Ejemplo n.º 5
0
        public void remove(batchEnum _enum, GameObject _obj)
        {
            GameObjNode node = findGameObj(_obj);

            if (node != null)
            {
                if (node.prev != null)
                {       // middle or last node
                    node.prev.next = node.next;
                }
                else
                {  // first
                    this.active = node.next;
                }

                if (node.next != null)
                {       // middle node
                    node.next.prev = node.prev;
                }

                addBodyToDestroy(_obj.physicsObj.body);

                if (_obj.spriteRef != null)
                {
                    SBNode SBNode = SpriteBatchManager.Instance().getBatch(_enum);
                    SBNode.removeDisplayObject(_obj.spriteRef);
                }

                if (_obj.physicsObj != null)
                {
                    PhysicsMan.Instance().removePhysicsObj(_obj.physicsObj);
                }
            }
        }
Ejemplo n.º 6
0
            //-----------------------------------------------------------------------------
            // Game::Draw()
            //		This function is called once per frame
            //	    Use this for draw graphics to the screen.
            //      Only do rendering here
            //-----------------------------------------------------------------------------
            public override void Draw()
            {
                //toggle drawing collision boxes by pressing the 'c' key

                //draw all the sprites attached to sprite batches
                SpriteBatchManager.Draw();
            }
Ejemplo n.º 7
0
        public void createData()
        {
            player1KillsText  = (TextSprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.p1KillsText);
            player1DeathsText = (TextSprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.p1DeathsText);

            player2KillsText  = (TextSprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.p2KillsText);
            player2DeathsText = (TextSprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.p2DeathsText);

            WinsText = (TextSprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.Wins);


            versionNum = (TextSprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.versionNum);
            courseName = (TextSprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.courseNum);

            versionNum.message = "v2.0";
            courseName.message = "";

            SBNode titleBatch = SpriteBatchManager.Instance().getBatch(batchEnum.displayText);

            titleBatch.addDisplayObject(player1KillsText);
            titleBatch.addDisplayObject(player1DeathsText);
            titleBatch.addDisplayObject(player2KillsText);
            titleBatch.addDisplayObject(player2DeathsText);
            titleBatch.addDisplayObject(WinsText);
            titleBatch.addDisplayObject(versionNum);
            titleBatch.addDisplayObject(courseName);
        }
Ejemplo n.º 8
0
        public void removeExplosion(object obj)
        {
            CallBackData nodeData = (CallBackData)obj;

            SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.explosions);

            sbNode.removeDisplayObject(nodeData.spriteRef);
        }
Ejemplo n.º 9
0
        private void createFence1()
        {
            World world = Game1.GameInstance.getWorld();

            Rectangle gameScreenSize = Game1.GameInstance.gameScreenSize;

            // Sprite Animation ///////////


            Sprite wallSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.fence1);

            // Sprite wallSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.Wall);
            Sprite_Proxy wallProxy = new Sprite_Proxy(wallSprite, 40, 5, fenceScale, Color.White);
            Wall         wall1     = new Wall(GameObjType.horzWalls, wallProxy);


            SBNode wallBatch = SpriteBatchManager.Instance().getBatch(batchEnum.boxs);

            wallBatch.addDisplayObject(wallProxy);

            //////////////////

            // Box2D /////////////

            var wallShape = new PolygonShape();

            wallShape.SetAsBox(wall1.spriteRef.sprite.width / 2, wall1.spriteRef.sprite.height / 2);

            var fd = new FixtureDef();

            fd.shape       = wallShape;
            fd.restitution = 0.9f;
            fd.friction    = 0.0f;
            fd.density     = 1.0f;
            fd.userData    = wall1;

            BodyDef bd = new BodyDef();

            bd.allowSleep = false;
            bd.type       = BodyType.Static;
            bd.position   = wall1.spriteRef.pos;

            var body = world.CreateBody(bd);

            body.CreateFixture(fd);
            body.SetUserData(wall1);
            body.Rotation = (float)(90.0f * (Math.PI / 180.0f));


            GameObjManager.Instance().addGameObj(wall1);

            PhysicsMan.Instance().addPhysicsObj(wall1, body);

            /////////////////////
        }
Ejemplo n.º 10
0
 private void clearData()
 {
     TextureManager.Instance().clear();
     ImageManager.Instance().clear();
     SpriteBatchManager.Instance().clear();
     SpriteProxyManager.Instance().clear();
     DisplayManager.Instance().clear();
     AnimManager.Instance().clear();
     GameObjManager.Instance().clear();
     Timer.Clear();
     PlayerManager.Instance().clear();
     BombManager.Instance().clear();
 }
Ejemplo n.º 11
0
        private void createP1Lives()
        {
            // Ship Sprites
            Sprite shipSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.Ship);

            Sprite_Proxy pShip1 = new Sprite_Proxy(shipSprite, 95, 85, 0.4f, Color.Blue);
            Sprite_Proxy pShip2 = new Sprite_Proxy(shipSprite, 110, 85, 0.4f, Color.Blue);
            Sprite_Proxy pShip3 = new Sprite_Proxy(shipSprite, 125, 85, 0.4f, Color.Blue);

            pShip1.rotation = -(float)(90.0f * (Math.PI / 180.0f));
            pShip2.rotation = -(float)(90.0f * (Math.PI / 180.0f));
            pShip3.rotation = -(float)(90.0f * (Math.PI / 180.0f));

            SBNode shipBatch = SpriteBatchManager.Instance().getBatch(batchEnum.ships);

            shipBatch.addDisplayObject(pShip1);
            shipBatch.addDisplayObject(pShip2);
            shipBatch.addDisplayObject(pShip3);

            lifeSprite1 = pShip3;
            lifeSprite2 = pShip2;
            lifeSprite3 = pShip1;

            color = Color.Blue;

            ///////////

            // Bomb Sprites
            Sprite bSprite1 = new Sprite(SpriteEnum.Bomb, 0, 0, 50, 50, true, 0,
                                         ImageManager.Instance().getImage(ImageEnum.bluebomb1), false);

            Sprite_Proxy pBomb1 = new Sprite_Proxy(bSprite1, 93, 95, 0.5f, Color.Blue);
            Sprite_Proxy pBomb2 = new Sprite_Proxy(bSprite1, 101, 95, 0.5f, Color.Blue);
            Sprite_Proxy pBomb3 = new Sprite_Proxy(bSprite1, 109, 95, 0.5f, Color.Blue);
            Sprite_Proxy pBomb4 = new Sprite_Proxy(bSprite1, 117, 95, 0.5f, Color.Blue);
            Sprite_Proxy pBomb5 = new Sprite_Proxy(bSprite1, 125, 95, 0.5f, Color.Blue);

            SBNode bombBatch = SpriteBatchManager.Instance().getBatch(batchEnum.bomb);

            bombBatch.addDisplayObject(pBomb1);
            bombBatch.addDisplayObject(pBomb2);
            bombBatch.addDisplayObject(pBomb3);
            bombBatch.addDisplayObject(pBomb4);
            bombBatch.addDisplayObject(pBomb5);

            bombSprite1 = pBomb1;
            bombSprite2 = pBomb2;
            bombSprite3 = pBomb3;
            bombSprite4 = pBomb4;
            bombSprite5 = pBomb5;
        }
Ejemplo n.º 12
0
            //-----------------------------------------------------------------------------
            // Game::UnLoadContent()
            //       unload content (resources loaded above)
            //       unload all content that was loaded before the Engine Loop started
            //-----------------------------------------------------------------------------
            public override void UnLoadContent()
            {
                TextureManager.Destroy();
                ImageManager.Destroy();

                GameSpriteManager.Destroy();
                BoxSpriteManager.Destroy();

                SpriteBatchManager.Destroy();

                ProxySpriteManager.Destroy();

                TimerEventManager.Destroy();
                DeathManager.Destroy();
            }
Ejemplo n.º 13
0
        public void addExplosion(Vector2 _pos, Color _color)
        {
            Sprite       expSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.Explosion);
            Sprite_Proxy expProxy  = new Sprite_Proxy(expSprite, (int)_pos.X, (int)_pos.Y, 0.20f, _color);

            SBNode expBatch = SpriteBatchManager.Instance().getBatch(batchEnum.explosions);

            expBatch.addDisplayObject(expProxy);

            TimeSpan     currentTime = Timer.GetCurrentTime();
            TimeSpan     t_1         = currentTime.Add(new TimeSpan(0, 0, 0, 0, 500));
            CallBackData nodeData    = new CallBackData(3, TimeSpan.Zero);

            nodeData.spriteRef = expProxy;

            Timer.Add(t_1, nodeData, removeExplosion);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            //if (networkSession == null)
            //{
            //    // If we are not in a network session, draw the
            //    // menu screen that will let us create or join one.
            //    DrawMenuScreen();
            //}
            //else
            //{
            //    // If we are in a network session, draw it.
            //    DrawNetworkSession();
            //}

            //if (state == gameState.game)
            //{
            //   // SpriteBatchManager.Instance().process();
            //}

            if (networkSession == null)
            {
                // If we are not in a network session, draw the
                // menu screen that will let us create or join one.
                DrawMenuScreen();
            }
            else
            {
                if (state == gameState.game)
                {
                    // this is where we draw the game
                    SpriteBatchManager.Instance().process();
                    DrawNetworkSession();
                }
            }



            // draw the game
            base.Draw(gameTime);
        }
Ejemplo n.º 15
0
        public void respawn(object obj)
        {
            CallBackData data = (CallBackData)obj;

            Player player = getPlayer(data.playerID);

            if (!player.Alive())
            {
                player.lives--;

                switch (player.lives)
                {
                case 3:
                {
                    SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.ships);
                    sbNode.removeDisplayObject(player.lifeSprite3);

                    respawnData(data.playerID);
                    player.state = PlayerState.alive;

                    break;
                }

                case 2:
                {
                    SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.ships);
                    sbNode.removeDisplayObject(player.lifeSprite2);

                    respawnData(data.playerID);
                    player.state = PlayerState.alive;

                    break;
                }

                case 1:
                {
                    SBNode sbNode = SpriteBatchManager.Instance().getBatch(batchEnum.ships);
                    sbNode.removeDisplayObject(player.lifeSprite1);

                    respawnData(data.playerID);
                    player.state = PlayerState.alive;

                    break;
                }


                case 0:
                {
                    if (player.id == PlayerID.one)
                    {
                        ScoreManager.Instance().p2Win();
                    }
                    else
                    {
                        ScoreManager.Instance().p1Win();
                    }


                    Game1.GameInstance.GameOver();
                    break;
                }
                }
                player.state = PlayerState.alive;
            }
        }
Ejemplo n.º 16
0
            //-----------------------------------------------------------------------------
            // Game::LoadContent()
            //		Allows you to load all content needed for your engine,
            //	    such as objects, graphics, etc.
            //-----------------------------------------------------------------------------

            public override void LoadContent()
            {
                Debug.WriteLine("----------------------------------");
                Debug.WriteLine("Load Content");
                Debug.WriteLine("----------------------------------\n");


                //-----------------------------------------------
                //Create Game Simulation instance
                Simulation.Create();

                //-----------------------------------------------
                //Manager Load
                //------------------------------
                //Texture Manager Create
                TextureManager.Create();
                //------------------------------
                //Image Manager Create
                ImageManager.Create();
                //------------------------------
                //Game/Box Sprite Manager Create
                GameSpriteManager.Create(5, 2);
                BoxSpriteManager.Create();
                //------------------------------
                //SpriteBatch Manager Create
                SpriteBatchManager.Create();
                //------------------------------
                //ProxySprite Manager Create
                ProxySpriteManager.Create(10, 1);
                //------------------------------
                //GameObject Manager Create
                GameObjectManager.Create();
                //------------------------------
                //CollisionPair Manager Create
                ColPairManager.Create();
                //------------------------------
                //TimerEvent Manager Create
                TimerEventManager.Create();
                //------------------------------
                //Glyph/Font Manager Create/Load
                GlyphManager.Create();
                FontManager.Create();

                //------------------------------
                //Death/Ghost Manager Create
                DeathManager.Create(1, 1);
                GhostManager.Create(1, 1);
                //-----------------------------------------------
                // Input Manager - Key Observer Load
                InputManager.LoadKeyInputObservers();

                //-----------------------------------------------
                //Print some initial stats
                TextureManager.DumpStats();
                ImageManager.DumpStats();
                GameSpriteManager.DumpStats();
                BoxSpriteManager.DumpStats();
                SpriteBatchManager.DumpStats();
                ProxySpriteManager.DumpStats();
                TimerEventManager.DumpStats();
                GameObjectManager.DumpStats();
                DeathManager.DumpStats();
                GhostManager.DumpStats();
                ColPairManager.DumpStats();
                GlyphManager.DumpStats();

                //------------------------------
                //Asset Loading

                //Texture/Image/Font Load
                TextureManager.LoadTextures();
                ImageManager.LoadImages();
                FontManager.LoadFonts();

                //-----------------------------------------------
                //Sprite Batch /Sprite Load
                SpriteBatch pSB_GameSprites = SpriteBatchManager.Add(SpriteBatch.Name.GameSprites);
                SpriteBatch pSB_Boxes       = SpriteBatchManager.Add(SpriteBatch.Name.SpriteBoxes);
                SpriteBatch pSB_Texts       = SpriteBatchManager.Add(SpriteBatch.Name.TextLetters);


                //-----------------------------------------------
                //Sprites/BoxSprites Load
                //NOTE that the following coordinates will not matter
                //once proxy sprites are used!

                //35w x 35h for all sprites;
                float const_AlienSpriteSize = 30.0f;


                //render dimensions/coordinates
                float squid_sX = 400.0f;
                float squid_sY = 400.0f;

                float crab_sX = 400.0f;
                float crab_sY = 350.0f;

                float octo_sX = 400.0f;
                float octo_sY = 300.0f;

                float missileSpriteWidth  = 4.0f;
                float missileSpriteHeight = 8.0f;

                float alienBombSpriteWidth  = 6.0f;
                float alienBombSpriteHeight = 12.0f;

                float shipSpriteWidth  = 55.0f;
                float shipSpriteHeight = 25.0f;

                float verticalWallWidth  = 678.0f;
                float verticalWallHeight = 10.0f;

                float horizontalWallWidth  = 678.0f;
                float horizontalWallHeight = 10.0f;

                //----------------------
                //aliens (initial sprites only)

                //note that the alien grid and alien column are game sprites for box sprite rendering,
                //but will pass a null image since they don't have anything to render
                GameSpriteManager.Add(GameSprite.Name.AlienGrid, Image.Name.NullObject, 0, 0, 0, 0);
                GameSpriteManager.Add(GameSprite.Name.AlienColumn, Image.Name.NullObject, 0, 0, 0, 0);

                //squid game sprite
                GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidOpen, squid_sX, squid_sY, const_AlienSpriteSize, const_AlienSpriteSize);
                //crab game sprite
                GameSpriteManager.Add(GameSprite.Name.Crab, Image.Name.CrabOpen, crab_sX, crab_sY, const_AlienSpriteSize, const_AlienSpriteSize);
                //octopus game sprite
                GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusOpen, octo_sX, octo_sY, const_AlienSpriteSize, const_AlienSpriteSize);

                //----------------------
                //alien bombs (initial sprites only)

                //zigzag bomb
                GameSpriteManager.Add(GameSprite.Name.ZigZagAlienBomb, Image.Name.AlienBombZigZag_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight);
                //cross bomb
                GameSpriteManager.Add(GameSprite.Name.CrossAlienBomb, Image.Name.AlienBombCross_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight);
                //rolling bomb
                GameSpriteManager.Add(GameSprite.Name.RollingAlienBomb, Image.Name.AlienBombRolling_Two, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight);

                //----------------------
                //hero ship
                GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 640.0f, 440.0f, shipSpriteWidth, shipSpriteHeight);
                //hero missile
                GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, missileSpriteWidth, missileSpriteHeight);

                //----------------------
                //walls
                //note screen w = 672px wide by 768px
                GameSpriteManager.Add(GameSprite.Name.VerticalWall, Image.Name.NullObject, 0, 0, verticalWallWidth, verticalWallHeight);
                GameSpriteManager.Add(GameSprite.Name.HorizontalWall, Image.Name.NullObject, 0, 0, horizontalWallWidth, horizontalWallHeight);


                //----------------------
                //BoxSprites are added in the CollisionObject constructor depending on the sprite!



                //-----------------------------------------------
                //Load the Animations (TimerEvents)

                TimerEventManager.LoadAlienAnimations();
                TimerEventManager.LoadBombAnimations();



                //-----------------------------------------------
                //Set the Game Simulation State;


                Simulation.SetState(Simulation.State.Realtime);



                //-----------------------------------------------
                //GameObject Load (Factory)

                //get the PCSRootTree that was created by GameObjectManager
                PCSTree rootGamObjTree = GameObjectManager.GetRootTree();

                //make sure root tree and root have been created;
                Debug.Assert(rootGamObjTree != null);
                Debug.Assert(rootGamObjTree.GetRoot() != null);

                //check the tree
                rootGamObjTree.DumpTree();
                /*     */

                //------------------------------------------------
                // Create Missile Tree

                MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

                rootGamObjTree.Insert(pMissileRoot, null);
                pMissileRoot.ActivateCollisionSprite(pSB_Boxes);

                //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree);
                GameObjectManager.AttachTree(pMissileRoot);

                //TEST------------------
                //PCSTree missileTree = new PCSTree();

                //MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

                //missileTree.Insert(pMissileRoot, null);
                //pMissileRoot.ActivateCollisionSprite(pSB_Boxes);

                //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree);
                //rootGamObjTree.Insert(pMissileRoot, rootGamObjTree.GetRoot());

                //------------------------------------------------
                // Create Ship Tree

                ShipRoot shipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

                DeathManager.Attach(shipRoot);
                shipRoot.ActivateCollisionSprite(pSB_Boxes);

                //check the tree
                rootGamObjTree.DumpTree();

                //attach the shipRoot to the rootGameObjTree, with the gamObjRoot as parent
                rootGamObjTree.Insert(shipRoot, null);

                //check the tree
                rootGamObjTree.DumpTree();

                ////attach a ship to the ship root;
                //Ship ship = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 0, 0.0f, 0.0f);
                //rootGamObjTree.Insert(ship, shipRoot);
                //ship.ActivateCollisionSprite(pSB_Boxes);
                //ship.ActivateGameSprite(pSB_GameSprites);

                //attach the shipRoot to the root game object tree
                //GameObjectManager.AttachTree(shipRoot, rootGamObjTree);
                GameObjectManager.AttachTree(shipRoot);

                //create the ship manager that handles all the ship's states
                //ShipManager.Create();
                ShipManager.CreateShipManager();

                //check the tree
                rootGamObjTree.DumpTree();



                //------------------------------------------------
                // Create an Alien Tree

                //AlienRoot alienRoot = new AlienRoot(GameObject.Name.AlienRoot, GameSprite.SpriteName.Null_Object, 0, 0.0f, 0.0f);

                //create the PCS tree that will hold all alien game objects
                PCSTree pAlienTree = new PCSTree();

                DeathManager.Attach(pAlienTree);

                //create the alien game object factory with pAlienTree as the factory's tree
                //factory will attach all alien game objects to pAlienTree
                AlienFactory pAlienFactory = new AlienFactory(SpriteBatch.Name.GameSprites, pAlienTree);

                DeathManager.Attach(pAlienFactory);

                //attach grid as a child of game object root; grid will be parent of all alien game objects
                Grid pGrid = (Grid)pAlienFactory.Create(AlienType.Type.AlienGrid, GameObject.Name.Grid);

                // set the grid as the root parent to attach all aliens to;
                pAlienFactory.SetParent(pGrid);

                //Build the grid (builder pattern)
                int numberOfColumns = 11;

                //numberOfColumns = 1;
                AlienFactory.BuildAlienGrid(pAlienFactory, pGrid, numberOfColumns);

                //check the tree
                rootGamObjTree.DumpTree();

                //GameObjectManager.AttachTree(pGrid, rootGamObjTree);
                GameObjectManager.AttachTree(pGrid);

                //------------------------------------------------
                // Create Alien Bomb tree

                //create the root
                BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

                //insert root into the bomb tree
                rootGamObjTree.Insert(pBombRoot, null);
                //pBombRoot.ActivateCollisionSprite(pSB_Boxes);

                //add the bombtree to the root tree
                //GameObjectManager.AttachTree(pBombRoot, rootGamObjTree);
                GameObjectManager.AttachTree(pBombRoot);

                //check the tree
                rootGamObjTree.DumpTree();



                //------------------------------------------------
                // Associate and Create Walls
                //note screen = 672px wide by 768px

                WallRoot pWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

                rootGamObjTree.Insert(pWallRoot, null);

                WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.HorizontalWall, 0, 336.0f, 728.0f, 612.0f, 10.0f);

                rootGamObjTree.Insert(pWallTop, pWallRoot);
                pWallTop.ActivateCollisionSprite(pSB_Boxes);

                WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.HorizontalWall, 0, 336.0f, 40.0f, 612.0f, 10.0f);

                rootGamObjTree.Insert(pWallBottom, pWallRoot);
                pWallBottom.ActivateCollisionSprite(pSB_Boxes);

                WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.HorizontalWall, 0, 652.0f, 384.0f, 10.0f, 693.0f);

                rootGamObjTree.Insert(pWallRight, pWallRoot);
                pWallRight.ActivateCollisionSprite(pSB_Boxes);

                WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.HorizontalWall, 0, 20.0f, 384.0f, 10.0f, 693.0f);

                rootGamObjTree.Insert(pWallLeft, pWallRoot);
                pWallLeft.ActivateCollisionSprite(pSB_Boxes);

                //now that it's fully created, attach the newly created wall tree to the main game object tree
                //GameObjectManager.AttachTree(pWallRoot, rootGamObjTree);
                GameObjectManager.AttachTree(pWallRoot);

                //check the tree
                rootGamObjTree.DumpTree();



                ColPair pColPair = null;

                /*            */
                //------------------------------------------------
                // Associate and Create Collision Pairs

                // associate object roots in a collision pair

                pColPair = ColPairManager.Add(ColPair.Name.Missile_Wall, pMissileRoot, pWallRoot);
                Debug.Assert(pColPair != null);

                // associate object roots in a collision pair
                pColPair = ColPairManager.Add(ColPair.Name.Missile_Wall, pMissileRoot, pWallRoot);
                //associate the observers that will act on the collision
                pColPair.Attach(new ShipReadyObserver());
                pColPair.Attach(new ShipRemoveMissileObserver());

                //// associate object roots in a collision pair
                //ColPairManager.Add(ColPair.Name.Alien_Missile, pMissileRoot, pGrid);



                // Bomb vs wall bottom
                pColPair = ColPairManager.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallRoot);
                pColPair.Attach(new BombObserver());
                //todo debug this test bomb reset observer
                pColPair.Attach(new RemoveBombObserver());



                Debug.WriteLine("\n\n\n\n\n");
                GameObjectManager.DumpAll();



                Debug.WriteLine("\n\nLoad Content Complete\n----------------------------------\n");

                //-----------------------------------------------
                //Data Dump;

                TextureManager.DumpStats();
                ImageManager.DumpStats();
                GameSpriteManager.DumpStats();
                BoxSpriteManager.DumpStats();
                SpriteBatchManager.DumpStats();
                ProxySpriteManager.DumpStats();
                TimerEventManager.DumpStats();
                GameObjectManager.DumpStats();
                DeathManager.DumpStats();
                GhostManager.DumpStats();
                ColPairManager.DumpStats();
                GlyphManager.DumpStats();

                //TextureManager.DumpLists();
                //ImageManager.DumpLists();
                //GameSpriteManager.DumpLists();
                BoxSpriteManager.DumpLists();
                //SpriteBatchManager.DumpLists();
                //ProxySpriteManager.DumpLists();
                //TimerEventManager.DumpLists();
                //GameObjectManager.DumpLists();
                //DeathManager.DumpLists();
                //GhostManager.DumpLists();
                //ColPairManager.DumpLists();
                //GlyphManager.DumpLists();

                //TextureManager.DumpAll();
                //ImageManager.DumpAll();
                //GameSpriteManager.DumpAll();
                //BoxSpriteManager.DumpAll();
                //SpriteBatchManager.DumpAll();
                //ProxySpriteManager.DumpAll();
                //TimerEventManager.DumpAll();
                //GameObjectManager.DumpAll();
                //DeathManager.DumpAll();
                //GhostManager.DumpAll();
                //ColPairManager.DumpAll();
                //GlyphManager.DumpAll();
            }
Ejemplo n.º 17
0
        public void createMissile()
        {
            OutputQueue p = new OutputQueue();

            Ship pShip     = playerShip;
            Body pShipBody = pShip.physicsObj.body;

            Sprite       missileSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.Missile);
            Sprite_Proxy proxyMissile  = new Sprite_Proxy(missileSprite, (int)pShip.spriteRef.pos.X, (int)pShip.spriteRef.pos.Y, 0.5f, pShip.spriteRef.color);
            Missile      missile       = new Missile(missileType, proxyMissile, id);

            SBNode missileBatch = SpriteBatchManager.Instance().getBatch(batchEnum.missiles);

            missileBatch.addDisplayObject(proxyMissile);

            World world = Game1.GameInstance.getWorld();

            var missileShape = new PolygonShape();

            missileShape.SetAsBox(3, 3);

            var fd = new FixtureDef();

            fd.shape       = missileShape;
            fd.restitution = 0.0f;
            fd.friction    = 0.0f;
            fd.density     = 0.0001f;
            fd.userData    = missile;

            // Grab ship orientation vector
            Vector2 direction = new Vector2((float)(Math.Cos(pShipBody.GetAngle())), (float)(Math.Sin(pShipBody.GetAngle())));

            direction.Normalize();

            BodyDef bd = new BodyDef();

            bd.fixedRotation = true;

            bd.type     = BodyType.Dynamic;
            bd.position = (new Vector2(pShip.spriteRef.pos.X, pShip.spriteRef.pos.Y)) + (direction * 10);



            var body = world.CreateBody(bd);

            body.SetBullet(true);
            body.Rotation = pShipBody.Rotation;
            body.CreateFixture(fd);
            body.SetUserData(missile);


            direction *= 1000;

            body.ApplyLinearImpulse(direction, body.GetWorldCenter());



            GameObjManager.Instance().addGameObj(missile);
            PhysicsMan.Instance().addPhysicsObj(missile, body);

            OutQueue.add(QueueType.missile, missile, this.id);
            //p.pushToNetwork();

            if (numMissiles > 0)
            {
                numMissiles--;
            }
        }
Ejemplo n.º 18
0
        public void createShip1(Vector2 pos, float _rot)
        {
            World world = Game1.GameInstance.getWorld();

            ////////////////  For Sprite System use ///////////////
            Sprite       shipSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.Ship);
            Sprite_Proxy proxyShip  = new Sprite_Proxy(shipSprite, pos.X, pos.Y, shipScale, Color.Blue);
            Ship         p1         = new Ship(GameObjType.p1ship, proxyShip);


            SBNode shipBatch = SpriteBatchManager.Instance().getBatch(batchEnum.ships);

            shipBatch.addDisplayObject(proxyShip);

            //////////////////////////////////////


            // Box2D Body Setup/////////////////////////
            var shipShape = new PolygonShape();

            Vector2[] verts = new Vector2[5];


            verts[0] = new Vector2(-5.0f, -5.0f);
            verts[1] = new Vector2(4.8f, -0.10f);
            verts[2] = new Vector2(5.0f, 0.00f);
            verts[3] = new Vector2(4.8f, 0.10f);
            verts[4] = new Vector2(-5.0f, 5.0f);

            shipShape.Set(verts, 5);
            shipShape._centroid = new Vector2(0, 0);


            var fd = new FixtureDef();

            fd.shape       = shipShape;
            fd.restitution = 0.9f;
            fd.friction    = 0.0f;
            fd.density     = 1.0f;
            fd.userData    = p1;

            BodyDef bd = new BodyDef();

            bd.allowSleep    = false;
            bd.fixedRotation = true;
            bd.type          = BodyType.Dynamic;
            bd.position      = p1.spriteRef.pos;


            var body = world.CreateBody(bd);

            body.CreateFixture(fd);
            body.SetUserData(p1);
            body.Rotation = _rot;
            ///////////////////////////////////////

            // Set sprite body reference


            PhysicsMan.Instance().addPhysicsObj(p1, body);
            //////////////////

            // Set Player's ship and add it to the GameObjManager //////////////
            PlayerManager.getPlayer(PlayerID.one).setShip(p1);

            GameObjManager.Instance().addGameObj(p1);
        }
Ejemplo n.º 19
0
        ////////////////

        private void createFencePosts()
        {
            Rectangle gameScreenSize = Game1.GameInstance.gameScreenSize;

            // Sprite Animation ///////////

            Sprite postSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.FencePost);

            int x = gameScreenSize.Width;

            // Top Wall ///////////
            Sprite_Proxy postProxy1 = new Sprite_Proxy(postSprite, 5, 5, fencePostScale, Color.White);
            Sprite_Proxy postProxy2 = new Sprite_Proxy(postSprite, 75, 5, fencePostScale, Color.White);
            Sprite_Proxy postProxy3 = new Sprite_Proxy(postSprite, 150, 5, fencePostScale, Color.White);
            Sprite_Proxy postProxy4 = new Sprite_Proxy(postSprite, 225, 5, fencePostScale, Color.White);
            Sprite_Proxy postProxy5 = new Sprite_Proxy(postSprite, 300, 5, fencePostScale, Color.White);
            ////////////////


            // Right Wall ///////////
            Sprite_Proxy postProxy6 = new Sprite_Proxy(postSprite, 300, 95, fencePostScale, Color.White);

            ///////////////////////

            // Left Wall /////////
            Sprite_Proxy postProxy7 = new Sprite_Proxy(postSprite, 5, 95, fencePostScale, Color.White);

            // Bottom Wall ////////
            Sprite_Proxy postProxy8  = new Sprite_Proxy(postSprite, 5, 190, fencePostScale, Color.White);
            Sprite_Proxy postProxy9  = new Sprite_Proxy(postSprite, 75, 190, fencePostScale, Color.White);
            Sprite_Proxy postProxy10 = new Sprite_Proxy(postSprite, 150, 190, fencePostScale, Color.White);
            Sprite_Proxy postProxy11 = new Sprite_Proxy(postSprite, 225, 190, fencePostScale, Color.White);
            Sprite_Proxy postProxy12 = new Sprite_Proxy(postSprite, 300, 190, fencePostScale, Color.White);
            //////////////


            // Center Posts ///
            Sprite_Proxy postProxy13 = new Sprite_Proxy(postSprite, 75, 71, fencePostScale, Color.White);
            Sprite_Proxy postProxy14 = new Sprite_Proxy(postSprite, 225, 71, fencePostScale, Color.White);
            Sprite_Proxy postProxy15 = new Sprite_Proxy(postSprite, 75, 119, fencePostScale, Color.White);
            Sprite_Proxy postProxy16 = new Sprite_Proxy(postSprite, 225, 119, fencePostScale, Color.White);
            ///////////////


            SBNode postBatch = SpriteBatchManager.Instance().getBatch(batchEnum.boxs);

            postBatch.addDisplayObject(postProxy1);
            postBatch.addDisplayObject(postProxy2);
            postBatch.addDisplayObject(postProxy3);
            postBatch.addDisplayObject(postProxy4);
            postBatch.addDisplayObject(postProxy5);
            postBatch.addDisplayObject(postProxy6);
            postBatch.addDisplayObject(postProxy7);
            postBatch.addDisplayObject(postProxy8);
            postBatch.addDisplayObject(postProxy9);
            postBatch.addDisplayObject(postProxy10);
            postBatch.addDisplayObject(postProxy11);
            postBatch.addDisplayObject(postProxy12);
            postBatch.addDisplayObject(postProxy13);
            postBatch.addDisplayObject(postProxy14);
            postBatch.addDisplayObject(postProxy15);
            postBatch.addDisplayObject(postProxy16);
        }