112 lines
3.3 KiB
C#
112 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class LevelZeroSpecial : MonoBehaviour
|
|
{
|
|
//[SerializeField]
|
|
//private int initalPlaceIndex = 0;
|
|
[SerializeField] private Item.DoorInteractable recepticleOne;
|
|
|
|
[SerializeField] private BasicLevelProgressionSystem progression;
|
|
|
|
[SerializeField] private int enabledOn = 4;
|
|
|
|
[SerializeField] private List<Item.HeavyInteractableItem> powercores;
|
|
|
|
[SerializeField] private List<Item.DoorInteractable> recepticals;
|
|
|
|
[SerializeField] private UI.WaypointMarker marker;
|
|
|
|
[SerializeField] private Animator cover;
|
|
|
|
[SerializeField] private Animator gate;
|
|
|
|
[SerializeField] private GameObject exitCollider;
|
|
|
|
[SerializeField] private Player.PlayerComponent player;
|
|
|
|
[SerializeField] private UI.WaypointMarker marker2Ref;
|
|
|
|
[SerializeField] private UI.WaypointMarker marker3Ref;
|
|
|
|
[SerializeField] private Game.Optimizer finalRoomOptimizer;
|
|
|
|
private int countPowered;
|
|
private bool isEnabled;
|
|
|
|
private readonly List<UI.WaypointMarker> markers = new();
|
|
|
|
private bool transitioningOut;
|
|
|
|
// Start is called before the first frame update
|
|
private void Start()
|
|
{
|
|
marker2Ref.gameObject.SetActive(false);
|
|
marker3Ref.gameObject.SetActive(false);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
private void Update()
|
|
{
|
|
if (progression.Sections[0] == progression.getCurrent())
|
|
if (recepticleOne.Powered)
|
|
progression.TwoPassed();
|
|
//progression.ProgressCurrentIfInput(BasicLevelProgressionSystem.InputType.EXTERNAL);
|
|
countPowered = 0;
|
|
if (progression.Sections[enabledOn] == progression.getCurrent() && !isEnabled)
|
|
{
|
|
isEnabled = true;
|
|
marker2Ref.gameObject.SetActive(true);
|
|
marker3Ref.gameObject.SetActive(true);
|
|
|
|
|
|
marker2Ref.target = recepticals[1].transform;
|
|
|
|
marker3Ref.target = recepticals[2].transform;
|
|
|
|
markers.Add(marker2Ref);
|
|
markers.Add(marker3Ref);
|
|
}
|
|
|
|
if (isEnabled)
|
|
foreach (var recepitcal in recepticals)
|
|
if (recepitcal.Powered)
|
|
{
|
|
countPowered++;
|
|
for (var i = 0; i < markers.Count; i++)
|
|
{
|
|
var marker = markers[i];
|
|
if (marker.gameObject.activeInHierarchy)
|
|
if (marker.target == recepitcal.transform)
|
|
{
|
|
marker.gameObject.SetActive(false);
|
|
markers.Remove(marker);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (countPowered == 3 && !transitioningOut)
|
|
{
|
|
//transition to cutscene
|
|
|
|
transitioningOut = true;
|
|
gate.Play("Open");
|
|
finalRoomOptimizer.Enable();
|
|
}
|
|
|
|
if (transitioningOut)
|
|
if (player.transform.position.z > exitCollider.transform.position.z)
|
|
StartCoroutine(transitionOut());
|
|
}
|
|
|
|
|
|
private IEnumerator transitionOut()
|
|
{
|
|
cover.Play("Cover_load_out");
|
|
yield return new WaitForSeconds(1);
|
|
|
|
SceneManager.LoadScene(0);
|
|
}
|
|
} |