Example #1
0
    private void ParseSuperObjectJSON(WebJSON.SuperObject msg)
    {
        MapLoader            l  = MapLoader.Loader;
        SuperObjectComponent so = null;

        if (msg.Offset != null)
        {
            so = controller.superObjects.FirstOrDefault(s => s.Offset == msg.Offset);
        }
        if (so != null)
        {
            if (msg.Position.HasValue)
            {
                so.transform.localPosition = msg.Position.Value;
            }
            if (msg.Rotation.HasValue)
            {
                so.transform.localEulerAngles = msg.Rotation.Value;
            }
            if (msg.Scale.HasValue)
            {
                so.transform.localScale = msg.Scale.Value;
            }
        }
    }
Example #2
0
    private WebJSON.SuperObject GetSuperObjectJSON(SuperObjectComponent so, bool includeChildren = true)
    {
        if (so == null)
        {
            return(null);
        }
        WebJSON.SuperObject soJSON = new WebJSON.SuperObject()
        {
            Type   = so.Type,
            Offset = so.Offset
        };
        soJSON.Name     = so.gameObject.name;
        soJSON.Position = so.gameObject.transform.localPosition;
        soJSON.Rotation = so.gameObject.transform.localEulerAngles;
        soJSON.Scale    = so.gameObject.transform.localScale;

        if (soJSON.Type == SuperObject.Type.Perso)
        {
            BasePersoBehaviour pb = GetPersoFromSuperObjectOffset(soJSON.Offset);
            if (pb != null)
            {
                soJSON.Perso = GetPersoJSON(pb);
            }
        }
        if (includeChildren)
        {
            soJSON.Children = so.Children.Select(s => GetSuperObjectJSON(s, includeChildren: includeChildren)).ToArray();
        }
        return(soJSON);
    }