예제 #1
0
        public static Entity SpawnText(EntityManager EntityManager, Entity parent, string text,
                                       float3 positionOffset, Color color, float fontSizer = 0.014f) // float2 iconSize,
        {
            float2     fontSize   = new float2(fontSizer, fontSizer);
            RenderText renderText = new RenderText();

            //renderText.alignment = 1;
            renderText.fontSize = fontSize.x;
            renderText.SetColor(color);
            renderText.SetText(text);
            float2 panelSize  = renderText.GetPanelSize();
            Entity textEntity = SpawnVisualElement(
                EntityManager,
                parent,
                positionOffset,         // + ((new float3(iconSize.x, -iconSize.y, 0) / 2f) - new float3(0, -fontSize.y, 0) / 2f),
                panelSize,
                null,
                null);

            // should get size from text when set - it will set size depending on individual font sizes

            /*if (isCentred == 1)
             * {
             *  renderText.offsetX = -panelSize.x * 0.5f;// uiDatam.skillbarIconSize / 2f;
             * }*/
            EntityManager.AddComponentData(textEntity, renderText);
            return(textEntity);
        }
예제 #2
0
        public static Entity SpawnButtonWithText(EntityManager EntityManager, Entity panelUI, float3 position, float buttonFontSize, string text,
                                                 Material buttonMaterial, Color buttonColor, Color textColor)
        {
            //Childrens children = new Childrens { };
            //children.children = new BlitableArray<Entity>(1, Unity.Collections.Allocator.Persistent);
            //float buttonFontSize = 0.01f;
            //RenderTextSystem.SetLetterColor(EntityManager, button, Color.green);
            //children.children[0] = button;
            //EntityManager.AddComponentData(panelUI, children);
            Entity button = SpawnButton(
                EntityManager,
                panelUI,
                position,
                (new float2(buttonFontSize * text.Length * 1f, buttonFontSize)),
                null,
                buttonMaterial);

            SetEntityColor(EntityManager, button, buttonColor);
            RenderText buttonText = new RenderText {
            };

            buttonText.fontSize = buttonFontSize;
            buttonText.SetText(text);
            buttonText.SetColor(textColor);
            EntityManager.AddComponentData(button, buttonText);
            return(button);
        }
예제 #3
0
        public void SetText(string text, ref RenderText newText)
        {
            byte updatedText;

            fontIndexes = RenderText.StringToBytes(text, fontIndexes, out updatedText);
            endIndex    = 0;
            maxIndex    = (byte)text.Length;
            newText.SetText(new BlitableArray <byte>(0, Unity.Collections.Allocator.Persistent));
        }
예제 #4
0
        public void IncreaseIndex(ref RenderText newText)
        {
            if (endIndex >= maxIndex + 1)
            {
                endIndex = 0;
            }
            if ((int)endIndex > fontIndexes.Length)
            {
                return;
            }
            //UnityEngine.Debug.LogError("Changing End Index: " + endIndex);
            BlitableArray <byte> culledArray = new BlitableArray <byte>((int)endIndex, Unity.Collections.Allocator.Persistent);

            for (int i = 0; i < (int)endIndex; i++)
            {
                culledArray[i] = fontIndexes[i];
            }
            newText.SetText(culledArray);
            endIndex++;
            //newText.SetText("hello world".Substring(0, (int)(endIndex)));
        }
예제 #5
0
파일: ItemUISystem.cs 프로젝트: Deus0/zoxel
 public void SetItemUIText(Entity iconEntity, Entity character, int arrayIndex)
 {
     if (arrayIndex != -1)
     {
         Inventory inventory    = World.EntityManager.GetComponentData <Inventory>(character);
         string    numberString = inventory.items[arrayIndex].quantity.ToString();
         if (numberString == "0" || numberString == "1")
         {
             numberString = "";
         }
         //Childrens childrens = World.EntityManager.GetComponentData<Childrens>(uis[characterID]);
         Entity     textGrandChild = World.EntityManager.GetComponentData <Childrens>(iconEntity).children[0];
         RenderText text           = World.EntityManager.GetComponentData <RenderText>(textGrandChild);
         if (numberString == "0" || numberString == "1")
         {
             numberString = "";
         }
         text.SetText(numberString);
         World.EntityManager.SetComponentData(textGrandChild, text);
     }
 }
