public void Initialize(WaypointsInfo points, Vector3 targetHitPoint) { targetWaypoint = 1; waypoints = points; targetHitPosition = targetHitPoint; hasReachedDestination = false; base.Initialize(); }
private List <WaypointsInfo> GetClosestWPList(int WPNO, int Course, int WPRange, int FinishWaypoint) { List <WaypointsInfo> Result = new List <WaypointsInfo>(); MainForm.WayPoints WP = new MainForm.WayPoints(); WP.X = WowControl.WP[WPNO].X; WP.Y = WowControl.WP[WPNO].Y; WP.Z = WowControl.WP[WPNO].Z; for (int i = 0; i < WowControl.WP.Length; i++) { double Range = WowControl.CheckPoint(WowControl.WP[i].X, WowControl.WP[i].Y, WowControl.WP[i].Z, WP.X, WP.Y, WP.Z); if ((Range < WPRange) & (WaypointAlreadyInCourse(i, Course) == false)) { WaypointsInfo Temp = new WaypointsInfo(); Temp.Index = i; Temp.Range = Range; Result.Add(Temp); } } Result.Sort((a, b) => a.Range.CompareTo(b.Range)); return(Result); }
private void CalculateCourses() { for (int i = 0; i < Courses.Count; i++) { if (CourseIsBad(i) == false) { int CourseLenght = 0; for (int c = 0; c < Courses[i].Count; c++) { if (c < Courses[i].Count - 1) { CourseLenght += (int)WowControl.CheckPoint(WowControl.WP[Courses[i][c]].X, WowControl.WP[Courses[i][c]].Y, WowControl.WP[Courses[i][c]].Z, WowControl.WP[Courses[i][c + 1]].X, WowControl.WP[Courses[i][c + 1]].Y, WowControl.WP[Courses[i][c + 1]].Z); } } WaypointsInfo Temp = new WaypointsInfo(); Temp.Index = i; Temp.Range = CourseLenght; CalculatedCourses.Add(Temp); } } }
IEnumerator SpawnShip() { while (isActive) { int waypointIndex = Random.Range(0, maxPointSelectionIndex); pointInfo = shuffledSpawnPoints [waypointIndex]; int shipIndex = Random.Range(StartShipSelectionIndex, EndShipSelectionIndex + 1); Ship spawnedShip = Instantiate(shipPrefab[shipIndex], pointInfo.StartingPoint.position, Quaternion.identity, shipParent); spawnedShip.Initialize(pointInfo, targetHitPosition); audioSource.PlayOneShot(shipSpawn); spawnedShip.OnDeath += SpawnedShip_OnDeath; shuffledSpawnPoints.RemoveAt(waypointIndex); shuffledSpawnPoints.Add(pointInfo); spawnedShips.Add(spawnedShip); yield return(new WaitForSeconds(ShipSpawnDelay)); } }
private List<WaypointsInfo> GetClosestWPList(int WPNO, int Course, int WPRange, int FinishWaypoint) { List<WaypointsInfo> Result = new List<WaypointsInfo>(); MainForm.WayPoints WP = new MainForm.WayPoints(); WP.X = WowControl.WP[WPNO].X; WP.Y = WowControl.WP[WPNO].Y; WP.Z = WowControl.WP[WPNO].Z; for (int i = 0; i < WowControl.WP.Length; i++) { double Range = WowControl.CheckPoint(WowControl.WP[i].X, WowControl.WP[i].Y, WowControl.WP[i].Z, WP.X, WP.Y, WP.Z); if ((Range < WPRange) & (WaypointAlreadyInCourse(i, Course) == false)) { WaypointsInfo Temp = new WaypointsInfo(); Temp.Index = i; Temp.Range = Range; Result.Add(Temp); } } Result.Sort((a, b) => a.Range.CompareTo(b.Range)); return Result; }
private void CalculateCourses() { for (int i = 0; i < Courses.Count; i++) { if (CourseIsBad(i) == false) { int CourseLenght = 0; for (int c = 0; c < Courses[i].Count; c++) { if (c < Courses[i].Count - 1) CourseLenght += (int)WowControl.CheckPoint(WowControl.WP[Courses[i][c]].X, WowControl.WP[Courses[i][c]].Y, WowControl.WP[Courses[i][c]].Z, WowControl.WP[Courses[i][c + 1]].X, WowControl.WP[Courses[i][c + 1]].Y, WowControl.WP[Courses[i][c + 1]].Z); } WaypointsInfo Temp = new WaypointsInfo(); Temp.Index = i; Temp.Range = CourseLenght; CalculatedCourses.Add(Temp); } } }