Completed course 2 adn 3, working on 4

This commit is contained in:
2026-03-20 17:34:22 +00:00
parent 623ad6f509
commit db966bab55
507 changed files with 67348 additions and 4667 deletions

View File

@@ -22,7 +22,7 @@ public class UnitMover : MonoBehaviour
Vector3[] destinations = new Vector3[numUnits];
//calculate the rows and columns
int rows = Mathf.RoundToInt(Mathf.Sqrt(numUnits));
int cols = Mathf.CeilToInt((float)numUnits / rows);
int cols = Mathf.CeilToInt((float)numUnits / (float)rows);
//we need to know the current row and column we're calculating
int curRow = 0;
int curCol = 0;
@@ -30,7 +30,7 @@ public class UnitMover : MonoBehaviour
float length = ((float)cols - 1) * unitGap;
for(int x = 0; x < numUnits; x++)
{
destinations[x] = moveToPos = (new Vector3(curRow, 0, curCol) * unitGap) - new Vector3(length / 2, 0, width / 2);
destinations[x] = moveToPos + (new Vector3(curRow, 0, curCol) * unitGap) - new Vector3(length / 2, 0, width / 2);
curCol++;
if(curCol == rows)
{
@@ -43,7 +43,7 @@ public class UnitMover : MonoBehaviour
public static Vector3[] GetUnitGroupDestinationsAroundResource(Vector3 resourcePos, int unitsNum)
{
Vector3[] destinations = new Vector3[unitsNum];
float unitDistanceGap = 160.0f / (float)unitsNum;
float unitDistanceGap = 360.0f / (float)unitsNum;
for(int x = 0; x < unitsNum; x++)
{
float angle = unitDistanceGap * x;
@@ -56,6 +56,6 @@ public class UnitMover : MonoBehaviour
{
float angle = Random.Range(0, 360);
Vector3 dir = new Vector3(Mathf.Sin(angle * Mathf.Deg2Rad), 0, Mathf.Cos(angle * Mathf.Deg2Rad));
return resourcePos;
return resourcePos + dir;
}
}