2023-05-11 05:59:58 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
public class LevelZeroSpecial : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private int initalPlaceIndex = 0;
|
|
|
|
[SerializeField]
|
|
|
|
private DoorInteractable recepticleOne;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private BasicLevelProgressionSystem progression;
|
|
|
|
[SerializeField]
|
|
|
|
private int enabledOn = 4;
|
|
|
|
private bool isEnabled = false;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private List<HeavyInteractableItem> powercores;
|
|
|
|
[SerializeField]
|
|
|
|
private List<DoorInteractable> recepticals;
|
|
|
|
[SerializeField]
|
|
|
|
private WaypointMarker marker;
|
|
|
|
|
|
|
|
private List<WaypointMarker> markers=new List<WaypointMarker>();
|
|
|
|
private int countPowered = 0;
|
|
|
|
[SerializeField]
|
|
|
|
private Animator cover;
|
|
|
|
[SerializeField]
|
|
|
|
private Animator gate;
|
|
|
|
private bool transitioningOut = false;
|
|
|
|
[SerializeField]
|
|
|
|
private GameObject exitCollider;
|
|
|
|
[SerializeField]
|
|
|
|
private PlayerComponent player;
|
|
|
|
[SerializeField]
|
|
|
|
WaypointMarker marker2Ref;
|
|
|
|
[SerializeField]
|
|
|
|
WaypointMarker marker3Ref;
|
2023-05-17 06:15:44 +02:00
|
|
|
[SerializeField]
|
|
|
|
private Optimizer finalRoomOptimizer;
|
2023-05-11 05:59:58 +02:00
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
marker2Ref.gameObject.SetActive(false);
|
|
|
|
marker3Ref.gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
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 (DoorInteractable recepitcal in recepticals)
|
|
|
|
{
|
|
|
|
if (recepitcal.Powered)
|
|
|
|
{
|
|
|
|
countPowered++;
|
|
|
|
for(int i = 0; i < markers.Count; i++)
|
|
|
|
{
|
|
|
|
WaypointMarker marker = markers[i];
|
|
|
|
if (marker.gameObject.activeInHierarchy)
|
|
|
|
{
|
|
|
|
if (marker.target = recepitcal.transform)
|
|
|
|
{
|
|
|
|
marker.gameObject.SetActive(true);
|
|
|
|
markers.Remove(marker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (countPowered == 3 && !transitioningOut)
|
|
|
|
{
|
|
|
|
//transition to cutscene
|
|
|
|
|
|
|
|
transitioningOut = true;
|
|
|
|
gate.Play("Open");
|
2023-05-17 06:15:44 +02:00
|
|
|
finalRoomOptimizer.Enable();
|
2023-05-11 05:59:58 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
if (transitioningOut)
|
|
|
|
{
|
|
|
|
if (player.transform.position.z > exitCollider.transform.position.z)
|
|
|
|
{
|
|
|
|
StartCoroutine(transitionOut());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator transitionOut()
|
|
|
|
{
|
|
|
|
cover.Play("Cover_load_out");
|
|
|
|
yield return new WaitForSeconds(1);
|
|
|
|
|
|
|
|
SceneManager.LoadScene(0);
|
|
|
|
}
|
|
|
|
}
|