131 lines
2.9 KiB
C#
131 lines
2.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
|
|
//thomas09
|
|
//this is no longer used. but it'd be good to keep for the future.
|
|
public class Tutorial : MonoBehaviour
|
|
{
|
|
private TMP_Text tutorialText;
|
|
private Player player;
|
|
|
|
[SerializeField] private TMP_Text playerReserveAmmo;
|
|
|
|
private float timer = 0;
|
|
private float startTime;
|
|
private const float MAX_TIME = 1.0f;
|
|
|
|
private float cachedStartingAmmo;
|
|
|
|
private void OnEnable()
|
|
{
|
|
StartCoroutine(TutorialConditoner());
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
player = Player.Instance;
|
|
tutorialText = GetComponent<TMP_Text>();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
|
|
}
|
|
|
|
private IEnumerator TutorialConditoner()
|
|
{
|
|
RunCheck();
|
|
yield return new WaitUntil(() => startTime + MAX_TIME < Time.time);
|
|
AimCheck();
|
|
yield return new WaitUntil(() => startTime + MAX_TIME < Time.time);
|
|
InventoryCheck();
|
|
yield return new WaitUntil(() => startTime + MAX_TIME < Time.time);
|
|
yield return StartCoroutine(AmmoCheck());
|
|
KillEnemyCheck();
|
|
yield return new WaitUntil(() => startTime + MAX_TIME < Time.time);
|
|
GrenadeCheck();
|
|
yield return new WaitUntil(() => startTime + MAX_TIME < Time.time);
|
|
TutorialCompleted();
|
|
}
|
|
|
|
|
|
private void RunCheck()
|
|
{
|
|
startTime = Time.time;
|
|
if (player.GetInputHandler().GetMovementData().RunClicked)
|
|
{
|
|
CheckCompletionTimer();
|
|
}
|
|
}
|
|
|
|
private void AimCheck()
|
|
{
|
|
startTime = Time.time;
|
|
if (player.IsAiming)
|
|
{
|
|
CheckCompletionTimer();
|
|
}
|
|
}
|
|
|
|
private void InventoryCheck()
|
|
{
|
|
startTime = Time.time;
|
|
if (UIManager.Instance.Inventory.activeInHierarchy)
|
|
{
|
|
CheckCompletionTimer();
|
|
}
|
|
}
|
|
|
|
private IEnumerator AmmoCheck()
|
|
{
|
|
startTime = Time.time;
|
|
int startingAmmo = int.Parse(playerReserveAmmo.text);
|
|
cachedStartingAmmo = startingAmmo;
|
|
|
|
yield return new WaitUntil(() => int.Parse(playerReserveAmmo.text) > startingAmmo);
|
|
|
|
}
|
|
|
|
private void KillEnemyCheck()
|
|
{
|
|
startTime = Time.time;
|
|
CheckCompletionTimer();
|
|
}
|
|
|
|
private void GrenadeCheck()
|
|
{
|
|
if(player.GetWeaponData().name == "13")
|
|
{
|
|
AudioManager.Instance.playSound("Success");
|
|
PacketManager.sendChatMessage("/run");
|
|
}
|
|
}
|
|
|
|
private void TutorialCompleted()
|
|
{
|
|
AudioManager.Instance.playSound("success");
|
|
}
|
|
|
|
|
|
private void CheckCompletionTimer()
|
|
{
|
|
if(startTime + MAX_TIME < Time.time)
|
|
{
|
|
AudioManager.Instance.playSound("Success");
|
|
PacketManager.sendChatMessage("/run");
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
tutorialText.SetText("");
|
|
}
|
|
}
|