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

112 lines
3.3 KiB
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelZeroSpecial : MonoBehaviour
{
//[SerializeField]
//private int initalPlaceIndex = 0;
2023-06-02 06:30:58 +02:00
[SerializeField] private Item.DoorInteractable recepticleOne;
2023-06-01 17:03:48 +02:00
[SerializeField] private BasicLevelProgressionSystem progression;
[SerializeField] private int enabledOn = 4;
2023-06-02 06:30:58 +02:00
[SerializeField] private List<Item.HeavyInteractableItem> powercores;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private List<Item.DoorInteractable> recepticals;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private UI.WaypointMarker marker;
2023-06-01 17:03:48 +02:00
[SerializeField] private Animator cover;
[SerializeField] private Animator gate;
[SerializeField] private GameObject exitCollider;
2023-06-01 20:25:46 +02:00
[SerializeField] private Player.PlayerComponent player;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private UI.WaypointMarker marker2Ref;
2023-06-01 17:03:48 +02:00
2023-06-02 06:30:58 +02:00
[SerializeField] private UI.WaypointMarker marker3Ref;
2023-06-01 17:03:48 +02:00
2023-06-01 20:25:46 +02:00
[SerializeField] private Game.Optimizer finalRoomOptimizer;
2023-06-01 17:03:48 +02:00
private int countPowered;
private bool isEnabled;
2023-06-02 06:30:58 +02:00
private readonly List<UI.WaypointMarker> markers = new();
2023-06-01 17:03:48 +02:00
private bool transitioningOut;
// Start is called before the first frame update
2023-06-01 17:03:48 +02:00
private void Start()
{
marker2Ref.gameObject.SetActive(false);
marker3Ref.gameObject.SetActive(false);
}
// Update is called once per frame
2023-06-01 17:03:48 +02:00
private void Update()
{
if (progression.Sections[0] == progression.getCurrent())
if (recepticleOne.Powered)
progression.TwoPassed();
2023-06-01 17:03:48 +02:00
//progression.ProgressCurrentIfInput(BasicLevelProgressionSystem.InputType.EXTERNAL);
countPowered = 0;
if (progression.Sections[enabledOn] == progression.getCurrent() && !isEnabled)
{
isEnabled = true;
marker2Ref.gameObject.SetActive(true);
marker3Ref.gameObject.SetActive(true);
2023-06-01 17:03:48 +02:00
marker2Ref.target = recepticals[1].transform;
marker3Ref.target = recepticals[2].transform;
2023-06-01 17:03:48 +02:00
markers.Add(marker2Ref);
markers.Add(marker3Ref);
}
2023-06-01 17:03:48 +02:00
if (isEnabled)
foreach (var recepitcal in recepticals)
if (recepitcal.Powered)
{
countPowered++;
2023-06-01 17:03:48 +02:00
for (var i = 0; i < markers.Count; i++)
{
2023-06-01 17:03:48 +02:00
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
2023-06-01 17:03:48 +02:00
transitioningOut = true;
gate.Play("Open");
finalRoomOptimizer.Enable();
}
2023-06-01 17:03:48 +02:00
if (transitioningOut)
if (player.transform.position.z > exitCollider.transform.position.z)
StartCoroutine(transitionOut());
}
2023-06-01 17:03:48 +02:00
private IEnumerator transitionOut()
{
cover.Play("Cover_load_out");
yield return new WaitForSeconds(1);
2023-06-01 17:03:48 +02:00
SceneManager.LoadScene(0);
}
2023-06-01 17:03:48 +02:00
}