Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        public void pushToNetwork(LocalNetworkGamer localGamer)
        {
            int icount = outQ.Count;

            for (int i = 0; i < icount; i++)
            {
                qHeader pHead = outQ.Dequeue();

                switch (pHead.type)
                {
                case QueueType.ship_rot_anti:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_rot_anti, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_rot_clock:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_rot_clock, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_bomb:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_bomb, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_missile:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_missile, pHead.outseq, pHead.packetOwner);
                    }

                    break;

                case QueueType.ship_impulse:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.ship_impulse, pHead.outseq, pHead.packetOwner);
                    }

                    break;


                case QueueType.EventMessage:
                    Send(localGamer, pHead);
                    if (pHead.inseq > 1 || localGamer.IsHost)
                    {
                        inQueue.add(pHead.obj, QueueType.EventMessage, pHead.outseq, pHead.packetOwner);
                    }

                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public void Send(LocalNetworkGamer local, qHeader pHeader)
        {
            PacketWriter pWrite = new PacketWriter();

            pWrite.Write((int)pHeader.type);
            pWrite.Write((int)pHeader.packetOwner);
            pWrite.Write(pHeader.inseq);
            pWrite.Write(pHeader.outseq);


            switch (pHeader.type)
            {
            case QueueType.ship_rot_clock:
                Ship_rot_message p1 = (Ship_rot_message)pHeader.obj;
                pWrite.Write((int)p1.rot);
                pWrite.Write((int)p1.x);
                pWrite.Write((int)p1.y);
                pWrite.Write((int)p1.serverRotvalue);
                break;

            case QueueType.ship_rot_anti:
                Ship_rot_message p4 = (Ship_rot_message)pHeader.obj;
                pWrite.Write((int)p4.rot);
                pWrite.Write((int)p4.x);
                pWrite.Write((int)p4.y);
                pWrite.Write((int)p4.serverRotvalue);
                break;

            case QueueType.ship_missile:
                Ship_Create_Missile_Message missile = (Ship_Create_Missile_Message)pHeader.obj;
                pWrite.Write((int)missile.x);
                pWrite.Write((int)missile.y);
                pWrite.Write((int)missile.rot);
                break;

            case QueueType.ship_impulse:
                ship_impulse p = (ship_impulse)pHeader.obj;
                pWrite.Write((int)p.impulse.X);
                pWrite.Write((int)p.impulse.Y);
                pWrite.Write((int)p.x);
                pWrite.Write((int)p.y);
                pWrite.Write((int)p.rot);
                break;

            case QueueType.ship_bomb:
                Ship_Create_Bomb_Message bomb = (Ship_Create_Bomb_Message)pHeader.obj;
                pWrite.Write((int)bomb.x);
                pWrite.Write((int)bomb.y);
                pWrite.Write((int)bomb.rot);
                break;

            case QueueType.EventMessage:
                EvenMessage e = new EvenMessage((EvenMessage)pHeader.obj);
                pWrite.Write(e.gameIdA);
                pWrite.Write(e.gameIdB);
                pWrite.Write(e.CollisionPt);
                break;
            }

            local.SendData(pWrite, SendDataOptions.InOrder);
        }