Initial commit

This commit is contained in:
2026-01-13 15:43:33 +00:00
commit 44ef19d058
4517 changed files with 1234348 additions and 0 deletions

90
Assets/Scripts/Door.cs Normal file
View File

@@ -0,0 +1,90 @@
using Unity.VisualScripting;
using UnityEngine;
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()
{
}
void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Player") && autoDoor && !locked && !isOpen)
{
OpenDoor(openHeight);
isOpen = true;
}
else if(other.CompareTag("Player") && autoDoor && locked)
{
Debug.Log("The door is locked.");
}
}
void OnTriggerExit(Collider other)
{
if(other.CompareTag("Player") && autoDoor && isOpen)
{
CloseDoor(openHeight);
isOpen = false;
}
}
void OpenDoor(float height)
{
door.transform.Translate(0f,-height,0f);
}
void CloseDoor(float height)
{
door.transform.Translate(0f,height,0f);
}
public void Interact(GameObject interactor)
{
if (autoDoor)
{
if (!locked)
door.transform.Translate(0f,-3f,0f);
}
else
{
Debug.Log("You need to use a key to open this door.");
}
}
public bool CanInteract(GameObject interactor)
{
return !locked;
}
public string GetInteractionPrompt()
{
return locked ? "Door is locked" : "Open door";
}
public void OnHighlight()
{
// e.g. outline effect
}
public void OnUnhighlight()
{
// remove outline
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9594e2f70d2fd1f4fa122cc870fea88e

View File

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

View File

@@ -0,0 +1,25 @@
using StarterAssets;
using UnityEngine;
using UnityEngine.AI;
public class Drone : MonoBehaviour
{
FirstPersonController player;
NavMeshAgent agent;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
agent = GetComponent<NavMeshAgent>();
}
void Start()
{
player = FindFirstObjectByType<FirstPersonController>();
}
// Update is called once per frame
void Update()
{
agent.SetDestination(player.transform.position);
transform.LookAt(player.transform);
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using UnityEngine;
public class EnemyHealth : MonoBehaviour
{
[SerializeField] int maxHealth = 100;
int currentHealth;
void Awake()
{
currentHealth = maxHealth;
}
public void TakeDamage(int damage)
{
currentHealth -= damage;
if (currentHealth <= 0)
{
gameObject.SetActive(false);
}
}
// 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()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7607d877a899edd469640c39419addcd

View File

@@ -0,0 +1,27 @@
using StarterAssets;
using UnityEngine;
using UnityEngine.AI;
public class Robot : MonoBehaviour
{
[SerializeField] AnimationClip idle;
FirstPersonController player;
NavMeshAgent agent;
Animator animator;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
agent = GetComponent<NavMeshAgent>();
animator = GetComponent<Animator>();
}
void Start()
{
player = FindFirstObjectByType<FirstPersonController>();
}
// Update is called once per frame
void Update()
{
agent.SetDestination(player.transform.position);
}
}

View File

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

View File

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

View File

@@ -0,0 +1,10 @@
using UnityEngine;
public interface IInteractable
{
void Interact(GameObject interactor);
bool CanInteract(GameObject interactor);
string GetInteractionPrompt();
void OnHighlight();
void OnUnhighlight();
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3e4925da55418084eb4c49cceb0bd37f

39
Assets/Scripts/Weapon.cs Normal file
View File

@@ -0,0 +1,39 @@
using System.Runtime.InteropServices;
using StarterAssets;
using UnityEngine;
public class Weapon : MonoBehaviour
{
[SerializeField] int weaponDamage = 10;
[SerializeField] ParticleSystem muzzleFlash;
[SerializeField] GameObject hitVFXPrefab;
Animator animator;
StarterAssetsInputs starterAssetsInputs;
const string SHOOT_STRING = "Shoot";
void Awake()
{
starterAssetsInputs = GetComponentInParent<StarterAssetsInputs>();
animator = GetComponentInParent<Animator>();
}
// Update is called once per frame
void Update()
{
HandleShoot();
}
void HandleShoot()
{
if (!starterAssetsInputs.shoot) return;
muzzleFlash.Play();
animator.Play(SHOOT_STRING, 0, 0f);
starterAssetsInputs.ShootInput(false);
RaycastHit hit;
if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, Mathf.Infinity))
{
Instantiate(hitVFXPrefab, hit.point, Quaternion.identity);
EnemyHealth enemyHealth = hit.transform.GetComponent<EnemyHealth>();
enemyHealth?.TakeDamage(weaponDamage);
}
}
}

View File

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