Beispiel #1
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);
        }
Beispiel #2
0
        public Bomb(GameObjType _type, PlayerID _owner, Ship s)
        {
            type = _type;

            createBomb(_owner, s);

            owner = _owner;

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

            playBombLaySound();

            armBomb();
        }
Beispiel #3
0
        private void reactionToBomb(Ship s, Bomb b, Vector2 _point)
        {
            if (s.type == GameObjType.p1ship)
            {
                GameObjManager.Instance().remove(batchEnum.ships, s);
                BombManager.Instance().removeBomb(b, s.spriteRef.pos, s.spriteRef.color);

                s.hit(PlayerID.one);

                ScoreManager.Instance().p2Kill();

                playShipHitSound();
            }

            else if (s.type == GameObjType.p2ship)
            {
                GameObjManager.Instance().remove(batchEnum.ships, s);
                BombManager.Instance().removeBomb(b, s.spriteRef.pos, s.spriteRef.color);

                s.hit(PlayerID.two);

                ScoreManager.Instance().p1Kill();

                playShipHitSound();
            }
            else { }
        }
Beispiel #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;
        }
Beispiel #5
0
 public override void VisitShip(Ship s, Vector2 _point)
 {
     reactionToBomb(s, this, _point);
 }
Beispiel #6
0
        private void reactionToShip(Ship s, Missile m, Vector2 _point)
        {
            if (s.type == GameObjType.p1ship && m.type == GameObjType.p2missiles)
            {

                GameObjManager.Instance().addExplosion(s.spriteRef.pos, s.spriteRef.color);
                GameObjManager.Instance().remove(batchEnum.ships, s);
                GameObjManager.Instance().remove(batchEnum.missiles, m);

                hit(PlayerID.one);

                ScoreManager.Instance().p2Kill();

                playMissileHitSound();
                playShipHitSound();

                PlayerManager.Instance().getPlayer(m.owner).increaseNumMissiles();
            }

            else if (s.type == GameObjType.p2ship && m.type == GameObjType.p1missiles)
            {

                GameObjManager.Instance().addExplosion(s.spriteRef.pos, s.spriteRef.color);

                GameObjManager.Instance().remove(batchEnum.ships, s);
                GameObjManager.Instance().remove(batchEnum.missiles, m);

                hit(PlayerID.two);

                ScoreManager.Instance().p1Kill();

                playMissileHitSound();
                playShipHitSound();

                PlayerManager.Instance().getPlayer(m.owner).increaseNumMissiles();
            }
            else { }
        }
Beispiel #7
0
 public virtual void VisitShip(Ship s, Vector2 _point)
 {
 }
Beispiel #8
0
 public override void VisitShip(Ship s, Vector2 _point)
 {
     playFenceHit();
     hit();
 }
Beispiel #9
0
 public override void VisitShip(Ship s, Vector2 _point)
 {
     reactionToMissile(this, s, _point);
 }
Beispiel #10
0
 public void setShip(Ship s)
 {
     playerShip = s;
 }
Beispiel #11
0
 public override void VisitShip(Ship s, Vector2 _point)
 {
     reactionToBomb(s, this, _point);
 }