private HologramManager CreateNewHologramFromJSON(HologramData hologramData)
    {
        GameObject      hologram        = MyHologramCreation.CreateNewHologramFromBatch(hologramData.Type);
        HologramManager hologramManager = hologram.GetComponent <HologramManager>();

        hologramManager.MyManager = this;
        return(hologramManager);
    }
Exemple #2
0
    internal static HologramData CreateSimpleHologramData(string id, Vector3 position, Quaternion rotation, Vector3 scale)
    {
        var data = new HologramData(id, HologramType.Simple, position, rotation, scale)
        {
            Content = ""
        };

        return(data);
    }
Exemple #3
0
    public static GameObject CreateHologram(HologramData data)
    {
        GameObject hologram = Instantiate(new GameObject("Hologram"));

        Hologram          hologramComponent          = hologram.AddComponent <Hologram>();
        BuildingPrototype buildingPrototypeComponent = hologram.AddComponent <BuildingPrototype>();
        SpriteRenderer    spriteRenderer             = hologram.AddComponent <SpriteRenderer>();

        spriteRenderer.sortingLayerName = "Buildings";
        spriteRenderer.sortingOrder     = 100;
        spriteRenderer.sprite           = data.hologramSprite;
        spriteRenderer.color            = data.canBuildColor;

        hologramComponent.spriteRenderer = spriteRenderer;
        hologramComponent.hologramData   = data;

        return(hologram);
    }
    internal void CreateOrUpdateHologramsFromJSON(List <HologramData> hologramsList)
    {
        _holograms.RemoveAll(i => i == null);

        for (int index = hologramsList.Count() - 1; index >= 0; index--)
        {
            HologramData hologramData   = hologramsList[index];
            var          hologramInList = _holograms.FirstOrDefault(i => i.Id == hologramData.Id);
            if (hologramInList == null)
            {
                hologramInList = CreateNewHologramFromJSON(hologramData);
                hologramInList.CreateHologramFromData(hologramData);
            }
            else
            {
                hologramInList.UpdateHologramFromData(hologramData);
            }
        }
    }
    internal List <HologramData> GetHologramsData()
    {
        _holograms.RemoveAll(i => i == null);

        List <HologramData> list = new List <HologramData>();

        foreach (var hologram in _holograms)
        {
            HologramData hologramData = hologram.GetHologramData();
            if (hologramData == null)
            {
                Debug.Log("Id or hologram is null");
                continue;
            }
            list.Add(hologramData);
        }

        return(list);
    }