Steam lobby implemented
This commit is contained in:
@ -1,233 +1,195 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class BasicLevelProgressionSystem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private ObjectiveText objectiveGui;
|
||||
[SerializeField]
|
||||
private WaypointMarker marker;
|
||||
[SerializeField]
|
||||
private PlayerComponent player;
|
||||
//[SerializeField]
|
||||
//private float minDist = 3;
|
||||
|
||||
[SerializeField]
|
||||
private List<ProgressionSection> sections;
|
||||
public List<ProgressionSection> Sections { get { return sections; } }
|
||||
//Fire1 is click or A
|
||||
//Place is F or "Y" button
|
||||
//Cycle is Tab or RB
|
||||
//Siwtch is Shift or "X"
|
||||
public enum InputType { FIRE1, PLACE, CYCLE, SWITCH, COLLISION, LOCATION,AIM,EXTERNAL};
|
||||
private int progress = 0;
|
||||
private bool transitioning = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public enum InputType
|
||||
{
|
||||
FIRE1,
|
||||
PLACE,
|
||||
CYCLE,
|
||||
SWITCH,
|
||||
COLLISION,
|
||||
LOCATION,
|
||||
AIM,
|
||||
EXTERNAL
|
||||
}
|
||||
|
||||
[SerializeField] private ObjectiveText objectiveGui;
|
||||
|
||||
[SerializeField] private WaypointMarker marker;
|
||||
|
||||
[SerializeField] private PlayerComponent player;
|
||||
//[SerializeField]
|
||||
//private float minDist = 3;
|
||||
|
||||
[SerializeField] private List<ProgressionSection> sections;
|
||||
|
||||
private int progress;
|
||||
private bool transitioning;
|
||||
public List<ProgressionSection> Sections => sections;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
|
||||
Transform cur = this.getCurrent().getActive();
|
||||
if(cur != null)
|
||||
var cur = getCurrent().getActive();
|
||||
if (cur != null)
|
||||
{
|
||||
if (!this.getCurrent().objectiveOneMet)
|
||||
if (!getCurrent().objectiveOneMet)
|
||||
{
|
||||
marker.target = cur;
|
||||
objectiveGui.visualObjects[0].text.text = this.getCurrent().instruction1;
|
||||
objectiveGui.visualObjects[1].text.text = this.getCurrent().istruction2;
|
||||
objectiveGui.visualObjects[0].text.text = getCurrent().instruction1;
|
||||
objectiveGui.visualObjects[1].text.text = getCurrent().istruction2;
|
||||
}
|
||||
else if(!this.getCurrent().objectiveTwoMet)
|
||||
else if (!getCurrent().objectiveTwoMet)
|
||||
{
|
||||
marker.target = cur;
|
||||
}
|
||||
}
|
||||
|
||||
if(Input.GetButtonDown("Fire1")||Input.GetAxis("Fire1")>0.5f&&!transitioning)
|
||||
{
|
||||
if (Input.GetButtonDown("Fire1") || (Input.GetAxis("Fire1") > 0.5f && !transitioning))
|
||||
ProgressCurrentIfInput(InputType.FIRE1);
|
||||
}
|
||||
if (Input.GetButtonDown("TempPlace"))
|
||||
{
|
||||
ProgressCurrentIfInput(InputType.PLACE);
|
||||
}
|
||||
if (Input.GetButtonDown("CycleItems"))
|
||||
{
|
||||
ProgressCurrentIfInput(InputType.CYCLE);
|
||||
}
|
||||
if(Input.GetButtonDown("Fire3"))
|
||||
{
|
||||
|
||||
ProgressCurrentIfInput(InputType.SWITCH);
|
||||
}
|
||||
if(Input.GetAxis("Aim")>.5f || Input.GetButtonDown("Aim"))
|
||||
{
|
||||
if(!transitioning)
|
||||
ProgressCurrentIfInput(InputType.AIM);
|
||||
}
|
||||
if (Input.GetButtonDown("TempPlace")) ProgressCurrentIfInput(InputType.PLACE);
|
||||
if (Input.GetButtonDown("CycleItems")) ProgressCurrentIfInput(InputType.CYCLE);
|
||||
if (Input.GetButtonDown("Fire3")) ProgressCurrentIfInput(InputType.SWITCH);
|
||||
if (Input.GetAxis("Aim") > .5f || Input.GetButtonDown("Aim"))
|
||||
if (!transitioning)
|
||||
ProgressCurrentIfInput(InputType.AIM);
|
||||
|
||||
if (Vector3.Distance(player.transform.position, this.getCurrent().getActive().position) < 3)
|
||||
if (Vector3.Distance(player.transform.position, getCurrent().getActive().position) < 3)
|
||||
{
|
||||
bool canIterate= this.getCurrent().Iterate();
|
||||
var canIterate = getCurrent().Iterate();
|
||||
if (!canIterate)
|
||||
{
|
||||
if (!this.getCurrent().objectiveOneMet && this.getCurrent().conditionalOne == InputType.LOCATION)
|
||||
{
|
||||
if (!getCurrent().objectiveOneMet && getCurrent().conditionalOne == InputType.LOCATION)
|
||||
OnePassed();
|
||||
}else if (this.getCurrent().objectiveOneMet && this.getCurrent().conditionalTwo == InputType.LOCATION && !this.getCurrent().objectiveTwoMet)
|
||||
{
|
||||
TwoPassed();
|
||||
}
|
||||
|
||||
else if (getCurrent().objectiveOneMet && getCurrent().conditionalTwo == InputType.LOCATION &&
|
||||
!getCurrent().objectiveTwoMet) TwoPassed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.GetComponentInParent<PlayerComponent>() != null)
|
||||
{
|
||||
ProgressCurrentIfCollide();
|
||||
}
|
||||
if (other.gameObject.GetComponentInParent<PlayerComponent>() != null) ProgressCurrentIfCollide();
|
||||
}
|
||||
|
||||
void ProgressCurrentIfCollide()
|
||||
private void ProgressCurrentIfCollide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnePassed()
|
||||
{
|
||||
this.getCurrent().objectiveOneMet = true;
|
||||
this.getCurrent().Progress();
|
||||
getCurrent().objectiveOneMet = true;
|
||||
getCurrent().Progress();
|
||||
|
||||
this.objectiveGui.visualObjects[0].isComplete = true;
|
||||
objectiveGui.visualObjects[0].isComplete = true;
|
||||
}
|
||||
|
||||
public void TwoPassed()
|
||||
{
|
||||
if (transitioning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.getCurrent().objectiveTwoMet = true;
|
||||
this.objectiveGui.visualObjects[1].isComplete = true;
|
||||
this.objectiveGui.FadeOut();
|
||||
if (transitioning) return;
|
||||
getCurrent().objectiveTwoMet = true;
|
||||
objectiveGui.visualObjects[1].isComplete = true;
|
||||
objectiveGui.FadeOut();
|
||||
transitioning = true;
|
||||
StartCoroutine(waitForFadeIn());
|
||||
}
|
||||
|
||||
public void ProgressCurrentIfInput(InputType type)
|
||||
{
|
||||
|
||||
if (this.getCurrent().AtEnd() && this.getCurrent().conditionalOne == type&&!this.getCurrent().objectiveOneMet)
|
||||
{
|
||||
if (getCurrent().AtEnd() && getCurrent().conditionalOne == type && !getCurrent().objectiveOneMet)
|
||||
OnePassed();
|
||||
}else if(this.getCurrent().AtEnd() && this.getCurrent().conditionalTwo == type)
|
||||
{
|
||||
TwoPassed();
|
||||
}
|
||||
|
||||
else if (getCurrent().AtEnd() && getCurrent().conditionalTwo == type) TwoPassed();
|
||||
}
|
||||
|
||||
public ProgressionSection getCurrent()
|
||||
{
|
||||
|
||||
return this.sections[progress];
|
||||
return sections[progress];
|
||||
}
|
||||
|
||||
private IEnumerator waitForFadeIn()
|
||||
{
|
||||
|
||||
yield return new WaitForSeconds(3);
|
||||
if (this.sections.Count > this.progress+1)
|
||||
if (sections.Count > progress + 1)
|
||||
{
|
||||
this.progress++;
|
||||
this.objectiveGui.FadeIn();
|
||||
this.objectiveGui.visualObjects[0].isComplete = false;
|
||||
this.objectiveGui.visualObjects[1].isComplete = false;
|
||||
progress++;
|
||||
objectiveGui.FadeIn();
|
||||
objectiveGui.visualObjects[0].isComplete = false;
|
||||
objectiveGui.visualObjects[1].isComplete = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
transitioning = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class ProgressionSection
|
||||
{
|
||||
[SerializeField]
|
||||
public string instruction1;
|
||||
[SerializeField]
|
||||
public string istruction2;
|
||||
[SerializeField]
|
||||
public bool objectiveOneMet = false;
|
||||
[SerializeField]
|
||||
public BasicLevelProgressionSystem.InputType conditionalOne;
|
||||
[SerializeField]
|
||||
public bool objectiveTwoMet = false;
|
||||
[SerializeField]
|
||||
public BasicLevelProgressionSystem.InputType conditionalTwo;
|
||||
[SerializeField] public string instruction1;
|
||||
|
||||
[SerializeField] public string istruction2;
|
||||
|
||||
[SerializeField] public bool objectiveOneMet;
|
||||
|
||||
[SerializeField] public BasicLevelProgressionSystem.InputType conditionalOne;
|
||||
|
||||
[SerializeField] public bool objectiveTwoMet;
|
||||
|
||||
[SerializeField] public BasicLevelProgressionSystem.InputType conditionalTwo;
|
||||
|
||||
[SerializeField] public List<Transform> positionsOne = new();
|
||||
|
||||
[SerializeField] public List<Transform> positionsTwo = new();
|
||||
|
||||
[HideInInspector] public int activePosition;
|
||||
|
||||
[SerializeField]
|
||||
public List<Transform> positionsOne= new List<Transform>();
|
||||
[SerializeField]
|
||||
public List<Transform> positionsTwo = new List<Transform>();
|
||||
[HideInInspector]
|
||||
public int activePosition = 0;
|
||||
public Transform getActive()
|
||||
{
|
||||
if (!objectiveOneMet)
|
||||
{
|
||||
return positionsOne[activePosition];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return positionsTwo[activePosition];
|
||||
}
|
||||
|
||||
return positionsTwo[activePosition];
|
||||
}
|
||||
|
||||
public bool Iterate()
|
||||
{
|
||||
if (!objectiveOneMet && this.activePosition + 1 < positionsOne.Count)
|
||||
if (!objectiveOneMet && activePosition + 1 < positionsOne.Count)
|
||||
{
|
||||
this.activePosition += 1;
|
||||
return true;
|
||||
}else if (objectiveOneMet && !objectiveTwoMet && this.activePosition + 1 < positionsTwo.Count)
|
||||
{
|
||||
this.activePosition += 1;
|
||||
activePosition += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (objectiveOneMet && !objectiveTwoMet && activePosition + 1 < positionsTwo.Count)
|
||||
{
|
||||
activePosition += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public bool AtEnd()
|
||||
{
|
||||
if (!objectiveOneMet && this.activePosition + 1 < positionsOne.Count)
|
||||
{
|
||||
|
||||
if (!objectiveOneMet && activePosition + 1 < positionsOne.Count)
|
||||
return false;
|
||||
}
|
||||
else if (objectiveOneMet && !objectiveTwoMet && this.activePosition + 1 < positionsTwo.Count)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
if (objectiveOneMet && !objectiveTwoMet && activePosition + 1 < positionsTwo.Count) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Progress()
|
||||
{
|
||||
this.activePosition = 0;
|
||||
activePosition = 0;
|
||||
}
|
||||
}
|
@ -5,126 +5,108 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
public class LevelZeroSpecial : MonoBehaviour
|
||||
{
|
||||
|
||||
//[SerializeField]
|
||||
//private int initalPlaceIndex = 0;
|
||||
[SerializeField]
|
||||
private DoorInteractable recepticleOne;
|
||||
[SerializeField] private DoorInteractable recepticleOne;
|
||||
|
||||
[SerializeField]
|
||||
private BasicLevelProgressionSystem progression;
|
||||
[SerializeField]
|
||||
private int enabledOn = 4;
|
||||
private bool isEnabled = false;
|
||||
[SerializeField] private BasicLevelProgressionSystem progression;
|
||||
|
||||
[SerializeField]
|
||||
private List<HeavyInteractableItem> powercores;
|
||||
[SerializeField]
|
||||
private List<DoorInteractable> recepticals;
|
||||
[SerializeField]
|
||||
private WaypointMarker marker;
|
||||
[SerializeField] private int enabledOn = 4;
|
||||
|
||||
[SerializeField] private List<HeavyInteractableItem> powercores;
|
||||
|
||||
[SerializeField] private List<DoorInteractable> recepticals;
|
||||
|
||||
[SerializeField] private WaypointMarker marker;
|
||||
|
||||
[SerializeField] private Animator cover;
|
||||
|
||||
[SerializeField] private Animator gate;
|
||||
|
||||
[SerializeField] private GameObject exitCollider;
|
||||
|
||||
[SerializeField] private PlayerComponent player;
|
||||
|
||||
[SerializeField] private WaypointMarker marker2Ref;
|
||||
|
||||
[SerializeField] private WaypointMarker marker3Ref;
|
||||
|
||||
[SerializeField] private Optimizer finalRoomOptimizer;
|
||||
|
||||
private int countPowered;
|
||||
private bool isEnabled;
|
||||
|
||||
private readonly List<WaypointMarker> markers = new();
|
||||
|
||||
private bool transitioningOut;
|
||||
|
||||
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()
|
||||
private void Start()
|
||||
{
|
||||
marker2Ref.gameObject.SetActive(false);
|
||||
marker3Ref.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void Update()
|
||||
{
|
||||
if (progression.Sections[0] == progression.getCurrent())
|
||||
{
|
||||
if (recepticleOne.Powered)
|
||||
{
|
||||
progression.TwoPassed();
|
||||
//progression.ProgressCurrentIfInput(BasicLevelProgressionSystem.InputType.EXTERNAL);
|
||||
}
|
||||
}
|
||||
//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 (isEnabled)
|
||||
foreach (var recepitcal in recepticals)
|
||||
if (recepitcal.Powered)
|
||||
{
|
||||
countPowered++;
|
||||
for(int i = 0; i < markers.Count; i++)
|
||||
for (var i = 0; i < markers.Count; i++)
|
||||
{
|
||||
WaypointMarker marker = markers[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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
IEnumerator transitionOut()
|
||||
|
||||
private IEnumerator transitionOut()
|
||||
{
|
||||
cover.Play("Cover_load_out");
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user