예제 #6
0
        public void UpdateStatUI(UpdateStatUICommand command)
        {
            ZoxID zoxID = World.EntityManager.GetComponentData <ZoxID>(command.character);

            if (!uis.ContainsKey(zoxID.id))
            {
                return; // character died
            }
            Stats     stats        = World.EntityManager.GetComponentData <Stats>(command.character);
            Entity    ui           = uis[zoxID.id];
            Childrens children     = World.EntityManager.GetComponentData <Childrens>(ui);
            int       uiArrayIndex = command.statIndex;

            if (command.statType == (byte)StatType.Base)
            {
                Staz      stat  = stats.stats[command.statIndex];
                Entity    icon  = children.children[uiArrayIndex];
                Childrens texts = World.EntityManager.GetComponentData <Childrens>(icon);

                Entity     textEntity = texts.children[0];
                RenderText renderText = World.EntityManager.GetComponentData <RenderText>(textEntity);
                renderText.SetText(((int)stat.value).ToString());
                World.EntityManager.SetComponentData(textEntity, renderText);
            }
            else
            {
                uiArrayIndex += stats.stats.Length;
            }
            if (command.statType == (byte)StatType.State)
            {
                StateStaz stat  = stats.states[command.statIndex];
                Entity    icon  = children.children[uiArrayIndex];
                Childrens texts = World.EntityManager.GetComponentData <Childrens>(icon);

                Entity     textEntity = texts.children[0];
                RenderText renderText = World.EntityManager.GetComponentData <RenderText>(textEntity);
                renderText.SetText(((int)stat.value).ToString());
                World.EntityManager.SetComponentData(textEntity, renderText);

                /*Entity textEntity2 = texts.children[0];
                 * RenderText renderText2 = World.EntityManager.GetComponentData<RenderText>(textEntity2);
                 * renderText2.SetText(((int)stat.maxValue).ToString());
                 * World.EntityManager.SetComponentData(textEntity2, renderText2);*/
            }
            else
            {
                uiArrayIndex += stats.states.Length;
            }
            if (command.statType == (byte)StatType.Regen)
            {
                RegenStaz stat  = stats.regens[command.statIndex];
                Entity    icon  = children.children[uiArrayIndex];
                Childrens texts = World.EntityManager.GetComponentData <Childrens>(icon);

                Entity     textEntity = texts.children[0];
                RenderText renderText = World.EntityManager.GetComponentData <RenderText>(textEntity);
                renderText.SetText(((int)stat.value).ToString());
                World.EntityManager.SetComponentData(textEntity, renderText);
            }
            else
            {
                uiArrayIndex += stats.regens.Length;
            }
            if (command.statType == (byte)StatType.Attribute)
            {
                AttributeStaz stat  = stats.attributes[command.statIndex];
                Entity        icon  = children.children[uiArrayIndex];
                Childrens     texts = World.EntityManager.GetComponentData <Childrens>(icon);

                Entity     textEntity = texts.children[0];
                RenderText renderText = World.EntityManager.GetComponentData <RenderText>(textEntity);
                renderText.SetText(((int)stat.value).ToString());
                World.EntityManager.SetComponentData(textEntity, renderText);
            }
            else
            {
                uiArrayIndex += stats.attributes.Length;
            }
            if (command.statType == (byte)StatType.Level)
            {
                Level      stat       = stats.levels[command.statIndex];
                Entity     icon       = children.children[uiArrayIndex];
                Childrens  texts      = World.EntityManager.GetComponentData <Childrens>(icon);
                Entity     textEntity = texts.children[0];
                RenderText renderText = World.EntityManager.GetComponentData <RenderText>(textEntity);
                renderText.SetText(((int)stat.value).ToString());
                World.EntityManager.SetComponentData(textEntity, renderText);
                // experience required

                /*Entity textEntity2 = texts.children[1];
                 * RenderText renderText2 = World.EntityManager.GetComponentData<RenderText>(textEntity2);
                 * renderText2.SetText(((int)stat.experienceGained).ToString());
                 * World.EntityManager.SetComponentData(textEntity2, renderText2);
                 * // experience gained
                 * Entity textEntity3 = texts.children[2];
                 * RenderText renderText3 = World.EntityManager.GetComponentData<RenderText>(textEntity3);
                 * renderText3.SetText(((int)stat.experienceRequired).ToString());
                 * World.EntityManager.SetComponentData(textEntity3, renderText3);*/
            }
        }