public async Task <InvokeResult <Mission> > GetWayPointsAsync(IConnectedUas uas) { var mission = new Mission(); var missionRequest = new UasMissionRequestList { TargetSystem = uas.Uas.SystemId, TargetComponent = uas.Uas.ComponentId }; var result = await uas.Transport.RequestDataAsync <UasMissionCount>(missionRequest, UasMessages.MissionCount); if (result.Successful) { for (ushort idx = 0; idx < result.Result.Count; ++idx) { var reqf = new UasMissionRequestInt { TargetSystem = uas.Uas.SystemId, TargetComponent = uas.Uas.ComponentId, Seq = idx }; var wpResult = await uas.Transport.RequestDataAsync <UasMissionItemInt>(reqf, UasMessages.MissionItemInt); if (wpResult.Successful) { mission.Waypoints.Add(Waypoint.Create(wpResult.Result)); } } } return(InvokeResult <Mission> .Create(mission)); }
public static Waypoint CreateWaypoint() { string name = "Waypoint "; int index = 0; while (GameObject.Find(name + ++index) != null) { ; } return(Waypoint.Create(Vector3.zero, HierarchyVisibility.Hidden, name + index)); }
private static IEnumerator GenerateLevelProccess() { ChunkModifier m; Vector2Int a; Vector2Int b; Vector3 position; int r; playing = 0; levelTime = 0; r = CurrentLevel.Radius; loadingProcces = 0; loadingProccesLimit = ((int)CurrentLevel.Path.Lenght / r) + CurrentLevel.Path.Nodes.Count; animatedLevelPreview = CurrentLevel.Preview; for (int x = 0; x < animatedLevelPreview.width; x++) { for (int y = 0; y < animatedLevelPreview.height; y++) { animatedLevelPreview.SetPixel(x, y, Color.white); } } animatedLevelPreview.Apply(); Chunk.Destroy(); Waypoint.Destroy(); //SetupModifiers() a = CurrentLevel.Path.Nodes[0]; b = Vector2Int.zero; for (int i = 0; i < CurrentLevel.Path.Nodes.Count; i++) { if (CurrentLevel.Path.Nodes[i].x < a.x) { a.x = CurrentLevel.Path.Nodes[i].x; } if (CurrentLevel.Path.Nodes[i].x > b.x) { b.x = CurrentLevel.Path.Nodes[i].x; } if (CurrentLevel.Path.Nodes[i].y > b.y) { b.y = CurrentLevel.Path.Nodes[i].y; } } a -= Vector2Int.one * CurrentLevel.Radius * 2; b += Vector2Int.one * CurrentLevel.Radius * 2; m = new ChunkModifier(a, (int)Mathf.Max(b.x - a.x, b.y - a.y)); m.DrawLevelPath(CurrentLevel, 4); yield return(null); loadingProcces++; Chunk.ClearModifiers(); Chunk.AddModifier(m); //GenerateChunks() for (int i = 1; i < CurrentLevel.Path.Lenght; i += r) { position = (Vector2)CurrentLevel.Path.Evaluate(i); for (int x = -r; x <= r; x += r) { for (int y = -r; y <= r; y += r) { Chunk.Update(position.x + x, position.y + y, 2); } } for (int j = 0; j < r; j++) { CurrentLevel.Path.Paint(ref animatedLevelPreview, j + i); } yield return(null); loadingProcces++; } //PlaceWaypoints() for (int i = 2; i < CurrentLevel.Path.Nodes.Count; i++) { position = (Vector2)CurrentLevel.Path.Nodes[i]; position.z = position.y; position.y = Terrain.GetSlope(position.z); Waypoint.Create(position, CurrentLevel.Radius * 2); yield return(null); loadingProcces++; } Player.transform.position = Vector3.forward; Player.transform.rotation = Quaternion.LookRotation(Vector3.forward); Camera.transform.position = Vector3.up; yield return(null); loadingProcces++; playing = 1; levelTime = 0; }