Example #1
0
        //Adds stats of the new Entity to the Lists
        public void AddEntity(int[] stats, string[] traits)
        {
            ID.Add(next_ID);
            Alive.Add(next_ID);


            Str.Add(stats[0]);
            Agi.Add(stats[1]);
            Int.Add(stats[2]);

            //Behaviour.Add(traits);
            Behaviour.Add(traits);

            ////selects the corresponding Behaviour
            switch (traits[1])
            {
            case "Friendly": Friendlies.Add(next_ID); break;

            case "Hostile": Hostiles.Add(next_ID); break;

            case "Neutral": Neutrals.Add(next_ID); break;

            default: Console.WriteLine("Error, assuming Neutral"); Neutrals.Add(next_ID); break;
            }

            switch (traits[2])
            {
            case "Melee": AttackDamage.Add(stats[0] + stats[1]); break;

            case "Ranged": AttackDamage.Add(stats[1] + stats[2]); break;
            }

            next_ID++;
        }
Example #2
0
 private void CreateDuelStatistics()
 {
     AttackDamage = new AttackDamage(statisticsLevelUpdater.GetBaseCalculatedAttackDamage(level));
     Armour       = new Armour(statisticsLevelUpdater.GetBaseCalculatedArmour(level));
     Health       = new Health(statisticsLevelUpdater.GetBaseCalculatedHealth(level));
     Mana         = new Mana(statisticsLevelUpdater.GetBaseCalculatedMana(level));
     duelStatsUIView.SetDuelStatsValuesOnUI(this);
 }
Example #3
0
    protected override void OnAttack(Collider2D collision)
    {
        BeHitBase beHit = collision.GetComponent <BeHitBase>();

        if (beHit)
        {
            AttackDamage.AttackPolarity = Player.PlayerPolarity;
            AttackDamage.AttackPosition = transform.position;
            DamageBase damage = AttackDamage.Copy();

            float u = (collision.transform.position - transform.position).magnitude / collider.radius;

            damage.AttackForce = AttackDamage.AttackForce * Mathf.Lerp(1, centerForce, u);
            beHit.OnBeHitBefore(damage);
            if (Player.OnAttack != null)
            {
                Player.OnAttack.Invoke(beHit.Player);
            }
        }
        base.OnAttack(collision);
    }
Example #4
0
    protected virtual void InitializUnitStats(BaseStats baseStats)
    {
        Health = new Health(baseStats.BaseHealth);

        AttackDamage         = new AttackDamage(baseStats.BaseAttackDamage);
        AbilityPower         = new AbilityPower();
        Armor                = new Resistance(baseStats.BaseArmor);
        MagicResistance      = new Resistance(baseStats.BaseMagicResistance);
        AttackSpeed          = new AttackSpeed(baseStats.BaseAttackSpeed);
        CooldownReduction    = new CooldownReduction();
        CriticalStrikeChance = new CriticalStrikeChance();
        MovementSpeed        = new MovementSpeed(baseStats.BaseMovementSpeed);

        HealthRegeneration      = new ResourceRegeneration();
        Lethality               = new Lethality();
        ArmorPenetrationPercent = new ResistancePenetrationPercent();
        MagicPenetrationFlat    = new ResistancePenetrationFlat();
        MagicPenetrationPercent = new ResistancePenetrationPercent();
        LifeSteal               = new PercentBonusOnlyStat();
        SpellVamp               = new PercentBonusOnlyStat();
        AttackRange             = new AttackRange(baseStats.BaseAttackRange);
        Tenacity = new Tenacity();

        CriticalStrikeDamage           = new CriticalStrikeDamage();
        CriticalStrikeDamageReduction  = new PercentBonusOnlyStat();
        PhysicalDamageModifier         = new DamageModifier();
        MagicDamageModifier            = new DamageModifier();
        PhysicalDamageReceivedModifier = new DamageModifier();
        MagicDamageReceivedModifier    = new DamageModifier();
        HealAndShieldPower             = new PercentBonusOnlyStat();
        SlowResistance = new SlowResistance();

        GrievousWounds = new GrievousWounds();

        ExtraAdjustments();
    }
Example #5
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();
        }
Example #7
0
	void Awake(){
		attackSphere = GetComponentInChildren<AttackDamage>();
		attackSphere.gameObject.SetActive(false);
	}