예제 #1
0
    private void ShootHomingProjectile()
    {
        Unit  closestUnit = null;
        Unit  tempUnit;
        float distance = float.MaxValue;
        float tempDistance;

        Vector3 groundPosition = Vector3.right * transform.position.x + Vector3.forward * transform.position.z;

        foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, effectRadius))
        {
            tempUnit = collider.GetComponentInParent <Unit>();
            if (tempUnit != null && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
            {
                if (tempUnit.BuffManager.IsAffectedByDebuff(champion.AbilityManager.CharacterAbilities[1].AbilityDebuffs[0]))
                {
                    closestUnit = tempUnit;
                    break;
                }
                tempDistance = Vector3.Distance(transform.position, tempUnit.transform.position);
                if (tempDistance < distance)
                {
                    distance    = tempDistance;
                    closestUnit = tempUnit;
                }
            }
        }

        if (closestUnit != null)
        {
            ProjectileUnitTargeted projectile = Instantiate(projectilePrefab, transform.position, transform.rotation).GetComponent <ProjectileUnitTargeted>();
            projectile.ShootProjectile(champion.Team, closestUnit, speed);
            projectile.OnAbilityEffectHit += OnProjectileHit;
        }
    }
예제 #2
0
    private Unit FindTargetBehindUnitHit(Unit unitHit)
    {
        Unit  closestEnemy  = null;
        float enemyAngle    = float.MaxValue;
        float enemyDistance = float.MaxValue;
        Unit  tempUnit;
        float tempAngle;
        float tempDistance;

        Vector3 groundPosition = Vector3.right * unitHit.transform.position.x + Vector3.forward * unitHit.transform.position.z;

        foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, effectRadius))
        {
            tempUnit = collider.GetComponentInParent <Unit>();
            if (tempUnit != null && tempUnit != unitHit && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
            {
                tempAngle    = Vector3.Angle(vectorOnCast, tempUnit.transform.position - unitHit.transform.position);
                tempDistance = Vector3.Distance(unitHit.transform.position, tempUnit.transform.position);
                if ((tempAngle <= 10 && tempDistance < enemyDistance) ||
                    (enemyAngle > 10 && tempAngle <= 20 && tempDistance < enemyDistance) ||
                    (enemyAngle > 20 && tempAngle <= 55 && tempDistance < enemyDistance) ||
                    (enemyAngle > 55 && tempAngle <= 80 && tempDistance <= effectRadiusOnBigAngle && tempDistance < enemyDistance))
                {
                    closestEnemy  = tempUnit;
                    enemyAngle    = tempAngle;
                    enemyDistance = tempDistance;
                }
            }
        }

        return(closestEnemy);
    }
예제 #3
0
    private void AddNewDebuffToAllEnemiesInEffectRadius(Unit unitHit)
    {
        Unit tempUnit;

        Vector3 groundPosition = Vector3.right * unitHit.transform.position.x + Vector3.forward * unitHit.transform.position.z;

        foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, effectRadius))
        {
            tempUnit = collider.GetComponentInParent <Unit>();
            if (tempUnit != null && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
            {
                AbilityDebuffs[0].AddNewBuffToAffectedUnit(tempUnit);
            }
        }
    }
예제 #4
0
    protected virtual bool CanAffectTarget(Unit unitHit)
    {
        if (TargetIsValid.CheckIfTargetIsValid(unitHit, affectedUnitType, castingUnitTeam))
        {
            foreach (Unit unit in UnitsAlreadyHit)
            {
                if (unitHit == unit)
                {
                    return(false);
                }
            }

            return(true);
        }

        return(false);
    }
