Commit e64749d5 authored by Patryk Woźnicki's avatar Patryk Woźnicki

Fixed Basic Example

parent ad73f5e4
......@@ -237,7 +237,7 @@ MonoBehaviour:
_parent: {fileID: 4211513374172175099}
_visualizationSpeed: 0.1
_gridWidth: 19
_gridHeight: 19
_gridHeight: 15
_coverPercentage: 0.1
_samples: 10
--- !u!4 &1165111858
......
fileFormatVersion: 2
guid: a0c86a7082294a5d983c72c69c41d534
timeCreated: 1579192603
\ No newline at end of file
......@@ -21,8 +21,8 @@ namespace Mini.Procgen.Examples
private Transform _parent = null;
[SerializeField]
private float _visualizationSpeed = 0.1f;
[Space(10)]
[Space(10)]
[SerializeField, Range(2, 19)]
private int _gridWidth = 19;
[SerializeField, Range(2, 19)]
......@@ -31,7 +31,7 @@ namespace Mini.Procgen.Examples
private float _coverPercentage = 0.5f;
[SerializeField]
private int _samples = 10;
private List<GameObject> _pointsList = new List<GameObject>();
private Coroutine _scatterRoutine = null;
#endregion Private Fields
......@@ -58,7 +58,7 @@ namespace Mini.Procgen.Examples
point.SetActive(false);
Destroy(point);
}
_scatterRoutine = StartCoroutine(ScatterRoutine());
}
}
......@@ -75,12 +75,13 @@ namespace Mini.Procgen.Examples
{
List<Vector2Int> points = SimpleScatter.ScatterOnGrid(this._gridWidth, this._gridHeight, this._coverPercentage, this._samples);
WaitForSecondsRealtime wait = new WaitForSecondsRealtime(this._visualizationSpeed);
foreach (Vector2Int point in points)
{
GameObject pointGO = Instantiate(this._prefab, this._parent, false);
pointGO.transform.position = CalculatePointGameObjectPosition(point);
this._pointsList.Add(pointGO);
yield return wait;
}
......@@ -89,7 +90,7 @@ namespace Mini.Procgen.Examples
private Vector3 CalculatePointGameObjectPosition(Vector2Int point)
{
return new Vector3(-4.5f + point.x * 0.5f, 0, -4.5f + point.y * 0.5f);
return new Vector3(-((this._gridWidth - 1) / 2f * 0.5f) + point.x * 0.5f, 0, -((this._gridHeight - 1) / 2f * 0.5f) + point.y * 0.5f);
}
#endregion Private Methods
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment