- Map markers have a lit texture when they are on the correct location.
- Markers now expire when they end up finding no collisions for long enough.
This commit is contained in:
@@ -44,7 +44,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 5
|
||||
Data: 7
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -248,19 +248,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _CollidingLocations
|
||||
Data: _LitLampMaterial
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _CollidingLocations
|
||||
Data: _LitLampMaterial
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 18|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: VRC.SDK3.Data.DataList, VRCSDK3
|
||||
Data: UnityEngine.Material, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@@ -278,10 +278,70 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 20|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _CollidingLocations
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _CollidingLocations
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 22|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: VRC.SDK3.Data.DataList, VRCSDK3
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 22
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -305,13 +365,13 @@ MonoBehaviour:
|
||||
Data: _CollisionCheckCounter
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _CollisionCheckCounter
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 21|System.RuntimeType, mscorlib
|
||||
Data: 25|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32, mscorlib
|
||||
@@ -320,7 +380,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 21
|
||||
Data: 25
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -335,7 +395,55 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _NoCollisionCounter
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _NoCollisionCounter
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 25
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 25
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 28|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
|
||||
@@ -14,10 +14,14 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
|
||||
[SerializeField] private GameManagerRound3 _GameManager;
|
||||
|
||||
[SerializeField] private Material _LitLampMaterial;
|
||||
|
||||
private DataList _CollidingLocations = new DataList();
|
||||
private int _CollisionCheckCounter = 0;
|
||||
private int _NoCollisionCounter = 0;
|
||||
|
||||
private const int MAX_REPEAT_COLLISION_CHECKS = 3;
|
||||
private const int MAX_TIME_WITH_NO_COLLISIONS = 8;
|
||||
private const float TIME_BETWEEN_REPEAT_COLLISION_CHECKS = 0.15f;
|
||||
|
||||
|
||||
@@ -28,6 +32,7 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
{
|
||||
_CollidingLocations.Add(Location);
|
||||
_CollisionCheckCounter = 0;
|
||||
_NoCollisionCounter = 0;
|
||||
if (!IsGrabbed) CheckCollisions();
|
||||
}
|
||||
}
|
||||
@@ -39,6 +44,7 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
{
|
||||
_CollidingLocations.Remove(Location);
|
||||
_CollisionCheckCounter = 0;
|
||||
_NoCollisionCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +58,7 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
|
||||
LocationFindingEnabled = true;
|
||||
IsGrabbed = true;
|
||||
_NoCollisionCounter = 0;
|
||||
_CollidingLocations.Clear();
|
||||
|
||||
base.OnPickup();
|
||||
@@ -67,6 +74,7 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
transform.eulerAngles = new Vector3(0.0f, transform.eulerAngles.y, 0.0f);
|
||||
}
|
||||
|
||||
_NoCollisionCounter = 0;
|
||||
CheckCollisions();
|
||||
|
||||
base.OnDrop();
|
||||
@@ -75,10 +83,12 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
|
||||
public void CheckCollisions()
|
||||
{
|
||||
if (!LocationFindingEnabled) return;
|
||||
if (!LocationFindingEnabled || IsGrabbed) return;
|
||||
|
||||
if (_CollidingLocations.Count > 0 && IsUpright() && !IsGrabbed)
|
||||
if (_CollidingLocations.Count > 0 && IsUpright())
|
||||
{
|
||||
_NoCollisionCounter = 0;
|
||||
|
||||
for (int i = 0; i < _CollidingLocations.Count; i++)
|
||||
{
|
||||
FloorMapLocation Location = (FloorMapLocation)_CollidingLocations[i].Reference;
|
||||
@@ -87,8 +97,7 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
bool FoundCorrectResponse = ConfirmChoice(Location.Country, Location.City);
|
||||
if (FoundCorrectResponse)
|
||||
{
|
||||
DisableMovementCompletely(Location);
|
||||
_GameManager.CorrectResponse();
|
||||
SendCorrectResponse(Location);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -102,20 +111,24 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
DisableMovementCompletely();
|
||||
|
||||
_GameManager.IncorrectResponse();
|
||||
|
||||
_CollisionCheckCounter = 0;
|
||||
_CollidingLocations.Clear();
|
||||
SendIncorrectResponse();
|
||||
}
|
||||
_CollisionCheckCounter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the marker isn't sitting mostly upright and is not grabbed,
|
||||
// don't check collisions until later, in case it becomes upright.
|
||||
SendCustomEventDelayedSeconds(nameof(CheckCollisions), TIME_BETWEEN_REPEAT_COLLISION_CHECKS);
|
||||
_NoCollisionCounter++;
|
||||
Debug.Log("No collisions for " + _NoCollisionCounter + " ticks.");
|
||||
if (_NoCollisionCounter >= MAX_TIME_WITH_NO_COLLISIONS)
|
||||
{
|
||||
SendIncorrectResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the marker isn't sitting mostly upright and is not grabbed,
|
||||
// don't check collisions until later, in case it becomes upright.
|
||||
SendCustomEventDelayedSeconds(nameof(CheckCollisions), TIME_BETWEEN_REPEAT_COLLISION_CHECKS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +144,31 @@ public class FloorMapMarker : UdonSharpBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SendCorrectResponse(FloorMapLocation CorrectLocation)
|
||||
{
|
||||
DisableMovementCompletely(CorrectLocation);
|
||||
|
||||
MeshRenderer MarkerMesh;
|
||||
if (MarkerMesh = GetComponent<MeshRenderer>())
|
||||
{
|
||||
Material[] Materials = MarkerMesh.materials;
|
||||
Materials[2] = _LitLampMaterial;
|
||||
MarkerMesh.materials = Materials;
|
||||
}
|
||||
|
||||
_GameManager.CorrectResponse();
|
||||
}
|
||||
|
||||
private void SendIncorrectResponse()
|
||||
{
|
||||
DisableMovementCompletely();
|
||||
|
||||
_GameManager.IncorrectResponse();
|
||||
|
||||
_CollisionCheckCounter = 0;
|
||||
_CollidingLocations.Clear();
|
||||
}
|
||||
|
||||
public void EnablePickup(bool Enable)
|
||||
{
|
||||
VRCPickup Pickup;
|
||||
|
||||
Reference in New Issue
Block a user