|
@@ -30,44 +30,52 @@ public class CoinCreation : MonoBehaviour
|
|
|
PlaceCoins();
|
|
|
}
|
|
|
|
|
|
+ int points_size = points.Count;
|
|
|
public void PlaceCoins()
|
|
|
{
|
|
|
- //Abstand zwischen den Coins berechnen
|
|
|
+ if ((pointIndex + 1) < points_size) // Check: sind noch mindestens 2 Punkte in der Liste?
|
|
|
+ {
|
|
|
+ //Abstand zwischen den Coins berechnen
|
|
|
|
|
|
- RoutePoint start_point = points[pointIndex];
|
|
|
- start_point.x = start_point.x + 190f; //offset wegen relativen Kreuzungskoordinaten
|
|
|
+ RoutePoint start_point = points[pointIndex];
|
|
|
+ start_point.x = start_point.x + 190f; //offset wegen relativen Kreuzungskoordinaten
|
|
|
|
|
|
- pointIndex++;
|
|
|
+ pointIndex++;
|
|
|
|
|
|
- RoutePoint end_point = points[pointIndex];
|
|
|
- end_point.x = end_point.x + 190f; //offset wegen relativen Kreuzungskoordinaten
|
|
|
+ RoutePoint end_point = points[pointIndex];
|
|
|
+ end_point.x = end_point.x + 190f; //offset wegen relativen Kreuzungskoordinaten
|
|
|
|
|
|
- float distance_x = System.Math.Abs(start_point.x - end_point.x);
|
|
|
- float distance_z = System.Math.Abs(start_point.z - end_point.z);
|
|
|
-
|
|
|
- float space_x = 0; //default
|
|
|
- float space_z = 0; //default
|
|
|
- if (distance_x > 0) // wenn entlang der x Richung verteilt wird
|
|
|
- {
|
|
|
- space_x = distance_x / stepsize;
|
|
|
- }
|
|
|
- if (distance_z > 0) // wenn entlang der z Richung verteilt wird
|
|
|
- {
|
|
|
- space_z = distance_z / stepsize;
|
|
|
- }
|
|
|
+ float distance_x = System.Math.Abs(start_point.x - end_point.x);
|
|
|
+ float distance_z = System.Math.Abs(start_point.z - end_point.z);
|
|
|
|
|
|
+ float space_x = 0; //default
|
|
|
+ float space_z = 0; //default
|
|
|
+ if (distance_x > 0) // wenn entlang der x Richung verteilt wird
|
|
|
+ {
|
|
|
+ space_x = distance_x / stepsize;
|
|
|
+ }
|
|
|
+ if (distance_z > 0) // wenn entlang der z Richung verteilt wird
|
|
|
+ {
|
|
|
+ space_z = distance_z / stepsize;
|
|
|
+ }
|
|
|
|
|
|
- for (int i = 0; i > stepsize; ++i)
|
|
|
- {
|
|
|
+
|
|
|
+ for (int i = 0; i > stepsize; ++i)
|
|
|
+ {
|
|
|
//position berechnen
|
|
|
coin_position.x = start_point.x + i * space_x;
|
|
|
coin_position.y = 0.5f;
|
|
|
- coin_position.z = start_point.z + i * space_z;
|
|
|
+ coin_position.z = start_point.z + i * space_z;
|
|
|
|
|
|
//Coin erstellen
|
|
|
coin = coinPool.GetItem();
|
|
|
coin.transform.position = coin_position;
|
|
|
coin.transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Debug.Log("The End of the Route is near, so no new coins needed!");
|
|
|
}
|
|
|
}
|
|
|
}
|