Merge branch 'staging' into portals-and-body

This commit is contained in:
2022-03-29 09:30:41 +00:00
115 changed files with 20376 additions and 4814 deletions

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hover : MonoBehaviour
{
Material material;
Color color;
Outline outline;
// Start is called before the first frame update
void Start()
{
material = GetComponent<Renderer>().material;
color = material.color;
outline = gameObject.GetComponent<Outline>();
outline.enabled = false;
}
// Update is called once per frame
void Update()
{
}
public void HoverStart()
{
outline.enabled = true;
}
public void HoverEnd()
{
outline.enabled = false;
}
}

View File

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

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Menu : MonoBehaviour
{
public InputActionReference toggleReference;
// Start is called before the first frame update
void Awake()
{
toggleReference.action.started += Toggle;
}
private void OnDestroy()
{
toggleReference.action.started -= Toggle;
}
void Toggle(InputAction.CallbackContext context)
{
bool isActive = gameObject.active;
gameObject.SetActive(!isActive);
}
// Update is called once per frame
void Update()
{
}
}

View File

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

View File

@@ -28,4 +28,10 @@ public class NoddingMovement : MonoBehaviour
transform.Translate(new Vector3(camera.transform.forward.x, 0, camera.transform.forward.z) * speed * Time.deltaTime * (camera.transform.eulerAngles.x-360));
}
}
public void toggle()
{
bool isActive = this.enabled;
this.enabled = (!isActive);
}
}

View File

