SanAndreasUnity/Assets/Scripts/Behaviours/Vehicles/RadioStation.cs

56 lines
1.7 KiB
C#
Raw Normal View History

using SanAndreasUnity.Behaviours.Audio;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace SanAndreasUnity.Behaviours.Vehicles
{
public class RadioStation
{
private static readonly string[] streams = { "CH", "CO", "CR", "DS", "HC", "MH", "MR", "NJ", "RE", "RG", "TK" };
2020-05-05 15:45:06 +00:00
public static readonly string[] StationNames = { "PlayBack FM", "KRose", "K-DST", "Bounce FM", "SFUR", "Radio Los Santos", "Radio X", "CSR", "K-Jah", "Master Sounds", "WCTR" };
private static readonly int startIndex = 3;
private static readonly int endIndex = 114;
private static RadioStation[] _stations;
public static RadioStation[] stations
{
get
{
if (_stations == null)
{
_stations = new RadioStation[streams.Length];
int i = 0;
foreach (var stream in streams)
{
_stations[i++] = new RadioStation(stream);
}
}
return _stations;
}
}
private readonly string streamName;
private int clipIndex;
2019-11-18 14:08:57 +00:00
public AudioClip LoadCurrentClip() { return AudioManager.CreateAudioClipFromStream(streamName, clipIndex); }
public float currentTime;
private RadioStation(string streamName)
{
this.streamName = streamName;
clipIndex = Random.Range(startIndex, endIndex);
currentTime = 0.0f;
}
public void NextClip()
{
clipIndex++;
if (clipIndex > endIndex)
clipIndex = startIndex;
currentTime = 0.0f;
}
}
}