Beispiel #1
0
        public void Update()
        {
            if (state == LOBBY_STATE.START)
            {
                if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_H))
                {
                    state = LOBBY_STATE.HOST;
                    GameManager.SetAsServer();

                    NetPeerConfiguration config = new NetPeerConfiguration("Connected Test");
                    config.AcceptIncomingConnections = true;
                    config.MaximumConnections        = 100;
                    config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
                    config.Port = 14240;

                    //server = new NetPeer(config);
                    //server.Start();

                    MyServer.Instance.Setup(config);
                }
            }
            else if (state == LOBBY_STATE.HOST)
            {
                if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_SPACE))
                {
                    GameStateMessage msg1 = new GameStateMessage(SEND_TYPE.LOCAL, GAME_STATE.PLAY);
                    GameStateMessage msg2 = new GameStateMessage(SEND_TYPE.NETWORKED, GAME_STATE.PLAY);

                    InputQueue.AddToQueue(msg1);
                    InputQueue.AddToQueue(msg2);
                }
            }
        }
Beispiel #2
0
 void ProcessPlayerInputMessage(PlayerInputMessage msg)
 {
     if (msg.playerID == 1)
     {
         player1.Rotate(msg.horzInput);
         player1.Move(msg.vertInput);
         if (msg.fireMissile)
         {
             GameManager.FireMissile(player1);
         }
         if (msg.layMine)
         {
             GameManager.LayMine(player1);
         }
         Vec2 t = player1.GetHeading();
         MissileMineMessage p1MissileUpdate = new MissileMineMessage(1, msg.fireMissile, msg.layMine, t.X, t.Y);
         InputQueue.AddToQueue(p1MissileUpdate);
     }
     else if (msg.playerID == 2)
     {
         player2.Rotate(msg.horzInput);
         player2.Move(msg.vertInput);
         if (msg.fireMissile)
         {
             GameManager.FireMissile(player2);
         }
         if (msg.layMine)
         {
             GameManager.LayMine(player2);
         }
         Vec2 t = player2.GetHeading();
         MissileMineMessage p2MissileUpdate = new MissileMineMessage(2, msg.fireMissile, msg.layMine, t.X, t.Y);
         InputQueue.AddToQueue(p2MissileUpdate);
     }
 }
Beispiel #3
0
 public static InputQueue Instance()
 {
     if (instance == null)
     {
         instance = new InputQueue();
     }
     return(instance);
 }
Beispiel #4
0
        public void OnHit()
        {
            AudioManager.PlaySoundEvent(AUDIO_EVENT.FENCE_HIT);
            ParticleSpawner.SpawnParticleEvent(PARTICLE_EVENT.FENCE_HIT, this);

            FenceHitMessage msg = new FenceHitMessage(fence_id);

            InputQueue.AddToQueue(msg);
        }
Beispiel #5
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            PhysicWorld.Instance();
            GameManager.Instance();
            ParticleSpawner.Instance();
            AudioManager.Instance();
            InputQueue.Instance();
            OutputQueue.Instance();
            MyClient.Instance();

            prevTime = GetTime();

            GameManager.Start();
        }
Beispiel #6
0
 private void AddPointUpdate()
 {
     if (clean == true)
     {
         if (p1Score >= 3 || p2Score >= 3)
         {
             state = GAME_STATE.GAME_OVER;
             GAMEOVERMESSAGE msg = new GAMEOVERMESSAGE(1);
             InputQueue.AddToQueue(msg);
         }
         else
         {
             LoadLevel();
             state = GAME_STATE.PLAY;
         }
     }
 }
Beispiel #7
0
        public static void Process()
        {
            while (instance.pOutputQueue.Count > 0)
            {
                DataMessage msg = instance.pOutputQueue.Dequeue();

                if (msg.sendType == SEND_TYPE.LOCAL)
                {
                    InputQueue.AddToQueue(msg);
                }
                else
                {
                    //InputQueue.AddToQueue(msg);
                    MyClient.Instance().SendData(msg);
                }
            }
        }
