fixed the issue with pausing while respawning:

This commit is contained in:
Melbyj1125
2022-04-12 22:40:25 -05:00
parent 7d9e78891f
commit 7f4e2173ad
8 changed files with 68 additions and 22 deletions

View File

@@ -5008,6 +5008,7 @@ MonoBehaviour:
hasDash: 0
playerPoints: 15
isPaused: 0
isRespawning: 1
windOn: 0
windDirection: {x: 0, y: 0, z: 0}
--- !u!114 &7688428083034862284

View File

@@ -3629,6 +3629,10 @@ PrefabInstance:
propertyPath: hasGrapple
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1707207228499037468, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: isRespawning
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5759777694531189237, guid: 0ea305f96ab853340bb9f0ed320dac08, type: 3}
propertyPath: m_RootOrder
value: 13

View File

@@ -18,6 +18,7 @@ public class Pitfall : NetworkBehaviour
private void OnTriggerEnter(Collider other) {
if (cooldown == false && other.transform.gameObject.tag == "PlayerTrigger" && other.gameObject.transform.root.gameObject.GetComponent<NetworkObject>().OwnerClientId == NetworkManager.Singleton.LocalClientId) {
other.transform.root.GetComponentInChildren<PlayerStats>().IsRespawning = true;
RespawnPlayerServerRPC(other.gameObject.transform.root.gameObject.GetComponent<NetworkObject>().OwnerClientId);
cooldown = true;
StartCoroutine(CoolItDown());
@@ -135,6 +136,7 @@ public class Pitfall : NetworkBehaviour
character.GetComponentInChildren<AerialStateManager>().enabled = true;
character.GetComponentInChildren<OffenseStateManager>().enabled = true;
character.GetComponentInChildren<CoolDown>().populatePlayerCanvas();
character.GetComponentInChildren<PlayerStats>().IsRespawning = false;
}
}

View File

@@ -29,7 +29,7 @@ public class SlowTerrain : NetworkBehaviour
foreach (GameObject player in players) {
if (player.GetComponent<NetworkObject>().OwnerClientId == playerID) {
player.GetComponentInChildren<PlayerStats>().ApplySlimeBody();
player.GetComponentInChildren<PlayerStats>().ApplySuperSlow();
}
}
}
@@ -57,7 +57,7 @@ public class SlowTerrain : NetworkBehaviour
foreach (GameObject player in players) {
if (player.GetComponent<NetworkObject>().OwnerClientId == playerID) {
player.GetComponentInChildren<PlayerStats>().ClearSlimeBody();
player.GetComponentInChildren<PlayerStats>().ClearSuperSlow();
}
}
}

View File

@@ -40,7 +40,7 @@ public class SpawnManager : NetworkBehaviour {
_runner.GetComponentInChildren<PlayerInventory>().UpdateEquips(playerData.pInv.NetworkItemList, this.gameObject.GetComponent<InventoryManager>().ItemDict);
_runner.GetComponentInChildren<CoolDown>().populatePlayerCanvas();
_runner.GetComponent<NetworkObject>().SpawnAsPlayerObject(NetworkManager.Singleton.LocalClientId, null, true);
_runner.GetComponentInChildren<PlayerStats>().IsRespawning = false;
// Increment runners
runnersSpawned++;
}
@@ -75,7 +75,7 @@ public class SpawnManager : NetworkBehaviour {
// Spawn as player
_runner = Instantiate(runnerPrefab, runnersSpawnPoints[runnersSpawned], Quaternion.Euler(0, -90, 0)).gameObject;
_runner.GetComponent<NetworkObject>().SpawnAsPlayerObject(clientId, null, true);
_runner.GetComponentInChildren<PlayerStats>().IsRespawning = false;
// Increment runners
runnersSpawned++;
@@ -114,9 +114,9 @@ public class SpawnManager : NetworkBehaviour {
// Find the local player
if (character.GetComponent<NetworkObject>().OwnerClientId == clientID) {
List<string> itemList = itemsAsString.Split(',').ToList();
character.GetComponentInChildren<PlayerInventory>().UpdateEquips(itemList, this.gameObject.GetComponent<InventoryManager>().ItemDict);
character.GetComponentInChildren<CoolDown>().populatePlayerCanvas();
}
}
}

