Exemplo n.º 1
0
 public void RpcAddPoint(int id, Vector3 position, int senderID)
 {
     if (NetPlayer.local.playerID == senderID)
     {
         return;
     }
     else
     {
         PointPacket ep = new PointPacket();
         ep.id           = id;
         ep.requirements = new int[0];
         ep.type         = ElementType.point;
         ep.position     = position;
         Receive(ep);
     }
 }
Exemplo n.º 2
0
    void Create(ElementPacket packet)
    {
        switch (packet.type)
        {
        case ElementType.point:
            PointPacket p = packet as PointPacket;
            new Point(p.position, p.id);
            break;

        case ElementType.edge:
            List <Point> points = new List <Point>();
            foreach (int reqid in packet.requirements)
            {
                points.Add(DCGBase.all[reqid] as Point);
            }
            new Edge(points, packet.id);
            break;

        case ElementType.face:
            List <Edge> edges = new List <Edge>();
            foreach (int reqid in packet.requirements)
            {
                edges.Add(DCGBase.all[reqid] as Edge);
            }
            new Face(edges, packet.id);
            break;

        case ElementType.solid:
            List <Face> faces = new List <Face>();
            foreach (int reqid in packet.requirements)
            {
                faces.Add(DCGBase.all[reqid] as Face);
            }
            new Solid(faces, packet.id);
            break;

        default:
            Debug.LogError("Network sent unfamiliar item type!");
            break;
        }

        if (waiting.ContainsKey(packet.id)) //if this item is in the waitlist, remove it.
        {
            waiting.Remove(packet.id);
        }

        if (expectations.ContainsKey(packet.id))
        {
            foreach (int reqer in expectations[packet.id].requirers)
            {
                bool hasAll = true;
                foreach (int req in waiting[reqer].requirements)
                {
                    hasAll = hasAll && DCGBase.all.ContainsKey(req);
                }
                if (hasAll)
                {
                    Create(waiting[reqer]);
                }
            }
            expectations.Remove(packet.id);
        }
    }