// public void RegisterShip(ShipClass ship, List <ShipClass> list) { if (list.Contains(ship)) { ship.GetComponent <UIController>().ToggleUI(true); return; } list.Add(ship); ship.GetComponent <UIController>().ToggleUI(true); }
public IEnumerator AutomatedShoot() { ShipClass target = null; Rigidbody rb = null; if (shipClass.Fleet.Enemies.Count < 1) { useTargettingSystem = false; yield break; } int random = Random.Range(0, shipClass.Fleet.Enemies.Count - 1); if (shipClass.Fleet != null) { target = shipClass.Fleet.Enemies[random]; rb = target.GetComponent <Rigidbody>(); } while (target != null && transform != null && target.Alive && shipClass.Alive) { float distance = Vector3.Distance(transform.position, target.transform.position); float time = distance / 600f; Vector3 lead = rb.velocity * time; weapons.Target(target.transform.position + lead); weapons.Fire(target.transform.position + lead); yield return(new WaitForSeconds(0.025f)); } StartCoroutine(AutomatedShoot()); yield return(null); }
public void UnregisterShip(ShipClass ship, List <ShipClass> list) { list.Remove(ship); ship.GetComponent <UIController>().ToggleUI(false); }