Newer
Older
BlackoutClient / Assets / Scripts / ServerTag.cs
using MiniJSON;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ServerTag : MonoBehaviour
{
    public string Name;
    public string Type;
    public string Group;
    public string JSON = "{}";

    public Dictionary<string, object> GetJSON()
    {
        Dictionary<string, object> details = Json.Deserialize(JSON) as Dictionary<string, object>;
        if (details == null) details = new Dictionary<string, object>();

        details["name"] = Name;
        details["type"] = Type;
        details["group"] = Group;

        details["x"] = transform.position.x;
        details["y"] = transform.position.y;
        details["z"] = transform.position.z;

        if (Group == "" || Group == null)
        {
            ServerTagGroup groupTag = GetComponentInParent<ServerTagGroup>();
            if (groupTag != null)
            {
                details["group"] = groupTag.Group;
            }
        }

        return details;
    }

    // Start is called before the first frame update
    void Start()
    {
        foreach (MeshRenderer mr in GetComponentsInChildren<MeshRenderer>())
        {
            mr.enabled = false;
            Destroy(mr);
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}