示例#1
0
 protected override void OnUpdate()
 {
     Entities.WithAll <Stats, ZoxID>().ForEach((Entity e, ref Stats stats, ref ZoxID zoxID) =>
     {
         if (stats.leveledUpEffects == 1)
         {
             stats.leveledUpEffects = 0;
             // should have index of what leveled up!
             if (stats.levels.Length > 0)
             {
                 ParticlesManager.instance.PlayParticles(new ParticleSpawnCommand {
                     name = "LevelUp", life = 3
                 }, e, World.EntityManager);
                 //UnityEngine.Debug.Log("Leveling Up for character: " + stats.id + " to level " + level.value);
                 Level level = stats.levels[0];
                 //UpdateStatUI(level, zoxID.id);
                 StatsUISpawnSystem.OnUpdatedStat(World.EntityManager, e, StatType.Level, 0);
                 StatsUISpawnSystem.OnUpdatedStat(World.EntityManager, e, StatType.Base, 0);
                 //statsUISpawnSystem.SetText(zoxID.id, level);
                 //statsUISpawnSystem.SetText(zoxID.id, stats.stats[0]);
                 // play level up sound
             }
         }
     });
 }
示例#2
0
 protected override void OnUpdate()
 {
     Entities.WithAll <UpdateAttributeCommand>().ForEach((Entity e, ref UpdateAttributeCommand command) =>
     {
         //if (characterSpawnSystem.characters.ContainsKey(command.characterID))
         if (World.EntityManager.Exists(command.character))
         {
             //Entity character = characterSpawnSystem.characters[command.characterID];
             Stats stats   = World.EntityManager.GetComponentData <Stats>(command.character);
             int statIndex = (int)(command.statIndex);
             if ((StatType)command.statType == StatType.Attribute)
             {
                 if (statIndex >= 0 && statIndex < stats.attributes.Length)
                 {
                     AttributeStaz attribute     = stats.attributes[statIndex];
                     attribute.value            += command.amount;
                     stats.attributes[statIndex] = attribute;
                     stats.attributesApplied     = 0;
                     World.EntityManager.SetComponentData(command.character, stats);
                     StatsUISpawnSystem.OnUpdatedStat(World.EntityManager, command.character, (StatType)command.statType, command.statIndex);
                 }
             }
             else if ((StatType)command.statType == StatType.Base)
             {
                 if (statIndex >= 0 && statIndex < stats.stats.Length)
                 {
                     Staz stat              = stats.stats[statIndex];
                     stat.value            += command.amount;
                     stats.stats[statIndex] = stat;
                     World.EntityManager.SetComponentData(command.character, stats);
                     StatsUISpawnSystem.OnUpdatedStat(World.EntityManager, command.character, (StatType)command.statType, command.statIndex);
                 }
             }
             // StatUISystem.OnUpdated(command.characterIndex, attribute);
         }
         World.EntityManager.DestroyEntity(e);
         //SetText(characterID, originalArrayIndex, (int)improveStat.value);
     });
 }
示例#3
0
        protected override void OnUpdate()
        {
            // Update Statbars
            Entities.WithAll <Regening, Stats>().ForEach((Entity e, ref Regening regening, ref Stats stats) =>
            {
                // generally this is bad practice. Needs to be done when adding stats/removign them from character, or just creating the regening
                if (stats.states.Length != regening.stateUpdated.Length)
                {
                    regening.Initialize(stats.states.Length);
                }

                for (int i = 0; i < regening.stateUpdated.Length; i++)
                {
                    if (regening.stateUpdated[i] == 1)
                    {
                        regening.stateUpdated[i] = 0;
                        StatsUISpawnSystem.OnUpdatedStat(World.EntityManager, e, StatType.State, 0);
                    }
                }
                for (int i = 0; i < regening.stateMaxed.Length; i++)
                {
                    if (regening.stateMaxed[i] == 1)
                    {
                        regening.stateMaxed[i] = 0;
                        UpdateStatbar(stats, e, i);
                    }
                }
                if (regening.finished == 1)
                {
                    //regening.finished = 0;
                    // remove regening when all regening done
                    //Debug.LogError("Regening finished!");
                    World.EntityManager.RemoveComponent <Regening>(e);
                }
            });
        }
示例#4
0
        private void RewardVictor(ref Stats deadMonster, Entity attacker, ref Stats attackerStats, int defenderClanID, int defenderMetaID)
        {
            //int levelID = 0;

            /*if (!(StatsIndexes.experience < attackerStats.states.Length))
             * {
             *  Debug.LogError("States are too small, doesnt havexp in them: " + attackerStats.states.Length);
             *  return;
             * }*/
            if (attackerStats.levels.Length == 0)
            {
                return;
            }
            // should create a KillSystem that gives rewards
            //StateStaz experience = attackerStats.states[StatsIndexes.experience];
            Level attackerLevel = attackerStats.levels[0];
            // should pick up items called Soul Orbs that give you experience instead
            int levelValue = 0;

            if (deadMonster.levels.Length > 0)
            {
                levelValue = deadMonster.levels[0].value;
            }
            float experienceGiven = (levelValue + 1) * UnityEngine.Random.Range(0.5f, 1.5f);
            ZoxID attackerID      = World.EntityManager.GetComponentData <ZoxID>(attacker);

            if (attackerID.creatorID == 0)
            {
                // normal experience
                // Debug.LogError("Giving experience: " + experienceGiven);
                attackerLevel.experienceGained += experienceGiven;// adding health as experience, shouldnt be based on their level?
            }
            else
            {
                if (characterSpawnSystem.characters.ContainsKey(attackerID.creatorID) == false)
                {
                    //Debug.LogError("Creator does not exist.");
                    attackerLevel.experienceGained += experienceGiven;
                }
                else
                {
                    Entity summonerEntity = characterSpawnSystem.characters[attackerID.creatorID];
                    if (World.EntityManager.HasComponent <Stats>(summonerEntity))
                    {
                        Stats summoner = World.EntityManager.GetComponentData <Stats>(summonerEntity);
                        if (summoner.levels.Length > 0)
                        {
                            //StateStaz summonerExp = summoner.states[StatsIndexes.experience];
                            Level summonerLevel = summoner.levels[0];
                            summonerLevel.experienceGained += experienceGiven / 2f;
                            if (summonerLevel.experienceGained >= summonerLevel.experienceRequired)
                            {
                                summoner.leveledUp = 1;
                            }
                            summoner.levels[0] = summonerLevel;
                            World.EntityManager.SetComponentData(summonerEntity, summoner);
                            attackerLevel.experienceGained += experienceGiven / 2f;
                            StatsUISpawnSystem.OnUpdatedStat(World.EntityManager, summonerEntity, StatType.Level, 0);
                        }
                        else
                        {
                            attackerLevel.experienceGained += experienceGiven;
                        }
                    }
                    else
                    {
                        attackerLevel.experienceGained += experienceGiven;
                        //Debug.LogError("Creator exists. But has no stats.");
                        //experience.value += experienceGiven;// adding health as experience, shouldnt be based on their level?
                    }
                }
            }
            if (attackerLevel.experienceGained >= attackerLevel.experienceRequired)
            {
                attackerStats.leveledUp = 1;
            }
            attackerStats.levels[0] = attackerLevel;
            World.EntityManager.SetComponentData(attacker, attackerStats);
            StatsUISpawnSystem.OnUpdatedStat(World.EntityManager, attacker, StatType.Level, 0);

            // give quest completion stat to the character

            if (characterSpawnSystem.characters.ContainsKey(attackerID.id))
            {
                Entity characterEntity = characterSpawnSystem.characters[attackerID.id];
                // get questlog
                if (World.EntityManager.HasComponent <QuestLog>(characterEntity))
                {
                    QuestLog questLog = World.EntityManager.GetComponentData <QuestLog>(characterEntity);
                    if (questLog.OnKilledCharacter(defenderMetaID))
                    {
                        World.EntityManager.SetComponentData(characterEntity, questLog);
                        // update questlog UI
                        //Bootstrap.instance.systemsManager.questLogUISpawnSystem.UpdateUI(createdID.id);
                    }
                }
            }
        }