Beispiel #8
0
        public static void Process3()
        {
            InputQueue pInputQueue = new InputQueue();
            int        count       = inQ.Count;

            for (int i = 0; i < count; i++)
            {
                //read header
                QueueHdr qH = inQ.Dequeue();

                Message msg = null;

                switch (qH.type)
                {
                case Queue_type.QUEUE_SHIP_BOMB:
                    msg = new Ship_Create_Bomb_Message((Ship_Create_Bomb_Message)qH.data);
                    break;

                case Queue_type.QUEUE_SHIP_MISSILE:
                    msg = new Ship_Create_Missile_Message((Ship_Create_Missile_Message)qH.data);
                    break;

                case Queue_type.QUEUE_SHIP_IMPULSE:
                    msg = new Ship_Impulse_Message((Ship_Impulse_Message)qH.data);
                    break;

                case Queue_type.QUEUE_SHIP_ROT:
                    msg = new Ship_Rot_Message((Ship_Rot_Message)qH.data);
                    break;

                case Queue_type.QUEUE_PHYSICS_BUFFER:
                    msg = new PhysicsBuffer_Message((PhysicsBuffer_Message)qH.data);
                    break;

                case Queue_type.QUEUE_EVENT:
                    msg = new Event_Message((Event_Message)qH.data);
                    break;
                }

                msg.execute();
            }
        }
Beispiel #9
0
        void CheckForInput()
        {
            int  p1_H       = InputManager.GetAxis(INPUTAXIS.HORIZONTAL_P1);
            int  p1_V       = InputManager.GetAxis(INPUTAXIS.VERTICAL_P1);
            bool p1_Missile = InputManager.GetButtonDown(INPUTBUTTON.P1_FIRE);
            bool p1_Mine    = InputManager.GetButtonDown(INPUTBUTTON.P1_FIRE2);

            PlayerInputMessage p1msg = new PlayerInputMessage(SEND_TYPE.LOCAL, 1, p1_H, p1_V, p1_Missile, p1_Mine);

            InputQueue.AddToQueue(p1msg);



            int  p2_H       = InputManager.GetAxis(INPUTAXIS.HORIZONTAL_P2);
            int  p2_V       = InputManager.GetAxis(INPUTAXIS.VERTICAL_P2);
            bool p2_Missile = InputManager.GetButtonDown(INPUTBUTTON.P2_FIRE);

            // PlayerInputMessage p2msg = new PlayerInputMessage(2, p2_H, p2_V, p2_Missile);

            //  InputQueue.AddToQueue(p2msg);
        }
Beispiel #10
0
        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------

        // static int number = 0;
        public override void Update()
        {
            float curTime         = GetTime();
            float gameElapsedTime = curTime - prevTime;

            PhysicWorld.Update(gameElapsedTime);
            GameManager.Update(gameElapsedTime);

            InputManager.Update();
            InputTest.KeyboardTest();

            MyClient.Instance().Update();

            OutputQueue.Process();
            InputQueue.Process();



            GameManager.CleanUp();

            prevTime = curTime;
        }
Beispiel #11
0
        private void PlayScreenUpdate()
        {
            //if (InputManager.GetButtonDown(INPUTBUTTON.JUMP))
            //{
            //    state = GAME_STATE.GAME_OVER;
            //    DestroyAll();
            //    GAMEOVERMESSAGE go = new GAMEOVERMESSAGE(1);
            //    InputQueue.AddToQueue(go);
            //}

            for (int i = gameObjList.Count - 1; i >= 0; i--)
            {
                gameObjList[i].Update();
                // if(gameObjList[i] is Missile)
                // {
                //    Missile mis = gameObjList[i] as Missile;
                //    MissileUpdateMessage m = new MissileUpdateMessage(mis.MissileID, mis.GetPixelPosition().X, mis.GetPixelPosition().Y);
                //    InputQueue.AddToQueue(m);
                //}
            }


            // Network Stuff
            Vec2  p1Pos              = player1.GetPixelPosition();
            float p1Ang              = player1.GetAngle_Rad();
            PlayerUpdateMessage msg  = new PlayerUpdateMessage(1, p1Pos.X, p1Pos.Y);
            RotationMessage     rmsg = new RotationMessage(1, p1Ang);

            Vec2  p2Pos = player2.GetPixelPosition();
            float p2Ang = player2.GetAngle_Rad();
            PlayerUpdateMessage msg2  = new PlayerUpdateMessage(2, p2Pos.X, p2Pos.Y);
            RotationMessage     rmsg2 = new RotationMessage(2, p2Ang);

            InputQueue.AddToQueue(msg);
            InputQueue.AddToQueue(rmsg);
            InputQueue.AddToQueue(msg2);
            InputQueue.AddToQueue(rmsg2);
        }
Beispiel #12
0
        void CheckForInput()
        {
            if (GameManager.GetGameState() == GAME_STATE.PLAY)
            {
                int  p1_H       = InputManager.GetAxis(INPUTAXIS.HORIZONTAL_P1);
                int  p1_V       = InputManager.GetAxis(INPUTAXIS.VERTICAL_P1);
                bool p1_Missile = InputManager.GetButtonDown(INPUTBUTTON.P1_FIRE);


                //PlayerInputMessage p1msg = new PlayerInputMessage(SEND_TYPE.NETWORKED, 1, p1_H, p1_V, p1_Missile);

                //InputQueue.AddToQueue(p1msg);

                int  p2_H       = InputManager.GetAxis(INPUTAXIS.HORIZONTAL_P2);
                int  p2_V       = InputManager.GetAxis(INPUTAXIS.VERTICAL_P2);
                bool p2_Missile = InputManager.GetButtonDown(INPUTBUTTON.P2_FIRE);
                bool p2_Mine    = InputManager.GetButtonDown(INPUTBUTTON.P2_FIRE2);

                PlayerInputMessage p2msg = new PlayerInputMessage(SEND_TYPE.NETWORKED, 2, p2_H, p2_V, p2_Missile, p2_Mine);

                InputQueue.AddToQueue(p2msg);
            }
        }
Beispiel #13
0
        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------

        // static int number = 0;
        public override void Update()
        {
            float curTime         = GetTime();
            float gameElapsedTime = curTime - prevTime;

            PhysicWorld.Update(gameElapsedTime);

            InputManager.Update();
            CheckForInput();

            GameManager.Update(gameElapsedTime);

            MyServer.Instance.Update();

            InputQueue.Process();

            OutputQueue.Process();



            GameManager.CleanUp();

            prevTime = curTime;
        }
