Polishing 1
General polishing commit
This commit is contained in:
38
Assets/Forest_Scripts/CutscenePlayer.cs
Normal file
38
Assets/Forest_Scripts/CutscenePlayer.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CutscenePlayer : MonoBehaviour {
|
||||
|
||||
public Sprite[] theSprites;
|
||||
public Image theBase;
|
||||
public float speed = 1.0f;
|
||||
private float TUNS = 0.0f;
|
||||
private int i = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
if (i < theSprites.Length + 1) {
|
||||
if (Time.time > TUNS)
|
||||
{
|
||||
i += 1;
|
||||
|
||||
if(i < theSprites.Length)
|
||||
theBase.sprite = theSprites[i];
|
||||
|
||||
TUNS = Time.time + speed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/CutscenePlayer.cs.meta
Normal file
11
Assets/Forest_Scripts/CutscenePlayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 719609795ac17cf44ae9bbe0f5137724
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/Forest_Scripts/LightLurch.cs
Normal file
132
Assets/Forest_Scripts/LightLurch.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LightLurch : MonoBehaviour {
|
||||
|
||||
private enum states { standard, lit, unlit }
|
||||
[Header("Distances")]
|
||||
[SerializeField]
|
||||
private float standardRadius, standardIntensity;
|
||||
[SerializeField]
|
||||
private float tinyRadius, tinyIntensity;
|
||||
[SerializeField]
|
||||
private float maxRadius, maxIntensity;
|
||||
[Header("Emission")]
|
||||
[SerializeField]
|
||||
private float emissionMultiplier = 1;
|
||||
private float emissionValue;
|
||||
[SerializeField]
|
||||
private float maxEmission, minEmission, baseEmission = 1;
|
||||
|
||||
private float intensitySnapshot;
|
||||
private Light lightSource;
|
||||
private Renderer lurchRenderer;
|
||||
|
||||
[SerializeField]
|
||||
private KeyCode triggerButton;
|
||||
[SerializeField]
|
||||
private float litDuration;
|
||||
[SerializeField]
|
||||
private float unLitDuration;
|
||||
[SerializeField]
|
||||
private float animationSpeed;
|
||||
|
||||
[Header("Debug")]
|
||||
[SerializeField]
|
||||
private states state;
|
||||
[SerializeField]
|
||||
private float t = 0;
|
||||
[SerializeField]
|
||||
private float ldCounter;
|
||||
private float llCounter;
|
||||
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
state = states.standard;
|
||||
GameObject lurch = GetComponent<LurchMovement>().theLurch.gameObject;
|
||||
lightSource = lurch.GetComponent<Light>();
|
||||
lurchRenderer = lurch.GetComponent<Renderer>();
|
||||
lightSource.color = lurchRenderer.material.GetColor("_Color");
|
||||
intensitySnapshot = lightSource.intensity;
|
||||
lurchRenderer.material.SetColor("_EmissionColor", lightSource.color * (emissionMultiplier * emissionValue));
|
||||
emissionValue = baseEmission;
|
||||
lurchRenderer.material.EnableKeyword("_EMISSION");
|
||||
lightSource.enabled = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
t += Time.deltaTime * animationSpeed;
|
||||
lurchRenderer.material.SetColor("_EmissionColor", lightSource.color * (emissionMultiplier * emissionValue));
|
||||
switch (state)
|
||||
{
|
||||
case states.standard:
|
||||
StandardGlow();
|
||||
break;
|
||||
case states.lit:
|
||||
LightUp();
|
||||
break;
|
||||
case states.unlit:
|
||||
GlowLow();
|
||||
break;
|
||||
}
|
||||
if (Input.GetKeyDown(triggerButton) && state == states.standard)
|
||||
{
|
||||
t = 0;
|
||||
ldCounter = litDuration;
|
||||
llCounter = animationSpeed;
|
||||
state = states.lit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void StandardGlow()
|
||||
{
|
||||
lightSource.intensity = Mathf.Lerp(tinyIntensity, standardIntensity, t);
|
||||
lightSource.range = Mathf.Lerp(tinyRadius, standardRadius, t);
|
||||
emissionValue = Mathf.Lerp(minEmission, baseEmission, t);
|
||||
|
||||
}
|
||||
|
||||
private void LightUp()
|
||||
{
|
||||
lightSource.intensity = Mathf.Lerp(standardIntensity, maxIntensity, t);
|
||||
lightSource.range = Mathf.Lerp(standardRadius, maxRadius, t);
|
||||
emissionValue = Mathf.Lerp(baseEmission, maxEmission, t);
|
||||
|
||||
if (ldCounter <= 0)
|
||||
{
|
||||
t = 0;
|
||||
state = states.unlit;
|
||||
ldCounter = unLitDuration;
|
||||
llCounter = animationSpeed;
|
||||
return;
|
||||
}
|
||||
ldCounter -= Time.deltaTime;
|
||||
|
||||
}
|
||||
|
||||
private void GlowLow()
|
||||
{
|
||||
lightSource.intensity = Mathf.Lerp(maxIntensity, tinyIntensity, t);
|
||||
lightSource.range = Mathf.Lerp(maxRadius, tinyRadius, t);
|
||||
emissionValue = Mathf.Lerp(maxEmission, minEmission, t);
|
||||
|
||||
|
||||
if (llCounter <= 0)
|
||||
{
|
||||
if (ldCounter <= 0)
|
||||
{
|
||||
t = 0;
|
||||
state = states.standard;
|
||||
llCounter = animationSpeed;
|
||||
return;
|
||||
}
|
||||
ldCounter -= Time.deltaTime;
|
||||
}
|
||||
llCounter -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/LightLurch.cs.meta
Normal file
11
Assets/Forest_Scripts/LightLurch.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b614d5a678d653549b924deec5548458
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
254
Assets/Forest_Scripts/LurchMovement.cs
Normal file
254
Assets/Forest_Scripts/LurchMovement.cs
Normal file
@@ -0,0 +1,254 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LurchMovement : MonoBehaviour {
|
||||
|
||||
[Header("Mouse")]
|
||||
[Range(0.01f, 4.0f)]
|
||||
public float mouseSensitivity;
|
||||
public bool invertMouse;
|
||||
public bool lockMouse;
|
||||
|
||||
private float yaw = 0.0f;
|
||||
private float pitch = 0.0f;
|
||||
|
||||
[Header("Smooth Follow")]
|
||||
[Range(0.1f, 2)]
|
||||
public float speed;
|
||||
private Vector3 velocity = Vector3.zero;
|
||||
|
||||
[Header("Lurch")]
|
||||
public Transform theLurch;
|
||||
private Rigidbody lurchBody;
|
||||
|
||||
[Header("Jump Charge")]
|
||||
public float maxJumpForce;
|
||||
public float upForceModifier = 2.0f;
|
||||
private float currentJumpForce;
|
||||
private float currentJumpForwardForce;
|
||||
public float forceIncreaseSpeed;
|
||||
|
||||
public Color normalColor;
|
||||
public Color fullyChargedColor;
|
||||
private Color lerpedColor;
|
||||
|
||||
public Vector3 normalSize;
|
||||
[Range(0.1f, 1.0f)]
|
||||
public float chargedSizeModifier;
|
||||
private Vector3 chargedSize;
|
||||
private Vector3 currentSize;
|
||||
|
||||
static float t = 0.0f;
|
||||
|
||||
[Header("Jump n Stick")]
|
||||
public bool canStick;
|
||||
[SerializeField]
|
||||
private float cooldown;
|
||||
[SerializeField]
|
||||
private Transform stickPoint;
|
||||
private bool stickToGround = false;
|
||||
[SerializeField]
|
||||
private float stickyOffset = 1;
|
||||
private bool blockCharge = false;
|
||||
|
||||
[Header("Gliding")]
|
||||
public bool canGlide;
|
||||
private Vector3 glideSize;
|
||||
[Range(1.0f, 10.0f)]
|
||||
public float glideForce;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
lurchBody = theLurch.GetComponent<Rigidbody>();
|
||||
normalSize = theLurch.transform.localScale;
|
||||
chargedSize = theLurch.transform.localScale * chargedSizeModifier;
|
||||
glideSize = new Vector3(normalSize.x, normalSize.y * 0.5f, normalSize.z);
|
||||
stickPoint = new GameObject().transform;
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
theLurch.rotation = Quaternion.Euler(0, transform.eulerAngles.y, 0);
|
||||
|
||||
theLurch.GetComponent<Renderer>().material.color = lerpedColor;
|
||||
theLurch.transform.localScale = currentSize;
|
||||
|
||||
MouseControl();
|
||||
JumpControl();
|
||||
SmoothFollow();
|
||||
Gliding();
|
||||
StickToPoint();
|
||||
}
|
||||
|
||||
public void DontStick()
|
||||
{
|
||||
stickToGround = false;
|
||||
}
|
||||
void MouseControl()
|
||||
{
|
||||
float mouseInputX = Input.GetAxis("Mouse X") * mouseSensitivity;
|
||||
float mouseInputY;
|
||||
|
||||
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
|
||||
|
||||
if (!invertMouse)
|
||||
{
|
||||
mouseInputY = Input.GetAxis("Mouse Y") * mouseSensitivity;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseInputY = -Input.GetAxis("Mouse Y") * mouseSensitivity;
|
||||
}
|
||||
|
||||
yaw += mouseInputX;
|
||||
pitch -= mouseInputY;
|
||||
|
||||
if (lockMouse)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
void SmoothFollow()
|
||||
{
|
||||
Vector3 targetPosition = theLurch.TransformPoint(new Vector3(0, 0, 0));
|
||||
|
||||
// Smoothly move the camera towards that target position
|
||||
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, speed);
|
||||
}
|
||||
|
||||
void JumpControl()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire1"))
|
||||
{
|
||||
blockCharge = false;
|
||||
}
|
||||
if (Input.GetButton("Fire1") && currentJumpForce < maxJumpForce && cooldown <= 0 && !blockCharge )
|
||||
{
|
||||
currentJumpForce += forceIncreaseSpeed;
|
||||
lerpedColor = Color.Lerp(normalColor, fullyChargedColor, t);
|
||||
if (t < 1.0f)
|
||||
{
|
||||
t += 2 * Time.deltaTime;
|
||||
}
|
||||
|
||||
currentSize = Vector3.Lerp(currentSize, chargedSize, Time.deltaTime * 1.5f);
|
||||
|
||||
}
|
||||
else if(!Input.GetButton("Fire1"))
|
||||
{
|
||||
lerpedColor = normalColor;
|
||||
t = 0.0f;
|
||||
currentSize = Vector3.Lerp(currentSize, normalSize, Time.deltaTime * 5f);
|
||||
|
||||
}
|
||||
|
||||
if (cooldown > 0.0f)
|
||||
{
|
||||
cooldown -= Time.deltaTime;
|
||||
currentJumpForce = 0.0f;
|
||||
}
|
||||
|
||||
if (Input.GetButtonUp("Fire1") && cooldown <= 0 && !blockCharge) {
|
||||
cooldown = 0.5f;
|
||||
lurchBody.isKinematic = false;
|
||||
stickToGround = false;
|
||||
|
||||
lurchBody.AddForce(theLurch.forward * currentJumpForce, ForceMode.Impulse);
|
||||
lurchBody.AddForce(theLurch.up * currentJumpForce * upForceModifier, ForceMode.Impulse);
|
||||
}
|
||||
else if (Input.GetButton("Fire2")) {
|
||||
currentJumpForce = 0.0f;
|
||||
cooldown = 0.5f;
|
||||
currentSize = Vector3.Lerp(currentSize, normalSize, Time.deltaTime * 5f);
|
||||
blockCharge = true;
|
||||
}
|
||||
else if (LurchOnGround() && Time.time > cooldown)
|
||||
{
|
||||
//stickToGround = true;
|
||||
lurchBody.isKinematic = true;
|
||||
}
|
||||
else if (!LurchOnGround() && Time.time > cooldown && !AmSticking())
|
||||
{
|
||||
currentJumpForce = 0.0f;
|
||||
}
|
||||
|
||||
if (AmSticking())
|
||||
{
|
||||
lurchBody.isKinematic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lurchBody.isKinematic = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Gliding()
|
||||
{
|
||||
|
||||
if (canGlide && !lurchBody.isKinematic && Input.GetButton("Fire1") &&!LurchOnGround())
|
||||
{
|
||||
Debug.Log("Ich kann jetzt gleiten");
|
||||
theLurch.transform.localScale = glideSize;
|
||||
|
||||
lurchBody.AddForce(theLurch.forward * glideForce);
|
||||
lurchBody.AddForce(theLurch.up * 0.08f, ForceMode.Impulse);
|
||||
|
||||
}
|
||||
if (!Input.GetButton("Fire1"))
|
||||
{
|
||||
theLurch.transform.localScale = currentSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool LurchOnGround()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(theLurch.position, Vector3.down, out hit, 0.34f) && cooldown <= 0.0f)
|
||||
{
|
||||
if (!stickToGround)
|
||||
{
|
||||
lurchBody.isKinematic = true;
|
||||
stickPoint.parent = hit.transform;
|
||||
stickPoint.position = hit.point;
|
||||
stickToGround = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AmSticking()
|
||||
{
|
||||
if (canStick) {
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(theLurch.position, theLurch.forward, out hit, 1.4f))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (lurchBody.isKinematic)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void StickToPoint()
|
||||
{
|
||||
if (stickToGround)
|
||||
{
|
||||
theLurch.position = stickPoint.position + new Vector3(0, stickyOffset, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/LurchMovement.cs.meta
Normal file
11
Assets/Forest_Scripts/LurchMovement.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a548db4f33b8a24aa4ebca81f61e6dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Forest_Scripts/LurchRespawn.cs
Normal file
135
Assets/Forest_Scripts/LurchRespawn.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LurchRespawn : MonoBehaviour {
|
||||
|
||||
//Spawnpoints
|
||||
[SerializeField]
|
||||
private List<GameObject> respawnPoints = new List<GameObject>();
|
||||
private GameObject lastRespawnPoint;
|
||||
private int lastRespawnPointIndex;
|
||||
|
||||
//Refs
|
||||
[SerializeField]
|
||||
private Transform lowerBounds;
|
||||
|
||||
//ExtRefs
|
||||
[SerializeField]
|
||||
private GameObject lurch;
|
||||
private LurchMovement compLurchMovement;
|
||||
|
||||
//States
|
||||
private bool offGround = false;
|
||||
private Vector3 lastGroundPos;
|
||||
|
||||
//Settings
|
||||
[Header("Settings")]
|
||||
[SerializeField]
|
||||
[Tooltip("Update the spawnpoint every n frames")]
|
||||
private int UpdateFrequenzy = 15;
|
||||
[SerializeField]
|
||||
private float maxFallDist = 100;
|
||||
public float maxDistanceToPoint = 10.0f;
|
||||
[SerializeField]
|
||||
private KeyCode respawnKey = KeyCode.R;
|
||||
|
||||
void Start () {
|
||||
if (respawnPoints.Count == 0)
|
||||
{
|
||||
this.enabled = false;
|
||||
throw new System.Exception("No respawn points assigned");
|
||||
}
|
||||
compLurchMovement = gameObject.GetComponent<LurchMovement>();
|
||||
lastGroundPos = lurch.transform.position;
|
||||
|
||||
lastRespawnPoint = respawnPoints[0];
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if(Input.GetKeyDown(respawnKey))
|
||||
{
|
||||
RespawnLurch("Player respawned");
|
||||
}
|
||||
|
||||
if(!offGround)
|
||||
{
|
||||
if(!compLurchMovement.LurchOnGround())
|
||||
{
|
||||
offGround = true;
|
||||
lastGroundPos = lurch.transform.position;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (compLurchMovement.LurchOnGround())
|
||||
{
|
||||
offGround = false;
|
||||
float fallDist = Vector3.Distance(lurch.transform.position, lastGroundPos);
|
||||
if (fallDist > maxFallDist)
|
||||
{
|
||||
//We fell too far
|
||||
RespawnLurch("Lurch fell too far");
|
||||
}
|
||||
lastGroundPos = lurch.transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
if(Time.frameCount % UpdateFrequenzy == 0)
|
||||
{
|
||||
UpdateRespawnPoint();
|
||||
}
|
||||
|
||||
if (Time.frameCount % UpdateFrequenzy * 2 == 0)
|
||||
{
|
||||
CheckBounds();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CheckBounds()
|
||||
{
|
||||
if(transform.position.y < lowerBounds.position.y)
|
||||
{
|
||||
RespawnLurch("Lurch went out of bounds");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRespawnPoint()
|
||||
{
|
||||
float nextPointDist;
|
||||
float lastPointDist = Vector3.Distance(transform.position, lastRespawnPoint.transform.position);
|
||||
for (int i = lastRespawnPointIndex; i < respawnPoints.Count; i++)
|
||||
{
|
||||
nextPointDist = Vector3.Distance(transform.position, respawnPoints[i].transform.position);
|
||||
if (nextPointDist < lastPointDist && nextPointDist < maxDistanceToPoint)
|
||||
{
|
||||
lastRespawnPoint = respawnPoints[i];
|
||||
lastRespawnPointIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RespawnLurch(string message = "Lurch respawned")
|
||||
{
|
||||
Debug.LogWarning("Lurch respawned: " + message);
|
||||
compLurchMovement.DontStick();
|
||||
lurch.transform.position = lastRespawnPoint.transform.position;
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
for(int i = 0; i < respawnPoints.Count; i++)
|
||||
{
|
||||
if(respawnPoints[i] == lastRespawnPoint)
|
||||
{
|
||||
Gizmos.DrawIcon(respawnPoints[i].transform.position, "RespawnActive.png");
|
||||
} else if (i < lastRespawnPointIndex)
|
||||
{
|
||||
Gizmos.DrawIcon(respawnPoints[i].transform.position, "RespawnInactive.png");
|
||||
} else
|
||||
Gizmos.DrawIcon(respawnPoints[i].transform.position, "Respawn.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/LurchRespawn.cs.meta
Normal file
11
Assets/Forest_Scripts/LurchRespawn.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 167337a6a977deb408440dbf31acb6c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Forest_Scripts/MateMate.cs
Normal file
39
Assets/Forest_Scripts/MateMate.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MateMate : MonoBehaviour {
|
||||
|
||||
public bool mateStick;
|
||||
public bool mateGlide;
|
||||
public bool mateGlow;
|
||||
|
||||
public GameObject cutscene;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.transform.root.GetComponentInChildren<LurchMovement>())
|
||||
{
|
||||
if(mateStick)
|
||||
other.transform.root.GetComponentInChildren<LurchMovement>().canStick = true;
|
||||
|
||||
if(mateGlide)
|
||||
other.transform.root.GetComponentInChildren<LurchMovement>().canGlide = true;
|
||||
|
||||
if(mateGlow)
|
||||
other.transform.root.GetComponentInChildren<LightLurch>().enabled = true;
|
||||
|
||||
cutscene.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/MateMate.cs.meta
Normal file
11
Assets/Forest_Scripts/MateMate.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70076831801618547a292c354b3bba38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Forest_Scripts/Objects.meta
Normal file
8
Assets/Forest_Scripts/Objects.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a972842cd67bc904a93eac69a3331151
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Assets/Forest_Scripts/Objects/Movement.cs
Normal file
90
Assets/Forest_Scripts/Objects/Movement.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Movement : MonoBehaviour {
|
||||
|
||||
[System.Serializable]
|
||||
class MovementDirection
|
||||
{
|
||||
[SerializeField]
|
||||
private bool enabled = false;
|
||||
[SerializeField]
|
||||
private enum Direction { Left_Right, Up_Down, Fwd_Bkw }
|
||||
[SerializeField]
|
||||
private Direction direction;
|
||||
[SerializeField]
|
||||
private bool loop = false;
|
||||
[SerializeField]
|
||||
private bool goBack = false;
|
||||
[SerializeField]
|
||||
private float distance = 100;
|
||||
[SerializeField]
|
||||
private float speed = 0;
|
||||
[SerializeField]
|
||||
private float dist;
|
||||
|
||||
private Vector3 initialPosition;
|
||||
public void SetInitialPosition(Vector3 initPos)
|
||||
{
|
||||
initialPosition = initPos;
|
||||
}
|
||||
|
||||
public Vector3 Move(Vector3 dirIn)
|
||||
{
|
||||
int dir = (int)direction;
|
||||
Vector3 dirOut = dirIn;
|
||||
enabled = loop ? true : enabled;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
dist = initialPosition[dir] - dirOut[dir];
|
||||
|
||||
if (goBack)
|
||||
{
|
||||
dirOut[dir] += speed * Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
dirOut[dir] -= speed * Time.deltaTime;
|
||||
}
|
||||
|
||||
if (dist > distance && !goBack)
|
||||
{
|
||||
if (loop)
|
||||
{
|
||||
goBack = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
else if (dist <= 0)
|
||||
{
|
||||
goBack = false;
|
||||
|
||||
}
|
||||
}
|
||||
return dirOut;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private List<MovementDirection> directions;
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
foreach (MovementDirection direction in directions)
|
||||
{
|
||||
direction.SetInitialPosition(transform.position);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
foreach ( MovementDirection direction in directions)
|
||||
{
|
||||
transform.position = direction.Move(transform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/Objects/Movement.cs.meta
Normal file
11
Assets/Forest_Scripts/Objects/Movement.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff6f74910bdc270439212f0b80ab09b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Forest_Scripts/TriggerEffects.meta
Normal file
8
Assets/Forest_Scripts/TriggerEffects.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8b7c82b907af1c45a4d5abd120ab492
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Assets/Forest_Scripts/TriggerEffects/DarkAmbience.cs
Normal file
63
Assets/Forest_Scripts/TriggerEffects/DarkAmbience.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DarkAmbience : MonoBehaviour {
|
||||
|
||||
private float defaultEnvLightingIntensity, defaultEnfReflectionIntensity;
|
||||
[SerializeField]
|
||||
private float targetEnvLightingIntensity, targetEnfReflectionIntensity;
|
||||
[SerializeField]
|
||||
private float lerpSpeed;
|
||||
[SerializeField]
|
||||
private bool isDark = false;
|
||||
private float t = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
defaultEnvLightingIntensity = RenderSettings.ambientIntensity;
|
||||
defaultEnfReflectionIntensity = RenderSettings.reflectionIntensity;
|
||||
}
|
||||
|
||||
public void SwitchDarkness(bool dark)
|
||||
{
|
||||
isDark = dark;
|
||||
t = 0;
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
t = 0;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if(other.transform.root.tag == "Player")
|
||||
{
|
||||
SwitchDarkness(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.transform.root.tag == "Player")
|
||||
{
|
||||
SwitchDarkness(false);
|
||||
}
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
if(isDark)
|
||||
{
|
||||
RenderSettings.ambientIntensity = Mathf.Lerp(defaultEnvLightingIntensity, targetEnvLightingIntensity, t);
|
||||
RenderSettings.reflectionIntensity = Mathf.Lerp(defaultEnfReflectionIntensity, targetEnfReflectionIntensity, t);
|
||||
}
|
||||
else if (t < 1)
|
||||
{
|
||||
RenderSettings.ambientIntensity = Mathf.Lerp(targetEnvLightingIntensity, defaultEnvLightingIntensity, t);
|
||||
RenderSettings.reflectionIntensity = Mathf.Lerp(targetEnfReflectionIntensity, defaultEnfReflectionIntensity , t);
|
||||
}
|
||||
t += Time.deltaTime * lerpSpeed;
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/TriggerEffects/DarkAmbience.cs.meta
Normal file
11
Assets/Forest_Scripts/TriggerEffects/DarkAmbience.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f0436f919a77164da3e5047c1b7795f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Forest_Scripts/TriggerEffects/EliminatePlayer.cs
Normal file
50
Assets/Forest_Scripts/TriggerEffects/EliminatePlayer.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EliminatePlayer : MonoBehaviour {
|
||||
|
||||
[SerializeField]
|
||||
private string name = "Generic trap";
|
||||
[SerializeField]
|
||||
private float resapwnDelay = 0;
|
||||
[Tooltip("Optional particle effect. Spawned when player enters the trigger")]
|
||||
[SerializeField]
|
||||
private GameObject effect;
|
||||
[SerializeField]
|
||||
private LurchRespawn player;
|
||||
[SerializeField]
|
||||
private bool killQueued = false;
|
||||
[SerializeField]
|
||||
private float rdCounter = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if (rdCounter <= 0 && killQueued)
|
||||
{
|
||||
player.RespawnLurch(name);
|
||||
killQueued = false;
|
||||
} else
|
||||
{
|
||||
rdCounter -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.transform.root.tag == "Player")
|
||||
{
|
||||
rdCounter = resapwnDelay;
|
||||
killQueued = true;
|
||||
if(effect != null)
|
||||
{
|
||||
GameObject.Instantiate(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/TriggerEffects/EliminatePlayer.cs.meta
Normal file
11
Assets/Forest_Scripts/TriggerEffects/EliminatePlayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 558ac06dec86b64459dd109124ea89be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/Forest_Scripts/TriggerEffects/TriggerActivate.cs
Normal file
54
Assets/Forest_Scripts/TriggerEffects/TriggerActivate.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TriggerActivate : MonoBehaviour {
|
||||
|
||||
public AudioSource theAudio;
|
||||
public AudioClip theClip;
|
||||
public GameObject theObject;
|
||||
public Rigidbody theRigidBody;
|
||||
private Vector3 startPos;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
if (theObject)
|
||||
{
|
||||
theObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (theRigidBody)
|
||||
{
|
||||
theRigidBody.isKinematic = true;
|
||||
startPos = theRigidBody.transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.transform.root.tag == "Player") {
|
||||
if (theAudio)
|
||||
{
|
||||
theAudio.clip = theClip;
|
||||
theAudio.Play();
|
||||
}
|
||||
|
||||
if (theObject)
|
||||
{
|
||||
theObject.SetActive(true);
|
||||
}
|
||||
|
||||
if (theRigidBody)
|
||||
{
|
||||
theRigidBody.isKinematic = false;
|
||||
theRigidBody.transform.position = startPos;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Forest_Scripts/TriggerEffects/TriggerActivate.cs.meta
Normal file
11
Assets/Forest_Scripts/TriggerEffects/TriggerActivate.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83c4b1f877f8abd49a2b7e25885df4e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TriggerDeactivateLight : MonoBehaviour {
|
||||
|
||||
public LightLurch theScript;
|
||||
public Light theLight;
|
||||
public bool activate;
|
||||
public bool deactivate;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.transform.root.tag == "Player")
|
||||
{
|
||||
if (deactivate)
|
||||
{
|
||||
theScript.enabled = false;
|
||||
theLight.enabled = false;
|
||||
}
|
||||
|
||||
if (activate)
|
||||
{
|
||||
theScript.enabled = true;
|
||||
theLight.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16cc9ec86764da94098c2d3773e4e6e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user