Commit b64b096f authored by Bošániová Monika's avatar Bošániová Monika
Browse files

tutorial update

parent 50a80283
This diff is collapsed.
......@@ -21,8 +21,9 @@ public class Automate : MonoBehaviour
Colors side = Colors.Blue;
private GameObject movingParts;
private List<string> waitingMoves = new List<string>();
private Vector3 targetVector;
private float progressOfRotation;
private float progressOfRotation = 20;
private float angle = 0;
private static List<string> clearList = new List<string>();
......@@ -31,11 +32,11 @@ public class Automate : MonoBehaviour
private string thirdPhase = "Solve third rows's corners";
private string fourthPhase = "Solve third row's middles";
private readonly List<string> allMoves = new List<string>()
{ "U", "D", "L", "R", "F", "B",
"U2", "D2", "L2", "R2", "F2", "B2",
"U'", "D'", "L'", "R'", "F'", "B'",
};
//private readonly List<string> allMoves = new List<string>()
// { "U", "D", "L", "R", "F", "B",
// "U2", "D2", "L2", "R2", "F2", "B2",
// "U'", "D'", "L'", "R'", "F'", "B'",
// };
private CubeState cubeState;
......@@ -54,16 +55,17 @@ public class Automate : MonoBehaviour
if (CubeState.autoRotating)
{
Debug.Log("progressOfRotation " + progressOfRotation);
movingParts.transform.RotateAround(Vector3.zero, targetVector, angle/20);
progressOfRotation += 5;
if(progressOfRotation == 100)
progressOfRotation++;
if(progressOfRotation >= 20)
{
foreach (Transform child in movingParts.transform)
{
child.position = new Vector3(Mathf.Round(child.position.x), Mathf.Round(child.position.y), Mathf.Round(child.position.z));
}
CubeState.autoRotating = false;
Rotator.Update2DMap(movingParts, cubeMap);
var childsToEdit = new List<Transform>();
foreach (Transform child in movingParts.transform)
......@@ -72,7 +74,16 @@ public class Automate : MonoBehaviour
child.SetParent(rubicsCube.transform);
}
}
else
{
Debug.Log("waitingMoves.Count " + waitingMoves.Count);
if (waitingMoves.Count > 0)
{
DoMoveNow(waitingMoves[0]);
waitingMoves.RemoveAt(0);
}
}
if (movelist.getItems().Count > 0 && !CubeState.autoRotating && CubeState.started && AutomatePlaying && movelistIterator.MoveNext())
{
......@@ -155,8 +166,9 @@ public class Automate : MonoBehaviour
int shuffleLength = UnityEngine.Random.Range(10, 30);
for (int i = 0; i < shuffleLength; i++)
{
int randomMove = UnityEngine.Random.Range(0, allMoves.Count);
moves.Add(allMoves[randomMove]);
int randomMove = UnityEngine.Random.Range(0, Enum.GetNames(typeof(Assets.Scripts.Moves)).Length);
moves.Add(((Assets.Scripts.Moves)randomMove).ToString());
//allMoves[randomMove]);
}
movelist.AddCollection(moves);
movelistIterator.Reset();
......@@ -173,14 +185,19 @@ public class Automate : MonoBehaviour
public void DoMove(string move)
{
waitingMoves.Add(move);
return;
}
public void DoMoveNow(string move)
{
switch (move)
switch (move)
{
case "R":
case "R":
side = Colors.Blue;
angle = 90;
break;
case "R'":
case "Ri":
side = Colors.Blue;
angle = -90;
break;
......@@ -192,7 +209,7 @@ public class Automate : MonoBehaviour
side = Colors.Green;
angle = 90;
break;
case "L'":
case "Li":
side = Colors.Green;
angle = -90;
break;
......@@ -204,7 +221,7 @@ public class Automate : MonoBehaviour
side = Colors.Orange;
angle = -90;
break;
case "F'":
case "Fi":
side = Colors.Orange;
angle = 90;
break;
......@@ -214,9 +231,9 @@ public class Automate : MonoBehaviour
break;
case "B":
side = Colors.Red;
angle = -90;
angle = -90;
break;
case "B'":
case "Bi":
side = Colors.Red;
angle = 90;
break;
......@@ -228,7 +245,7 @@ public class Automate : MonoBehaviour
side = Colors.Yellow;
angle = 90;
break;
case "U'":
case "Ui":
side = Colors.Yellow;
angle = -90;
break;
......@@ -240,7 +257,7 @@ public class Automate : MonoBehaviour
side = Colors.White;
angle = -90;
break;
case "D'":
case "Di":
side = Colors.White;
angle = 90;
break;
......@@ -252,7 +269,7 @@ public class Automate : MonoBehaviour
algorithmMessage.text = firstPhase;
return;
case "2":
algorithmMessage.text = secondPhase;
algorithmMessage.text = secondPhase;
return;
case "3":
algorithmMessage.text = thirdPhase;
......@@ -260,11 +277,11 @@ public class Automate : MonoBehaviour
case "4":
algorithmMessage.text = fourthPhase;
return;
default:
default:
return;
}
List<Transform> childsToEdit = new List<Transform>();
float epsilon = 0.01f;
foreach (Transform child in rubicsCube.transform)
......@@ -285,7 +302,6 @@ public class Automate : MonoBehaviour
foreach (Transform child in childsToEdit)
child.SetParent(movingParts.transform);
RotateSide();
}
void DoOppositeMove(string moveToMakeOpposite)
......@@ -293,22 +309,22 @@ public class Automate : MonoBehaviour
switch (moveToMakeOpposite)
{
case "F":
DoMove("F'");
DoMove("Fi");
return;
case "B":
DoMove("B'");
DoMove("Bi");
return;
case "R":
DoMove("R'");
DoMove("Ri");
return;
case "L":
DoMove("L'");
DoMove("Li");
return;
case "U":
DoMove("U'");
DoMove("Ui");
return;
case "D":
DoMove("D'");
DoMove("Di");
return;
case "F2":
DoMove("F2");
......@@ -328,22 +344,22 @@ public class Automate : MonoBehaviour
case "D2":
DoMove("D2");
return;
case "F'":
case "Fi":
DoMove("F");
return;
case "B'":
case "Bi":
DoMove("B");
return;
case "L'":
case "Li":
DoMove("L");
return;
case "R'":
case "Ri":
DoMove("R");
return;
case "U'":
case "Ui":
DoMove("U");
return;
case "D'":
case "Di":
DoMove("D");
return;
case "2":
......
namespace Assets.Scripts
{
public enum Moves
{ U, D, L, R, F, B,
U2, D2, L2, R2, F2, B2,
Ui, Di, Li, Ri, Fi, Bi,
};
}
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class TutorialLevel : MonoBehaviour
{
private int tutorialIndex = 0;
private static int tutorialIndex = 0;
public GameObject TutorialObjectsParent;
public GameObject CubeMap;
public GameObject RotationButtons;
public GameObject Goal;
public GameObject nextButton;
public TextMeshProUGUI result;
Automate automate;
PiecesHiding piecesHiding;
private static Assets.Scripts.Moves generatedMove;
private bool tutorialChecker => tutorialIndex >= 4;
// Start is called before the first frame update
void Start()
{
//TutorialObjectsParent = GameObject.Find("Introduction");
print("Mam " + TutorialObjectsParent.name);
/*
VisualizeLayers();
VisualizeFaces();
VisualizeCenters();
VisualizeEdges();
VisualizeCorners();
*/
automate = FindObjectOfType<Automate>();
piecesHiding = FindObjectOfType<PiecesHiding>();
//cubeState = FindObjectOfType<CubeState>();
}
void Update()
......@@ -33,38 +41,128 @@ public class TutorialLevel : MonoBehaviour
{
Transform actualVisibleObjects = TutorialObjectsParent.transform.Find(tutorialIndex.ToString());
if (tutorialIndex != 0)
if (tutorialIndex != 0 && tutorialIndex <= 4)
{
Transform previousVisibleObjects = TutorialObjectsParent.transform.Find((tutorialIndex - 1).ToString());
previousVisibleObjects.gameObject.SetActive(false);
}
actualVisibleObjects.gameObject.SetActive(true);
switch (tutorialIndex)
{
case 2:
piecesHiding.UnHighlightSideSide();
CubeMap.SetActive(true);
break;
case 3:
RotationButtons.SetActive(true);
break;
default:
if (tutorialIndex >= 4)
{
Goal.SetActive(true);
ChooseAndDoRandomMove();
}
break;
}
if(tutorialIndex < 4)
actualVisibleObjects.gameObject.SetActive(true);
tutorialIndex += 1;
}
private void VisualizeCorners()
{
throw new NotImplementedException();
}
private void VisualizeEdges()
public void ChooseAndDoRandomMove()
{
throw new NotImplementedException();
}
int randomMove = UnityEngine.Random.Range(0, Enum.GetNames(typeof(Assets.Scripts.Moves)).Length);
generatedMove = (Assets.Scripts.Moves)randomMove;
nextButton.SetActive(false);
result.text = "";
automate.DoMove((generatedMove).ToString());
private void VisualizeCenters()
{
throw new NotImplementedException();
}
private void VisualizeFaces()
public void setPlayerMoveAndCheck(string input)
{
throw new NotImplementedException();
if (tutorialChecker)
{
string oppositeMove = getOppositeMove(generatedMove.ToString());
if (input == oppositeMove)
{
result.text = "SPRÁVNE!";
nextButton.SetActive(true);
}
else
{
result.text = "NESPRÁVNE! Tohle bylo " + input + ", ale spravne je " + oppositeMove;
automate.DoMove(getOppositeMove(input));
}
}
}
private void VisualizeLayers()
private string getOppositeMove(string input)
{
switch (input)
{
case "F":
return( "Fi");
case "B":
return("Bi");
case "R":
return("Ri");
case "L":
return("Li");
case "U":
return("Ui");
case "D":
return("Di");
case "F2":
return("F2");
case "B2":
return("B2");
case "R2":
return("R2");
case "L2":
return("L2");
case "U2":
return("U2");
case "D2":
return("D2");
case "Fi":
return("F");
case "Bi":
return("B");
case "Li":
return("L");
case "Ri":
return("R");
case "Ui":
return("U");
case "Di":
return("D");
default:
return("");
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment