Exemplo n.º 1
0
        private void reactionToShip(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);

                hit(PlayerID.one);

                ScoreManager.Instance().p2Kill();

                playShipHitSound();
                playBombHitSound();
            }

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

                hit(PlayerID.two);

                ScoreManager.Instance().p1Kill();

                playShipHitSound();
                playBombHitSound();
            }
            else
            {
            }

            playShipHitSound();
        }
Exemplo n.º 2
0
 public static GameObjManager Instance()
 {
     if (instance == null)
     {
         instance = new GameObjManager();
     }
     return(instance);
 }
        private void reactionToBomb(Missile m, Bomb b, Vector2 _point)
        {
            BombManager.Instance().removeBomb(b, b.spriteRef.pos, b.spriteRef.color);

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

            PlayerManager.getPlayer(m.owner).increaseNumMissiles();
        }
Exemplo n.º 4
0
        private void reactionToWall(Wall w, Missile m, Vector2 _point)
        {
            // Vector2 pos = m.physicsObj.body.GetWorldPoint(_man.LocalPoint);
            Vector2 pos = _point;

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

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

            hit();
        }
Exemplo n.º 5
0
        private void reactionToMissile(Missile m1, Missile m2, Vector2 _point)
        {
            // Vector2 pos = m1.physicsObj.body.GetWorldPoint(_man.LocalPoint);
            Vector2 pos = _point;

            GameObjManager.Instance().addExplosion(pos, m1.spriteRef.color);
            GameObjManager.Instance().remove(batchEnum.missiles, m1);
            GameObjManager.Instance().remove(batchEnum.missiles, m2);

            PlayerManager.Instance().getPlayer(m1.owner).increaseNumMissiles();
            PlayerManager.Instance().getPlayer(m2.owner).increaseNumMissiles();

            playMissileHitSound();
        }
Exemplo n.º 6
0
        public void process()
        {
            int count = inpQ.Count;

            CollisionManager.GameObjManager pObj = CollisionManager.GameObjManager.Instance();

            for (int i = 0; i < count; i++)
            {
                qHeader pInstance = inpQ.Dequeue();

                switch (pInstance.type)
                {
                case QueueType.ship_impulse:
                    ship_impulse imp = (ship_impulse)pInstance.obj;
                    imp.execute();
                    break;

                case QueueType.ship_missile:
                    Ship_Create_Missile_Message smiss = (Ship_Create_Missile_Message)pInstance.obj;
                    CollisionManager.Player     p2    = PlayerManager.getPlayer(smiss.id);
                    p2.createMissile();
                    break;

                case QueueType.ship_rot_anti:
                    Ship_rot_message srmsg = (Ship_rot_message)pInstance.obj;
                    srmsg.rot = -0.1f;
                    srmsg.execute();
                    break;

                case QueueType.ship_bomb:
                    Ship_Create_Bomb_Message smsg = (Ship_Create_Bomb_Message)pInstance.obj;
                    CollisionManager.GameObjManager.Instance().createBomb(smsg.id);
                    break;


                case QueueType.EventMessage:
                    EvenMessage msg = (EvenMessage)pInstance.obj;
                    msg.execute();
                    break;

                case QueueType.ship_rot_clock:
                    Ship_rot_message p3 = (Ship_rot_message)pInstance.obj;
                    p3.rot = 0.1f;
                    p3.execute();
                    break;
                }
            }
        }
        private void armed(object obj)
        {
            World world = Game1.GameInstance.getWorld();

            Ship ship     = PlayerManager.getPlayer(owner).playerShip;
            Body shipBody = ship.physicsObj.body;


            var bombShape = new PolygonShape();

            bombShape.SetAsBox(5, 5);

            var fd = new FixtureDef();

            fd.shape       = bombShape;
            fd.restitution = 0.0f;
            fd.friction    = 0.0f;
            fd.density     = 0.0001f;
            fd.userData    = this;


            BodyDef bd = new BodyDef();

            bd.fixedRotation = true;

            bd.type     = BodyType.Static;
            bd.position = orgPos;

            var body = world.CreateBody(bd);

            body.CreateFixture(fd);
            body.SetUserData(this);


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

            bombAnim(nodeData);

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

            playBombArmedSound();
        }
Exemplo n.º 8
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.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.getPlayer(m.owner).increaseNumMissiles();
            }
            else
            {
            }
        }
Exemplo n.º 9
0
 public static GameObjManager Instance()
 {
     if (instance == null)
         instance = new GameObjManager();
     return instance;
 }
Exemplo n.º 10
0
 public void clear()
 {
     this.active = null;
     instance = null;
 }
Exemplo n.º 11
0
 public void clear()
 {
     this.active = null;
     instance    = null;
 }
Exemplo n.º 12
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--;
            }
        }