Skip to content
Snippets Groups Projects
Commit 444628bc authored by Henry's avatar Henry
Browse files

there can be only 1

parent f439a2bf
No related branches found
No related tags found
No related merge requests found
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Glider : MonoBehaviour
{
[Range(0f, 20f)] public float activeTime = 10f;
[Range(0f, -20f)] public float glideFallSpeed = -1f;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
StartCoroutine(GliderActive(other));
gameObject.transform.position = new Vector3(0, -10000, 0);
}
}
public IEnumerator GliderActive(Collider collision)
{
var roller = collision.gameObject.GetComponent<Roll>();
roller.glideFallSpeed = glideFallSpeed;
roller.gliding = true;
yield return new WaitForSeconds(activeTime);
roller.gliding = false;
Destroy(gameObject);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Speed : MonoBehaviour
{
[Range(1f, 10f)] public float speedMultiplier = 1f;
[Range(0f, 20f)] public float activeTime = 3f;
[Range(0f, 10f)] public float speedFallOffTime = 1f;
public bool refillStamina = false;
public bool freezeStamina = false;
public bool respawn = false;
public float resawnTime = 10f;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
var roller = other.gameObject.GetComponent<Roll>();
roller.powerUpDecay = speedFallOffTime;
roller.powerUpDecayTime = speedFallOffTime;
roller.powerUpActiveTime = activeTime;
roller.powerUpSpeedMulti = speedMultiplier;
if (refillStamina) { roller.sprintTimeCurrent = roller.sprintTimeTotal; }
if (freezeStamina) { StartCoroutine(LockStamina(roller)); }
else if (respawn) { StartCoroutine(RespawnTimer()); }
else { Destroy(gameObject); }
}
}
public IEnumerator LockStamina(Roll roller)
{
roller.staminaLocked = true;
gameObject.transform.position = new Vector3(0, -10000, 0);
yield return new WaitForSeconds(activeTime);
roller.staminaLocked = false;
Destroy(gameObject);
}
public IEnumerator RespawnTimer()
{
var startPos = transform.position;
gameObject.transform.position = new Vector3(0, -10000, 0);
yield return new WaitForSeconds(resawnTime);
gameObject.transform.position = startPos;
}
}
fileFormatVersion: 2
guid: ecf2472dc6cc0e24e8bf9aa0dc6ca890
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment