69 lines
1.6 KiB
C#
69 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class A14LGameManager : MonoBehaviour
|
|
{
|
|
public static A14LGameManager instance;
|
|
public Transform player;
|
|
public int currentIndex = 8;
|
|
public List<Transform> positions = new List<Transform>();
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
StartCoroutine(WaitToRetry());
|
|
}
|
|
|
|
public void GoUp()
|
|
{
|
|
MoveTo(currentIndex + 1);
|
|
}
|
|
|
|
public void GoDown()
|
|
{
|
|
if (currentIndex > 0)
|
|
{
|
|
MoveTo(currentIndex - 1);
|
|
}
|
|
else
|
|
{
|
|
StartCoroutine(WaitToRetry());
|
|
}
|
|
|
|
}
|
|
|
|
IEnumerator WaitToRetry()
|
|
{
|
|
yield return new WaitForSeconds(1);
|
|
A14LQuestionManager.instance.SetupQuestion(currentIndex);
|
|
A14LQuestionManager.instance.ShowQuestion();
|
|
}
|
|
|
|
public void MoveTo(int i)
|
|
{
|
|
StartCoroutine(DoMovement(currentIndex, i));
|
|
}
|
|
|
|
IEnumerator DoMovement(int from, int to)
|
|
{
|
|
if (!A14LQuestionManager.instance.CanFinish(to))
|
|
{
|
|
for (float i = 0; i < 1; i += .01f)
|
|
{
|
|
player.position = Vector3.Lerp(positions[from].position, positions[to].position, i);
|
|
yield return new WaitForSeconds(.01f);
|
|
}
|
|
currentIndex = to;
|
|
A14LQuestionManager.instance.SetupQuestion(currentIndex);
|
|
A14LQuestionManager.instance.ShowQuestion();
|
|
Debug.Log(" :D ");
|
|
}
|
|
else
|
|
{
|
|
GameControl.instance.FinishGame();
|
|
}
|
|
|
|
}
|
|
}
|