Sync issues were resolved enough to continue development.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
@@ -14,21 +15,22 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
[SerializeField] private GameManagerRound2 _GameManager;
|
||||
[SerializeField] private AudioManager _AudioManager;
|
||||
|
||||
[SerializeField] private MeshRenderer[] _LocationPanelInfoSheets;
|
||||
[SerializeField] private GameObject[] _LocationPanelsEmpty;
|
||||
[SerializeField] private GameObject[] _LocationPanelsLoot;
|
||||
[SerializeField] private GameObject[] _LocationPanelsWarrant;
|
||||
[SerializeField] private GameObject[] _LocationPanelsCrook;
|
||||
[SerializeField] private TextMeshProUGUI[] _LocationPanelText;
|
||||
|
||||
[UdonSynced, FieldChangeCallback(nameof(LootLocation))] private int _LootLocation = 0;
|
||||
[UdonSynced, FieldChangeCallback(nameof(WarrantLocation))] private int _WarrantLocation = 0;
|
||||
[UdonSynced, FieldChangeCallback(nameof(CrookLocation))] private int _CrookLocation = 0;
|
||||
|
||||
public MeshRenderer[] LocationPanelInfoSheets;
|
||||
public GameObject[] LocationPanelsEmpty;
|
||||
public GameObject[] LocationPanelsLoot;
|
||||
public GameObject[] LocationPanelsWarrant;
|
||||
public GameObject[] LocationPanelsCrook;
|
||||
public TextMeshProUGUI[] LocationPanelText;
|
||||
|
||||
[SerializeField] private Material[] _LocationSheetMaterialSelections;
|
||||
|
||||
private Animator _Animator;
|
||||
private VRCImageDownloader _LootImageDownloader;
|
||||
private Material _LootMaterial;
|
||||
|
||||
[UdonSynced] private int _ActiveSpinners = 0;
|
||||
[UdonSynced] private bool[] _OrderIsCorrect = new bool[3];
|
||||
@@ -39,10 +41,14 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
_HasBeenCheckedBefore = new bool[LocationPanelsEmpty.Length];
|
||||
|
||||
_Animator = GetComponent<Animator>();
|
||||
_LootImageDownloader = new VRCImageDownloader();
|
||||
|
||||
MeshRenderer LootMesh;
|
||||
if (LootMesh = _LocationPanelsLoot[0].GetComponent<MeshRenderer>())
|
||||
{
|
||||
_LootMaterial = LootMesh.sharedMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
@@ -50,6 +56,30 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
_LootImageDownloader.Dispose();
|
||||
}
|
||||
|
||||
public void PopulateBoard(string[] Landmarks)
|
||||
{
|
||||
_HasBeenCheckedBefore = new bool[_LocationPanelsEmpty.Length];
|
||||
|
||||
for (int i = 0; i < Landmarks.Length; i++)
|
||||
{
|
||||
_LocationPanelText[i].text = Landmarks[i];
|
||||
}
|
||||
}
|
||||
|
||||
private void GetLootImage()
|
||||
{
|
||||
if (_LootMaterial)
|
||||
{
|
||||
TextureInfo AdditionalTextureInfo = new TextureInfo();
|
||||
AdditionalTextureInfo.WrapModeU = TextureWrapMode.Clamp;
|
||||
AdditionalTextureInfo.WrapModeV = TextureWrapMode.Clamp;
|
||||
AdditionalTextureInfo.GenerateMipMaps = true;
|
||||
_LootImageDownloader.DownloadImage(
|
||||
_GameManager.GetLootImageURL(), _LootMaterial,
|
||||
null, AdditionalTextureInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[NetworkCallable]
|
||||
public void RevealPanel(int Panel)
|
||||
@@ -215,55 +245,37 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
{
|
||||
Random.InitState(Networking.GetServerTimeInMilliseconds());
|
||||
|
||||
LootLocation = Random.Range(0, LocationPanelsLoot.Length) + 1;
|
||||
LootLocation = Random.Range(0, _LocationPanelsLoot.Length) + 1;
|
||||
|
||||
int TempWarrantLocation = _LootLocation;
|
||||
while (TempWarrantLocation == _LootLocation)
|
||||
{
|
||||
TempWarrantLocation = Random.Range(0, LocationPanelsWarrant.Length) + 1;
|
||||
TempWarrantLocation = Random.Range(0, _LocationPanelsWarrant.Length) + 1;
|
||||
}
|
||||
WarrantLocation = TempWarrantLocation;
|
||||
|
||||
int TempCrookLocation = _WarrantLocation;
|
||||
while (TempCrookLocation == _WarrantLocation || TempCrookLocation == _LootLocation)
|
||||
{
|
||||
TempCrookLocation = Random.Range(0, LocationPanelsCrook.Length) + 1;
|
||||
TempCrookLocation = Random.Range(0, _LocationPanelsCrook.Length) + 1;
|
||||
}
|
||||
CrookLocation = TempCrookLocation;
|
||||
|
||||
for (int i = 0; i < LocationPanelsEmpty.Length; i++)
|
||||
for (int i = 0; i < _LocationPanelsEmpty.Length; i++)
|
||||
{
|
||||
_HasBeenCheckedBefore[i] = false;
|
||||
}
|
||||
|
||||
MeshRenderer LootMesh;
|
||||
if (LootMesh = LocationPanelsLoot[LootLocation - 1].GetComponent<MeshRenderer>())
|
||||
{
|
||||
TextureInfo AdditionalTextureInfo = new TextureInfo();
|
||||
AdditionalTextureInfo.WrapModeU = TextureWrapMode.Clamp;
|
||||
AdditionalTextureInfo.WrapModeV = TextureWrapMode.Clamp;
|
||||
AdditionalTextureInfo.GenerateMipMaps = true;
|
||||
_LootImageDownloader.DownloadImage(
|
||||
_GameManager.GetLootImageURL(),
|
||||
LootMesh.sharedMaterial,
|
||||
(IUdonEventReceiver)this,
|
||||
AdditionalTextureInfo);
|
||||
}
|
||||
|
||||
MeshRenderer CrookMesh;
|
||||
if (CrookMesh = LocationPanelsCrook[CrookLocation - 1].GetComponent<MeshRenderer>())
|
||||
if (CrookMesh = _LocationPanelsCrook[CrookLocation - 1].GetComponent<MeshRenderer>())
|
||||
{
|
||||
CrookMesh.sharedMaterial.SetTexture("_MainTex", _GameManager.GetCrookPortrait());
|
||||
}
|
||||
|
||||
RandomiseMaterials();
|
||||
|
||||
RequestSerialization();
|
||||
}
|
||||
|
||||
private void RandomiseMaterials()
|
||||
public void RandomiseMaterials()
|
||||
{
|
||||
int[] MaterialsArray = new int[LocationPanelInfoSheets.Length];
|
||||
int[] MaterialsArray = new int[_LocationPanelInfoSheets.Length];
|
||||
int PreviousMaterial = 0;
|
||||
for (int i = 0; i < MaterialsArray.Length; i++)
|
||||
{
|
||||
@@ -278,16 +290,14 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
}
|
||||
|
||||
RandomMaterialSettings = MaterialsArray;
|
||||
|
||||
RequestSerialization();
|
||||
}
|
||||
private void ApplyRandomMaterials()
|
||||
{
|
||||
for (int i = 0; i < RandomMaterialSettings.Length; i++)
|
||||
{
|
||||
Material[] Materials = LocationPanelInfoSheets[i].materials;
|
||||
Material[] Materials = _LocationPanelInfoSheets[i].materials;
|
||||
Materials[1] = _LocationSheetMaterialSelections[RandomMaterialSettings[i]];
|
||||
LocationPanelInfoSheets[i].materials = Materials;
|
||||
_LocationPanelInfoSheets[i].materials = Materials;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,11 +305,11 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
{
|
||||
if (Panel > 0)
|
||||
{
|
||||
LocationPanelsLoot[Panel - 1].SetActive(false);
|
||||
LocationPanelsWarrant[Panel - 1].SetActive(false);
|
||||
LocationPanelsCrook[Panel - 1].SetActive(false);
|
||||
_LocationPanelsLoot[Panel - 1].SetActive(false);
|
||||
_LocationPanelsWarrant[Panel - 1].SetActive(false);
|
||||
_LocationPanelsCrook[Panel - 1].SetActive(false);
|
||||
|
||||
LocationPanelsEmpty[Panel - 1].SetActive(true);
|
||||
_LocationPanelsEmpty[Panel - 1].SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,11 +317,11 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
{
|
||||
if (Panel > 0)
|
||||
{
|
||||
LocationPanelsEmpty[Panel - 1].SetActive(false);
|
||||
LocationPanelsWarrant[Panel - 1].SetActive(false);
|
||||
LocationPanelsCrook[Panel - 1].SetActive(false);
|
||||
_LocationPanelsEmpty[Panel - 1].SetActive(false);
|
||||
_LocationPanelsWarrant[Panel - 1].SetActive(false);
|
||||
_LocationPanelsCrook[Panel - 1].SetActive(false);
|
||||
|
||||
LocationPanelsLoot[Panel - 1].SetActive(true);
|
||||
_LocationPanelsLoot[Panel - 1].SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,11 +329,11 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
{
|
||||
if (Panel > 0)
|
||||
{
|
||||
LocationPanelsEmpty[Panel - 1].SetActive(false);
|
||||
LocationPanelsLoot[Panel - 1].SetActive(false);
|
||||
LocationPanelsCrook[Panel - 1].SetActive(false);
|
||||
_LocationPanelsEmpty[Panel - 1].SetActive(false);
|
||||
_LocationPanelsLoot[Panel - 1].SetActive(false);
|
||||
_LocationPanelsCrook[Panel - 1].SetActive(false);
|
||||
|
||||
LocationPanelsWarrant[Panel - 1].SetActive(true);
|
||||
_LocationPanelsWarrant[Panel - 1].SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,11 +341,11 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
{
|
||||
if (Panel > 0)
|
||||
{
|
||||
LocationPanelsEmpty[Panel - 1].SetActive(false);
|
||||
LocationPanelsLoot[Panel - 1].SetActive(false);
|
||||
LocationPanelsWarrant[Panel - 1].SetActive(false);
|
||||
_LocationPanelsEmpty[Panel - 1].SetActive(false);
|
||||
_LocationPanelsLoot[Panel - 1].SetActive(false);
|
||||
_LocationPanelsWarrant[Panel - 1].SetActive(false);
|
||||
|
||||
LocationPanelsCrook[Panel - 1].SetActive(true);
|
||||
_LocationPanelsCrook[Panel - 1].SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,6 +357,8 @@ public class LocationBoard : UdonSharpBehaviour
|
||||
PlaceEmpty(_LootLocation);
|
||||
_LootLocation = value;
|
||||
PlaceLoot(value);
|
||||
|
||||
GetLootImage();
|
||||
}
|
||||
get => _LootLocation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user