Exemplo n.º 1
0
 private ScreenWrite(GraphicsDevice graphicsDev)
 {
     this.graphicsDev = graphicsDev;
     textBatch = new SpriteBatch(graphicsDev);
     menuFont = Game1.GameInstance.Content.Load<SpriteFont>("SpriteFont1");
     mainMenu = Game1.GameInstance.MenuProxy;
 }
Exemplo n.º 2
0
        public Ship(GameObjType _type, Sprite_Proxy _spriteRef)
        {
            type = _type;
            spriteRef = _spriteRef;

            waveBank = WaveBankManager.WaveBank();
            soundBank = SoundBankManager.SoundBank();
        }
Exemplo n.º 3
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.Instance().getPlayer(PlayerID.one).setShip(p1);

            GameObjManager.Instance().addGameObj(p1);
        }
Exemplo n.º 4
0
        public Wall(GameObjType _type, Sprite_Proxy _spriteRef)
        {
            type = _type;
            spriteRef = _spriteRef;

            anim = new Animation(spriteRef.sprite);

            setUpAnimation();

            soundBank = SoundBankManager.SoundBank();
            waveBank = WaveBankManager.WaveBank();
        }
Exemplo n.º 5
0
        public Missile(GameObjType _type, Sprite_Proxy _spriteRef, PlayerID _owner)
        {
            type = _type;

            spriteRef = _spriteRef;

            objSpeed = new Vector2(0, -15);

            soundBank = SoundBankManager.SoundBank();
            waveBank = WaveBankManager.WaveBank();

            owner = _owner;

            playFireSound();
        }
Exemplo n.º 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // TODO: use this.Content to load your game content here

                world = new World(new Vector2(0, 0), true);

                myContactListener myContactListener = new myContactListener();

                world.ContactListener = myContactListener;

                Data.Instance().createData();

            if(state != gameState.winner)
                state = gameState.mainmenu;

                player1 = PlayerManager.Instance().getPlayer(PlayerID.one);
                player2 = PlayerManager.Instance().getPlayer(PlayerID.two);

                menuTex = new Text("MainMenu", TextEnum.menu, 0, 20, 20, false, SpriteAnimation.Type.Text_Sprite);
                menuImg = new Image(ImageEnum.menu, 0, 0, 800, 480, menuTex);
                menuSprite = new Sprite(SpriteEnum.menu, 0, 0, 800, 500, false, 0, menuImg, false);
                menuProxy = new Sprite_Proxy(menuSprite, 400, 240, 1, Color.White);
                menuBatch = new SpriteBatch(GraphicsDevice);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
 public FencePost(GameObjType _type, Sprite_Proxy _spriteRef)
 {
     type = _type;
     spriteRef = _spriteRef;
 }
Exemplo n.º 10
0
        // Center Fences
        private void createTopFence()
        {
            World world = Game1.GameInstance.getWorld();

            Rectangle gameScreenSize = Game1.GameInstance.gameScreenSize;

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

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

            DisplayManager.Instance().addDisplayObj(SpriteEnum.Wall, wallSprite);

            Sprite_Proxy wallProxy = new Sprite_Proxy(wallSprite, 150, 71, 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.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);
            /////////////////////
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        private void createP2Lives()
        {
            Sprite shipSprite = (Sprite)DisplayManager.Instance().getDisplayObj(SpriteEnum.Ship);

            Sprite_Proxy pShip1 = new Sprite_Proxy(shipSprite, 175, 85, 0.4f, Color.Chartreuse);
            Sprite_Proxy pShip2 = new Sprite_Proxy(shipSprite, 190, 85, 0.4f, Color.Chartreuse);
            Sprite_Proxy pShip3 = new Sprite_Proxy(shipSprite, 205, 85, 0.4f, Color.Chartreuse);

            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 = pShip1;
            lifeSprite2 = pShip2;
            lifeSprite3 = pShip3;

            color = Color.Chartreuse;

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

            Sprite_Proxy pBomb1 = new Sprite_Proxy(bSprite1, 175, 95, 0.5f, Color.Chartreuse);
            Sprite_Proxy pBomb2 = new Sprite_Proxy(bSprite1, 183, 95, 0.5f, Color.Chartreuse);
            Sprite_Proxy pBomb3 = new Sprite_Proxy(bSprite1, 191, 95, 0.5f, Color.Chartreuse);
            Sprite_Proxy pBomb4 = new Sprite_Proxy(bSprite1, 199, 95, 0.5f, Color.Chartreuse);
            Sprite_Proxy pBomb5 = new Sprite_Proxy(bSprite1, 207, 95, 0.5f, Color.Chartreuse);

            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;
        }
Exemplo n.º 13
0
        public void createMissile()
        {
            if (state == PlayerState.alive && missileAvailable())
            {
                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);

                if (numMissiles < maxNumMissiles)
                    numMissiles++;
            }
        }