Beispiel #14
0
        void ClientReadGameStateFromServer(LocalNetworkGamer gamer)
        {
            // Keep reading as long as incoming packets are available.
            while (gamer.IsDataAvailable)
            {
                NetworkGamer sender;

                // Read a single packet from the network.
                gamer.ReceiveData(packetReader, out sender);

                // This packet contains data about all the players in the session.
                // We keep reading from it until we have processed all the data.
                while (packetReader.Position < packetReader.Length)
                {
                    if (packetReader.Length <= 2)
                    {
                        break;
                    }
                    // Read the state of one tank from the network packet.
                    // byte gamerId = packetReader.ReadByte();
                    //Vector2 position = packetReader.ReadVector2();
                    //float tankRotation = packetReader.ReadSingle();
                    //float turretRotation = packetReader.ReadSingle();

                    QueueHdr qH;

                    qH.inSeqNum  = packetReader.ReadInt32();
                    qH.outSeqNum = packetReader.ReadInt32();
                    qH.type      = (Queue_type)packetReader.ReadInt32();

                    // int incomingCount = packetReader.ReadInt32();


                    //Debug.WriteLine("qH.inSeqNum  ServerRead = " + qH.inSeqNum);
                    //Debug.WriteLine("qH.outSeqNum ServerRead = " + qH.outSeqNum);
                    //Debug.WriteLine("qH.type ServerRead = " + qH.type);
                    //Debug.WriteLine("incomingCount ServerRead = " + incomingCount);


                    //////////////////////// send to input queue on client
                    //PhysicsBuffer[] physicsBuff2 = new PhysicsBuffer[incomingCount];


                    switch (qH.type)
                    {
                    case Queue_type.QUEUE_PHYSICS_BUFFER:
                        if (qH.type == Queue_type.QUEUE_PHYSICS_BUFFER)
                        {
                            int             incomingCount = packetReader.ReadInt32();
                            PhysicsBuffer[] physicsBuff2  = new PhysicsBuffer[incomingCount];

                            for (int y = 0; y < incomingCount; y++)
                            {
                                //PhysicsBuffer_Message localPhysicsBuffer_Message = new PhysicsBuffer_Message((PhysicsBuffer_Message)qH.data);
                                //PhysicsBuffer myPhysicsBuffer = new PhysicsBuffer();
                                //myPhysicsBuffer.id = packetReader.ReadInt32();
                                //myPhysicsBuffer.position = packetReader.ReadVector2();
                                //myPhysicsBuffer.rotation = (float)packetReader.ReadSingle();
                                //Push to buffer
                                physicsBuff2[y].id       = packetReader.ReadInt32();
                                physicsBuff2[y].position = packetReader.ReadVector2();
                                physicsBuff2[y].rotation = (float)packetReader.ReadSingle();
                            }

                            // send this msg to Input Queue inQ so client can read the messages
                            PhysicsBuffer_Message msg = new PhysicsBuffer_Message(ref physicsBuff2);
                            PhysicsBuffer_Message_inQueue.add(msg);
                        }
                        break;

                    case Queue_type.QUEUE_SHIP_MISSILE:
                        Ship_Create_Missile_Message msgMissile = new Ship_Create_Missile_Message(player2);
                        qH.data = msgMissile;
                        InputQueue.add(qH);
                        break;

                    case Queue_type.QUEUE_SHIP_BOMB:
                        Ship_Create_Bomb_Message msgBomb = new Ship_Create_Bomb_Message(player2);
                        qH.data = msgBomb;
                        InputQueue.add(qH);
                        break;

                    case Queue_type.QUEUE_SHIP_IMPULSE:
                        Vector2 impulse = packetReader.ReadVector2();
                        Ship_Impulse_Message msgImpulse = new Ship_Impulse_Message(player2, impulse);
                        qH.data = msgImpulse;
                        InputQueue.add(qH);
                        break;

                    case Queue_type.QUEUE_SHIP_ROT:
                        float            rotation    = packetReader.ReadSingle();
                        Ship_Rot_Message msgRotation = new Ship_Rot_Message(player2, rotation);
                        qH.data = msgRotation;
                        InputQueue.add(qH);
                        break;

                    case Queue_type.QUEUE_EVENT:
                        //msg = new Event_Message((Event_Message)qH.data);

                        int idA = packetReader.ReadInt32();
                        // Debug.WriteLine("idA =" + idA);
                        int idB = packetReader.ReadInt32();
                        // Debug.WriteLine("idA =" + idB);
                        Vector2 collisionPt = packetReader.ReadVector2();
                        // Debug.WriteLine("idA =" + collisionPt);

                        Event_Message eventMsg = new Event_Message(idA, idB, collisionPt);
                        qH.data = eventMsg;
                        InputQueue.add(qH);



                        break;
                    }
                }
            }
        }
Beispiel #15
0
        void ServerReadInputFromClients(LocalNetworkGamer gamer)
        {
            // Keep reading as long as incoming packets are available.
            while (gamer.IsDataAvailable)
            {
                NetworkGamer sender;

                // Read a single packet from the network.
                gamer.ReceiveData(packetReader, out sender);

                if (!sender.IsLocal)
                {
                    // Look up the tank associated with whoever sent this packet.
                    //Tank remoteTank = sender.Tag as Tank;
                    Ship remoteShip = sender.Tag as Ship;

                    // Read the latest inputs controlling this tank.
                    // remoteTank.TankInput = packetReader.ReadVector2();
                    // remoteTank.TurretInput = packetReader.ReadVector2();

                    QueueHdr qH;

                    qH.inSeqNum  = packetReader.ReadInt32();
                    qH.outSeqNum = packetReader.ReadInt32();
                    qH.type      = (Queue_type)packetReader.ReadInt32();
                    //qH.data = packetReader.ReadVector2();



                    switch (qH.type)
                    {
                    case Queue_type.QUEUE_SHIP_BOMB:
                        Ship_Create_Bomb_Message msg = new Ship_Create_Bomb_Message(player1);
                        qH.data = msg;
                        InputQueue.add(qH);
                        break;

                    case Queue_type.QUEUE_SHIP_MISSILE:
                        Ship_Create_Missile_Message msg2 = new Ship_Create_Missile_Message(player1);
                        qH.data = msg2;
                        InputQueue.add(qH);
                        break;

                    case Queue_type.QUEUE_SHIP_IMPULSE:
                        Ship_Impulse_Message sim = new Ship_Impulse_Message(player1, packetReader.ReadVector2());
                        // qH.data = packetReader.ReadVector2();
                        qH.data = sim;
                        //  Ship_Impulse_Message msg3 = new Ship_Impulse_Message((Ship_Impulse_Message)qH.data);
                        // msg = new Ship_Impulse_Message((Ship_Impulse_Message)qH.data);
                        // qH.data = msg3;
                        InputQueue.add(qH);

                        break;

                    case Queue_type.QUEUE_SHIP_ROT:
                        Ship_Rot_Message rotMessage = new Ship_Rot_Message(player1, packetReader.ReadSingle());    // float? ReadDouble()
                        // qH.data = packetReader.ReadVector2();
                        qH.data = rotMessage;
                        // Ship_Rot_Message msg4 = new Ship_Rot_Message((Ship_Rot_Message)qH.data);
                        // qH.data = msg4;
                        InputQueue.add(qH);
                        // msg = new Ship_Rot_Message((Ship_Rot_Message)qH.data);
                        break;

                    case Queue_type.QUEUE_EVENT:
                        break;
                    }
                }
            }
        }
