Fix death sync & respawn on all fainted

This commit is contained in:
Pedro Gomes 2024-07-20 23:10:07 +01:00
parent e47a0d9b1f
commit 626d554a51
10 changed files with 203 additions and 14 deletions

View File

@ -13,7 +13,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 583639914168640231, guid: 55a572819c594ad4c90a6e68c2f30e0e, type: 3}
propertyPath: m_SynchronizeParameters.Array.size
value: 7
value: 9
objectReference: {fileID: 0}
- target: {fileID: 583639914168640231, guid: 55a572819c594ad4c90a6e68c2f30e0e, type: 3}
propertyPath: m_SynchronizeParameters.Array.data[5].Name
@ -31,6 +31,22 @@ PrefabInstance:
propertyPath: m_SynchronizeParameters.Array.data[6].Type
value: 4
objectReference: {fileID: 0}
- target: {fileID: 583639914168640231, guid: 55a572819c594ad4c90a6e68c2f30e0e, type: 3}
propertyPath: m_SynchronizeParameters.Array.data[7].Name
value: dead
objectReference: {fileID: 0}
- target: {fileID: 583639914168640231, guid: 55a572819c594ad4c90a6e68c2f30e0e, type: 3}
propertyPath: m_SynchronizeParameters.Array.data[7].Type
value: 9
objectReference: {fileID: 0}
- target: {fileID: 583639914168640231, guid: 55a572819c594ad4c90a6e68c2f30e0e, type: 3}
propertyPath: m_SynchronizeParameters.Array.data[8].Name
value: revived
objectReference: {fileID: 0}
- target: {fileID: 583639914168640231, guid: 55a572819c594ad4c90a6e68c2f30e0e, type: 3}
propertyPath: m_SynchronizeParameters.Array.data[8].Type
value: 9
objectReference: {fileID: 0}
- target: {fileID: 686220006257547049, guid: 55a572819c594ad4c90a6e68c2f30e0e, type: 3}
propertyPath: m_RootOrder
value: 0
@ -119,13 +135,21 @@ PrefabInstance:
propertyPath: sceneViewId
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: observableSearch
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.size
value: 4
value: 5
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[3]
value:
objectReference: {fileID: 1830776764180054666}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[4]
value:
objectReference: {fileID: 1788221149024619301}
- target: {fileID: 7726918647213528475, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: classTag
@ -212,6 +236,17 @@ MonoBehaviour:
m_EditorClassIdentifier:
rotationSpeed: 1440
rotationAxis: 1
--- !u!114 &1830776764180054666 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3993657840148777867, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
m_PrefabInstance: {fileID: 3315893290401286401}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6cb53fadb6be8254587f5d0ad1c57778, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &5284782871780965989 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7445357712997283684, guid: 9c432d220280f704684a6d5b9354c782, type: 3}

View File

@ -31,13 +31,21 @@ PrefabInstance:
propertyPath: sceneViewId
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: observableSearch
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.size
value: 4
value: 5
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[3]
value:
objectReference: {fileID: 8856054663210089579}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[4]
value:
objectReference: {fileID: 5587652594478694127}
- target: {fileID: 7726918647213528475, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: classTag
@ -110,6 +118,17 @@ Transform:
m_CorrespondingSourceObject: {fileID: 7445357712997283684, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
m_PrefabInstance: {fileID: 5587652594317244384}
m_PrefabAsset: {fileID: 0}
--- !u!114 &8856054663210089579 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3993657840148777867, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
m_PrefabInstance: {fileID: 5587652594317244384}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6cb53fadb6be8254587f5d0ad1c57778, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &6299060357122510577
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -95,13 +95,21 @@ PrefabInstance:
propertyPath: sceneViewId
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: observableSearch
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.size
value: 4
value: 5
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[3]
value:
objectReference: {fileID: 7230415786316253121}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[4]
value:
objectReference: {fileID: 6192144265892874537}
- target: {fileID: 7726918647213528475, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: classTag
@ -166,3 +174,14 @@ Transform:
m_CorrespondingSourceObject: {fileID: 7445357712997283684, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
m_PrefabInstance: {fileID: 5997609963189718090}
m_PrefabAsset: {fileID: 0}
--- !u!114 &7230415786316253121 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3993657840148777867, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
m_PrefabInstance: {fileID: 5997609963189718090}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6cb53fadb6be8254587f5d0ad1c57778, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -31,13 +31,21 @@ PrefabInstance:
propertyPath: sceneViewId
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: observableSearch
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.size
value: 4
value: 5
objectReference: {fileID: 0}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[3]
value:
objectReference: {fileID: 1240144468001624216}
- target: {fileID: 7687765528848249431, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: ObservedComponents.Array.data[4]
value:
objectReference: {fileID: 8112063480741076945}
- target: {fileID: 7726918647213528475, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
propertyPath: classTag
@ -97,6 +105,17 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
--- !u!114 &1240144468001624216 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3993657840148777867, guid: 9c432d220280f704684a6d5b9354c782, type: 3}
m_PrefabInstance: {fileID: 2763436073792215827}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6cb53fadb6be8254587f5d0ad1c57778, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &4686711277245459575 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7445357712997283684, guid: 9c432d220280f704684a6d5b9354c782, type: 3}

View File

@ -328,6 +328,7 @@ MonoBehaviour:
photonView: {fileID: 0}
character: {fileID: 0}
projectileSpawnLocation: {fileID: 1501747715295767159}
health: {fileID: 0}
--- !u!195 &5523225171841185422
NavMeshAgent:
m_ObjectHideFlags: 0
@ -1095,6 +1096,7 @@ Transform:
- {fileID: 1916390312058359477}
- {fileID: 610548425681831209}
- {fileID: 5039314715756572421}
- {fileID: 5447783134482355923}
m_Father: {fileID: 8785094005405139760}
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1118,7 +1120,9 @@ MonoBehaviour:
bleedOutProgressGO: {fileID: 9102572405850637775}
reviveProgressFill: {fileID: 3216778857540899709}
bleedOutProgressFill: {fileID: 1417942816497691017}
onPlayerSpawned: {fileID: 1248313421135328660}
playersInsideReviveTrigger: []
playersDeathManagers: []
--- !u!54 &292444422420756798
Rigidbody:
m_ObjectHideFlags: 0
@ -2173,6 +2177,54 @@ MonoBehaviour:
Response:
m_PersistentCalls:
m_Calls: []
--- !u!1 &8924332507532078973
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5447783134482355923}
- component: {fileID: 1248313421135328660}
m_Layer: 0
m_Name: OnPlayerSpawned
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5447783134482355923
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8924332507532078973}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5521421693679146049}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1248313421135328660
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8924332507532078973}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 687794f951b2e3543aed2872920d3d6e, type: 3}
m_Name:
m_EditorClassIdentifier:
Event: {fileID: 11400000, guid: b3af5678d5130fe409229924bbcb4705, type: 2}
Response:
m_PersistentCalls:
m_Calls: []
--- !u!1 &8935706411944435492
GameObject:
m_ObjectHideFlags: 0

View File

@ -227,7 +227,7 @@ public class NetworkManager : MonoBehaviourPunCallbacks, IOnEventCallback
PhotonNetwork.RaiseEvent(GameConstants.NetworkEventCodes.CancelChangeLevelVoted, PhotonNetwork.LocalPlayer, raiseEventOptions, SendOptions.SendReliable);
}
private void Send_All_OnLoadLevelStarting()
public void Send_All_OnLoadLevelStarting()
{
RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.All };
PhotonNetwork.RaiseEvent(GameConstants.NetworkEventCodes.LoadLevelStarting, 0, raiseEventOptions, SendOptions.SendReliable);

View File

