making spot use node controller stuff

This commit is contained in:
Amaan Shawkath
2021-06-13 02:21:16 +01:00
parent 2bd44e54ca
commit 432db522a6

View File

@@ -1,6 +1,8 @@
using Cinemachine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class SpotController : MonoBehaviour
{
@@ -16,6 +18,7 @@ public class SpotController : MonoBehaviour
public AudioClip idleSound;
public AudioClip interactSound;
public AudioClip moveClip;
public AudioClip powerUpSound;
private float speed = 6f;
private float revSpeed = 5f;
@@ -27,20 +30,36 @@ public class SpotController : MonoBehaviour
private Light light;
private bool blocked = false;
private bool inUse = false;
private GameManager gameManager;
public CinemachineVirtualCamera localCamera;
private void Start()
{
sphere.transform.parent = null;
light = visor.GetComponentInChildren<Light>();
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
}
public void InteractNode(Node pre)
{
// power on the robot
StartCoroutine(FlashRoutine());
backgroundSource.clip = idleSound;
backgroundSource.Play();
light = visor.GetComponentInChildren<Light>();
inUse = true;
StartCoroutine(FlashRoutine());
gameManager.SetActiveCamera(localCamera);
}
private void Update()
{
if (inUse)
{
moveInput = Input.GetAxisRaw("Vertical");
turnInput = Input.GetAxisRaw("Horizontal");
@@ -78,6 +97,7 @@ public class SpotController : MonoBehaviour
blocked = false;
}
}
}
IEnumerator FlashRoutine()
{
@@ -94,6 +114,22 @@ public class SpotController : MonoBehaviour
}
private void LateUpdate()
{
if (!inUse) { return; }
if (Keyboard.current.xKey.wasPressedThisFrame)
{
inUse = false;
StopCoroutine(FlashRoutine());
backgroundSource.Stop();
sfxSource.Stop();
interactSource.Stop();
gameManager.SetActiveCamera(gameManager.networkCamera);
gameManager.previousNode.SetActiveNode();
}
if (moveInput != 0)
{
if (!sfxSource.isPlaying)