private IEnumerator Scanning(float time) { systemScanning = true; buttonText.text = "SCANNING"; float buttonBgWidth = 0; float timeElapsed = 0; float timePerc = 0; while (timeElapsed < time) { timePerc = timeElapsed / time; buttonBgWidth = timePerc * buttonBgWidthMax; buttonBgRect.sizeDelta = new Vector2(buttonBgWidth, 0); buttonBgImg.color = Color.Lerp(buttonBgColMin, buttonBgColMax, timePerc); timeElapsed += 0.01f; yield return(new WaitForSeconds(0.01f)); } starVisScreen.DrawVisualisations(World.GetLocation().sys); starVisScreen.ChangeScreen(true); World.Star currStar = World.GetLocation().sys.star; topContainer.SetActive(true); topOutline.enabled = false; Write(currStar.type, typeText); yield return(new WaitForSeconds(1.1f)); Write(currStar.temperature + "K", tempText); yield return(new WaitForSeconds(0.8f)); Write(currStar.type, descTypeText); yield return(new WaitForSeconds(0.6f)); Write(currStar.description, descText); systemScanned = true; systemScanning = false; buttonText.text = "SCANNED"; }
public void DrawVisualisations(World.Sys sys) { Vector2 canvasDiam = canvasRect.sizeDelta; star = new VisImage(); planets = new List <VisImage>(); #region Init //Star World.Star starObj = sys.star; star.type = starObj.type; star.id = starObj.id; star.color = starObj.visColor; star.sprite = starSprite; star.size = starObj.visSize; //Planets foreach (World.Planet planet in sys.planets) { Sprite sprite; if (!planet.field) { sprite = planetSprite; } else { sprite = fieldSprite; } VisImage planetVis = new VisImage { type = planet.type, id = planet.id, color = planet.visColor, sprite = sprite, field = planet.field }; planets.Add(planetVis); } #endregion #region Positions float paddingFromStar = (star.size / 2) * 1.5f; star.posX = 0; float planetsTotalWidth = 0; foreach (VisImage planet in planets) { planetsTotalWidth += planet.size; } float canvasTotal = (canvasDiam.x / 2) - paddingFromStar; float planetsTotalSpace = canvasTotal - planetsTotalWidth; float planetsSpace = planetsTotalSpace / planets.Count; for (int i = 0; i <= planets.Count - 1; i++) { VisImage planet = planets[i]; float virtPosX = ((planet.size + planetsSpace) * i) + paddingFromStar; planet.virtPosX = virtPosX; if (virtPosX > canvasDiam.x / 2) { virtPosX = (canvasDiam.x / 2) - planet.size; } if (!planet.field) { planet.posX = virtPosX; } else { planet.posX = 0; } } #endregion #region Sizes for (int i = 0; i <= planets.Count - 1; i++) { VisImage planetVis = planets[i]; World.Planet planet = World.GetLocation().sys.planets[i]; if (!planetVis.field) { planetVis.size = planet.visSize; } else { planetVis.size = planetVis.virtPosX * 2; } } #endregion #region Render DrawVisualisation(star); foreach (VisImage planet in planets) { DrawVisualisation(planet); if (!planet.field) { DrawOrbit(planet); } //Set a random orbit point planet.rect.RotateAround(star.rect.position, Vector3.right, Random.Range(0, 360)); } #endregion displaying = true; }