nathaniel.buck@unity3d.com
3 年前
当前提交
684cd853
共有 39 个文件被更改,包括 4138 次插入 和 1161 次删除
-
8Assets/Art/Glyph/Symbols.png.meta
-
36Assets/Prefabs/UI/UserCardPanel.prefab
-
999Assets/Prefabs/NGO/SymbolObject.prefab
-
1Assets/Prefabs/NGO/SymbolContainer.prefab
-
222Assets/Prefabs/NGO/PlayerCursor.prefab
-
945Assets/Prefabs/NGO/InGameLogic.prefab
-
8Assets/Scripts/Game/LocalLobby.cs
-
4Assets/Scripts/Infrastructure/Messenger.cs
-
1Assets/Scripts/Lobby/LobbyContentHeartbeat.cs
-
5Assets/Scripts/Lobby/ToLocalLobby.cs
-
89Assets/Scripts/Netcode/InGameRunner.cs
-
31Assets/Scripts/Netcode/PlayerCursor.cs
-
34Assets/Scripts/Netcode/Scorer.cs
-
100Assets/Scripts/Netcode/SequenceSelector.cs
-
12Assets/Scripts/Netcode/SetupInGame.cs
-
5Assets/Scripts/Netcode/SymbolContainer.cs
-
14Assets/Scripts/Netcode/SymbolObject.cs
-
3Assets/Scripts/Relay/RelayUtpHost.cs
-
8Packages/manifest.json
-
26Packages/packages-lock.json
-
6ProjectSettings/Packages/com.unity.services.vivox/Settings.json
-
1001Assets/Prefabs/NGO/IntroAnimation.anim
-
8Assets/Prefabs/NGO/IntroAnimation.anim.meta
-
213Assets/Prefabs/NGO/IntroOutroAnimator.controller
-
8Assets/Prefabs/NGO/IntroOutroAnimator.controller.meta
-
231Assets/Prefabs/NGO/OutroAnimation.anim
-
8Assets/Prefabs/NGO/OutroAnimation.anim.meta
-
40Assets/Scripts/Netcode/IntroOutroRunner.cs
-
11Assets/Scripts/Netcode/IntroOutroRunner.cs.meta
-
123Assets/Scripts/Netcode/NetworkedDataStore.cs
-
11Assets/Scripts/Netcode/NetworkedDataStore.cs.meta
-
24Assets/Scripts/Netcode/PlayerData.cs
-
11Assets/Scripts/Netcode/PlayerData.cs.meta
-
34Assets/Scripts/Netcode/ResultsUserUI.cs
-
11Assets/Scripts/Netcode/ResultsUserUI.cs.meta
-
1001Assets/Prefabs/Runes/icon_bg.prefab
-
7Assets/Prefabs/Runes/icon_bg.prefab.meta
-
0/Assets/Prefabs/NGO
-
0/Assets/Prefabs/NGO.meta
999
Assets/Prefabs/NGO/SymbolObject.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
945
Assets/Prefabs/NGO/InGameLogic.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
1001
Assets/Prefabs/NGO/IntroAnimation.anim
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 3a2b72af2ce1fa542abc8f6966bb93ff |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 7400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1102 &-4718454066486239908 |
|||
AnimatorState: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 1 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: IntroAnimation |
|||
m_Speed: 1 |
|||
m_CycleOffset: 0 |
|||
m_Transitions: |
|||
- {fileID: -2422862649711649101} |
|||
m_StateMachineBehaviours: [] |
|||
m_Position: {x: 50, y: 50, z: 0} |
|||
m_IKOnFeet: 0 |
|||
m_WriteDefaultValues: 1 |
|||
m_Mirror: 0 |
|||
m_SpeedParameterActive: 0 |
|||
m_MirrorParameterActive: 0 |
|||
m_CycleOffsetParameterActive: 0 |
|||
m_TimeParameterActive: 0 |
|||
m_Motion: {fileID: 7400000, guid: 3a2b72af2ce1fa542abc8f6966bb93ff, type: 2} |
|||
m_Tag: |
|||
m_SpeedParameter: |
|||
m_MirrorParameter: |
|||
m_CycleOffsetParameter: |
|||
m_TimeParameter: |
|||
--- !u!1101 &-3457292013045787442 |
|||
AnimatorStateTransition: |
|||
m_ObjectHideFlags: 1 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: |
|||
m_Conditions: |
|||
- m_ConditionMode: 1 |
|||
m_ConditionEvent: DoIntro |
|||
m_EventTreshold: 0 |
|||
m_DstStateMachine: {fileID: 0} |
|||
m_DstState: {fileID: -4718454066486239908} |
|||
m_Solo: 0 |
|||
m_Mute: 0 |
|||
m_IsExit: 0 |
|||
serializedVersion: 3 |
|||
m_TransitionDuration: 0 |
|||
m_TransitionOffset: 0 |
|||
m_ExitTime: 0.75 |
|||
m_HasExitTime: 0 |
|||
m_HasFixedDuration: 1 |
|||
m_InterruptionSource: 0 |
|||
m_OrderedInterruption: 1 |
|||
m_CanTransitionToSelf: 1 |
|||
--- !u!1101 &-2422862649711649101 |
|||
AnimatorStateTransition: |
|||
m_ObjectHideFlags: 1 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: |
|||
m_Conditions: |
|||
- m_ConditionMode: 1 |
|||
m_ConditionEvent: DoOutro |
|||
m_EventTreshold: 0 |
|||
m_DstStateMachine: {fileID: 0} |
|||
m_DstState: {fileID: 6302186184720228616} |
|||
m_Solo: 0 |
|||
m_Mute: 0 |
|||
m_IsExit: 0 |
|||
serializedVersion: 3 |
|||
m_TransitionDuration: 0 |
|||
m_TransitionOffset: 0 |
|||
m_ExitTime: 0 |
|||
m_HasExitTime: 0 |
|||
m_HasFixedDuration: 1 |
|||
m_InterruptionSource: 0 |
|||
m_OrderedInterruption: 1 |
|||
m_CanTransitionToSelf: 1 |
|||
--- !u!1102 &-915027616136477805 |
|||
AnimatorState: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 1 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: Idle |
|||
m_Speed: 1 |
|||
m_CycleOffset: 0 |
|||
m_Transitions: |
|||
- {fileID: -3457292013045787442} |
|||
m_StateMachineBehaviours: [] |
|||
m_Position: {x: 50, y: 50, z: 0} |
|||
m_IKOnFeet: 0 |
|||
m_WriteDefaultValues: 1 |
|||
m_Mirror: 0 |
|||
m_SpeedParameterActive: 0 |
|||
m_MirrorParameterActive: 0 |
|||
m_CycleOffsetParameterActive: 0 |
|||
m_TimeParameterActive: 0 |
|||
m_Motion: {fileID: 0} |
|||
m_Tag: |
|||
m_SpeedParameter: |
|||
m_MirrorParameter: |
|||
m_CycleOffsetParameter: |
|||
m_TimeParameter: |
|||
--- !u!91 &9100000 |
|||
AnimatorController: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: IntroOutroAnimator |
|||
serializedVersion: 5 |
|||
m_AnimatorParameters: |
|||
- m_Name: DoIntro |
|||
m_Type: 9 |
|||
m_DefaultFloat: 0 |
|||
m_DefaultInt: 0 |
|||
m_DefaultBool: 0 |
|||
m_Controller: {fileID: 0} |
|||
- m_Name: DoOutro |
|||
m_Type: 9 |
|||
m_DefaultFloat: 0 |
|||
m_DefaultInt: 0 |
|||
m_DefaultBool: 0 |
|||
m_Controller: {fileID: 0} |
|||
m_AnimatorLayers: |
|||
- serializedVersion: 5 |
|||
m_Name: Base Layer |
|||
m_StateMachine: {fileID: 6276916818762604846} |
|||
m_Mask: {fileID: 0} |
|||
m_Motions: [] |
|||
m_Behaviours: [] |
|||
m_BlendingMode: 0 |
|||
m_SyncedLayerIndex: -1 |
|||
m_DefaultWeight: 0 |
|||
m_IKPass: 0 |
|||
m_SyncedLayerAffectsTiming: 0 |
|||
m_Controller: {fileID: 9100000} |
|||
--- !u!1107 &5144759055998950383 |
|||
AnimatorStateMachine: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 1 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: New Layer |
|||
m_ChildStates: [] |
|||
m_ChildStateMachines: [] |
|||
m_AnyStateTransitions: [] |
|||
m_EntryTransitions: [] |
|||
m_StateMachineTransitions: {} |
|||
m_StateMachineBehaviours: [] |
|||
m_AnyStatePosition: {x: 50, y: 20, z: 0} |
|||
m_EntryPosition: {x: 50, y: 120, z: 0} |
|||
m_ExitPosition: {x: 800, y: 120, z: 0} |
|||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} |
|||
m_DefaultState: {fileID: 0} |
|||
--- !u!1107 &6276916818762604846 |
|||
AnimatorStateMachine: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 1 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: Base Layer |
|||
m_ChildStates: |
|||
- serializedVersion: 1 |
|||
m_State: {fileID: -915027616136477805} |
|||
m_Position: {x: 330, y: 120, z: 0} |
|||
- serializedVersion: 1 |
|||
m_State: {fileID: -4718454066486239908} |
|||
m_Position: {x: 330, y: 210, z: 0} |
|||
- serializedVersion: 1 |
|||
m_State: {fileID: 6302186184720228616} |
|||
m_Position: {x: 330, y: 300, z: 0} |
|||
m_ChildStateMachines: [] |
|||
m_AnyStateTransitions: [] |
|||
m_EntryTransitions: [] |
|||
m_StateMachineTransitions: {} |
|||
m_StateMachineBehaviours: [] |
|||
m_AnyStatePosition: {x: 50, y: 20, z: 0} |
|||
m_EntryPosition: {x: 50, y: 120, z: 0} |
|||
m_ExitPosition: {x: 800, y: 120, z: 0} |
|||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} |
|||
m_DefaultState: {fileID: -915027616136477805} |
|||
--- !u!1102 &6302186184720228616 |
|||
AnimatorState: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 1 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: OutroAnimation |
|||
m_Speed: 1 |
|||
m_CycleOffset: 0 |
|||
m_Transitions: [] |
|||
m_StateMachineBehaviours: [] |
|||
m_Position: {x: 50, y: 50, z: 0} |
|||
m_IKOnFeet: 0 |
|||
m_WriteDefaultValues: 1 |
|||
m_Mirror: 0 |
|||
m_SpeedParameterActive: 0 |
|||
m_MirrorParameterActive: 0 |
|||
m_CycleOffsetParameterActive: 0 |
|||
m_TimeParameterActive: 0 |
|||
m_Motion: {fileID: 7400000, guid: 0114c447b277a3647946290240759633, type: 2} |
|||
m_Tag: |
|||
m_SpeedParameter: |
|||
m_MirrorParameter: |
|||
m_CycleOffsetParameter: |
|||
m_TimeParameter: |
|
|||
fileFormatVersion: 2 |
|||
guid: c01005020548c754c81f738e21ae2217 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 9100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!74 &7400000 |
|||
AnimationClip: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: OutroAnimation |
|||
serializedVersion: 6 |
|||
m_Legacy: 0 |
|||
m_Compressed: 0 |
|||
m_UseHighQualityCurve: 1 |
|||
m_RotationCurves: [] |
|||
m_CompressedRotationCurves: [] |
|||
m_EulerCurves: [] |
|||
m_PositionCurves: [] |
|||
m_ScaleCurves: [] |
|||
m_FloatCurves: |
|||
- curve: |
|||
serializedVersion: 2 |
|||
m_Curve: |
|||
- serializedVersion: 3 |
|||
time: 0 |
|||
value: 0 |
|||
inSlope: Infinity |
|||
outSlope: Infinity |
|||
tangentMode: 103 |
|||
weightedMode: 0 |
|||
inWeight: 0 |
|||
outWeight: 0 |
|||
- serializedVersion: 3 |
|||
time: 3 |
|||
value: 1 |
|||
inSlope: Infinity |
|||
outSlope: Infinity |
|||
tangentMode: 103 |
|||
weightedMode: 0 |
|||
inWeight: 0 |
|||
outWeight: 0 |
|||
m_PreInfinity: 2 |
|||
m_PostInfinity: 2 |
|||
m_RotationOrder: 4 |
|||
attribute: m_IsActive |
|||
path: InfoText/OutroText |
|||
classID: 1 |
|||
script: {fileID: 0} |
|||
- curve: |
|||
serializedVersion: 2 |
|||
m_Curve: |
|||
- serializedVersion: 3 |
|||
time: 0 |
|||
value: 1 |
|||
inSlope: 0 |
|||
outSlope: 0 |
|||
tangentMode: 136 |
|||
weightedMode: 0 |
|||
inWeight: 0.33333334 |
|||
outWeight: 0.33333334 |
|||
- serializedVersion: 3 |
|||
time: 0.15 |
|||
value: 0 |
|||
inSlope: 0 |
|||
outSlope: 0 |
|||
tangentMode: 136 |
|||
weightedMode: 0 |
|||
inWeight: 0.33333334 |
|||
outWeight: 0.33333334 |
|||
m_PreInfinity: 2 |
|||
m_PostInfinity: 2 |
|||
m_RotationOrder: 4 |
|||
attribute: m_Alpha |
|||
path: ScoreAndTargetPanel |
|||
classID: 225 |
|||
script: {fileID: 0} |
|||
- curve: |
|||
serializedVersion: 2 |
|||
m_Curve: |
|||
- serializedVersion: 3 |
|||
time: 0 |
|||
value: 0 |
|||
inSlope: Infinity |
|||
outSlope: Infinity |
|||
tangentMode: 103 |
|||
weightedMode: 0 |
|||
inWeight: 0 |
|||
outWeight: 0 |
|||
m_PreInfinity: 2 |
|||
m_PostInfinity: 2 |
|||
m_RotationOrder: 4 |
|||
attribute: m_IsActive |
|||
path: InfoText/WaitingText |
|||
classID: 1 |
|||
script: {fileID: 0} |
|||
m_PPtrCurves: [] |
|||
m_SampleRate: 60 |
|||
m_WrapMode: 0 |
|||
m_Bounds: |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
m_Extent: {x: 0, y: 0, z: 0} |
|||
m_ClipBindingConstant: |
|||
genericBindings: |
|||
- serializedVersion: 2 |
|||
path: 2389439745 |
|||
attribute: 2086281974 |
|||
script: {fileID: 0} |
|||
typeID: 1 |
|||
customType: 0 |
|||
isPPtrCurve: 0 |
|||
- serializedVersion: 2 |
|||
path: 2885466011 |
|||
attribute: 1574349066 |
|||
script: {fileID: 0} |
|||
typeID: 225 |
|||
customType: 0 |
|||
isPPtrCurve: 0 |
|||
- serializedVersion: 2 |
|||
path: 3489324656 |
|||
attribute: 2086281974 |
|||
script: {fileID: 0} |
|||
typeID: 1 |
|||
customType: 0 |
|||
isPPtrCurve: 0 |
|||
pptrCurveMapping: [] |
|||
m_AnimationClipSettings: |
|||
serializedVersion: 2 |
|||
m_AdditiveReferencePoseClip: {fileID: 0} |
|||
m_AdditiveReferencePoseTime: 0 |
|||
m_StartTime: 0 |
|||
m_StopTime: 6 |
|||
m_OrientationOffsetY: 0 |
|||
m_Level: 0 |
|||
m_CycleOffset: 0 |
|||
m_HasAdditiveReferencePose: 0 |
|||
m_LoopTime: 0 |
|||
m_LoopBlend: 0 |
|||
m_LoopBlendOrientation: 0 |
|||
m_LoopBlendPositionY: 0 |
|||
m_LoopBlendPositionXZ: 0 |
|||
m_KeepOriginalOrientation: 0 |
|||
m_KeepOriginalPositionY: 1 |
|||
m_KeepOriginalPositionXZ: 0 |
|||
m_HeightFromFeet: 0 |
|||
m_Mirror: 0 |
|||
m_EditorCurves: |
|||
- curve: |
|||
serializedVersion: 2 |
|||
m_Curve: |
|||
- serializedVersion: 3 |
|||
time: 0 |
|||
value: 0 |
|||
inSlope: Infinity |
|||
outSlope: Infinity |
|||
tangentMode: 103 |
|||
weightedMode: 0 |
|||
inWeight: 0 |
|||
outWeight: 0 |
|||
- serializedVersion: 3 |
|||
time: 3 |
|||
value: 1 |
|||
inSlope: Infinity |
|||
outSlope: Infinity |
|||
tangentMode: 103 |
|||
weightedMode: 0 |
|||
inWeight: 0 |
|||
outWeight: 0 |
|||
m_PreInfinity: 2 |
|||
m_PostInfinity: 2 |
|||
m_RotationOrder: 4 |
|||
attribute: m_IsActive |
|||
path: InfoText/OutroText |
|||
classID: 1 |
|||
script: {fileID: 0} |
|||
- curve: |
|||
serializedVersion: 2 |
|||
m_Curve: |
|||
- serializedVersion: 3 |
|||
time: 0 |
|||
value: 1 |
|||
inSlope: 0 |
|||
outSlope: 0 |
|||
tangentMode: 136 |
|||
weightedMode: 0 |
|||
inWeight: 0.33333334 |
|||
outWeight: 0.33333334 |
|||
- serializedVersion: 3 |
|||
time: 0.15 |
|||
value: 0 |
|||
inSlope: 0 |
|||
outSlope: 0 |
|||
tangentMode: 136 |
|||
weightedMode: 0 |
|||
inWeight: 0.33333334 |
|||
outWeight: 0.33333334 |
|||
m_PreInfinity: 2 |
|||
m_PostInfinity: 2 |
|||
m_RotationOrder: 4 |
|||
attribute: m_Alpha |
|||
path: ScoreAndTargetPanel |
|||
classID: 225 |
|||
script: {fileID: 0} |
|||
- curve: |
|||
serializedVersion: 2 |
|||
m_Curve: |
|||
- serializedVersion: 3 |
|||
time: 0 |
|||
value: 0 |
|||
inSlope: Infinity |
|||
outSlope: Infinity |
|||
tangentMode: 103 |
|||
weightedMode: 0 |
|||
inWeight: 0 |
|||
outWeight: 0 |
|||
m_PreInfinity: 2 |
|||
m_PostInfinity: 2 |
|||
m_RotationOrder: 4 |
|||
attribute: m_IsActive |
|||
path: InfoText/WaitingText |
|||
classID: 1 |
|||
script: {fileID: 0} |
|||
m_EulerEditorCurves: [] |
|||
m_HasGenericRootTransform: 0 |
|||
m_HasMotionFloatCurves: 0 |
|||
m_Events: |
|||
- time: 6 |
|||
functionName: OnOutroComplete |
|||
data: |
|||
objectReferenceParameter: {fileID: 0} |
|||
floatParameter: 0 |
|||
intParameter: 0 |
|||
messageOptions: 0 |
|
|||
fileFormatVersion: 2 |
|||
guid: 0114c447b277a3647946290240759633 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 7400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine; |
|||
|
|||
namespace LobbyRelaySample.ngo |
|||
{ |
|||
/// <summary>
|
|||
/// Handles any visual tasks for running the NGO minigame's intro and outro.
|
|||
/// </summary>
|
|||
public class IntroOutroRunner : MonoBehaviour |
|||
{ |
|||
[SerializeField] private Animator m_animator; |
|||
private Action m_onOutroComplete; |
|||
|
|||
public void DoIntro() |
|||
{ |
|||
m_animator.SetTrigger("DoIntro"); |
|||
} |
|||
|
|||
public void DoOutro(Action onOutroComplete) |
|||
{ |
|||
m_onOutroComplete = onOutroComplete; |
|||
m_animator.SetTrigger("DoOutro"); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Called via an AnimationEvent.
|
|||
/// </summary>
|
|||
public void OnIntroComplete() |
|||
{ |
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.InstructionsShown, null); |
|||
} |
|||
/// <summary>
|
|||
/// Called via an AnimationEvent.
|
|||
/// </summary>
|
|||
public void OnOutroComplete() |
|||
{ |
|||
m_onOutroComplete?.Invoke(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9f7a308a72bf6ce4a862a246eaed82cb |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.Netcode; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace LobbyRelaySample.ngo |
|||
{ |
|||
/// <summary>
|
|||
/// A place to store data needed by networked behaviors. Each client has an instance, but the server's instance stores the actual data.
|
|||
/// </summary>
|
|||
public class NetworkedDataStore : NetworkBehaviour |
|||
{ |
|||
// Using a singleton here since we need spawned PlayerCursors to be able to find it, but we don't need the flexibility offered by the Locator.
|
|||
public static NetworkedDataStore Instance; |
|||
|
|||
private Dictionary<ulong, PlayerData> m_playerData = new Dictionary<ulong, PlayerData>(); |
|||
private ulong m_localId; |
|||
|
|||
// Clients will need to retrieve the host's player data since it isn't synchronized. During that process, they will supply these callbacks
|
|||
private Action<PlayerData> m_onGetCurrentCallback; |
|||
private UnityEvent<PlayerData> m_onEachPlayerCallback; |
|||
|
|||
public void Awake() |
|||
{ |
|||
Instance = this; |
|||
} |
|||
public override void OnDestroy() |
|||
{ |
|||
base.OnDestroy(); |
|||
if (Instance == this) |
|||
Instance = null; |
|||
} |
|||
|
|||
public override void OnNetworkSpawn() |
|||
{ |
|||
m_localId = NetworkManager.Singleton.LocalClientId; |
|||
} |
|||
|
|||
public void AddPlayer(ulong id, string name) |
|||
{ |
|||
if (!IsServer) |
|||
return; |
|||
|
|||
if (!m_playerData.ContainsKey(id)) |
|||
m_playerData.Add(id, new PlayerData(name, id, 0)); |
|||
else |
|||
m_playerData[id] = new PlayerData(name, id, 0); |
|||
} |
|||
|
|||
/// <returns>The updated score for the player matching the id after adding the delta, or int.MinValue otherwise.</returns>
|
|||
public int UpdateScore(ulong id, int delta) |
|||
{ |
|||
if (!IsServer) |
|||
return int.MinValue; |
|||
|
|||
if (m_playerData.ContainsKey(id)) |
|||
{ |
|||
m_playerData[id].score += delta; |
|||
return m_playerData[id].score; |
|||
} |
|||
return int.MinValue; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retrieve the data for all players from 1st to last place, calling onEachPlayer for each.
|
|||
/// </summary>
|
|||
public void GetAllPlayerData(UnityEvent<PlayerData> onEachPlayer) |
|||
{ |
|||
m_onEachPlayerCallback = onEachPlayer; |
|||
GetAllPlayerData_ServerRpc(m_localId); |
|||
} |
|||
|
|||
[ServerRpc(RequireOwnership = false)] |
|||
private void GetAllPlayerData_ServerRpc(ulong callerId) |
|||
{ |
|||
var sortedData = m_playerData.Select(kvp => kvp.Value).OrderByDescending(data => data.score); |
|||
GetAllPlayerData_ClientRpc(callerId, sortedData.ToArray()); |
|||
} |
|||
|
|||
[ClientRpc] |
|||
private void GetAllPlayerData_ClientRpc(ulong callerId, PlayerData[] sortedData) |
|||
{ |
|||
if (callerId != m_localId) |
|||
return; |
|||
|
|||
int rank = 1; |
|||
foreach (var data in sortedData) |
|||
{ |
|||
m_onEachPlayerCallback.Invoke(data); |
|||
rank++; |
|||
} |
|||
m_onEachPlayerCallback = null; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retreive the data for one player, passing it to the onGet callback.
|
|||
/// </summary>
|
|||
public void GetPlayerData(ulong targetId, Action<PlayerData> onGet) |
|||
{ |
|||
m_onGetCurrentCallback = onGet; |
|||
GetPlayerData_ServerRpc(targetId, m_localId); |
|||
} |
|||
|
|||
[ServerRpc(RequireOwnership = false)] |
|||
private void GetPlayerData_ServerRpc(ulong id, ulong callerId) |
|||
{ |
|||
if (m_playerData.ContainsKey(id)) |
|||
GetPlayerData_ClientRpc(callerId, m_playerData[id]); |
|||
else |
|||
GetPlayerData_ClientRpc(callerId, new PlayerData(null, 0)); |
|||
} |
|||
|
|||
[ClientRpc] |
|||
public void GetPlayerData_ClientRpc(ulong callerId, PlayerData data) |
|||
{ |
|||
if (callerId == m_localId) |
|||
{ m_onGetCurrentCallback?.Invoke(data); |
|||
m_onGetCurrentCallback = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5a054eb742dd9f748afc05982dc263b0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.Netcode; |
|||
|
|||
namespace LobbyRelaySample.ngo |
|||
{ |
|||
/// <summary>
|
|||
/// An example of a custom type serialized for use in RPC calls. This represents the state of a player as far as NGO is concerned,
|
|||
/// with relevant fields copied in or modified directly.
|
|||
/// </summary>
|
|||
public class PlayerData : INetworkSerializable |
|||
{ |
|||
public string name; |
|||
public ulong id; |
|||
public int score; |
|||
public PlayerData() { } // A default constructor is explicitly required for serialization.
|
|||
public PlayerData(string name, ulong id, int score = 0) { this.name = name; this.id = id; this.score = score; } |
|||
|
|||
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter |
|||
{ |
|||
serializer.SerializeValue(ref name); |
|||
serializer.SerializeValue(ref id); |
|||
serializer.SerializeValue(ref score); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3e81b917b9edfc64f95cebddd2deb7b2 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using Unity.Netcode; |
|||
|
|||
namespace LobbyRelaySample.ngo |
|||
{ |
|||
/// <summary>
|
|||
/// Displays the results for all players after the NGO minigame.
|
|||
/// </summary>
|
|||
public class ResultsUserUI : NetworkBehaviour |
|||
{ |
|||
[Tooltip("The containers for the player data outputs, in order, to be hidden until the game ends.")] |
|||
[SerializeField] private CanvasGroup[] m_containers; |
|||
[Tooltip("These should be in order of appearance, i.e. the 0th entry is the 1st-place player, and so on.")] |
|||
[SerializeField] private TMPro.TMP_Text[] m_playerNameOutputs; |
|||
[Tooltip("These should also be in order of appearance.")] |
|||
[SerializeField] private TMPro.TMP_Text[] m_playerScoreOutputs; |
|||
private int m_index = 0; |
|||
|
|||
public void Start() |
|||
{ |
|||
foreach (var container in m_containers) |
|||
container.alpha = 0; |
|||
} |
|||
|
|||
// Assigned to an event in the Inspector.
|
|||
public void ReceiveScoreInOrder(PlayerData data) |
|||
{ |
|||
m_containers[m_index].alpha = 1; |
|||
m_playerNameOutputs[m_index].text = data.name; |
|||
m_playerScoreOutputs[m_index].text = data.score.ToString("00"); |
|||
m_index++; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3a4ddeb182a27644480e6c47c065924e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Assets/Prefabs/Runes/icon_bg.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: b3e57d1c65c0fc746a2a46a3d227990b |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue