Merge branch 'ResetButton'

This commit is contained in:
2022-02-28 14:07:46 -06:00
11 changed files with 1475 additions and 1 deletions

View File

@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
using MLAPI.Messaging;
public class ResetZonesGlobal : MonoBehaviour {
private bool cooldown = false;
[SerializeField]
private int RespawnZone;
private void OnTriggerEnter(Collider other) {
if (cooldown == false && other.transform.gameObject.tag == "PlayerTrigger" && other.gameObject.transform.root.gameObject.GetComponent<NetworkObject>().OwnerClientId == NetworkManager.Singleton.LocalClientId) {
SetClientRespawnZoneServerRPC(other.gameObject.transform.root.gameObject.GetComponent<NetworkObject>().OwnerClientId, RespawnZone);
cooldown = true;
StartCoroutine(CoolItDown());
}
}
[ServerRpc(RequireOwnership = false)]
private void SetClientRespawnZoneServerRPC(ulong clientID, int RespawnZone) {
SetClientRespawnZoneClientRPC(clientID, RespawnZone);
}
[ClientRpc]
private void SetClientRespawnZoneClientRPC(ulong clientID, int RespawnZone) {
// Get all players in the scene
GameObject[] playableCharacters = GameObject.FindGameObjectsWithTag("Player");
// Find our player first
foreach (GameObject character in playableCharacters) {
if (character.GetComponent<NetworkObject>().OwnerClientId == clientID) {
// Set their zone
character.GetComponent<ResetZones>().SetCurrentZone(RespawnZone);
}
}
}
IEnumerator CoolItDown() {
yield return new WaitForSecondsRealtime(1f);
cooldown = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6560db454bf09ef49bdb0240a370b8aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: