using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices.WindowsRuntime; using UnityEngine; public class Fleet : MonoBehaviour { public float TravelDistanceTotal = 0; public int TravelTimeTotal = 0; public string Name { get; set; } public GameObject CurrentLocation; public GameObject Destination; public List Ships = new(); // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public int GetNumberOfShips() { return Ships.Count; } public int GetStrength() { int result = 0; foreach (Ship g in Ships) { result += g.Strength; } return result; } public int GetSpeed() { int result = FleetManager.maxSpeed; foreach (Ship g in Ships) { if (g.Speed < result) { result = g.Speed; } } return result; } public float GetTravelDistanceTotal() { float result = 0; Vector3 dest = Destination.transform.position; Vector3 curr = CurrentLocation.transform.position; Vector3 path = dest - curr; result = path.magnitude; return result; } public int GetTravelTimeTotal() { int result = 0; result = (int) (this.TravelDistanceTotal / this.GetSpeed()); return result; } public void SetDestination(GameObject destStarSystem) { if(this.CurrentLocation == destStarSystem) { return; } this.Destination = destStarSystem; this.TravelDistanceTotal = GetTravelDistanceTotal(); this.TravelTimeTotal = GetTravelTimeTotal(); //TODO: make fleet invisible } public void Travel() { this.TravelTimeTotal--; if (this.TravelTimeTotal == 0) //fleet arrived { //TODO put fleet into ui of destination Star System this.CurrentLocation = this.Destination; } } }