Beispiel #1
0
    private void PerformAttack()
    {
        foreach (Player player in tm.playerList)
        {
            if (Vector3.Distance(player.transform.position, this.transform.position) < 3f && Random.value > 0.8)
            {
                currentAttack = AttackBeingPerformed.Explode;
                animator.AnimateExplodeAttack();
                return;
            }
        }

        if (Vector3.Distance(currentTarget.transform.position, this.transform.position) > 12f)
        {
            currentAttack = AttackBeingPerformed.Spawn;
            animator.AnimateSpawnAttack();
            return;
        }

        int choice = Random.Range(0, 5);

        if (choice == previousAttackChoice)
        {
            choice = Random.Range(0, 5);
        }
        previousAttackChoice = choice;

        switch (choice)
        {
        case 0:
            currentAttack = AttackBeingPerformed.Sweep;
            animator.AnimateSweepAttack();
            break;

        case 1:
            currentAttack = AttackBeingPerformed.Laser;
            animator.AnimateLaserAttack();
            break;

        case 2:
            currentAttack = AttackBeingPerformed.Explode;
            animator.AnimateExplodeAttack();
            break;

        case 3:
            currentAttack = AttackBeingPerformed.Spawn;
            animator.AnimateSpawnAttack();
            break;

        case 4:
            currentAttack = AttackBeingPerformed.Blast;
            animator.AnimateBlastAttack();
            break;

        default:
            currentAttack = AttackBeingPerformed.Spawn;
            animator.AnimateSpawnAttack();
            break;
        }
    }
Beispiel #2
0
 public void ReturnToIdle()
 {
     timeToNextAttack    = Random.Range(minIdleTime, maxIdleTime);
     previousTargetIndex = currentTarget.id;
     currentAttack       = AttackBeingPerformed.None;
     currentTarget       = null;
     animator.AnimateIdle();
 }