Merge pull request #2 from Lautha1/Thunderstorm-&-Fixes

Thunderstorm Programmed
This commit is contained in:
Julia 2021-11-17 13:36:57 -06:00 committed by GitHub
commit df46bee0f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 17 deletions

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -180,6 +180,11 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
--- !u!1 &28406467 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 5633209979457551608, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
m_PrefabInstance: {fileID: 28406466}
m_PrefabAsset: {fileID: 0}
--- !u!1 &109409391
GameObject:
m_ObjectHideFlags: 0
@ -20173,6 +20178,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 22b9223de86b6b940949490b6302be85, type: 3}
m_Name:
m_EditorClassIdentifier:
playerObject: {fileID: 28406467}
clouds: {fileID: 1296818170}
bolt: {fileID: 1525445328}
pow: {fileID: 283204433}
sparks: {fileID: 1139442489}
--- !u!1 &750468703
GameObject:
m_ObjectHideFlags: 0
@ -30740,7 +30750,7 @@ ParticleSystem:
cullingMode: 0
ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1}
looping: 0
looping: 1
prewarm: 0
playOnAwake: 1
useUnscaledTime: 0

View File

@ -4,27 +4,84 @@ using UnityEngine;
public class Thunderstorm : MonoBehaviour
{
//DESIGN DECISION, does this ability happen once or last for a DURATION (SAY 30 SECONDS?)
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;
// Should function as follows
//Attaches to player (target)
//While target is above 'Y' height
//spawn particle system
//If player touches ground before 5 seconds have passed
//No zap
//Else if player doesn't touch ground
//Zap em, hit them with a strong downwards impact, and ragdoll them for 3 seconds (2 if fast standup?)
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();
}
// Update is called once per frame
void Update()
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

@ -370,7 +370,7 @@ public class PlayerMovement : NetworkBehaviour
}
//Ragdoll Functions
private void getHit(Vector3 dir, float force){
public void getHit(Vector3 dir, float force){
if(firstHit == false){
EnableRagdoll();
dir.Normalize();