Ejemplo n.º 1
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.º 2
0
        public void removeBomb(Bomb b)
        {
            if (b.state == BombState.alive)
            {
                b.state = BombState.dead;

                b.spriteRef.sprite.image = b.image1;

                GameObjManager.Instance().remove(batchEnum.bomb, b);

                BombManager.Instance().addBomb(b);

                playBombHitSound();

                PlayerManager.Instance().getPlayer(b.owner).addBombSprite();
            }
        }
Ejemplo n.º 3
0
        public static Player getPlayer(PlayerID _id)
        {
            PlayerManager p = PlayerManager.Instance();

            Player returnPlayer = null;

            switch (_id)
            {
            case PlayerID.one:
                returnPlayer = p.p1;
                break;

            case PlayerID.two:
                returnPlayer = p.p2;
                break;
            }
            return(returnPlayer);
        }
Ejemplo n.º 4
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();

            state = gameState.game;

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

            spriteBatch = new SpriteBatch(GraphicsDevice);

            // font = Content.Load<SpriteFont>("Font");
            font = Content.Load <SpriteFont>("SpriteFont1");
        }
Ejemplo n.º 5
0
 override public void execute()
 {
     //PlayerManager pm = new PlayerManager
     CollisionManager.Player player = PlayerManager.Instance().getPlayer(this.id);
     player.playerShip.physicsObj.body.ApplyLinearImpulse(this.impulse, player.playerShip.physicsObj.body.Position);
 }
Ejemplo n.º 6
0
 public override void execute()
 {
     CollisionManager.Player player = PlayerManager.Instance().getPlayer(this.id);
     player.createMissile();
 }
Ejemplo n.º 7
0
 public override void execute()
 {
     CollisionManager.Player player = PlayerManager.Instance().getPlayer(this.id);
     player.playerShip.physicsObj.body.Rotation += this.rotation;
 }
Ejemplo n.º 8
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);
        }