Fixed Weather Wheel Bugs

- Weather now applies to respawned players
- Weather now doesn't disable movement on respawned players
- Weather Wheel can't be spammed
This commit is contained in:
Julia Butenhoff 2022-03-14 19:21:04 -05:00
parent 9c7f6e2f8b
commit 60e3213d41
7 changed files with 74 additions and 5 deletions

View File

@ -11221,6 +11221,7 @@ GameObject:
- component: {fileID: 213179467}
- component: {fileID: 213179466}
- component: {fileID: 213179465}
- component: {fileID: 213179468}
m_Layer: 0
m_Name: Wind
m_TagString: WindSystem
@ -16014,6 +16015,19 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 22
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &213179468
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 213179464}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76ec7f4abf3a38f47a8c177ed4a94116, type: 3}
m_Name:
m_EditorClassIdentifier:
windDireciton: {x: 0, y: 0, z: 0}
--- !u!1 &215113614
GameObject:
m_ObjectHideFlags: 0

View File

@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WindDirection : MonoBehaviour
{
public Vector3 windDireciton;
private void Start() {
windDireciton = new Vector3(0, 0, 0);
}
}

View File

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

View File

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.SceneManagement;
public class PlayerStats : MonoBehaviour
{
@ -172,6 +173,30 @@ public class PlayerStats : MonoBehaviour
private float tempAcc;
private float accModification;
void Start() {
// Used mainly for respawning
// Sets the weather back up if any particle systems are playing
// Make sure we are in the game scene
if (SceneManager.GetActiveScene().buildIndex == 3) {
if (GameObject.FindGameObjectWithTag("RainSystem").GetComponent<ParticleSystem>().isPlaying) {
// Rain Playing
SetWeather(Weather.Rain);
}
else if (GameObject.FindGameObjectWithTag("SnowSystem").GetComponent<ParticleSystem>().isPlaying) {
// Snow Playing
SetWeather(Weather.Snow);
}
else if (GameObject.FindGameObjectWithTag("WindSystem").GetComponent<ParticleSystem>().isPlaying) {
// Wind Playing
SetWeather(Weather.Wind, GameObject.FindGameObjectWithTag("WindSystem").GetComponent<WindDirection>().windDireciton);
}
else if (GameObject.FindGameObjectWithTag("FogSystem").GetComponent<ParticleSystem>().isPlaying) {
SetWeather(Weather.Fog);
}
}
}
//sets weather effect on player
public void SetWeather(Weather weather, Vector3 windDir = default(Vector3)){

View File

@ -154,7 +154,6 @@ public class PauseMenu : NetworkBehaviour {
ResetZones.Zone curZone = ResetZones.Zone.VALLEY;
foreach(ResetZonesGlobal reZone in respawnZones) {
if (reZone.gameObject.GetComponent<BoxCollider>().bounds.Intersects(player.GetComponentInChildren<CapsuleCollider>().bounds)) {
Debug.LogError("Current Zone = " + reZone.RespawnZone);
curZone = (ResetZones.Zone)reZone.RespawnZone;
}
}

View File

@ -14,8 +14,8 @@ public class WeatherWheel : NetworkBehaviour {
public GameObject pointer;
private float weatherDuration = 30f;
private float postWeatherCooldown = 15f;
private float weatherDuration = 20f;
private float postWeatherCooldown = 10f;
void Start() {
gameObject.GetComponent<Image>().enabled = false;
@ -125,6 +125,7 @@ public class WeatherWheel : NetworkBehaviour {
// Allow weather to be spun again
onCooldown = false;
gameObject.GetComponent<Button>().interactable = true;
}
[ServerRpc(RequireOwnership = false)]
@ -156,11 +157,15 @@ public class WeatherWheel : NetworkBehaviour {
break;
case PlayerStats.Weather.Wind:
GameObject.FindGameObjectWithTag("WindSystem").GetComponent<ParticleSystem>().Play();
// Also store the wind direction
GameObject.FindGameObjectWithTag("WindSystem").GetComponent<WindDirection>().windDireciton = windDir;
break;
case PlayerStats.Weather.Fog:
GameObject.FindGameObjectWithTag("FogSystem").GetComponent<ParticleSystem>().Play();
break;
}
}
[ServerRpc(RequireOwnership = false)]
@ -192,12 +197,15 @@ public class WeatherWheel : NetworkBehaviour {
public void SpinWheel() {
// Only spin if not spinning already and not on cooldown
if (isSpinning && !onCooldown) { return; }
if (isSpinning || onCooldown) { return; }
// Do the spin
wheelSpeed = Random.Range(4.000f, 5.000f);
subtractSpeed = Random.Range(0.003f, 0.009f);
isSpinning = true;
onCooldown = true;
// Also make the button uninteractable
gameObject.GetComponent<Button>().interactable = false;
}
}

View File

@ -33,7 +33,7 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
value: 22424703114646680e0b0227036c78111b125507233d28242c20137df7ee3d2cfb
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650