Working on entrance and building out first level

This commit is contained in:
2026-01-16 16:53:33 +00:00
parent 9cfaec3ea1
commit 4a37a76e9e
33 changed files with 4450 additions and 238 deletions

View File

@@ -0,0 +1,31 @@
using UnityEngine;
using StarterAssets;
using System.Collections;
using UnityEngine.UIElements;
public class Decomtamination : MonoBehaviour
{
[SerializeField] GameObject decomtaminationChamberDoor;
StarterAssetsInputs inputs;
Log log;
void Awake()
{
inputs = FindFirstObjectByType<StarterAssetsInputs>();
log = FindFirstObjectByType<Log>();
}
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Decomtaminating();
}
}
void Decomtaminating()
{
Debug.Log("Decomtaminating");
StartCoroutine(inputs.ToggleInput(5f));
log.WriteOutLog("You have entered the decomtamination chamber. Please wait while we process your decontamination...", 0.05f);
decomtaminationChamberDoor.GetComponent<Door>().UnlockDoor();
GetComponent<BoxCollider>().enabled = false;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e19ca9f3a0e0c14489732f1886062ae3

View File

@@ -4,27 +4,14 @@ using UnityEngine.Rendering;
public class Door : MonoBehaviour, IInteractable
{
[SerializeField] bool autoDoor;
[SerializeField] bool locked;
[SerializeField] bool isOpen;
[SerializeField] GameObject door;
[SerializeField] float openHeight = 3f;
[SerializeField] float openTime = 2f;
void Awake()
{
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
[SerializeField] AudioClip audioClip;
[SerializeField] bool autoDoor;
[SerializeField] bool locked;
[SerializeField] bool isOpen;
[SerializeField] bool singleUse;
void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player") && autoDoor && !locked && !isOpen)
@@ -45,14 +32,24 @@ public class Door : MonoBehaviour, IInteractable
isOpen = false;
}
}
void OpenDoor(float height)
public void OpenDoor(float height)
{
door.transform.Translate(0f,-height,0f);
}
void CloseDoor(float height)
public void CloseDoor(float height)
{
door.transform.Translate(0f,height,0f);
if(singleUse)
locked = true;
}
public void LockDoor()
{
locked = true;
}
public void UnlockDoor()
{
locked = false;
}
public void Interact(GameObject interactor)
@@ -88,8 +85,11 @@ public bool CanInteract(GameObject interactor)
public string GetInteractionPrompt()
{
if (locked)
return "Door is locked";
return "Door is locked";
if(autoDoor)
return "";
return isOpen ? "Press [E] to close door" : "Press [E] to open door";
}
public void OnHighlight()

34
Assets/Scripts/Log.cs Normal file
View File

@@ -0,0 +1,34 @@
using UnityEngine;
using System.Collections;
using TMPro;
public class Log : MonoBehaviour
{
TextMeshProUGUI tmpText;
void Awake()
{
tmpText = GetComponent<TextMeshProUGUI>();
}
void Start()
{
tmpText.text = "";
tmpText.enabled = false;
}
public void WriteOutLog(string text, float letterDelay = 0.05f)
{
StartCoroutine(WriteLog(text, letterDelay));
}
IEnumerator WriteLog(string text, float letterDelay)
{
tmpText.text = "";
tmpText.enabled = true;
foreach (char letter in text)
{
tmpText.text += letter;
yield return new WaitForSeconds(letterDelay);
}
tmpText.enabled = false;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0aff546340c1fed46aca390d6645058b

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fbdb5b73c909d1e45a27aac0a316583d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using UnityEngine;
public class WelcomeTrigger : BaseTrigger
{
protected override void OnPlayerEnter()
{
log.WriteOutLog("Welcome to my spaceship engineer, we are currently undergoing some maintance so please allow my robots some leeway", 0.05f);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 298f124a3fdf91f41b692cf145cb29cd

View File

@@ -0,0 +1,24 @@
using UnityEngine;
public class BaseTrigger : MonoBehaviour
{
protected Log log;
protected virtual void Awake()
{
log = FindFirstObjectByType<Log>();
}
protected virtual void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
OnPlayerEnter();
}
}
// Override this in subclasses
protected virtual void OnPlayerEnter()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5060b3e8fb6da8f41a3da4eaa47ba624