Esempio n. 1
0
    public void Animate(MainJsonObject obj)
    {
        SendMessageJson jsonObj = new SendMessageJson();

        jsonObj.action = obj.action;
        jsonObj.msgId  = obj.msgId;
        string message = JsonConvert.SerializeObject(jsonObj);

        NetworkManager.Instance.Send(message);

        float   dt    = obj.contentObj.dt;
        JObject token = JObject.Parse(JObject.Parse(obj.content)["frames"].ToString());

        foreach (string key in token.Properties().Select(p => p.Name).ToList())
        {
            List <List <float> > array     = JArray.Parse(token[key].ToString()).ToObject <List <List <float> > >();
            List <Vector3>       positions = new List <Vector3>();
            List <Vector3>       rotations = new List <Vector3>();
            foreach (List <float> frame in array)
            {
                positions.Add(new Vector3(frame[0], frame[1], frame[2]));
                rotations.Add(new Vector3(frame[3], frame[4], frame[5]));
            }
            ObjectAnimation animation = new ObjectAnimation(dt, positions, rotations);
            AnimationManager.Instance.AddAnimation(objects[int.Parse(key)], animation);
        }
    }
Esempio n. 2
0
    private void SendMessage(MainJsonObject obj, ContentJsonObject contentObj = null)
    {
        MainObject      o       = objects[obj.contentObj.id];
        int             id      = o.GetId();
        SendMessageJson jsonObj = new SendMessageJson();
        ObjectType      type    = (ObjectType)obj.contentObj.type;

        jsonObj.action = obj.action;
        jsonObj.type   = prefabs[type].ToString();
        jsonObj.msgId  = obj.msgId;
        jsonObj.objId  = id;
        if (contentObj != null)
        {
            jsonObj.contentObj = contentObj;
        }
        string message = JsonConvert.SerializeObject(jsonObj);

        NetworkManager.Instance.Send(message);
    }