This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Levels/Level0Scripts/LevelZeroSpecial.cs

129 lines
3.5 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 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;
[SerializeField]
private Optimizer finalRoomOptimizer;
// 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");
finalRoomOptimizer.Enable();
}
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);
}
}