Finalized for game jam submission
Lots of bugfixes New tasks
This commit is contained in:
37
Assets/Scripts/ElectricBox.cs
Normal file
37
Assets/Scripts/ElectricBox.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ElectricBox : MonoBehaviour
|
||||
{
|
||||
public SpotInteractions spot;
|
||||
public GameObject door;
|
||||
public GameObject fakeDoor;
|
||||
public GameObject visuals;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
|
||||
if(spot.hasBeenUnlocked)
|
||||
{
|
||||
visuals.SetActive(true);
|
||||
// door.transform.Rotate(0, 90, 0, Space.Self);
|
||||
door.SetActive(false);
|
||||
fakeDoor.SetActive(true);
|
||||
|
||||
GetComponent<Collider>().enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ElectricBox.cs.meta
Normal file
11
Assets/Scripts/ElectricBox.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 377f0fd448cf3d247a892fa82aed33c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,6 +15,9 @@ public class GameManager : MonoBehaviour
|
||||
public Node previousNode;
|
||||
public bool networkView = false;
|
||||
|
||||
public bool playerHasUSB = false;
|
||||
public bool playerHasBattery = false;
|
||||
|
||||
private bool exiting = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -39,12 +42,13 @@ public class GameManager : MonoBehaviour
|
||||
activeCamera = vCam;
|
||||
|
||||
networkView = (!exiting && activeCamera == networkCamera) ? true : false;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
networkView = (activeCamera == networkCamera) ? true : false;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -52,7 +56,9 @@ public class GameManager : MonoBehaviour
|
||||
//Leave network view with x
|
||||
if (Keyboard.current.xKey.wasPressedThisFrame && networkView)
|
||||
{
|
||||
SetActiveCamera(networkCamera);
|
||||
player.GetComponent<StarterAssets.FirstPersonController>().enabled = true;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
SetActiveCamera(playerCamera);
|
||||
activeNode.GetComponent<Node>().DisableNode();
|
||||
activeNode = null;
|
||||
}
|
||||
|
||||
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:
|
||||
@@ -11,6 +11,8 @@ public class Node : MonoBehaviour
|
||||
public GameObject[] connections;
|
||||
public GameObject UI;
|
||||
|
||||
public bool isUnlocked = true;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -20,7 +22,10 @@ public class Node : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if(!isUnlocked)
|
||||
{
|
||||
DisableNode();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActiveNode()
|
||||
|
||||
@@ -9,8 +9,30 @@ public class NodeButton : MonoBehaviour
|
||||
public Node.Direction direction;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (node.connections[(int)direction] == null)
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.gray;
|
||||
gameObject.GetComponent<Collider>().enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
//Connected devices have no Node
|
||||
if(node.connections[(int)direction].GetComponent<Node>() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.connections[(int)direction].GetComponent<Node>().isUnlocked)
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.green;
|
||||
gameObject.GetComponent<Collider>().enabled = true;
|
||||
} else
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.gray;
|
||||
gameObject.GetComponent<Collider>().enabled = false;
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEngine.InputSystem;
|
||||
public class Switch : MonoBehaviour
|
||||
{
|
||||
public GameManager gameManager;
|
||||
public float interactionDistance = 10;
|
||||
private Renderer renderer;
|
||||
|
||||
public Node debugNode;
|
||||
@@ -14,7 +13,7 @@ public class Switch : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
renderer = gameObject.GetComponent<Renderer>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,21 +25,21 @@ public class Switch : MonoBehaviour
|
||||
|
||||
|
||||
|
||||
if (renderer.isVisible)
|
||||
{
|
||||
if (Vector3.Distance(transform.position, gameManager.player.transform.position) < interactionDistance) {
|
||||
//Debug.Log("Switch is visible and in range");
|
||||
if (Keyboard.current.eKey.wasPressedThisFrame && !gameManager.activeNode)
|
||||
{
|
||||
gameManager.previousNode = debugNode;
|
||||
gameManager.activeNode = debugNode.gameObject;
|
||||
gameManager.SetActiveCamera(gameManager.networkCamera);
|
||||
debugNode.SendMessage("SetActiveNode", debugNode.GetComponent<Node>());
|
||||
gameManager.player.GetComponent<StarterAssets.FirstPersonController>().enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void PlayerInteract()
|
||||
{
|
||||
if(!gameManager.activeNode)
|
||||
{
|
||||
gameManager.previousNode = debugNode;
|
||||
gameManager.activeNode = debugNode.gameObject;
|
||||
gameManager.SetActiveCamera(gameManager.networkCamera);
|
||||
debugNode.SendMessage("SetActiveNode", debugNode.GetComponent<Node>());
|
||||
gameManager.player.GetComponent<StarterAssets.FirstPersonController>().enabled = false;
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
60
Assets/Scripts/PlayerInteractable.cs
Normal file
60
Assets/Scripts/PlayerInteractable.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerInteractable : 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()
|
||||
{
|
||||
if (hint)
|
||||
{
|
||||
hint.SetActive(false);
|
||||
}
|
||||
|
||||
if (renderer.isVisible)
|
||||
{
|
||||
bool foundPlayer = false;
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, interactionDistance);
|
||||
foreach (Collider collider in colliders)
|
||||
{
|
||||
if(collider.gameObject.tag == "Player")
|
||||
{
|
||||
foundPlayer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundPlayer)
|
||||
{
|
||||
if(hint)
|
||||
{
|
||||
hint.SetActive(true);
|
||||
}
|
||||
|
||||
//Debug.Log("Switch is visible and in range");
|
||||
if (Keyboard.current.eKey.wasPressedThisFrame)
|
||||
{
|
||||
gameObject.SendMessage("PlayerInteract");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawWireSphere(transform.position, interactionDistance);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/PlayerInteractable.cs.meta
Normal file
11
Assets/Scripts/PlayerInteractable.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9098d14bdf480c44fb6828355f6b1b5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,6 +17,7 @@ public class RobotArmController : MonoBehaviour
|
||||
public float armRotationSpeed = 10;
|
||||
public Vector3 targetConstraints;
|
||||
public GameObject targetMarker;
|
||||
public GameObject hint;
|
||||
|
||||
|
||||
//Audio
|
||||
@@ -40,6 +41,9 @@ public class RobotArmController : MonoBehaviour
|
||||
RaycastHit hit;
|
||||
Physics.Raycast(grabber.grabSpot.transform.position, Vector3.down, out hit, 10);
|
||||
|
||||
hint.SetActive(isInUse);
|
||||
|
||||
|
||||
targetMarker.transform.position = new Vector3(grabber.grabSpot.transform.position.x, hit.point.y + 0.05f, grabber.grabSpot.transform.position.z);
|
||||
}
|
||||
|
||||
@@ -78,7 +82,7 @@ public class RobotArmController : MonoBehaviour
|
||||
//Hoch/Runter
|
||||
if (Keyboard.current.ctrlKey.isPressed && target.transform.position.y > transform.position.y)
|
||||
{
|
||||
if(Physics.Raycast(grabber.transform.position, Vector3.down, .9f))
|
||||
if(Physics.Raycast(grabber.grabSpot.transform.position, Vector3.down, .1f))
|
||||
{
|
||||
target.transform.localPosition -= Vector3.down * Time.deltaTime * armSpeed;
|
||||
}
|
||||
@@ -94,7 +98,7 @@ public class RobotArmController : MonoBehaviour
|
||||
|
||||
//Debug.Log(-targetConstraints.z);
|
||||
//Left/Right
|
||||
if (Keyboard.current.aKey.isPressed && target.transform.localPosition.z > -targetConstraints.z)
|
||||
/*if (Keyboard.current.aKey.isPressed && target.transform.localPosition.z > -targetConstraints.z)
|
||||
{
|
||||
target.transform.localPosition += Vector3.back * Time.deltaTime * armSpeed;
|
||||
isMoving = true;
|
||||
@@ -104,7 +108,7 @@ public class RobotArmController : MonoBehaviour
|
||||
{
|
||||
target.transform.localPosition += Vector3.forward * Time.deltaTime * armSpeed;
|
||||
isMoving = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
//Left/Right
|
||||
if (Keyboard.current.qKey.isPressed)
|
||||
|
||||
61
Assets/Scripts/SpotInteractions.cs
Normal file
61
Assets/Scripts/SpotInteractions.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SpotInteractions : MonoBehaviour
|
||||
{
|
||||
public float interactionDistance = 5;
|
||||
public GameObject hintMissing;
|
||||
public GameObject hintUnlocked;
|
||||
public GameObject hint;
|
||||
public GameObject visuals;
|
||||
private GameManager gameManager;
|
||||
private Renderer renderer;
|
||||
|
||||
|
||||
public bool hasBeenUnlocked;
|
||||
|
||||
public PlayerInteractable interactable;
|
||||
// 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()
|
||||
{
|
||||
if (hasBeenUnlocked)
|
||||
{
|
||||
interactable.hint = hintUnlocked;
|
||||
hint.SetActive(false);
|
||||
hintMissing.SetActive(false);
|
||||
visuals.SetActive(true);
|
||||
return;
|
||||
}
|
||||
if (gameManager.playerHasBattery)
|
||||
{
|
||||
interactable.hint = hint;
|
||||
hintUnlocked.SetActive(false);
|
||||
hintMissing.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
interactable.hint = hintMissing;
|
||||
hint.SetActive(false);
|
||||
hintUnlocked.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerInteract()
|
||||
{
|
||||
Debug.Log("Trying to modify spot");
|
||||
if (gameManager.playerHasBattery)
|
||||
{
|
||||
hasBeenUnlocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/SpotInteractions.cs.meta
Normal file
11
Assets/Scripts/SpotInteractions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a7be003f16d9034fac59a73bcda0a5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/Scripts/UnlockRack.cs
Normal file
60
Assets/Scripts/UnlockRack.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UnlockRack : MonoBehaviour
|
||||
{
|
||||
|
||||
private GameManager gameManager;
|
||||
private PlayerInteractable interactable;
|
||||
|
||||
public GameObject hintMissing;
|
||||
public GameObject hintUnlocked;
|
||||
public GameObject hint;
|
||||
|
||||
private bool hasBeenUnlocked = false;
|
||||
|
||||
public Node[] unlockNodes;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
interactable = GetComponent<PlayerInteractable>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if(hasBeenUnlocked)
|
||||
{
|
||||
interactable.hint = hintUnlocked;
|
||||
hint.SetActive(false);
|
||||
hintMissing.SetActive(false);
|
||||
return;
|
||||
}
|
||||
if(gameManager.playerHasUSB)
|
||||
{
|
||||
interactable.hint = hint;
|
||||
hintMissing.SetActive(false);
|
||||
hintUnlocked.SetActive(false);
|
||||
} else
|
||||
{
|
||||
interactable.hint = hintMissing;
|
||||
hint.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerInteract()
|
||||
{
|
||||
Debug.Log("Trying to unlock rack");
|
||||
if(gameManager.playerHasUSB)
|
||||
{
|
||||
foreach (Node node in unlockNodes)
|
||||
{
|
||||
node.isUnlocked = true;
|
||||
hasBeenUnlocked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UnlockRack.cs.meta
Normal file
11
Assets/Scripts/UnlockRack.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61360323545801d4d80d3e6481570470
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user