3DTD/Assets/Scripts/Tower/ProjectileTower.cs

36 lines
1.2 KiB
C#
Raw Normal View History

2024-04-20 13:15:33 +02:00
using System;
using System.Collections;
2024-04-20 15:56:26 +02:00
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
2024-04-20 20:27:06 +02:00
public class ProjectileTower : AimTower
{
2024-04-20 13:15:33 +02:00
[SerializeField, Range(0.01f, 20f)] private float attackSecondsDelay = 1f;
[SerializeField] private ProjectilePattern[] projectileSequence;
private ProjectileSpawner projectileSpawner;
protected override void Awake()
{
base.Awake();
projectileSpawner = GetComponent<ProjectileSpawner>();
Assert.IsNotNull(projectileSpawner);
2024-04-20 13:15:33 +02:00
StartCoroutine(AttackLoop());
}
private IEnumerator AttackLoop()
{
do {
yield return new WaitForSeconds(attackSecondsDelay);
Debug.DrawRay(transform.position, horizontalArc.ToKnobVector, Color.red, attackSecondsDelay);
Debug.DrawRay(transform.position, verticalArc.ToKnobVector, Color.green, attackSecondsDelay);
Debug.DrawRay(transform.position, AimDirection, Color.yellow, attackSecondsDelay);
2024-04-20 20:48:38 +02:00
projectileSpawner.RunBulletSequence(barrel.Tip.position, transform.up, AimDirection, projectileSequence);
2024-04-20 13:15:33 +02:00
} while (true);
}
}