Ejemplo n.º 1
0
    private void ReceiveBlockUpdates()
    {
        while (nwMgr.PacketQueue.HasPacket <BlockUpdatePacket>())
        {
            if (playersInfo.IsHosts[(int)myTeamRole])
            {
                print("im host, and i got your block update packet.");
                INetworkConnection recvConn;
                BlockUpdatePacket  packet = nwMgr.PacketQueue.GetNextPacket <BlockUpdatePacket>(out recvConn);

                if (packet.blockWasAdded)
                {
                    GameState.Block b = new GameState.Block();
                    b.position = packet.position;
                    b.type     = packet.type;
                    b.role     = packet.role;
                    GameObject.Find("Renderer").GetComponent <Renderer>().RenderAddBlock(b);
                    SendGameState();
                    print("i'm host and i just sent a packet back after adding");
                }
                else
                {
                    GameState.Block b = new GameState.Block();
                    b.position = packet.position;
                    b.type     = packet.type;
                    b.role     = packet.role;
                    GameObject.Find("Renderer").GetComponent <Renderer>().RenderRemoveBlock(b);
                    SendGameState();
                    print("i'm host and i just sent a packet back after removing");
                }
            }
        }
    }
Ejemplo n.º 2
0
 public void sendBlockUpdate(GameState.Block b, bool add)
 {
     if (add)
     {
         if (playersInfo.IsHosts[(int)myTeamRole])
         {
             GameObject.Find("Renderer").GetComponent <Renderer>().RenderAddBlock(b);
             SendGameState();
         }
         else
         {
             BlockUpdatePacket bup = new BlockUpdatePacket(b.position, b.type, add);
             bup.role = b.role;
             nwMgr.SendPacket("info", bup);
             print("im not host, I'm trying to send blockupdate packet");
         }
     }
     else
     {
         if (playersInfo.IsHosts[(int)myTeamRole])
         {
             GameObject.Find("Renderer").GetComponent <Renderer>().RenderRemoveBlock(b);
             SendGameState();
         }
         else
         {
             BlockUpdatePacket bup = new BlockUpdatePacket(b.position, b.type, add);
             bup.role = b.role;
             nwMgr.SendPacket("info", bup);
             print("im not host, I'm trying to send blockupdate packet");
         }
     }
 }