Beispiel #16
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // TODO: Add your update logic here
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            GraphicsDevice.Clear(Color.Black);

            HandleInput();

            if (networkSession == null)
            {
                // If we are not in a network session, update the
                // menu screen that will let us create or join one.
                UpdateMenuScreen();
            }
            else
            {
                // If we are in a network session, update it.
                UpdateNetworkSession();
            }

            base.Update(gameTime);

            if (state == gameState.game)
            {
                //Input Queue -> msg process
                InputQueue.Process3();

                world.Step((float)gameTime.ElapsedGameTime.TotalSeconds, 5, 8);


                // Out 0) contact listener fires collisions
                // events created in world step

                //Out 1) physics event(contact listener) msg -> Output queue

                if (Game1.networkSession != null)
                {
                    if (Game1.networkSession.IsHost)
                    {
                        // create Buffer
                        PhysicsBuffer[] physicsBuff = new PhysicsBuffer[PhysicsMan.Instance().getCount()];
                        int             num         = PhysicsMan.Instance().getCount();


                        // Update PhysicsObject to PhysicsBuffer for a message transmission
                        PhysicsMan.PushToBuffer(ref physicsBuff);

                        //// out 2) physics buffer msg => OutputQueue
                        PhysicsBuffer_Message msg = new PhysicsBuffer_Message(ref physicsBuff);
                        PhysicsBuffer_Message_outQueue.add(msg);
                    }
                }

                // ON remote ---------------------------------------------
                // read Physics Buffer from OutputQueue
                // no physics simulator

                // On Both----------------------------------------------

                // Out 3) input msg -> OutputQueue
                // InputQueue.Update ?? maybe this is checkinput()???

                checkInput();

                //OutputQueue -> InputQueue
                OutputQueue.PushToNetwork();

                // I put this down here to get pBuffGlobal to have the same amount of items as number of physics bodies
                // InputQueue.Process3();

                //Both----------------------------------------------

                //PhsicsBuffer to GameObject
                PhysicsMan.Update(ref PhysicsBuffer_Message.pBuffGlobal);

                //PhysicsMan.Instance().Update();

                ScoreManager.Instance().Update();

                GameObjManager.Instance().Update(world);

                Timer.Process(gameTime);
            }

            Game1.Camera.Update(gameTime);
        }
Beispiel #17
0
        // PacketWriter packetWriter2 = new PacketWriter();

        public static void PushToNetwork()
        {
            PacketWriter packetWriter2 = new PacketWriter();

            int count = outQ.Count;

            for (int i = 0; i < count; i++)
            {
                // Read the header
                QueueHdr qH = outQ.Dequeue();

                switch (qH.type)
                {
                case Queue_type.QUEUE_SHIP_BOMB:

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);
                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }

                        if (Game1.networkSession.IsHost)
                        {
                            LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                            server.SendData(packetWriter2, SendDataOptions.InOrder);
                        }
                    }
                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            // packetWriter2.Write((int)qH.data);

                            // Send our input data to the server.//
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }

                    break;

                case Queue_type.QUEUE_SHIP_MISSILE:

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }

                        if (Game1.networkSession.IsHost)
                        {
                            LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                            server.SendData(packetWriter2, SendDataOptions.InOrder);
                        }
                    }
                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            // packetWriter2.Write((int)qH.data);

                            // Send our input data to the server.
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }

                    break;

                case Queue_type.QUEUE_SHIP_IMPULSE:

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);

                    Ship_Impulse_Message sim = (Ship_Impulse_Message)qH.data;

                    packetWriter2.Write((Vector2)sim.impulse);
                    Debug.WriteLine("Outputq - sim.impulse = " + sim.impulse);
                    Debug.WriteLine("Outputq - sim.X = " + sim.impulse.X);
                    Debug.WriteLine("Outputq - sim.Y = " + sim.impulse.Y);

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }

                        if (Game1.networkSession.IsHost)
                        {
                            LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                            server.SendData(packetWriter2, SendDataOptions.InOrder);
                        }
                    }
                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);    ///just added 207pm
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            //Ship_Impulse_Message sim = (Ship_Impulse_Message)qH.data;

                            //packetWriter2.Write((Vector2)sim.impulse);



                            // Send our input data to the server.
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }
                    break;

                case Queue_type.QUEUE_SHIP_ROT:
                    //send to input queue

                    //packetWriter2.Write(qH.inSeqNum);
                    //        packetWriter2.Write(qH.outSeqNum);
                    //        packetWriter2.Write((int)qH.type);

                    //        Ship_Impulse_Message sim = (Ship_Impulse_Message)qH.data;

                    //        packetWriter2.Write((Vector2)sim.impulse);

                    packetWriter2.Write(qH.inSeqNum);
                    packetWriter2.Write(qH.outSeqNum);
                    packetWriter2.Write((int)qH.type);
                    Ship_Rot_Message rotMessage = (Ship_Rot_Message)qH.data;
                    packetWriter2.Write(rotMessage.rotation);
                    Debug.WriteLine(" OutputQ - rotMessage.rotation = " + rotMessage.rotation);


                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }
                    }

                    if (Game1.networkSession.IsHost)
                    {
                        LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                        server.SendData(packetWriter2, SendDataOptions.InOrder);
                    }

                    foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    {
                        if (!Game1.networkSession.IsHost)
                        {
                            // Write our latest input state into a network packet.
                            //packetWriter2.Write(qH.inSeqNum);
                            //packetWriter2.Write(qH.outSeqNum);
                            //packetWriter2.Write((int)qH.type);
                            //Ship_Rot_Message rotMessage = (Ship_Rot_Message)qH.data;
                            //packetWriter2.Write(rotMessage.rotation);
                            //  packetWriter2.Write((Vector2)qH.data);

                            // Send our input data to the server.
                            gamer.SendData(packetWriter2,
                                           SendDataOptions.InOrder, Game1.networkSession.Host);
                        }
                    }
                    break;

                case Queue_type.QUEUE_PHYSICS_BUFFER:

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }
                    }

                    if (Game1.networkSession != null)
                    {
                        // packetWriter2.Write(gamer.Id);
                        packetWriter2.Write(qH.inSeqNum);
                        packetWriter2.Write(qH.outSeqNum);
                        packetWriter2.Write((int)qH.type);
                        //Debug.WriteLine("qH.inSeqNum from PushToNetwork = " + qH.inSeqNum);
                        //Debug.WriteLine("qH.outSeqNum from PushToNetwork = " + qH.outSeqNum);
                        //Debug.WriteLine("qH.type from PushToNetwork = " + qH.type);
                        //PhysicsBuffer[] localPhysicsBuff = new PhysicsBuffer[];
                        PhysicsBuffer_Message PhysicsBuff_MessageInQueueHdr = new PhysicsBuffer_Message((PhysicsBuffer_Message)qH.data);

                        //get the count from the buffer
                        packetWriter2.Write(PhysicsBuff_MessageInQueueHdr.count);
                        //Debug.WriteLine("PhysicsBuff_MessageInQueueHdr.count = " + PhysicsBuff_MessageInQueueHdr.count);
                        PhysicsBuffer[] localPhysicsBuff = new PhysicsBuffer[PhysicsBuff_MessageInQueueHdr.count];
                        //get the the physics buffer struct of id, position , rotation out
                        localPhysicsBuff = PhysicsBuff_MessageInQueueHdr.pBuff;

                        for (int j = 0; j < PhysicsBuff_MessageInQueueHdr.count; j++)
                        {
                            PhysicsBuffer myPhysicsBuffer = new PhysicsBuffer();

                            myPhysicsBuffer.id       = localPhysicsBuff[j].id;
                            myPhysicsBuffer.position = localPhysicsBuff[j].position;
                            myPhysicsBuffer.rotation = localPhysicsBuff[j].rotation;
                            packetWriter2.Write(myPhysicsBuffer.id);
                            packetWriter2.Write(myPhysicsBuffer.position);
                            packetWriter2.Write(myPhysicsBuffer.rotation);
                            //Debug.WriteLine("myPhysicsBuffer.id = " + myPhysicsBuffer.id);
                            //Debug.WriteLine("myPhysicsBuffer.position = " + myPhysicsBuffer.position);
                            //Debug.WriteLine("myPhysicsBuffer.rotation = " + myPhysicsBuffer.rotation);
                        }



                        if (Game1.networkSession != null)
                        {
                            if (Game1.networkSession.IsHost)
                            {
                                LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                                server.SendData(packetWriter2, SendDataOptions.InOrder);
                            }
                        }

                        // if this is the client machine, need to send to server
                    }

                    // Send our input data to the server.
                    //if (Game1.networkSession != null)
                    //{
                    //    if (Game1.networkSession.IsHost)
                    //    {
                    //        foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    //        {
                    //            gamer.SendData(packetWriter2,
                    //                        SendDataOptions.InOrder, Game1.networkSession.);
                    //        }
                    //    }
                    //}



                    break;

                case Queue_type.QUEUE_EVENT:

                    if (Game1.networkSession != null)
                    {
                        if (Game1.networkSession.IsHost)
                        {
                            InputQueue.add(qH);
                        }
                    }
                    if (Game1.networkSession != null)
                    {
                        // Write our latest input state into a network packet.
                        packetWriter2.Write(qH.inSeqNum);
                        packetWriter2.Write(qH.outSeqNum);
                        packetWriter2.Write((int)qH.type);
                        // packetWriter2.Write((int)qH.data);
                        Event_Message eventMsg = new Event_Message((Event_Message)qH.data);
                        packetWriter2.Write(eventMsg.GameID_A);
                        //   Debug.WriteLine("eventMsg " + eventMsg.GameID_A);
                        packetWriter2.Write(eventMsg.GameID_B);
                        //  Debug.WriteLine("eventMsg " + eventMsg.GameID_B);
                        packetWriter2.Write(eventMsg.collision_pt);
                        //   Debug.WriteLine("eventMsg " + eventMsg.collision_pt);


                        if (Game1.networkSession != null)
                        {
                            if (Game1.networkSession.IsHost)
                            {
                                LocalNetworkGamer server = (LocalNetworkGamer)Game1.networkSession.Host;

                                server.SendData(packetWriter2, SendDataOptions.InOrder);
                            }
                        }

                        // Send our input data to the server.
                        // gamer.SendData(packetWriter2,
                        //              SendDataOptions.InOrder, Game1.networkSession.Host);
                    }


                    //foreach (LocalNetworkGamer gamer in Game1.networkSession.LocalGamers)
                    //{

                    //    if (!Game1.networkSession.IsHost)
                    //    {
                    //        // Write our latest input state into a network packet.
                    //        packetWriter2.Write(qH.inSeqNum);
                    //        packetWriter2.Write(qH.outSeqNum);
                    //        packetWriter2.Write((int)qH.type);
                    //       // Ship_Rot_Message rotMessage = (Ship_Rot_Message)qH.data;
                    //       // packetWriter2.Write(rotMessage.rotation);
                    //      //  packetWriter2.Write((Vector2)qH.data);

                    //        // Send our input data to the server.
                    //        gamer.SendData(packetWriter2,
                    //                       SendDataOptions.InOrder, Game1.networkSession.Host);
                    //    }
                    //}
                    break;

                default:
                    break;
                }
            }
        }