@ -37,6 +37,10 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
RiftPlayer possibleReviver;
public List<RiftPlayer> playersInsideReviveTrigger = new List<RiftPlayer>();
PlayerDeathManager potentialReferenceAddition;
NetworkManager networkManager;
private void Awake()
{
owner = GetComponentInParent<PhotonView>();
@ -51,6 +55,8 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
reviveProgressGO.SetActive(false);
bleedOutProgressGO.SetActive(false);
networkManager = FindObjectOfType<NetworkManager>();
}
private void Start()
@ -120,6 +126,11 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
if (!owner.IsMine) return;
if(AreAllPlayersFaintedOrDead())
{
networkManager.Send_All_OnLoadLevelStarting();
}
reviveProgressGO.SetActive(true);
bleedOutProgressGO.SetActive(true);
@ -165,9 +176,6 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
{
if (!owner.IsMine)
{
reviveProgressGO.SetActive(reviveTrigger.gameObject.activeSelf);
bleedOutProgressGO.SetActive(reviveTrigger.gameObject.activeSelf);
reviveProgressFill.fillAmount = reviveProgress / GameConstants.CharacterBalancing.ReviveTime;
bleedOutProgressFill.fillAmount = bleedOutTimer / GameConstants.CharacterBalancing.GroupBleedOutDuration;
@ -178,6 +186,11 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
if (playersInsideReviveTrigger.Count > 0)
{
for (int i = playersInsideReviveTrigger.Count - 1; i >= 0; i--)
{
if (playersInsideReviveTrigger[i].health.GetCurrentValue() <= 0)
playersInsideReviveTrigger.RemoveAt(i);
}
reviveProgress += GameConstants.CharacterBalancing.ReviveSpeed * playersInsideReviveTrigger.Count * Time.deltaTime;
reviveProgressFill.fillAmount = reviveProgress / GameConstants.CharacterBalancing.ReviveTime;
if (reviveProgress >= GameConstants.CharacterBalancing.ReviveTime)
@ -240,6 +253,14 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
//wait motherfucker
//else
//all dead, host load level
if(AreAllPlayersFaintedOrDead())
{
if(PhotonNetwork.IsMasterClient)
{
StartCoroutine(Return());
}
}
}
if (!owner.IsMine) return;
@ -253,6 +274,17 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
onLocalPlayerPermaDeath.Raise();
}
private bool AreAllPlayersFaintedOrDead()
{
for (int i = 0; i < networkManager.party.Count; i++)
{
potentialReferenceAddition = ((RiftPlayer)networkManager.party[i].TagObject).GetComponentInChildren<PlayerDeathManager>();
if (potentialReferenceAddition.IsFainted) continue;
else return false;
}
return true;
}
IEnumerator Return()
{
yield return new WaitForSeconds(GameConstants.GameBalancing.PermaDeathInfoTime);
@ -261,21 +293,25 @@ public class PlayerDeathManager : MonoBehaviour, IPunObservable
if (PhotonNetwork.IsMasterClient) PhotonNetwork.LoadLevel("4-RiftHuntersInn");
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.IsWriting)
if (stream.IsWriting)
{
stream.SendNext(isFainted);
stream.SendNext(reviveTrigger.gameObject.activeSelf);
stream.SendNext(reviveProgress);
stream.SendNext(bleedOutTimer);
}
else if(stream.IsReading)
else if (stream.IsReading)
{
isFainted = (bool)stream.ReceiveNext();
reviveTrigger.gameObject.SetActive((bool)stream.ReceiveNext());
reviveProgress = (float)stream.ReceiveNext();
bleedOutTimer = (float)stream.ReceiveNext();
reviveProgressGO.SetActive(reviveTrigger.gameObject.activeSelf);
bleedOutProgressGO.SetActive(reviveTrigger.gameObject.activeSelf);
}
}
}

View File

@ -19,13 +19,17 @@ public class RiftPlayer : MonoBehaviour
public Transform projectileSpawnLocation;
private Health health;
[HideInInspector]
public Health health;
PlayerDeathManager playerDeathManager;
private void Awake()
{
photonView = GetComponent<PhotonView>();
character = GetComponent<PlayerCharacterStats>();
health = GetComponent<Health>();
playerDeathManager = GetComponentInChildren<PlayerDeathManager>();
health.onDeath.AddListener(OnDeath);
}
@ -33,10 +37,14 @@ public class RiftPlayer : MonoBehaviour
// Start is called before the first frame update
void Start()
{
this.photonView.Owner.TagObject = this;
onPlayerSpawned.Raise(this.photonView);
this.gameObject.name = photonView.Owner.NickName;
}
private void OnDeath()
{
if (!photonView.IsMine) return;
@ -51,4 +59,5 @@ public class RiftPlayer : MonoBehaviour
}
}

View File

@ -94,7 +94,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Rotation: 13.729687
- _Rotation: 19.208542
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1

View File

@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.8.0.1
bundleVersion: 0.8.0.3
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0