Merge branch 'RespawningInScene'

This commit is contained in:
Vincent Wheat
2021-12-03 13:56:33 -06:00
13 changed files with 686 additions and 128 deletions

View File

@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rain : MonoBehaviour
{
private float tractionDefault;
private float accelerationDefault;
//Options for reduction
// % based aka you have 75% traction while in rain <- with this option we wouldn't need to care about individual players starting points
// Flat reduction penalty of number i.e. 3?
//Make rain increase acceleration
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player") //In multiplayer we may need a player 1 - X tag for keeping track of individual stats
{
PlayerStats pStats = other.gameObject.GetComponent<PlayerStats>();
tractionDefault = pStats.Traction;
if (tractionDefault > 3)
{
pStats.Traction -= 3;
}
else
{
pStats.Traction = 1;
}
accelerationDefault = pStats.Acc;
if (accelerationDefault < 8)
{
pStats.Acc += 3;
}
else
{
pStats.Acc = 10;
}
//pStats.Acc *= 1.25f;
//pStats.Traction *= 0.75f;
}
}
private void OnTriggerExit(Collider other)
{
if (other.tag == "Player")
{
PlayerStats pStats = other.gameObject.GetComponent<PlayerStats>();
pStats.Traction = tractionDefault;
pStats.Acc = accelerationDefault;
//pStats.Acc /= 1.25f;
//pStats.Traction /= 0.75f;
}
}
}

View File

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

View File

@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Snow : MonoBehaviour
{
private float tractionDefault;
private float accelerationDefault;
//Options for increase
// % based aka you have 75% traction while in rain <- with this option we wouldn't need to care about individual players starting points
// Flat reduction penalty of number i.e. 3?
//snow reduces acceleration <- playtest to consider adjusting max speed as well
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player") //In multiplayer we may need a player 1 - X tag for keeping track of individual stats
{
PlayerStats pStats = other.gameObject.GetComponent<PlayerStats>();
tractionDefault = pStats.Traction;
if (tractionDefault < 8)
{
pStats.Traction += 3;
}
else
{
pStats.Traction = 10;
}
accelerationDefault = pStats.Acc;
if (accelerationDefault > 3)
{
pStats.Acc -= 3;
}
else
{
pStats.Acc = 1;
}
//pStats.Traction *= 1.25f;
//pStats.Acc *= 0.75f;
}
}
private void OnTriggerExit(Collider other)
{
if (other.tag == "Player")
{
PlayerStats pStats = other.gameObject.GetComponent<PlayerStats>();
pStats.Traction = tractionDefault;
pStats.Acc = accelerationDefault;
//pStats.Traction /= 1.25f;
//pStats.Acc /= 0.75f;
}
}
}

View File

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

View File

@@ -0,0 +1,87 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Thunderstorm : MonoBehaviour
{
private bool inAir = false;
private float DURATION = 30.0f;
private float DISTANCE_THRESHOLD = 5.0f;
private float ZAP_COUNTDOWN = 5.0f;
private Vector3 down = Vector3.down;
private RaycastHit hit;
private Ray ray;
public GameObject playerObject; //When spawning set this programatically as a part of the spawn function
private PlayerMovement playerController;
public ParticleSystem clouds;
public ParticleSystem bolt;
public ParticleSystem pow;
public ParticleSystem sparks;
private void Awake()
{
playerController = playerObject.GetComponent<PlayerMovement>();
gameObject.transform.parent = playerObject.transform;
}
// Start is called before the first frame update
void Start()
{
ray = new Ray(gameObject.transform.position, down);
Physics.Raycast(ray, out hit, DISTANCE_THRESHOLD);
if (hit.collider == null)
{
inAir = true;
}
clouds.Play();
}
private void FixedUpdate()
{
//Last for a set duration
DURATION -= Time.fixedDeltaTime;
if (DURATION >= 0 && !inAir)
{
//Stop particle systems <-- is this needed?
Destroy(gameObject);
}
//If player is grounded we will stop zap counter
if(playerController.isGrounded)
{
inAir = false;
bolt.Stop();
sparks.Stop();
pow.Stop();
ZAP_COUNTDOWN = 5.0f;
}
else // Otherwise check if player is high enough to zap
{
ray = new Ray(gameObject.transform.position, down);
Physics.Raycast(ray, out hit, DISTANCE_THRESHOLD);
if (hit.collider == null)
{
inAir = true;
bolt.Play();
sparks.Play();
pow.Play();
}
}
ThunderCoroutine();
}
private void ThunderCoroutine()
{
if (inAir)
{
ZAP_COUNTDOWN -= Time.fixedDeltaTime;
if(ZAP_COUNTDOWN >= 0)
{
playerController.GetHit(down, 100); //Needs to be tested if force is appropriate
ZAP_COUNTDOWN = 5.0f;
}
}
}
}

View File

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