Finalized for game jam submission
Lots of bugfixes New tasks
This commit is contained in:
49
Assets/Scripts/Items/Battery.cs
Normal file
49
Assets/Scripts/Items/Battery.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Battery : MonoBehaviour
|
||||
{
|
||||
public float interactionDistance = 5;
|
||||
public GameObject hint;
|
||||
private GameManager gameManager;
|
||||
private Renderer renderer;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
renderer = gameObject.GetComponent<Renderer>();
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
hint.SetActive(false);
|
||||
|
||||
if(gameManager.playerHasBattery) { return; }
|
||||
if (renderer.isVisible)
|
||||
{
|
||||
if (Vector3.Distance(transform.position, gameManager.player.transform.position) <= interactionDistance)
|
||||
{
|
||||
hint.SetActive(true);
|
||||
hint.transform.rotation = Quaternion.LookRotation(hint.transform.position - gameManager.playerCamera.transform.position);
|
||||
|
||||
if (UnityEngine.InputSystem.Keyboard.current.eKey.wasPressedThisFrame)
|
||||
{
|
||||
gameManager.playerHasBattery = true;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawWireSphere(transform.position, interactionDistance);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Items/Battery.cs.meta
Normal file
11
Assets/Scripts/Items/Battery.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03d58ef94ec7c524f8a26083dbb4c2ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -16,6 +16,7 @@ public class DestructibleObject : MonoBehaviour
|
||||
{
|
||||
gameObject.GetComponent<Rigidbody>().isKinematic = true;
|
||||
gameObject.transform.position = originalPosition;
|
||||
gameObject.transform.parent = null;
|
||||
gameObject.GetComponent<Rigidbody>().isKinematic = false;
|
||||
}
|
||||
}
|
||||
|
||||
49
Assets/Scripts/Items/USB.cs
Normal file
49
Assets/Scripts/Items/USB.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class USB : MonoBehaviour
|
||||
{
|
||||
public float interactionDistance = 10;
|
||||
public GameObject hint;
|
||||
private GameManager gameManager;
|
||||
private Renderer renderer;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
renderer = gameObject.GetComponent<Renderer>();
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
hint.SetActive(false);
|
||||
if (renderer.isVisible)
|
||||
{
|
||||
if(Vector3.Distance(transform.position, gameManager.player.transform.position) <= interactionDistance)
|
||||
{
|
||||
hint.SetActive(true);
|
||||
hint.transform.rotation = Quaternion.LookRotation(hint.transform.position - gameManager.playerCamera.transform.position );
|
||||
|
||||
if (Keyboard.current.eKey.wasPressedThisFrame)
|
||||
{
|
||||
gameManager.playerHasUSB = true;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawWireSphere(transform.position, interactionDistance);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Items/USB.cs.meta
Normal file
11
Assets/Scripts/Items/USB.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2f476c3d951e8742a0e4f5dffeaacb3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user