2025-06-24 04:27:10 -04:00

80 lines
1.9 KiB
C#

using System;
using System.Linq;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDKBase;
using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class FloorMap : UdonSharpBehaviour
{
public FloorMapCountry[] Countries;
private string[] _ChosenCountries = new string[MAX_SELECTED_COUNTRIES];
private string[] _ChosenCities = new string[MAX_SELECTED_COUNTRIES];
private int _CurrentCountry = 0;
private const int MAX_SELECTED_COUNTRIES = 13;
public void RandomiseCountries()
{
_CurrentCountry = 0;
UnityEngine.Random.InitState(Networking.GetServerTimeInMilliseconds());
FloorMapCountry[] SelectedCountries = new FloorMapCountry[MAX_SELECTED_COUNTRIES];
for (int i = 0; i < MAX_SELECTED_COUNTRIES; i++)
{
int NewPulledIndex = UnityEngine.Random.Range(0, Countries.Length);
while (Countries[NewPulledIndex].gameObject.activeSelf)
{
NewPulledIndex = UnityEngine.Random.Range(0, Countries.Length);
}
FloorMapCountry Country = Countries[NewPulledIndex];
Country.gameObject.SetActive(true);
SelectedCountries[i] = Countries[NewPulledIndex];
FloorMapLocation Location = Country.Locations[UnityEngine.Random.Range(0, Country.Locations.Length)];
Location.gameObject.SetActive(true);
_ChosenCountries[i] = Location.Country;
_ChosenCities[i] = Location.City;
}
Debug.LogError("Current location: " + _ChosenCities[_CurrentCountry] + ", " + _ChosenCountries[_CurrentCountry]);
}
public int NextCountry()
{
_CurrentCountry++;
if (_CurrentCountry >= MAX_SELECTED_COUNTRIES)
{
Debug.LogError("We ran out of countries. Just end the game here.");
return -1;
}
return _CurrentCountry;
}
public int GetCurrentCountryIndex()
{
return _CurrentCountry;
}
public string GetCurrentCountry()
{
return _ChosenCountries[_CurrentCountry];
}
public string GetCurrentCity()
{
return _ChosenCities[_CurrentCountry];
}
}