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

add solvability script

parent 4e446437
......@@ -14,7 +14,7 @@ public class ColorButtons : MonoBehaviour
public Material actualMaterial;
private Colors beforeButtonColor;
private bool colorsChanged = false;
private static bool colorsChanged = false;
private string errorMassage = "You can't recolor middle pieces!";
......@@ -107,12 +107,12 @@ public class ColorButtons : MonoBehaviour
}
}
public void setColorsChanged(bool b)
public static void setColorsChanged(bool b)
{
colorsChanged = b;
}
public bool getColorsChanged()
public static bool getColorsChanged()
{
return colorsChanged;
}
......
using System.Collections;
using System.Collections.Generic;
public class CubeSolvable
{
private string moveString;
public CubeSolvable(string moveString)
{
this.moveString = moveString;
}
public bool isCubeSovable()
{
if (checkNumOfColors() && checkCorners() && checkSides())
return true;
return false;
}
private bool checkNumOfColors()
{
return true;
}
private bool checkCorners()
{
return true;
}
private bool checkSides()
{
return true;
}
}
......@@ -32,12 +32,22 @@ public class SolveTwoFace : MonoBehaviour
{
if (!CubeState.autoRotating)
{
//readCube.ReadState();
//get the state of the cube as a string
string moveString = cubeState.GetStateString(false);
print(moveString);
if (ColorButtons.getColorsChanged())
{
CubeSolvable cs = new CubeSolvable(moveString);
if (!cs.isCubeSovable())
{
errorMsgBox.text = "Cube is not solvable!";
return;
};
ColorButtons.setColorsChanged(false);
}
////solve the cube
Solver solver = new Solver(moveString);
////string info = "";
......
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