Example #1
0
 public void Initialize(Unity.Entities.World space)
 {
     //regenStartSystem = space.GetOrCreateSystem<RegenStartSystem>();
     regenSystem          = space.GetOrCreateSystem <RegenSystem>();
     regenCompleterSystem = space.GetOrCreateSystem <RegenCompleterSystem>();
     levelUpSystem        = space.GetOrCreateSystem <LevelUpSystem>();
     levelUpEffectsSystem = space.GetOrCreateSystem <LevelUpEffectsSystem>();
     attributesSystem     = space.GetOrCreateSystem <AttributesSystem>();
     //AddSystemToUpdateList(regenStartSystem);
     AddSystemToUpdateList(regenSystem);
     AddSystemToUpdateList(regenCompleterSystem);
     AddSystemToUpdateList(levelUpSystem);
     AddSystemToUpdateList(levelUpEffectsSystem);
     AddSystemToUpdateList(attributesSystem);
     statUpdateSystem = space.GetOrCreateSystem <StatUpdateSystem>();
     AddSystemToUpdateList(statUpdateSystem);
     SetLinks();
 }
Example #2
0
        // this should be in a StatUISystem -> with selection and other events handled..?
        public override void OnClickedButton(Entity player, Entity ui, int arrayIndex, ButtonType buttonType)
        {
            if (World.EntityManager.HasComponent <Inventory>(player) == false)
            {
                Debug.LogError("Character " + player.Index + " does not have stats component.");
                return;
            }
            int   originalArrayIndex = arrayIndex;
            Stats stats = World.EntityManager.GetComponentData <Stats>(player);
            // stat points
            int statPointID = -510241704;   // gotten from game settings?

            // statpoints is a base
            #region Indexing
            int statArrayIndex = -1;
            for (int i = 0; i < stats.stats.Length; i++)
            {
                if (stats.stats[i].id == statPointID)
                {
                    statArrayIndex = i;
                    break;
                }
            }
            if (statArrayIndex == -1)
            {
                return;
            }
            #endregion

            Staz statPoints = stats.stats[statArrayIndex];
            if (statPoints.value == 0)
            {
                return;
            }
            // update a stat!
            if (arrayIndex >= 0 && arrayIndex < stats.stats.Length)
            {
                return;
            }
            arrayIndex -= stats.stats.Length;
            // update states!
            if (arrayIndex >= 0 && arrayIndex < stats.states.Length)
            {
                return;
            }
            arrayIndex -= stats.states.Length;
            // update regens!
            if (arrayIndex >= 0 && arrayIndex < stats.regens.Length)
            {
                return;
            }
            arrayIndex -= stats.regens.Length;
            // update attributes!
            if (arrayIndex >= 0 && arrayIndex < stats.attributes.Length)
            {
                StatUpdateSystem.UpdateStat(World.EntityManager, player, StatType.Attribute, arrayIndex, 1);
            }
            arrayIndex -= stats.attributes.Length;
            // update regens!
            if (arrayIndex >= 0 && arrayIndex < stats.levels.Length)
            {
                return;
            }
            // decrease stat points
            StatUpdateSystem.UpdateStat(World.EntityManager, player, StatType.Base, statArrayIndex, -1);
        }