2024-02-16 06:17:16 +00:00
|
|
|
|
2023-07-31 02:32:04 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2024-02-16 06:17:16 +00:00
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
2023-07-31 02:32:04 +00:00
|
|
|
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)
|
|
|
|
{
|
2024-02-16 06:17:16 +00:00
|
|
|
island.normalizedOffset = 1 - MathUtils.Normalize(island.startPos.z, minValueZ, maxValueZ);
|
2023-07-31 02:32:04 +00:00
|
|
|
island.normalizedOffset /= loopMult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|