private void PopulateGridWithRandomGems(int numberOfRows, int numberOfColumns) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); var rand = new System.Random(); foreach (var point in grid.GridPoints) { var randomGem = gems[rand.Next(0, gems.Count)]; var gem = Instantiate(randomGem); grid.UpdateGridPoint(point.Position, gem); gem.GetComponent <MoveScript>().MoveToPosition(point.Position); gem.name = $"{point.Position}"; } // TODO: REFACTOR: Average guess that this finds a good enough distance for the camera to see everything var centerGemPosition = new Vector3(numberOfRows / 2, numberOfColumns / 2, -(numberOfRows / 2 + numberOfColumns / 2) - 1); Camera.main.GetComponent <MoveScript>().MoveToPosition(centerGemPosition); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; UnityEngine.Debug.Log($"Time taken to generate grid: {ts.ToString()}\n {grid.ToString()}"); }
public override string ToString() { return(gemGrid?.ToString()); }