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(); pm.flarePickup.AddFlareCount(r * 2); GameObject[] missles = GameObject.FindGameObjectsWithTag("missle"); foreach(GameObject m in missles) { if (m.GetComponent() != null) { m.GetComponent().SearchForFlares(); } } rounds = r; countdown = 0; } }