コード例 #1
0
    public override void SimulateEnemyFixedUpdate(Actor_Enemy actor)
    {
        if (actor.IsFrozen() || actor.IsStunned())
        {
            return;
        }

        actor.fTimeSinceLastAttack += Core.GetPlayerDeltaTime();

        float fMin = Core.GetLevel().GetRangedZoneMin();         //GetTargetRangeMin();
        float fMax = Core.GetLevel().GetRangedZoneMax();         //GetTargetRangeMax();

        fMax -= (fMax - fMin) * 0.25f;

        bool bInRange = fMin <= actor.transform.position.x && actor.transform.position.x <= fMax;

        if (bInRange)
        {
            if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier())
            {
                actor.fTimeSinceLastAttack = 0.0f;

                PlaySoundEffect(actor);

                // Zap both player ranged characters
                RangedAttackPlayer(actor, damage, MinionSlot.RANGED_1);
                RangedAttackPlayer(actor, damage, MinionSlot.RANGED_2);

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

                int firstHit = Random.Range(0, 2);

                // Add a line
                Vector3      prevPos         = pfxPositions [pfxPositions.Count - 1];
                Actor_Player firstPlayerHit  = Core.GetLevel().playerActors[(int)MinionSlot.RANGED_1 + firstHit];
                Actor_Player secondPlayerHit = Core.GetLevel().playerActors[(int)MinionSlot.RANGED_1 + (1 - firstHit)];
                Vector3      newPos          = firstPlayerHit.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(firstPlayerHit.transform.position);
                pfxPositions.Add(secondPlayerHit.transform.position);

                actor.render.SetChainPFXActive(fChainPFXDuration, pfxPositions.ToArray());
                actor.render.SetAnimStateAndNext(AnimState.ATTACK, AnimState.IDLE);
            }
            else if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier() * 0.5f)
            {
                float fSpeed = fMoveSpeed;
                if (actor.transform.position.x - fMin < 1.0f)
                {
                    fSpeed *= (actor.transform.position.x - fMin);
                }

                actor.Move(new Vector3(-fSpeed, 0.0f, 0.0f));
                actor.render.SetAnimState(AnimState.WALKING, false);
            }
        }
        else
        {
            actor.Move(new Vector3(-fMoveSpeed, 0.0f, 0.0f));
            actor.render.SetAnimState(AnimState.WALKING, false);
        }
    }
コード例 #2
0
    public override void SimulateEnemyFixedUpdate(Actor_Enemy actor)
    {
        actor.fTimeSinceLastAttack += Core.GetPlayerDeltaTime();

        float fMin = Core.GetLevel().GetRangedZoneMin();         //GetTargetRangeMin();
        float fMax = Core.GetLevel().GetRangedZoneMax();         //GetTargetRangeMax();

        fMax -= (fMax - fMin) * 0.25f;

        if (actor.targetSlot == MinionSlot.NUM_MINION_SLOTS)
        {
            actor.targetSlot = (MinionSlot)((int)MinionSlotType.RANGED.GetFirst() + Random.Range(0, MinionSlotType.RANGED.GetNumSlots()));
        }

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

        if (actor.summon == null)
        {
            // TODO : Do spawn PFX
            actor.summon = Instantiate <RenderActor>(summonPrefab);
            actor.summon.transform.position = actor.transform.position;

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

        if (actor.summon != null && Core.GetLevel().playerActors [(int)actor.targetSlot] != null)
        {
            Vector3 targetPos = Core.GetLevel().playerActors [(int)actor.targetSlot].transform.position;
            targetPos.y += fSummonHeight;
            actor.summon.transform.position = Vector3.Lerp(actor.summon.transform.position, targetPos, Core.GetEnemyDeltaTime() * reticuleMoveSpeed);
        }

        bool bInRange = fMin <= actor.transform.position.x && actor.transform.position.x <= fMax;

        if (bInRange)
        {
            if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier())
            {
                actor.fTimeSinceLastAttack = 0.0f;

                RangedAttackPlayer(actor, damage, actor.targetSlot);

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

                actor.render.SetAnimStateAndNext(AnimState.ATTACK, AnimState.IDLE);

                // Pick a new target slot for the next attack
                actor.targetSlot = (MinionSlot)((int)MinionSlotType.RANGED.GetFirst() + Random.Range(0, MinionSlotType.RANGED.GetNumSlots()));
            }
            else if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier() * 0.5f)
            {
                float fSpeed = fMoveSpeed;
                if (actor.transform.position.x - fMin < 1.0f)
                {
                    fSpeed *= (actor.transform.position.x - fMin);
                }

                actor.Move(new Vector3(-fSpeed, 0.0f, 0.0f));
                actor.render.SetAnimState(AnimState.WALKING, false);
            }
        }
        else
        {
            actor.Move(new Vector3(-fMoveSpeed, 0.0f, 0.0f));
            actor.render.SetAnimState(AnimState.WALKING, false);
        }
    }
コード例 #3
0
    public override void SimulateEnemyFixedUpdate(Actor_Enemy actor)
    {
        if (actor.fTargetX == 0.0f)
        {
            actor.fTargetX = Random.Range(Core.GetLevel().GetRangedZoneMin(), Core.GetLevel().GetRangedZoneMax());
        }

        if (actor.IsStunned() || actor.IsFrozen())
        {
            return;
        }

        actor.fTimeSinceLastAttack += Core.GetPlayerDeltaTime();

        float fMin = actor.fTargetX;
        float fMax = Core.GetLevel().GetRangedZoneMax();

        fMax -= (fMax - fMin) * 0.25f;

        bool bInRange = actor.transform.position.x <= fMax;

        if (bInRange)
        {
            actor.render.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
            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             = Core.GetLevel().GetRangedTarget();
                    projectile.transform.position = projectile.launchPos;
                }

                PlaySoundEffect(actor);

                actor.render.SetAnimStateAndNext(AnimState.ATTACK, AnimState.IDLE);
            }
            else if (actor.fTimeSinceLastAttack >= fAttackInterval * actor.GetAttackSpeedMultiplier() * 0.5f)
            {
                float fSpeed = fMoveSpeed;
                if (actor.transform.position.x - fMin < 1.0f)
                {
                    fSpeed *= (actor.transform.position.x - fMin);
                }

                // Cap backwards speed to prevent magnetic bugs being useless
                if (fSpeed < 0.0f)
                {
                    fSpeed = -1.0f;
                }

                actor.Move(new Vector3(-fSpeed, 0.0f, 0.0f));
                actor.render.SetAnimState(AnimState.WALKING, false);
                actor.render.transform.localScale = new Vector3(fSpeed > 0.0f ? 1.0f : -1.0f, 1.0f, 1.0f);
            }
        }
        else
        {
            actor.Move(new Vector3(-fMoveSpeed, 0.0f, 0.0f));
            actor.render.SetAnimState(AnimState.WALKING, false);
        }
    }