Beispiel #1
0
        public void SetRegenRate(int indexOf, float newValue)
        {
            RegenStaz stat = regens[indexOf];

            stat.rate       = newValue;
            regens[indexOf] = stat;
        }
Beispiel #2
0
 public void InitializeRegens(int count)
 {
     regens = new BlitableArray <RegenStaz>(count, Allocator.Persistent);
     for (int j = 0; j < regens.Length; j++)
     {
         regens[j] = new RegenStaz {
         };
     }
 }
Beispiel #3
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);*/
            }
        }
Beispiel #4
0
        public int AddStat(StatDatam statDatam)
        {
            int indexOf = -1;

            if (statDatam.type == StatType.Base)
            {
                Staz[] priorStates = stats.ToArray();
                stats = new BlitableArray <Staz>(stats.Length + 1, Allocator.Persistent);
                for (int i = 0; i < priorStates.Length; i++)
                {
                    stats[i] = priorStates[i];
                }
                Staz newState = new Staz();
                newState.id = statDatam.Value.id;
                stats[priorStates.Length] = newState;
                indexOf = priorStates.Length;
            }
            else if (statDatam.type == StatType.State)
            {
                StateStaz[] priorStates = states.ToArray();
                states = new BlitableArray <StateStaz>(states.Length + 1, Allocator.Persistent);
                for (int i = 0; i < priorStates.Length; i++)
                {
                    states[i] = priorStates[i];
                }
                StateStaz newState = new StateStaz();
                newState.id = statDatam.Value.id;
                states[priorStates.Length] = newState;
                indexOf = priorStates.Length;
            }
            else if (statDatam.type == StatType.Regen)
            {
                RegenStaz[] priorStates = regens.ToArray();
                regens = new BlitableArray <RegenStaz>(regens.Length + 1, Allocator.Persistent);
                for (int i = 0; i < priorStates.Length; i++)
                {
                    regens[i] = priorStates[i];
                }
                RegenStaz newState = new RegenStaz();
                newState.id                = statDatam.Value.id;
                newState.targetID          = statDatam.targetStatID;
                regens[priorStates.Length] = newState;
                indexOf = priorStates.Length;
            }
            else if (statDatam.type == StatType.Attribute)
            {
                AttributeStaz[] priorStats = attributes.ToArray();
                attributes = new BlitableArray <AttributeStaz>(attributes.Length + 1, Allocator.Persistent);
                for (int i = 0; i < priorStats.Length; i++)
                {
                    attributes[i] = priorStats[i];
                }
                AttributeStaz newStat = new AttributeStaz();
                newStat.id       = statDatam.Value.id;
                newStat.targetID = statDatam.targetStatID;
                attributes[priorStats.Length] = newStat;
                indexOf = priorStats.Length;
            }
            else if (statDatam.type == StatType.Level)
            {
                Level[] priorStats = levels.ToArray();
                levels = new BlitableArray <Level>(levels.Length + 1, Allocator.Persistent);
                for (int i = 0; i < priorStats.Length; i++)
                {
                    levels[i] = priorStats[i];
                }
                Level newStat = new Level();
                newStat.id = statDatam.Value.id;
                //newStat.targetID = statDatam.targetStatID;
                levels[priorStats.Length] = newStat;
                indexOf = priorStats.Length;
            }
            return(indexOf);
        }