View File

@@ -154,6 +154,12 @@ public class PlayerStats : MonoBehaviour
set{ isPaused = value; }
}
[SerializeField] private bool isRespawning = true;
public bool IsRespawning{
get{ return isRespawning; }
set{ isRespawning = value; }
}
////Weather Related stats
//Is wind on
[SerializeField] private bool windOn = false;
@@ -283,13 +289,13 @@ public class PlayerStats : MonoBehaviour
bool midWeatherOn;
public void ApplySlimeBody(){
maxVel *= .4f;
maxVel *= .5f;
curVel = minVel;
}
//Clear slime body effect
public void ClearSlimeBody(){
maxVel *= (1/.4f);
maxVel *= (1/.5f);
}
//Apply slime trail effect to the player
@@ -303,6 +309,21 @@ public class PlayerStats : MonoBehaviour
traction *= (1 / .3f);
curTraction *= (1 / .3f);
}
public void ApplySuperSlow(){
minVel *=.2f;
maxVel *=.2f;
acc *= .2f;
curVel = minVel;
}
public void ClearSuperSlow(){
minVel *= (1/.2f);
maxVel *= (1/.2f);
acc *= (1/.2f);
}
////
void Update(){
VariableValidation();

View File

@@ -57,23 +57,39 @@ public class PauseMenu : NetworkBehaviour {
// Listen for Pause button and not already paused
// TODO: UPDATE TO ALSO LISTEN FOR CONTROLLER PAUSE BUTTON PRESSED
if (isUsable && Input.GetKeyDown(KeyCode.Escape) && PauseMenuPanel.activeInHierarchy != true) {
// Display Pause Menu
PauseMenuPanel.SetActive(true);
isViewingRunnerControls = true;
// Disable player controls
setPlayerControlsStateServerRPC(false);
// Turn off "Restart from Checkpoint" button for the king
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject player in players) {
// Make sure they are the local player
if (player.GetComponent<NetworkObject>().IsLocalPlayer) {
foreach(GameObject player in players){
if(player.GetComponent<NetworkObject>().IsLocalPlayer){
if(player.GetComponent<KingMove>() == null){
if(!player.GetComponentInChildren<PlayerStats>().IsRespawning){
// Display Pause Menu
PauseMenuPanel.SetActive(true);
isViewingRunnerControls = true;
// Disable player controls
setPlayerControlsStateServerRPC(false);
}
}
// Check for king
if (player.GetComponent<KingMove>() != null) {
else{
// Display Pause Menu
PauseMenuPanel.SetActive(true);
isViewingRunnerControls = true;
// Disable player controls
setPlayerControlsStateServerRPC(false);
// Turn off "Restart from Checkpoint" button for the king
RestartButton.interactable = false;
}
}
}
}
@@ -193,6 +209,8 @@ public class PauseMenu : NetworkBehaviour {
}
}
player.GetComponentInChildren<PlayerStats>().IsRespawning = true;
RespawnPlayerServerRPC(player.GetComponent<NetworkObject>().OwnerClientId,
player.GetComponentInChildren<ResetZones>().GetRespawnPosition(curZone));
}
@@ -229,7 +247,6 @@ public class PauseMenu : NetworkBehaviour {
// Handle Client Spawning Locally
string itemsAsString = string.Join(",", playerData.pInv.NetworkItemList);
StartCoroutine(SpawnClient(clientID, itemsAsString));
}
}
@@ -291,6 +308,7 @@ public class PauseMenu : NetworkBehaviour {
character.GetComponentInChildren<AerialStateManager>().enabled = true;
character.GetComponentInChildren<OffenseStateManager>().enabled = true;
character.GetComponentInChildren<CoolDown>().populatePlayerCanvas();
character.GetComponentInChildren<PlayerStats>().IsRespawning = false;
}
}

View File

@@ -30,10 +30,10 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c7b151b180b650721283704240d14f0e12d3aedff78fce9332b25
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650