56 lines
1.2 KiB
C#
56 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FlareLauncher : MonoBehaviour
|
|
{
|
|
public GameObject flareProjectile;
|
|
//public int startingRounds;
|
|
private int rounds;
|
|
private float countdown;
|
|
public float firerate;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (rounds > 0)
|
|
{
|
|
if(countdown > 0)
|
|
{
|
|
countdown-=Time.deltaTime;
|
|
}
|
|
else
|
|
{
|
|
Instantiate(flareProjectile, transform.position, transform.rotation);
|
|
countdown = firerate;
|
|
rounds--;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ActivateFlares(int r)
|
|
{
|
|
PickupManager pm = GameObject.FindObjectOfType<PickupManager>();
|
|
|
|
pm.flarePickup.AddFlareCount(r * 2);
|
|
|
|
GameObject[] missles = GameObject.FindGameObjectsWithTag("missle");
|
|
|
|
foreach(GameObject m in missles)
|
|
{
|
|
if (m.GetComponent<missle>() != null)
|
|
{
|
|
m.GetComponent<missle>().SearchForFlares();
|
|
}
|
|
}
|
|
|
|
rounds = r;
|
|
countdown = 0;
|
|
}
|
|
}
|