@@ -2,17 +2,20 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InventoryItem : MonoBehaviour
public class TestRotator : MonoBehaviour
{
private GameObject cube;
// Start is called before the first frame update
void Start()
{
cube = GameObject.Find("Cube (1)");
}
// Update is called once per frame
void Update()
{
cube.transform.Rotate(0, 1, 0);
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using System;
using TMPro;
using UnityEngine;
public class ConsolePrinter : MonoBehaviour
{
static string historyOutput = "";
public TMP_Text textBox;
void OnEnable()
{
Application.logMessageReceived += Log;
}
void OnDisable()
{
Application.logMessageReceived -= Log;
}
private void Log(string logString, string stackTrace, LogType type)
{
historyOutput = Time.fixedTime + ": " + logString + "\n" + historyOutput;
if (historyOutput.Length > 5000)
{
historyOutput = historyOutput[..4000];
}
textBox.text = historyOutput;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: af6659aa65864ce9987c4e88ca2fa878
timeCreated: 1648411791

View File

@@ -1,39 +1,77 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
[Serializable]
[RequireComponent(typeof(XRSocketInteractor))]
public class Inventory : MonoBehaviour
{
public int slots = 1;
private List<int> _inv;
private XRSocketInteractor xrSocketInteractor;
public List<InventorySlot> additionalSlots;
public GameObject itemContainerPrefab;
private List<InventorySlot> _inventorySlots;
private void Awake()
{
xrSocketInteractor = GetComponent<XRSocketInteractor>();
_inv = new List<int>(slots);
var oldestInteractableSelected = xrSocketInteractor.GetOldestInteractableSelected();
xrSocketInteractor.selectEntered.AddListener(Call);
xrSocketInteractor.hoverEntered.AddListener(Call);
_inventorySlots = new List<InventorySlot>();
foreach (var inventorySlot in additionalSlots)
{
inventorySlot.SetParentInventory(this);
_inventorySlots.Add(inventorySlot);
}
}
private void Call(HoverEnterEventArgs arg0)
private void OnEnable()
{
Debug.Log("hoverenter "+arg0.interactableObject + " " + xrSocketInteractor.hasHover + " " + xrSocketInteractor.hasSelection);
var inventorySlotsInChildren = GetComponentsInChildren<InventorySlot>();
foreach (var inventorySlot in inventorySlotsInChildren)
{
inventorySlot.SetParentInventory(this);
_inventorySlots.Add(inventorySlot);
}
}
public bool AddItem(ItemData item)
{
if (item.canStack)
{
return AddItem(ConvertToInventoryItem(item));
}
return AddToFirstOpenSlot(item.gameObject);
}
public bool AddItem(InventoryItem item)
{
//Stacks the item if it already exists in the inventory.
foreach (var inventorySlot in _inventorySlots.Where(inventorySlot =>
inventorySlot.ContainsItem(item.GetItemid())))
{
inventorySlot.GetItem().ChangeCount(item.Count);
return true;
}
return AddToFirstOpenSlot(item.gameObject);
}
private void Call(SelectEnterEventArgs arg0)
private bool AddToFirstOpenSlot(GameObject item)
{
Debug.Log("selectenter "+arg0.interactableObject);
foreach (var inventorySlot in _inventorySlots.Where(inventorySlot => !inventorySlot.ContainsItem()))
{
inventorySlot.AssignItem(item);
return true;
}
return false;
}
}
private InventoryItem ConvertToInventoryItem(ItemData item)
{
var inventoryItem = Instantiate(itemContainerPrefab, transform);
itemContainerPrefab.GetComponent<InventoryItem>().itemPrefab = item.gameObject;
return inventoryItem.gameObject.GetComponent<InventoryItem>();
}
}

View File

@@ -1,11 +1,3 @@
fileFormatVersion: 2
guid: aca2b5bf18c279c4cb265c82010714b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
guid: 29f5f8aed8d641c3abc54850a6a876cc
timeCreated: 1648431912

View File

@@ -0,0 +1,172 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
[Serializable]
[RequireComponent(typeof(XRSocketInteractor))]
public class InventorySlot : MonoBehaviour
{
private XRSocketInteractor xrSocketInteractor;
private GameObject _itemInSlot;
private Inventory _parentInventory;
private void Awake()
{
xrSocketInteractor = GetComponent<XRSocketInteractor>();
var oldestInteractableSelected = xrSocketInteractor.GetOldestInteractableSelected();
xrSocketInteractor.selectEntered.AddListener(SelectEnter);
xrSocketInteractor.selectExited.AddListener(SelectExit);
xrSocketInteractor.hoverEntered.AddListener(HoverEnter);
xrSocketInteractor.hoverExited.AddListener(HoverExit);
}
private void HoverEnter(HoverEnterEventArgs args)
{
if (_itemInSlot == null) return;
if (_itemInSlot.GetComponent<InventoryItem>() == null) return;
if (_itemInSlot == args.interactableObject.transform.gameObject) return;
//Debug.Log("hoverenter "+args.interactableObject + " " + xrSocketInteractor.hasHover + " " + xrSocketInteractor.hasSelection);
var newItem = args.interactableObject.transform.gameObject;
var itemData = newItem.GetComponentInChildren<ItemData>();
Debug.Log("HOVER ENTER: "+itemData);
if (itemData.canStack && itemData.itemId == _itemInSlot.GetComponentInChildren<ItemData>().itemId)
{
var inventoryItem = newItem.GetComponent<InventoryItem>();
if (inventoryItem != null)
{
_itemInSlot.GetComponent<InventoryItem>().ChangeCount(inventoryItem.Count);
}
else
{
_itemInSlot.GetComponent<InventoryItem>().ChangeCount(1);
}
args.manager.interactableUnregistered += ManagerOninteractableUnregistered;
args.manager.UnregisterInteractable(args.interactableObject);
args.manager.interactableUnregistered -= ManagerOninteractableUnregistered;
}
}
private void HoverExit(HoverExitEventArgs args)
{
Debug.Log("hoverexit "+args.interactableObject + " " + xrSocketInteractor.hasHover + " " + xrSocketInteractor.hasSelection);
}
private void SelectEnter(SelectEnterEventArgs args)
{
Debug.Log("Added to slot item " + _itemInSlot);
var newItem = args.interactableObject.transform.gameObject;
//Converts the item into a inventory item
if (newItem.GetComponent<InventoryItem>() == null && newItem.GetComponent<ItemData>().canStack)
{
var load = Resources.Load("Helar/Item", typeof(GameObject)) as GameObject;
var instance = Instantiate(load, args.interactorObject.transform);
instance.GetComponent<InventoryItem>().itemPrefab = newItem.gameObject;
instance.transform.localScale = Vector3.one;
instance.transform.localPosition = Vector3.zero;
instance.GetComponent<InventoryItem>().enabled = true;
args.manager.interactableUnregistered += ManagerOninteractableUnregistered;
args.manager.UnregisterInteractable(args.interactableObject);
args.manager.interactableUnregistered -= ManagerOninteractableUnregistered;
args.interactableObject = instance.GetComponent<XRGrabInteractable>();
args.interactorObject.interactablesSelected.Add(instance.GetComponent<XRGrabInteractable>());
Debug.Log("Upgraded item to InventoryItem "+instance);
_itemInSlot = instance;
return;
}
_itemInSlot = newItem;
//xrSocketInteractor.attachTransform = _itemInSlot.transform;
Debug.Log("Holstered item" + _itemInSlot.GetComponentInChildren<ItemData>());
}
private void ManagerOninteractableUnregistered(InteractableUnregisteredEventArgs obj)
{
Debug.Log("Removing object "+ obj);
Destroy(obj.interactableObject.transform.gameObject);
}
private void SelectExit(SelectExitEventArgs args)
{
if (_itemInSlot == null) return;
if (_itemInSlot.GetComponent<InventoryItem>() == null) return;
var component = _itemInSlot.GetComponent<Rigidbody>();
component.useGravity = true;
component.angularDrag = 2f;
component.drag = 0.5f;
if (!_itemInSlot.GetComponentInChildren<ItemData>().canStack ||
_itemInSlot.GetComponent<InventoryItem>().Count == 1)
{
//var transformGameObject = _itemInSlot.GetComponentInChildren<ItemData>().transform.gameObject;
//Debug.Log(transformGameObject);
//args.interactableObject = transformGameObject.GetComponent<XRGrabInteractable>();
//todo change back to regular item
}
Debug.Log("Removed from slot item " + _itemInSlot);
_itemInSlot = null;
}
public void SetParentInventory(Inventory inventory)
{
_parentInventory = inventory;
}
public bool ContainsItem()
{
return _itemInSlot != null;
}
public bool ContainsItem(int id)
{
if (!ContainsItem()) return false;
var inventoryItem = _itemInSlot.GetComponent<InventoryItem>();
if (inventoryItem != null) return inventoryItem.GetItemid() == id;
return false;
}
public void AssignItem(GameObject newObject)
{
_itemInSlot = newObject;
}
public InventoryItem GetItem()
{
var inventoryItem = _itemInSlot.GetComponent<InventoryItem>();
if (inventoryItem == null) Debug.LogError("Item in slot doesn't have InventoryItem component");
return inventoryItem;
}
}

View File

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

View File

@@ -9,6 +9,7 @@ public class ItemSpawner : MonoBehaviour
public GameObject placeToSpawn;
public void SpawnItem()
{
//Debug.Log("Spawned " + objectToSpawn);
Instantiate(objectToSpawn, placeToSpawn.transform);
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
<<<<<<<< HEAD:Assets/Project Files/Scripts/Helar/Items.meta
guid: c509c0c7d8d7f2942a05792798d31fc0
folderAsset: yes
DefaultImporter:
========
guid: 1e00d72d45b494a4ea598ff34d46a589
PrefabImporter:
>>>>>>>> origin/joonasp_Milestone2:Assets/Project Files/Prefabs/JoonasP/EssenceNode.prefab.meta
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,115 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.Mathematics;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
[ExecuteAlways]
public class InventoryItem : MonoBehaviour
{
public GameObject itemPrefab;
private int _itemId;
private GameObject _childPrefab;
public int Count { get; private set; }
public TMP_Text itemCounterText;
private ItemData _itemData;
private void OnEnable()
{
if (itemPrefab == null)
{
enabled = false;
//Debug.LogError("Item has no attached prefab");
return;
}
enabled = true;
if (itemCounterText == null) itemCounterText = GetComponentInChildren<TMP_Text>();
_childPrefab = GetComponentInChildren<ItemData>()?.gameObject;
//Only attaches the prefab if it doesn't already have one ([ExecuteAlways] causes one to be spawned in editor).
if (_childPrefab != null) return;
_childPrefab = Instantiate(itemPrefab, transform);
_childPrefab.transform.localPosition = new Vector3(0, -0.45f, 0);
_childPrefab.transform.localScale = new Vector3(2, 2, 2);
_childPrefab.transform.rotation = quaternion.identity;
//Disable prefab components that arent relevant.
var colliderComponent = _childPrefab.GetComponent<Collider>();
if (colliderComponent != null) colliderComponent.enabled = false;
var rigidbodyComponent = _childPrefab.GetComponent<Rigidbody>();
if (rigidbodyComponent != null)
{
rigidbodyComponent.isKinematic = true;
rigidbodyComponent.useGravity = false;
}
var xrGrabInteractableComponent = _childPrefab.GetComponent<XRGrabInteractable>();
if (xrGrabInteractableComponent != null) xrGrabInteractableComponent.enabled = false;
}
private void Start()
{
_itemData = _childPrefab.GetComponent<ItemData>();
if (_itemData == null) Debug.LogError("Item prefab has no attached ItemData", _childPrefab);
_itemId = _itemData.itemId;
if (Count == 0) Count = 1;
UpdateText();
}
private void UpdateText()
{
itemCounterText.text = _itemData.canStack ? Count.ToString() : "";
}
/**
* Changes how many items are in this itemcontainer.
* Returns false if attempted to remove more items than exists in the container.
*/
public bool ChangeCount(int amount)
{
if (Count + amount < 0) return false;
Count += amount;
if (Count == 0)
{
//Destroys this gameobject if the count is 0 or lower
Destroy(this);
return true;
}
UpdateText();
return true;
}
public int GetItemid()
{
return _itemId;
}
public override string ToString()
{
return $"{base.ToString()}, Count: {Count}, ItemData: {_itemData}";
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class ItemData : MonoBehaviour
{
public int itemId;
public bool canStack;
public string itemName;
public string itemDescription;
public override string ToString()
{
return $"{base.ToString()}, itemId: {itemId}, canStack: {canStack}, itemName: {itemName}";
}
}

View File

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

View File

@@ -0,0 +1,83 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
public class EssenceNodeController : MonoBehaviour
{
[SerializeField]
private AudioSource chime;
public bool isTouched;
private bool followPlayer = false;
private Transform player;
private float timer;
private Material nodeMaterial;
private Coroutine decayCo;
private void Awake()
{
nodeMaterial = GetComponent<Renderer>().material;
}
public void Touched()
{
if (!isTouched)
{
GetComponent<Renderer>().material.color = Color.cyan;
chime.Play();
isTouched = true;
StopCoroutine(decayCo);
}
}
public void FollowPlayer()
{
followPlayer = true;
player = GameObject.FindGameObjectWithTag("MainCamera").transform;
StartCoroutine(Collect());
}
public void SetPitch(float value)
{
chime.pitch = value;
}
public void SetTimer(float seconds)
{
timer = seconds;
decayCo = StartCoroutine(Decay());
}
IEnumerator Collect()
{
yield return new WaitForSeconds(2f);
//TODO: Update value in player inventory
Destroy(gameObject);
}
IEnumerator Decay()
{
yield return new WaitForSeconds(timer);
Destroy(gameObject);
}
private void Update()
{
if (!isTouched)
{
//A way to either linearly reduce the alpha value of color or fade the color to gray (must react to changing timer values)
}
if (followPlayer)
{
transform.position = Vector3.Lerp(transform.position, new Vector3(player.position.x,player.position.y - 0.5f, player.position.z), Time.deltaTime);
}
}
}

View File

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

View File

@@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.XR.Interaction.Toolkit;
public class LeverController : MonoBehaviour
{
private Transform pivot; //The lever will use a pivot point
private Transform grabHand;
private bool leverGrabbed;
private bool eventCalled;
private bool leverDown;
private Vector3 handDelta;
private Vector3 lastPosition;
//These UnityEvent objects can be set in the inspector as any public methods from scripts
[SerializeField]
private UnityEvent onUp;
[SerializeField]
private UnityEvent onDown;
public float minAngle = 20f;
public float maxAngle = 75f;
public float hapticAmplitude = 1f;
public float hapticDuration = 0.1f;
public AudioSource upSound;
public AudioSource downSound;
//This script cannot work with multiplayer, see CheckHand() method
public Transform leftHand;
public Transform rightHand;
void Awake()
{
pivot = transform.parent;
leverGrabbed = false;
leverDown = false;
pivot.eulerAngles = new Vector3(pivot.eulerAngles.x, pivot.eulerAngles.y, minAngle);
leftHand = GameObject.Find("LeftHand Controller").transform;
rightHand = GameObject.Find("RightHand Controller").transform;
}
void Update()
{
if (leverGrabbed)
{
handDelta = lastPosition - grabHand.position; //The vector of hand movement between frames
pivot.RotateAround(pivot.position, pivot.forward, 200 * handDelta.y); //Is a Time.deltaTime multiplication needed here?
//Two following if statements set the up and down position angles and call events when angle is met
//Only one event is called per grab because the logic is in the update method
if(pivot.eulerAngles.z < minAngle)
{
pivot.eulerAngles = new Vector3(pivot.eulerAngles.x, pivot.eulerAngles.y, minAngle);
if (leverDown)
{
onUp.Invoke();
grabHand.gameObject.GetComponent<ActionBasedController>().SendHapticImpulse(hapticAmplitude, hapticDuration);
if (upSound != null) upSound.Play();
leverDown = false;
}
}
else if(pivot.eulerAngles.z > maxAngle)
{
pivot.eulerAngles = new Vector3(pivot.eulerAngles.x, pivot.eulerAngles.y, maxAngle);
if (!leverDown)
{
onDown.Invoke();
grabHand.gameObject.GetComponent<ActionBasedController>().SendHapticImpulse(hapticAmplitude, hapticDuration);
if (downSound != null) downSound.Play();
leverDown = true;
}
}
lastPosition = grabHand.position;
}
}
public void GrabLever()
{
CheckHand();
leverGrabbed = !leverGrabbed;
handDelta = Vector3.zero;
lastPosition = grabHand.position;
eventCalled = false;
}
private void CheckHand()
{
float leftDistance = Vector3.Distance(leftHand.position, transform.position);
float rightDistance = Vector3.Distance(rightHand.position, transform.position);
if (leftDistance > rightDistance) grabHand = rightHand;
else grabHand = leftHand;
}
}

View File

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

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LeverEventTest : MonoBehaviour
{
private void Awake()
{
gameObject.GetComponent<Renderer>().material.color = Color.red;
}
public void On()
{
gameObject.GetComponent<Renderer>().material.color = Color.green;
}
public void Off()
{
gameObject.GetComponent<Renderer>().material.color = Color.red;
}
}

View File

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

View File

@@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WellController : MonoBehaviour
{
public GameObject node;
public int numberOfNodes = 5;
private List<GameObject> nodes = new List<GameObject>();
public float spawnDelay;
public float despawnTime;
private Transform player;
public float rightDistance = 0.2f; //Distance between spawned nodes
public float maxUp = 0.2f; //Maximum up shift between orbs
public float minDown = -0.2f; //Same but for down
private Vector3 right;
private Vector3 up;
private void Awake()
{
}
public void StartMinigame()
{
player = GameObject.FindGameObjectWithTag("MainCamera").transform;
Vector3 nodeSpawn = player.transform.position + (player.forward * 0.5f);
nodeSpawn.y = player.transform.position.y;
up = player.transform.up;
right = player.transform.right;
StartCoroutine(SpawnNode(nodeSpawn, 0.5f, 0));
}
IEnumerator SpawnNode(Vector3 nodeSpawn, float pitch, int i)
{
if(i == numberOfNodes)
{
yield return new WaitForSeconds((despawnTime - spawnDelay) * 2); //Wait for all of the nodes to despawn
foreach(GameObject node in nodes)
{
node.GetComponent<EssenceNodeController>().FollowPlayer();
}
nodes.Clear();
yield break;
}
GameObject tempNode = Instantiate(node, nodeSpawn, Quaternion.identity);
tempNode.GetComponent<EssenceNodeController>().SetTimer(2f);
tempNode.GetComponent<AudioSource>().pitch = pitch;
nodeSpawn = nodeSpawn + right * rightDistance + Random.Range(minDown, maxUp) * up;
yield return new WaitForSeconds(spawnDelay);
StartCoroutine(SpawnNode(nodeSpawn, pitch, i + 1));
yield return new WaitForSeconds(despawnTime - spawnDelay);
if (tempNode.GetComponent<EssenceNodeController>().isTouched)
{
nodes.Add(tempNode);
}
}
private void Update()
{
transform.Rotate(new Vector3(10f, 10f, 10f) * Time.deltaTime);
}
}

View File

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

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
<<<<<<< HEAD:Assets/LowPolyDungeons/LowPolyDungeons_HDRP_2018.4.unitypackage.meta
guid: c9f42f34fc0706c499aa448484f3db62
guid: 756af0be88eb0024a9d659a6afb1bebc
=======
guid: 20b2cd43130816e429a419c3adf589b0
folderAsset: yes

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoorController : MonoBehaviour
{
[SerializeField] private Animator myDoor = null;
// Start is called before the first frame update
public void DoorOpen()
{
myDoor.Play("DoorOpen", 0, 0.0f);
}
public void DoorClose()
{
myDoor.Play("DoorClose", 0, 0.0f);
}
}

View File

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

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class PhysicsButton : MonoBehaviour
{
[SerializeField] private float threshold = 0.1f;
[SerializeField] private float deadzone = 0.025f;
private bool _isPressed;
private Vector3 _startPos;
private ConfigurableJoint _joint;
public UnityEvent onPressed, onReleased;
// Start is called before the first frame update
void Start()
{
_startPos = transform.localPosition;
_joint = GetComponent<ConfigurableJoint>();
}
// Update is called once per frame
void Update()
{
if (!_isPressed && GetValue() + threshold >= 1)
Pressed();
if (_isPressed && GetValue() - threshold <= 0)
Released();
}
private float GetValue()
{
var value = Vector3.Distance(_startPos, transform.localPosition) / _joint.linearLimit.limit;
if (Mathf.Abs(value) < deadzone)
value = 0;
return Mathf.Clamp(value, -1f, 1f);
}
private void Pressed()
{
_isPressed = true;
onPressed.Invoke();
Debug.Log("Pressed");
}
private void Released()
{
_isPressed = false;
onReleased.Invoke();
Debug.Log("Released");
}
}

View File

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

View File

@@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerDoorController : MonoBehaviour
{
[SerializeField] private Animator myDoor = null;
[SerializeField] private bool openTrigger = false;
[SerializeField] private bool closeTrigger = false;
[SerializeField] private string doorOpen = "DoorOpen";
[SerializeField] private string doorClose = "DoorClose";
// Start is called before the first frame update
public void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Debug.Log("col");
if (openTrigger)
{
Debug.Log("open");
myDoor.Play(doorOpen, 0, 0.0f);
gameObject.SetActive(false);
}
else if (closeTrigger)
{
myDoor.Play(doorClose, 0, 0.0f);
gameObject.SetActive(false);
}
}
}
}

View File

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