예제 #5
0
    private void DamageAllEnemiesInPassiveExplosionRadius(DamageSource damageSource, Unit killedUnit)
    {
        Unit tempUnit;

        Vector3 groundPosition = Vector3.right * killedUnit.transform.position.x + Vector3.forward * killedUnit.transform.position.z;

        foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, effectRadius))
        {
            tempUnit = collider.GetComponentInParent <Unit>();
            if (tempUnit != null && tempUnit != killedUnit && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
            {
                float damage = GetPassiveAbilityDamage(tempUnit);
                DamageUnit(tempUnit, passiveDamageType, damage);
                AbilityHit(tempUnit, damage);
            }
        }
    }
예제 #6
0
    private void ApplyDamageAndSlowToAllEnemiesInRadius()
    {
        Unit tempUnit;

        Vector3 groundPosition = Vector3.right * transform.position.x + Vector3.forward * transform.position.z;

        foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, effectRadius))
        {
            tempUnit = collider.GetComponentInParent <Unit>();
            if (tempUnit != null && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
            {
                float damage = GetAbilityDamage(tempUnit);
                DamageUnit(tempUnit, damage);
                AbilityHit(tempUnit, damage);
                AbilityDebuffs[0].AddNewBuffToAffectedUnit(tempUnit);
            }
        }
    }
예제 #7
0
    private IEnumerator AutoAttack()
    {
        if (!champion)
        {
            yield return(null);
        }

        Vector3 groundPosition;

        Unit autoAttackTarget = null;

        while (true)
        {
            if (CanUseAutoAttack())
            {
                if (autoAttackTarget == null || Vector3.Distance(autoAttackTarget.transform.position, transform.position) > attackRange.GetTotal())
                {
                    autoAttackTarget = null;
                    float distance = float.MaxValue;
                    groundPosition = Vector3.right * transform.position.x + Vector3.forward * transform.position.z;
                    foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, attackRange.GetTotal()))
                    {
                        Unit tempUnit = collider.GetComponentInParent <Unit>();
                        if (tempUnit != null && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
                        {
                            float tempDistance = Vector3.Distance(tempUnit.transform.position, transform.position);
                            if (tempDistance < distance)
                            {
                                autoAttackTarget = tempUnit;
                                distance         = tempDistance;
                            }
                        }
                    }
                }

                if (autoAttackTarget != null)
                {
                    champion.BasicAttack.UseBasicAttackFromAutoAttackOrTaunt(autoAttackTarget);
                }
            }

            yield return(null);
        }
    }
예제 #8
0
    private void DamageAllEnemiesInActiveExplosionRadius(Unit unitHit, int stacksOnExplosion = 0)
    {
        float damageModifier = stacksOnExplosion * damagePercentIncreasePerStack + 1;

        Unit  tempUnit;
        float selectedRadius = effectRadius;//TODO: unitHit is Turret ? effectRadiusOnTurret : effectRadius;

        Vector3 groundPosition = Vector3.right * unitHit.transform.position.x + Vector3.forward * unitHit.transform.position.z;

        foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, selectedRadius))
        {
            tempUnit = collider.GetComponentInParent <Unit>();
            if (tempUnit != null && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
            {
                float damage = GetAbilityDamage(tempUnit) * damageModifier;
                DamageUnit(tempUnit, damage);
                AbilityHit(tempUnit, damage);
            }
        }
    }
예제 #9
0
    private IEnumerator AutoAttackWithBiggerRange()
    {
        if (!champion)
        {
            yield return(null);
        }

        Unit    autoAttackTarget = null;
        Vector3 groundPosition   = Vector3.right * transform.position.x + Vector3.forward * transform.position.z;

        while (true)
        {
            if (CanUseAutoAttack())
            {
                float distance = float.MaxValue;
                foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, biggerAttackRange))
                {
                    Unit tempUnit = collider.GetComponentInParent <Unit>();
                    if (tempUnit != null && TargetIsValid.CheckIfTargetIsValid(tempUnit, affectedUnitType, champion.Team))
                    {
                        float tempDistance = Vector3.Distance(tempUnit.transform.position, transform.position);
                        if (tempDistance < distance)
                        {
                            autoAttackTarget = tempUnit;
                            distance         = tempDistance;
                        }
                    }
                }

                if (autoAttackTarget != null)
                {
                    champion.BasicAttack.SetupBasicAttack(autoAttackTarget, false);
                    break;
                }
            }

            yield return(null);
        }

        currentAutoAttackCoroutine = null;
    }
