HeavenStudioPlus/Assets/Scripts/Games/AirRally/IslandsManager.cs
minenice55 dd9a06ad52
Change Project License to MIT (#700)
* license change

replace unneeded package

* reword this
2024-02-16 06:17:16 +00:00

50 lines
1.4 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_AirRally
{
public class IslandsManager : MonoBehaviour
{
[Header("Properties")]
[SerializeField] private float loopMult = 1f;
[NonSerialized] public float endZ;
public float speedMult = 1f;
[NonSerialized] public float additionalSpeedMult = 1;
[SerializeField] private RvlIsland[] islands;
private float fullLengthZ;
private void Start()
{
speedMult /= loopMult;
float[] allZ = new float[islands.Length];
for (int i = 0; i < islands.Length; i++)
{
islands[i].manager = this;
allZ[i] = islands[i].startPos.z;
}
if (islands.Length > 0)
{
float minValueZ = Mathf.Min(allZ);
float maxValueZ = Mathf.Max(allZ);
fullLengthZ = maxValueZ - minValueZ;
endZ = -fullLengthZ * loopMult;
foreach (var island in islands)
{
island.normalizedOffset = 1 - MathUtils.Normalize(island.startPos.z, minValueZ, maxValueZ);
island.normalizedOffset /= loopMult;
}
}
}
}
}