VladimirPirozhenko 9067758171 Extracted code to Grid class, adjusted jump time to get better game feel
Also fixed scaling of score ui element
2022-08-14 06:14:54 +03:00

29 lines
794 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Grid
{
public readonly List<Vector3> GridPositions = new List<Vector3>();
private int gridRowCount;
public Grid(float gridLength)
{
gridRowCount = 1;
float rowLength = gridLength / gridRowCount;
foreach (var lane in LaneSystem.Instance.Lanes)
{
float lanePosition = lane * LaneSystem.Instance.LaneWidth;
for (int i = 0; i < gridRowCount; i++)
{
Vector3 gridPosition = new Vector3(lanePosition, 0, i * rowLength);
GridPositions.Add(gridPosition);
}
}
}
public Vector3 GetRandomPosition()
{
return GridPositions.GetRandomElement();
}
}