Exemplo n.º 1
0
 private void UpdateHealth()
 {
     if (Health.GetTotal() > Health.GetCurrentValue())
     {
         RestoreHealth(HealthRegeneration.GetTotal() * regenerationPercentPerTick);
     }
 }
Exemplo n.º 2
0
 void Start()
 {
     Lives              = 3;
     StartingHealth     = 1000;
     IsImmobilized      = false;
     IsDead             = false;
     CurrentHealth      = StartingHealth;
     healthRegeneration = new HealthRegeneration(this, 5f, 0.01f, 5);
     UpdateUI();
 }
Exemplo n.º 3
0
        public override void Activate(Player player)
        {
            HealthRegeneration regeneration = player.GetComponent <HealthRegeneration>();

            if (regeneration == null)
            {
                return;
            }

            regeneration.RegenerationAmount += m_Amount;
        }
Exemplo n.º 4
0
 public void RemoveModifier(IStatsModifier modifier)
 {
     if (AbilityPower.RemoveStatModificator(modifier.AbilityPower))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Base_Ap, AbilityPower.BaseValue);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ap_Flat, AbilityPower.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ap_Pct, AbilityPower.PercentBonus);
     }
     if (Armor.RemoveStatModificator(modifier.Armor))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Armor, Armor.Total);
     }
     if (ArmorPenetration.RemoveStatModificator(modifier.ArmorPenetration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Armor_Pen_Flat, ArmorPenetration.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Armor_Pen_Pct, ArmorPenetration.PercentBonus);
     }
     if (AttackDamage.RemoveStatModificator(modifier.AttackDamage))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Base_Ad, AttackDamage.BaseValue);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ad_Flat, AttackDamage.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Bonus_Ad_Pct, AttackDamage.PercentBonus);
     }
     if (AttackSpeedMultiplier.RemoveStatModificator(modifier.AttackSpeed))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Atks_multiplier, AttackSpeedMultiplier.Total);
     }
     if (CriticalChance.RemoveStatModificator(modifier.CriticalChance))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Crit_Chance, CriticalChance.Total);
     }
     GoldPerSecond.RemoveStatModificator(modifier.GoldPerSecond);
     if (HealthPoints.RemoveStatModificator(modifier.HealthPoints))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_MaxHp, HealthPoints.Total);
     }
     if (HealthRegeneration.RemoveStatModificator(modifier.HealthRegeneration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Hp5, HealthRegeneration.Total);
     }
     if (LifeSteal.RemoveStatModificator(modifier.LifeSteel))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_LifeSteal, LifeSteal.Total);
     }
     if (MagicResist.RemoveStatModificator(modifier.MagicResist))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Magic_Armor, MagicResist.Total);
     }
     if (MagicPenetration.RemoveStatModificator(modifier.MagicPenetration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Magic_Pen_Flat, MagicPenetration.FlatBonus);
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Magic_Pen_Pct, MagicPenetration.PercentBonus);
     }
     if (ManaPoints.RemoveStatModificator(modifier.ManaPoints))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_MaxMp, ManaPoints.Total);
     }
     if (ManaRegeneration.RemoveStatModificator(modifier.ManaRegeneration))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Mp5, ManaRegeneration.Total);
     }
     if (MoveSpeed.RemoveStatModificator(modifier.MoveSpeed))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_Speed, MoveSpeed.Total);
     }
     if (Range.RemoveStatModificator(modifier.Range))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Range, Range.Total);
     }
     if (Size.RemoveStatModificator(modifier.Size))
     {
         appendStat(_updatedStats, MasterMask.MM_Four, FieldMask.FM4_ModelSize, Size.Total);
     }
     if (SpellVamp.RemoveStatModificator(modifier.SpellVamp))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_SpellVamp, SpellVamp.Total);
     }
     if (Tenacity.RemoveStatModificator(modifier.Tenacity))
     {
         appendStat(_updatedStats, MasterMask.MM_Two, FieldMask.FM2_Tenacity, Tenacity.Total);
     }
 }
        private void InstantiateCharacters(int entityCount)
        {
            if (entityCount <= 0)
            {
                return;
            }

            var entityArray = new NativeArray <Entity>(entityCount, Allocator.TempJob);

            EntityManager.CreateEntity(m_Archetype, entityArray);

            var terrain = Terrain.activeTerrain;

            for (var entityIndex = 0; entityIndex < entityArray.Length; entityIndex++)
            {
                var type                  = (ViewType)m_Random.NextInt(Enum.GetValues(typeof(ViewType)).Length);
                var entity                = entityArray[entityIndex];
                var movementSpeed         = new MovementSpeed();
                var rotationSpeed         = new RotationSpeed();
                var rotationSpeedModifier = new RotationSpeedModifier();
                var walkSpeedModifier     = new WalkSpeedModifier();
                var chargeSpeedModifier   = new ChargeSpeedModifier();
                var engageSqrRadius       = new EngageSqrRadius();
                var attackDistance        = new AttackDistance {
                    Min = 1.5f, Max = 2
                };
                var attackAnimationDuration = new AttackAnimationDuration();
                var attackDamage            = new AttackDamage();
                var attackSpeed             = new AttackSpeed();
                var maxHealth          = new MaxHealth();
                var health             = new Health();
                var healthRegeneration = new HealthRegeneration();
                var viewInfo           = new ViewInfo();

                PostUpdateCommands.SetComponent(entity, new Translation {
                    Value = terrain.GetRandomPosition()
                });

                switch (type)
                {
                case ViewType.Knight:
                    PostUpdateCommands.AddComponent(entity, new Knight());
                    PostUpdateCommands.AddComponent(entity, new Faction {
                        Value = FactionType.Alliance
                    });
                    movementSpeed.Value           = m_Random.NextFloat(1, 3);
                    rotationSpeed.Value           = m_Random.NextFloat(1, 3);
                    rotationSpeedModifier.Value   = m_Random.NextFloat(1.25f, 2);
                    walkSpeedModifier.Value       = m_Random.NextFloat(0.9f, 1.25f);
                    chargeSpeedModifier.Value     = m_Random.NextFloat(2, 3);
                    engageSqrRadius.Value         = m_Random.NextFloat(400, 2500);
                    attackAnimationDuration.Value = 1;
                    attackDamage.Value            = m_Random.NextInt(10, 30);
                    attackSpeed.Value             = m_Random.NextFloat(1, 3);
                    maxHealth.Value          = m_Random.NextInt(100, 200);
                    health.Value             = maxHealth.Value;
                    healthRegeneration.Value = m_Random.NextFloat(1, 3);
                    viewInfo.Type            = ViewType.Knight;
                    break;

                case ViewType.OrcWolfRider:
                    PostUpdateCommands.AddComponent(entity, new OrcWolfRider());
                    PostUpdateCommands.AddComponent(entity, new Faction {
                        Value = FactionType.Horde
                    });
                    movementSpeed.Value           = m_Random.NextFloat(1, 3);
                    rotationSpeed.Value           = m_Random.NextFloat(1, 3);
                    rotationSpeedModifier.Value   = m_Random.NextFloat(1.25f, 2);
                    walkSpeedModifier.Value       = m_Random.NextFloat(0.9f, 1.25f);
                    chargeSpeedModifier.Value     = m_Random.NextFloat(2, 3);
                    engageSqrRadius.Value         = m_Random.NextFloat(400, 2500);
                    attackAnimationDuration.Value = 1.333f;
                    attackDamage.Value            = m_Random.NextInt(10, 30);
                    attackSpeed.Value             = m_Random.NextFloat(1, 3);
                    maxHealth.Value          = m_Random.NextInt(100, 200);
                    health.Value             = maxHealth.Value;
                    healthRegeneration.Value = m_Random.NextFloat(1, 3);
                    viewInfo.Type            = ViewType.OrcWolfRider;
                    break;

                case ViewType.Skeleton:
                    PostUpdateCommands.AddComponent(entity, new Skeleton());
                    PostUpdateCommands.AddComponent(entity, new Faction {
                        Value = FactionType.Legion
                    });
                    movementSpeed.Value           = m_Random.NextFloat(1, 3);
                    rotationSpeed.Value           = m_Random.NextFloat(1, 3);
                    rotationSpeedModifier.Value   = m_Random.NextFloat(1.25f, 2);
                    walkSpeedModifier.Value       = m_Random.NextFloat(0.9f, 1.25f);
                    chargeSpeedModifier.Value     = m_Random.NextFloat(2, 3);
                    engageSqrRadius.Value         = m_Random.NextFloat(400, 2500);
                    attackAnimationDuration.Value = 2.4f;
                    attackDamage.Value            = m_Random.NextInt(10, 30);
                    attackSpeed.Value             = m_Random.NextFloat(1, 3);
                    maxHealth.Value          = m_Random.NextInt(100, 200);
                    health.Value             = maxHealth.Value;
                    healthRegeneration.Value = m_Random.NextFloat(1, 3);
                    viewInfo.Type            = ViewType.Skeleton;
                    break;
                }

                PostUpdateCommands.SetComponent(entity, movementSpeed);
                PostUpdateCommands.SetComponent(entity, rotationSpeed);
                PostUpdateCommands.SetComponent(entity, rotationSpeedModifier);
                PostUpdateCommands.SetComponent(entity, walkSpeedModifier);
                PostUpdateCommands.SetComponent(entity, chargeSpeedModifier);
                PostUpdateCommands.SetComponent(entity, engageSqrRadius);
                PostUpdateCommands.SetComponent(entity, attackDistance);
                PostUpdateCommands.SetComponent(entity, attackAnimationDuration);
                PostUpdateCommands.SetComponent(entity, attackDamage);
                PostUpdateCommands.SetComponent(entity, attackSpeed);
                PostUpdateCommands.SetComponent(entity, maxHealth);
                PostUpdateCommands.SetComponent(entity, health);
                PostUpdateCommands.SetComponent(entity, healthRegeneration);
                PostUpdateCommands.SetComponent(entity, viewInfo);
#if UNITY_EDITOR
                EntityManager.SetName(entity, $"{viewInfo.Type} AI {entity}");
#endif
            }

            entityArray.Dispose();
        }