Exemple #1
0
    protected bool TryToAttackEnemy(Actor_Player player, Actor_Enemy enemy)
    {
        if (player.fTimeSinceLastAttack >= fAttackInterval * player.GetAttackSpeedMultiplier())
        {
            PlaySoundEffect(player);

            player.render.SetAnimStateAndNext(AnimState.ATTACK, AnimState.IDLE);
            player.fTimeSinceLastAttack = 0.0f;

            if (player.render.attackParticles != null)
            {
                //player.render.attackParticles.Stop();
                player.render.attackParticles.Play();
            }

            for (int i = 0; i < numAttacks; i++)
            {
                IncrementCombo(player);
                if (DealDamageToEnemy(player, enemy, enemy.transform.position, 0.0f))
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Exemple #2
0
    public override void SimulatePlayerFixedUpdate(Actor_Player actor)
    {
        actor.fTimeSinceLastAttack += Core.GetPlayerDeltaTime();

        //if (actor.currentTarget == null || actor.currentTarget.minion.fCurrentHealth <= 0.0f)
        {
            // Find new target
            actor.currentTarget = GetBestTarget(actor);
        }

        if (actor.minion.slot == MinionSlot.RANGED_1)
        {
            Actor_Player otherRangedMinion = Core.GetLevel().playerActors [(int)MinionSlot.RANGED_2];
            if (otherRangedMinion.fTimeSinceLastAttack >= fAttackInterval)
            {
                actor.fTimeSinceLastAttack = fAttackInterval * 0.5f;
            }
        }

        int       iSlot    = actor.minion.slot == MinionSlot.RANGED_1 ? 0 : 1;
        Transform reticule = Core.GetLevel().instance.targets [iSlot];
        Transform radius   = Core.GetLevel().instance.radii [iSlot];

        if (actor.currentTarget != null)
        {
            reticule.gameObject.SetActive(true);
            reticule.position = Vector3.Lerp(reticule.position, actor.currentTarget.transform.position + new Vector3(0.0f, 0.04f, 0.0f), Core.GetPlayerDeltaTime() * actor.minion.template.reticuleMoveSpeed * actor.GetAttackSpeedMultiplier());
            float fRadius = damage.fRadius * actor.GetAttackRadiusMultiplier() * 2.0f;
            radius.localScale = new Vector3(fRadius, 1.0f, fRadius);

            if (!actor.currentTarget.IsInRangedZone())
            {
                actor.currentTarget = null;
            }
            else
            if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier())
            {
                actor.fTimeSinceLastAttack = 0.0f;
                // Spawn a projectile
                for (int i = 0; i < numAttacks; i++)
                {
                    Projectile projectile = Instantiate <Projectile>(projectilePrefab);
                    projectile.firer              = actor;
                    projectile.firerTemplate      = this;
                    projectile.launchPos          = actor.transform.position + new Vector3(0.5f * i, fProjectileLaunchHeight, 0.0f);
                    projectile.fProgress          = i * 0.1f;
                    projectile.target             = actor.currentTarget;
                    projectile.transform.position = projectile.launchPos;
                }

                PlaySoundEffect(actor);

                actor.render.SetAnimStateAndNext(AnimState.ATTACK, AnimState.IDLE);
            }
        }
        else
        {
            //reticule.gameObject.SetActive(false);
        }
    }
    public override void SimulatePlayerFixedUpdate(Actor_Player actor)
    {
        actor.fTimeSinceLastAttack += Core.GetPlayerDeltaTime();

        //if (actor.currentTarget == null || actor.currentTarget.minion.fCurrentHealth <= 0.0f)
        {
            // Find new target
            actor.currentTarget = GetBestTarget(actor);
        }

        if (bLoopingSoundEffect && !actor.soundEffect.isPlaying)
        {
            actor.soundEffect.loop = true;
            actor.soundEffect.clip = soundEffect;
            actor.soundEffect.Play();
        }

        if (actor.currentTarget != null)
        {
            int       iSlot    = actor.minion.slot == MinionSlot.RANGED_1 ? 0 : 1;
            Transform reticule = Core.GetLevel().instance.targets [iSlot];
            Transform radius   = Core.GetLevel().instance.radii [iSlot];
            reticule.gameObject.SetActive(true);
            reticule.position = Vector3.Lerp(reticule.position, actor.currentTarget.transform.position + new Vector3(0.0f, 0.04f, 0.0f), Core.GetPlayerDeltaTime() * actor.minion.template.reticuleMoveSpeed * actor.GetAttackSpeedMultiplier());
            float fRadius = damage.fRadius * actor.GetAttackRadiusMultiplier() * 2.0f;
            radius.localScale = new Vector3(fRadius, 1.0f, fRadius);

            if (actor.iNumHitsWithSummon >= iNumHits)
            {
                actor.summon.PlayDeathAnimation();
                actor.summon             = null;
                actor.iNumHitsWithSummon = 0;
                reticule.position        = actor.currentTarget.transform.position + new Vector3(0.0f, 0.04f, 0.0f);
            }

            if (actor.summon == null)
            {
                // TODO : Do spawn PFX
                actor.summon = Instantiate <RenderActor>(summonPrefab);
                actor.summon.transform.SetParent(reticule);
                actor.summon.transform.localPosition = new Vector3(0.0f, fSummonHeight, 0.0f);

                if (summonEffect != null)
                {
                    summonEffect.Play();
                }
            }

            if (!actor.currentTarget.IsInRangedZone())
            {
                actor.currentTarget = null;
            }
            else if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier())
            {
                actor.fTimeSinceLastAttack = 0.0f;

                if (!bLoopingSoundEffect)
                {
                    PlaySoundEffect(actor);
                }

                if (DealDamageToEnemy(actor, actor.currentTarget, actor.currentTarget.transform.position, 0.0f))
                {
                    // We killed them
                    actor.currentTarget = null;
                }

                actor.iNumHitsWithSummon++;

                actor.summon.SetAnimStateAndNext(AnimState.ATTACK, AnimState.IDLE);
            }
        }
    }
    public override void SimulatePlayerFixedUpdate(Actor_Player actor)
    {
        actor.fTimeSinceLastAttack += Core.GetPlayerDeltaTime();

        //if (actor.currentTarget == null || actor.currentTarget.minion.fCurrentHealth <= 0.0f)
        {
            // Find new target
            actor.currentTarget = GetBestTarget(actor);
        }

        if (actor.currentTarget != null)
        {
            int       iSlot    = actor.minion.slot == MinionSlot.RANGED_1 ? 0 : 1;
            Transform reticule = Core.GetLevel().instance.targets [iSlot];
            Transform radius   = Core.GetLevel().instance.radii [iSlot];
            reticule.gameObject.SetActive(true);
            reticule.position = Vector3.Lerp(reticule.position, actor.currentTarget.transform.position + new Vector3(0.0f, 0.04f, 0.0f), Core.GetPlayerDeltaTime() * actor.minion.template.reticuleMoveSpeed * actor.GetAttackSpeedMultiplier());
            radius.localScale = new Vector3(0.0f, 1.0f, 0.0f);

            if (!actor.currentTarget.IsInRangedZone())
            {
                actor.currentTarget = null;
            }
            else if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier())
            {
                actor.fTimeSinceLastAttack = 0.0f;

                List <Vector3> pfxPositions = new List <Vector3> ();
                pfxPositions.Add(actor.transform.position + new Vector3(0.0f, fProjectileLaunchHeight, 0.0f));

                List <Actor_Enemy> alreadyHit    = new List <Actor_Enemy> ();
                Actor_Enemy        currentTarget = actor.currentTarget;
                float fChainRemaining            = iChain * actor.GetChainCountMultiplier();

                PlaySoundEffect(actor);

                while (fChainRemaining > 0.0f)
                {
                    DealDamageToEnemy(actor, currentTarget, currentTarget.transform.position, 0.0f);
                    if (currentTarget.HasWaterDebuff())
                    {
                        fChainRemaining -= 0.5f;
                    }
                    else
                    {
                        fChainRemaining -= 1.0f;
                    }

                    alreadyHit.Add(currentTarget);

                    // Add a line
                    Vector3 prevPos = pfxPositions [pfxPositions.Count - 1];
                    Vector3 newPos  = currentTarget.transform.position + new Vector3(0.0f, fProjectileLaunchHeight, 0.0f);
                    Vector3 dPos    = newPos - prevPos;
                    float   fLength = dPos.magnitude;
                    // If it is longer than 2 units, split it into segments
                    if (fLength >= 2.0f)
                    {
                        dPos.Normalize();
                        int numSegments = Mathf.FloorToInt(fLength / 2.0f);
                        for (int i = 0; i < numSegments; i++)
                        {
                            Vector3 pos    = prevPos + dPos * 2.0f * (i + 1);
                            Vector3 offset = Random.onUnitSphere;
                            offset.y = 0.0f;
                            pos     += offset;
                            pfxPositions.Add(pos);
                        }
                    }

                    pfxPositions.Add(newPos);

                    Actor_Enemy bestCandidate = null;
                    float       fBestDistance = fMaxChainGap * actor.GetChainGapMultiplier();
                    foreach (Actor_Enemy enemy in Core.GetLevel().enemyActors)
                    {
                        if (enemy != null && !alreadyHit.Contains(enemy))
                        {
                            float fDist = (currentTarget.transform.position - enemy.transform.position).magnitude;

                            if (fDist < fBestDistance)
                            {
                                fBestDistance = fDist;
                                bestCandidate = enemy;
                            }
                        }
                    }
                    if (bestCandidate == null)
                    {
                        break;
                    }

                    currentTarget = bestCandidate;
                }

                actor.render.SetChainPFXActive(fChainPFXDuration, pfxPositions.ToArray());
                actor.render.SetAnimStateAndNext(AnimState.ATTACK, AnimState.IDLE);
            }
        }
    }
