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; } }
protected override IEnumerator ShootBasicAttack(Unit target) { SetupBeforeAttackDelay(target); yield return(delayAttack); isShootingPassiveShot = true; if (!empoweringAbilityWasActiveOnBasicAttackCast) { empoweringAbilityWasActiveOnBasicAttackCast = unit.BuffManager.IsAffectedByBuff(basicAttackEmpoweringAbility.AbilityBuffs[0]); } SetupAfterAttackDelay(target, basicAttackPrefab); if (empoweringAbilityWasActiveOnBasicAttackCast) { empoweringAbilityWasActiveOnBasicAttackCast = false; basicAttackEmpoweringAbility.AbilityBuffs[0].ConsumeBuff(unit); yield return(delayPassiveShot); ProjectileUnitTargeted projectile2 = (Instantiate(empoweredBasicAttackPrefab, transform.position, transform.rotation)).GetComponent <ProjectileUnitTargeted>(); projectile2.transform.LookAt(target.transform); projectile2.ShootProjectile(unit.Team, target, speed, AttackIsCritical.CheckIfAttackIsCritical(unit.StatsManager.CriticalStrikeChance.GetTotal())); projectile2.OnAbilityEffectHit += PassiveBasicAttackHit; } isShootingPassiveShot = false; shootBasicAttackCoroutine = null; }
protected override IEnumerator AbilityWithCastTime() { IsBeingCasted = true; yield return(delayCastTime); IsBeingCasted = false; UseResource(); champion.OrientationManager.RotateCharacterInstantly(destinationOnCast); ProjectileUnitTargeted projectile = (Instantiate(projectilePrefab, transform.position, transform.rotation)).GetComponent <ProjectileUnitTargeted>(); projectile.ShootProjectile(champion.Team, targetedUnit, speed); projectile.OnAbilityEffectHit += OnAbilityEffectHit; FinishAbilityCast(); }
protected void SetupAfterAttackDelay(Unit target, GameObject basicAttackPrefab) { BasicAttackCycle.LockBasicAttack(); AttackIsInQueue = false; ((Champion)unit).OrientationManager.StopTargetRotation(); ProjectileUnitTargeted projectile = (Instantiate(basicAttackPrefab, transform.position, transform.rotation)).GetComponent <ProjectileUnitTargeted>(); projectile.ShootProjectile(unit.Team, target, speed, AttackIsCritical.CheckIfAttackIsCritical(unit.StatsManager.CriticalStrikeChance.GetTotal())); if (empoweringAbilityWasActiveOnBasicAttackCast) { projectile.OnAbilityEffectHit += BasicAttackHit; } else { projectile.OnAbilityEffectHit += base.BasicAttackHit; } }
protected virtual IEnumerator ShootBasicAttack(Unit target) { ((Champion)unit).OrientationManager.RotateCharacterUntilReachedTarget(target.transform, true, true); yield return(delayAttack); BasicAttackCycle.LockBasicAttack(); AttackIsInQueue = false; ((Champion)unit).OrientationManager.StopTargetRotation(); ProjectileUnitTargeted projectile = (Instantiate(basicAttackPrefab, transform.position, transform.rotation)).GetComponent <ProjectileUnitTargeted>(); projectile.ShootProjectile(unit.Team, target, speed, AttackIsCritical.CheckIfAttackIsCritical(unit.StatsManager.CriticalStrikeChance.GetTotal()), unit.StatusManager.IsBlinded()); projectile.OnAbilityEffectHit += BasicAttackHit; if (unit is Character) { ((Champion)unit).OnAttackEffectsManager.ApplyOnAttackEffectsToUnitHit(target); } shootBasicAttackCoroutine = null; }
protected override void OnAbilityEffectHit(AbilityEffect projectile, Unit unitHit, bool isACriticalStrike, bool willMiss) { base.OnAbilityEffectHit(projectile, unitHit, isACriticalStrike, willMiss); Unit nextUnit = FindTargetBehindUnitHit(unitHit); if (nextUnit) { bool secondHitIsACriticalStrike; if (unitHit.StatsManager.Health.IsDead()) { secondHitIsACriticalStrike = true; } else { secondHitIsACriticalStrike = AttackIsCritical.CheckIfAttackIsCritical(champion.StatsManager.CriticalStrikeChance.GetTotal()); } ProjectileUnitTargeted projectile2 = (Instantiate(projectilePrefab, unitHit.transform.position, transform.rotation)).GetComponent <ProjectileUnitTargeted>(); projectile2.transform.LookAt(nextUnit.transform.position); projectile2.ShootProjectile(champion.Team, nextUnit, speed, secondHitIsACriticalStrike); projectile2.OnAbilityEffectHit += base.OnAbilityEffectHit; } }