All checks were successful
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Successful in 5m0s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Successful in 4m57s
Build project / Publish to itch.io (StandaloneLinux64) (push) Successful in 5s
Build project / Publish to itch.io (StandaloneWindows64) (push) Successful in 5s
111 lines
3.5 KiB
C#
111 lines
3.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using System;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class OpenNextLevel : MonoBehaviour
|
|
{
|
|
public TMP_Text interactionPrompt;
|
|
private Outline outline;
|
|
|
|
[SerializeField] private Animator objectAnimator;
|
|
[SerializeField] private string animationName = "PickupAnimation";
|
|
[SerializeField] private AudioClip openSound = null;
|
|
|
|
[SerializeField] private string doorName = "Deck D";
|
|
|
|
[SerializeField] private KeyCardPlayer keyCardPlayer;
|
|
|
|
private bool isOpened = false;
|
|
|
|
void LoadNextLevel()
|
|
{
|
|
// load level2.unity
|
|
SceneManager.LoadScene("level2");
|
|
// if (interactionPrompt != null)
|
|
// {
|
|
// interactionPrompt.text = "Congratulations! You Escaped!";
|
|
// interactionPrompt.enabled = true;
|
|
// }
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
outline = GetComponent<Outline>();
|
|
if (outline != null)
|
|
{
|
|
outline.enabled = true;
|
|
}
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (!isOpened)
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
|
|
if (Physics.Raycast(ray, out RaycastHit hit, 10f))
|
|
{
|
|
if (hit.collider.gameObject == gameObject)
|
|
{
|
|
if (interactionPrompt != null && !Input.GetMouseButtonDown(0))
|
|
{
|
|
interactionPrompt.text = "Use Key Card to open door to " + doorName;
|
|
interactionPrompt.enabled = true;
|
|
}
|
|
|
|
// get state of keycard from player
|
|
|
|
if (Input.GetMouseButtonDown(0) && keyCardPlayer.hasKeyCard)
|
|
{
|
|
isOpened = true;
|
|
if (outline != null)
|
|
{
|
|
outline.enabled = false;
|
|
}
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
if (objectAnimator != null)
|
|
{
|
|
objectAnimator.Play(animationName, 0, 0.0f);
|
|
}
|
|
if (openSound != null)
|
|
{
|
|
SoundFXManager.instance.PlaySound(openSound, transform, 1.0f);
|
|
}
|
|
Invoke("LoadNextLevel", 2.2f);
|
|
}
|
|
// else if (Input.GetMouseButtonDown(0) && !keyCardPlayer.hasKeyCard)
|
|
// {
|
|
// if (interactionPrompt != null)
|
|
// {
|
|
// interactionPrompt.text = "You need a key card to open this door";
|
|
// interactionPrompt.enabled = true;
|
|
// }
|
|
// }
|
|
}
|
|
else
|
|
{
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|