예제 #10
0
 protected override bool CanAffectTarget(Unit unitHit)
 {
     return(TargetIsValid.CheckIfTargetIsValid(unitHit, affectedUnitType, castingUnitTeam));
 }
예제 #11
0
    public List <Unit> GetUnitsInRange(Unit affectedUnit, List <Unit> alreadyAffectedUnits)
    {
        List <Unit> unitsInRange = new List <Unit>();

        Character tempCharacter;
        Vector3   groundPosition = Vector3.right * affectedUnit.transform.position.x + Vector3.forward * affectedUnit.transform.position.z;

        foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, radius))
        {
            tempCharacter = collider.GetComponentInParent <Character>();
            if (tempCharacter != null && !alreadyAffectedUnits.Contains(tempCharacter) && TargetIsValid.CheckIfTargetIsValid(tempCharacter, affectedUnitType, champion.Team))
            {
                unitsInRange.Add(tempCharacter);
            }
        }

        return(unitsInRange);
    }
예제 #12
0
 protected bool IsAValidTarget(Unit target)
 {
     return(TargetIsValid.CheckIfTargetIsValid(target, affectedUnitType, champion.Team));
 }
예제 #13
0
    public override void UseAbility(Vector3 destination)
    {
        StartAbilityCast();

        Character targetedCharacter = null;
        Character tempCharacter;

        //TODO: Extract this into a class/method

        if (hit.point != Vector3.down)
        {
            float distance = float.MaxValue;
            float tempDistance;

            Vector3 mouseGroundPosition = Vector3.right * hit.point.x + Vector3.forward * hit.point.z;
            foreach (Collider collider in Physics.OverlapCapsule(mouseGroundPosition, mouseGroundPosition + Vector3.up * 5, MOUSE_RADIUS))
            {
                tempCharacter = collider.GetComponent <Character>();
                if (tempCharacter != null && tempCharacter != champion && TargetIsValid.CheckIfTargetIsValid(tempCharacter, affectedUnitType, champion.Team))
                {
                    tempDistance = Vector3.Distance(transform.position, tempCharacter.transform.position);
                    if (tempDistance < distance && tempDistance < range)
                    {
                        distance          = tempDistance;
                        targetedCharacter = tempCharacter;
                    }
                }
            }
        }

        if (targetedCharacter == null)
        {
            float lowestHealth = float.MaxValue;
            float tempLowestHealth;

            Vector3 groundPosition = Vector3.right * transform.position.x + Vector3.forward * transform.position.z;
            foreach (Collider collider in Physics.OverlapCapsule(groundPosition, groundPosition + Vector3.up * 5, range))
            {
                tempCharacter = collider.GetComponent <Character>();
                if (tempCharacter != null && tempCharacter != champion && TargetIsValid.CheckIfTargetIsValid(tempCharacter, affectedUnitType, champion.Team))
                {
                    tempLowestHealth = tempCharacter.StatsManager.Health.GetCurrentValue();
                    if (tempLowestHealth < lowestHealth)
                    {
                        lowestHealth      = tempLowestHealth;
                        targetedCharacter = tempCharacter;
                    }
                }
            }
        }

        if (targetedCharacter != null)
        {
            AbilityBuffs[0].AddNewBuffToAffectedUnit(targetedCharacter);
            AbilityDebuffs[0].AddNewBuffToAffectedUnit(targetedCharacter);
        }

        AbilityBuffs[0].AddNewBuffToAffectedUnit(champion);
        AbilityDebuffs[0].AddNewBuffToAffectedUnit(champion);

        FinishAbilityCast();
    }