Ejemplo n.º 1
0
 public Entity SpawnNumber(int number, float3 position)
 {
     return(UIUtilities.SpawnVisualElement(
                World.EntityManager,
                new Entity(),
                position,
                new float2(uiDatam.fontSize, uiDatam.fontSize),
                uiDatam.font.numbers[number], uiDatam.font.material, 8000));
 }
Ejemplo n.º 2
0
        public Entity SpawnNewFontLetter(ref RenderText renderText, Entity panelUI, float fontSize)
        {
            Entity letter = UIUtilities.SpawnVisualElement(
                World.EntityManager,
                panelUI,
                new float3(0, 0, -0.005f),
                new float2(fontSize, fontSize),
                null,
                uiData.font.material, 8000);

            return(letter);
        }
Ejemplo n.º 3
0
        protected override void OnSpawnedPanel(Entity character, Entity panelUI, object spawnData)
        {
            var position = World.EntityManager.GetComponentData <ChunkStreamPoint>(character).chunkPosition;
            //EntityBunch icons = new EntityBunch();
            List <Entity> icons2        = new List <Entity>();
            int           mapResolution = 4;

            if (Bootstrap.instance)
            {
                mapResolution = Bootstrap.instance.mapResolution;
            }
            int    rowsCount    = mapResolution;
            int    columnsCount = mapResolution;
            float2 iconSize     = uiDatam.defaultIconSize;

            //for (int j = -(columnsCount / 2); j < (columnsCount / 2); j++)
            for (int j = (columnsCount / 2) - 1; j >= -(columnsCount / 2); j--)
            {
                for (int i = -(rowsCount / 2); i < (rowsCount / 2); i++)
                {
                    float2 mapPosition = new float2(i + position.x, j + position.z);
                    if (chunkMapSystem.maps.ContainsKey(mapPosition))
                    {
                        float3 localMapPosition = float3.zero;// GetGridPosition(i + rowsCount / 2, -(j - (columnsCount / 2) + 1), rowsCount, columnsCount); // + columnsCount / 2
                        icons2.Add(UIUtilities.SpawnVisualElement(
                                       World.EntityManager,
                                       panelUI, localMapPosition,
                                       iconSize,
                                       chunkMapSystem.maps[mapPosition], uiDatam.mapIcon));
                    }
                    else
                    {
                        //Debug.LogError("Could not find map for positoin: " + mapPosition.ToString());
                    }
                }
            }
            Childrens children = new Childrens {
            };

            children.children = new BlitableArray <Entity>(icons2.Count, Unity.Collections.Allocator.Persistent);
            for (int i = 0; i < icons2.Count; i++)
            {
                children.children[i] = icons2[i]; // icons2.Count - 1 -
            }
            World.EntityManager.AddComponentData(panelUI, children);
            World.EntityManager.AddComponentData(panelUI, new GridUI
            {
                dirty    = 1,
                gridSize = new float2(mapResolution, mapResolution),
                iconSize = iconSize,
                margins  = new float2(0.003f, 0.003f),
                padding  = new float2(0.00f, 0.00f),
            });
            byte  uiIndex     = ((byte)((int)PlayerUIType.SkillbookUI));
            ZoxID characterID = World.EntityManager.GetComponentData <ZoxID>(character);

            World.EntityManager.SetComponentData(panelUI, new PanelUI
            {
                id          = uiIndex,
                characterID = characterID.id,
                orbitDepth  = uiDatam.orbitDepth,
                anchor      = (byte)UIAnchoredPosition.Middle
            });

            /*icons.entities = icons2.ToArray();;
             * if (mapIcons.ContainsKey(characterID.id))
             * {
             *  mapIcons.Remove(characterID.id);
             * // Debug.LogError("Map Icons in there twice for: " + characterID.id);
             * }
             * mapIcons.Add(characterID.id, icons);*/
        }
Ejemplo n.º 4
0
        protected override void OnSpawnedPanel(Entity character, Entity panelUI, object spawnData)
        {
            if (World.EntityManager.HasComponent <QuestLog>(character) == false)
            {
                Debug.LogError("Tried to add character without questlog.");
                return;
            }
            int      zoxID    = World.EntityManager.GetComponentData <ZoxID>(character).id;
            QuestLog questlog = World.EntityManager.GetComponentData <QuestLog>(character);

            //EntityBunch iconGroup = new EntityBunch();
            //EntityBunch textGroup = new EntityBunch();
            List <Entity> statIcons = new List <Entity>();
            List <Entity> statTexts = new List <Entity>();
            float2        iconSize  = uiDatam.defaultIconSize;

            for (int i = 0; i < questlog.quests.Length; i++)
            {
                Texture2D iconTexture = null;
                if (questlog.quests[i].metaID != 0)
                {
                    QuestDatam questMeta = meta[questlog.quests[i].metaID];
                    if (questMeta != null && questMeta.texture)
                    {
                        iconTexture = questMeta.texture.texture;
                    }
                }
                float3 position = float3.zero;// GetGridPosition(i, 3, 3);
                Entity icon     = UIUtilities.SpawnVisualElement(
                    World.EntityManager,
                    panelUI,
                    position,
                    iconSize,
                    iconTexture, uiDatam.defaultPlayerIcon);
                //Entity text = SpawnText(icon, ((int)questlog.quests[i].GetCompleted()).ToString());
                Entity text = UIUtilities.SpawnText(World.EntityManager, icon, ((int)questlog.quests[i].GetCompleted()).ToString());//, iconSize);
                statIcons.Add(icon);
                statTexts.Add(text);
            }
            //iconGroup.entities = statIcons.ToArray(); // new Entity[stats.stats.Length];
            //textGroup.entities = statTexts.ToArray(); // new Entity[stats.stats.Length];

            Childrens children = new Childrens {
            };

            children.children = new BlitableArray <Entity>(statIcons.Count, Unity.Collections.Allocator.Persistent);
            for (int i = 0; i < statIcons.Count; i++)
            {
                children.children[i] = statIcons[i];
            }
            World.EntityManager.AddComponentData(panelUI, children);
            World.EntityManager.AddComponentData(panelUI, new GridUI
            {
                dirty    = 1,
                gridSize = uiDatam.questlogGridSize,
                iconSize = iconSize,
                margins  = new float2(0.003f, 0.003f),
                padding  = new float2(0.003f, 0.003f),
            });
            byte uiIndex = ((byte)((int)PlayerUIType.QuestlogUI));

            World.EntityManager.SetComponentData(panelUI, new PanelUI
            {
                id          = uiIndex,
                characterID = zoxID,
                orbitDepth  = uiDatam.orbitDepth,
                anchor      = (byte)UIAnchoredPosition.Middle
            });
            OnSelectedButton(zoxID, 0);
        }