Exemple #5
0
    public override void SimulatePlayerFixedUpdate(Actor_Player actor)
    {
        if (damage.fAmount > 0.0f || damage.fPushAmount > 0.0f)         // 0 means no attack
        {
            actor.fTimeSinceLastAttack += Core.GetPlayerDeltaTime();

            if (actor.currentTarget == null || actor.currentTarget.minion.fCurrentHealth <= 0.0f || !actor.currentTarget.IsInMeleeZone())
            {
                actor.currentTarget = null;

                // Find new target
                Actor_Enemy closestEnemy = Core.GetLevel().GetClosestEnemyToMeleeZone();
                if (closestEnemy != null && closestEnemy.IsInMeleeZone())
                {
                    actor.currentTarget = closestEnemy;
                }
                else
                {
                    // No valid target.
                }
            }

            int       iSlot    = actor.minion.slot == MinionSlot.MELEE_1 ? 0 : 1;
            Transform reticule = Core.GetLevel().instance.meleeTargets [iSlot];
            Transform radius   = Core.GetLevel().instance.meleeRadii [iSlot];

            if (actor.currentTarget != null)
            {
                reticule.gameObject.SetActive(true);
                reticule.position = Vector3.Lerp(reticule.position, actor.currentTarget.transform.position + new Vector3(0.0f, 0.04f, 0.0f), Core.GetPlayerDeltaTime() * actor.minion.template.reticuleMoveSpeed * actor.GetAttackSpeedMultiplier());
                float fRadius = damage.fRadius * actor.GetAttackRadiusMultiplier() * 2.0f;
                radius.localScale = new Vector3(fRadius, 1.0f, fRadius);

                if (TryToAttackEnemy(actor, actor.currentTarget))
                {
                    // We killed them
                    actor.currentTarget = null;
                }
            }
            else
            {
                //reticule.gameObject.SetActive(false);
            }
        }
    }