Ejemplo n.º 1
0
    private void OnDogColorsReceived(NetworkMessage msg)
    {
        DogColorsMsg message = msg.ReadMessage <DogColorsMsg>();

        Debug.Log("Dog Colors Received.");
        splatColors = new List <Vector4>();
        Debug.Log(message.Dog0Color);
        Debug.Log(message.Dog1Color);
        Debug.Log(message.Dog2Color);
        splatColors.Add(message.Dog0Color);
        splatColors.Add(message.Dog1Color);
        splatColors.Add(message.Dog2Color);
        SplatManagerSystem.instance.Colors = new List <Vector4>();
        SplatManagerSystem.instance.Colors.Add(message.Dog0Color);
        SplatManagerSystem.instance.Colors.Add(message.Dog1Color);
        SplatManagerSystem.instance.Colors.Add(message.Dog2Color);


        Debug.Log("Old Channel: " + channelMask + " New Channel " + message.Channel);
        channelMask = message.Channel;

        SplatManager.SendColorsToRenderer();

        SetDogColors();
    }
Ejemplo n.º 2
0
    private void OnDogColorsRequested(NetworkMessage msg)
    {
        DogColorsMsg response = new DogColorsMsg();

        Debug.Log("Dog Color Request Received.");
        int id = msg.conn.connectionId;

        GameObject[] p = GameObject.FindGameObjectsWithTag("Player");

        for (int j = 0; j < p.Length; j++)
        {
            if (p[j] != null)
            {
                Splatter s = p[j].GetComponent <Splatter>();
                if (s != null && s._connectionId == id)
                {
                    response.Channel = s.channelMask;
                    if (!splatters.ContainsKey(s))
                    {
                        splatters.Add(s, s.gameObject.GetComponent <Drinker>());
                    }
                }
            }
        }

        int i = 0;

        foreach (Vector4 c in splatColors)
        {
            if (i == 0)
            {
                response.Dog0Color = c;
            }
            if (i == 1)
            {
                response.Dog1Color = c;
            }
            if (i == 2)
            {
                response.Dog2Color = c;
            }
            i++;
        }
        NetworkServer.SendToClient(id, DogColorsMsgId, response);
    }