public SetTarget ( |
||
target | ||
Результат | void |
private bool startMenuOverlay(OverlayRenderer overlayRenderer) { if (!Misc.Parse(SettingsManager.GetValue("ShowInMenu"), true)) { return(false); } var objects = GameObject.FindObjectsOfType(typeof(GameObject)); if (objects.Any(o => o.name == "LoadingBuffer")) { return(false); } var kerbin = objects.OfType <GameObject>().Where(b => b.name == "Kerbin").LastOrDefault(); if (kerbin == null) { Debug.LogWarning("[Kethane] Couldn't find Kerbin!"); return(false); } overlayRenderer.SetTarget(kerbin.transform); overlayRenderer.SetRadiusMultiplier(1.02f); var random = new System.Random(); var colors = new CellMap <Color32>(KethaneData.GridLevel); foreach (var cell in Cell.AtLevel(KethaneData.GridLevel)) { var rand = random.Next(100); Color32 color; if (rand < 16) { color = rand < 4 ? new Color32(21, 176, 26, 255) : new Color32(128, 128, 128, 192); foreach (var neighbor in cell.GetNeighbors(KethaneData.GridLevel)) { if (random.Next(2) < 1) { colors[neighbor] = color; } } } else { color = new Color32(0, 0, 0, 128); } colors[cell] = color; } overlayRenderer.SetCellColors(colors); return(true); }
private bool startMenuOverlay(OverlayRenderer overlayRenderer) { if (!Misc.Parse(SettingsManager.GetValue("ShowInMenu"), true)) { return false; } var objects = GameObject.FindObjectsOfType(typeof(GameObject)); if (objects.Any(o => o.name == "LoadingBuffer")) { return false; } var kerbin = objects.OfType<GameObject>().Where(b => b.name == "Kerbin").LastOrDefault(); if (kerbin == null) { Debug.LogWarning("[Kethane] Couldn't find Kerbin!"); return false; } overlayRenderer.SetTarget(kerbin.transform); overlayRenderer.SetRadiusMultiplier(1.02f); var random = new System.Random(); var colors = new CellMap<Color32>(KethaneData.GridLevel); foreach (var cell in Cell.AtLevel(KethaneData.GridLevel)) { var rand = random.Next(100); Color32 color; if (rand < 16) { color = rand < 4 ? new Color32(21, 176, 26, 255) : new Color32(128, 128, 128, 192); foreach (var neighbor in cell.GetNeighbors(KethaneData.GridLevel)) { if (random.Next(2) < 1) { colors[neighbor] = color; } } } else { color = new Color32(0, 0, 0, 128); } colors[cell] = color; } overlayRenderer.SetCellColors(colors); return true; }
public void Update() { if (HighLogic.LoadedScene != GameScenes.FLIGHT && HighLogic.LoadedScene != GameScenes.TRACKSTATION) { Destroy(gameObject); return; } if (!MapView.MapIsEnabled || !ShowOverlay || MapView.MapCamera == null || KethaneData.Current == null) { overlayRenderer.IsVisible = false; return; } overlayRenderer.IsVisible = true; var target = MapView.MapCamera.target; var newBody = getTargetBody(target); var bodyChanged = (newBody != null) && (newBody != body); if (bodyChanged) { body = newBody; heightAt = getHeightRatioMap(); bounds = new BoundsMap(heightAt, KethaneData.GridLevel); overlayRenderer.SetHeightMap(heightAt); var radius = bodyRadii.ContainsKey(body) ? bodyRadii[body] : 1.025; var parent = ScaledSpace.Instance.scaledSpaceTransforms.FirstOrDefault(t => t.name == body.name); overlayRenderer.SetRadiusMultiplier((float)radius); overlayRenderer.SetTarget(parent); } if (bodyChanged || resource == null || resource.Resource != SelectedResource) { resource = KethaneController.ResourceDefinitions.Where(r => r.Resource == SelectedResource).Single(); refreshCellColors(); } var ray = MapView.MapCamera.camera.ScreenPointToRay(Input.mousePosition); hoverCell = Cell.Raycast(ray, KethaneData.GridLevel, bounds, heightAt, gameObject.transform); }