Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bošániová Monika
Rubics_cube
Commits
3b0952c1
Commit
3b0952c1
authored
Jul 13, 2021
by
Bošániová Monika
Browse files
add solvability script
parent
4e446437
Changes
3
Hide whitespace changes
Inline
Side-by-side
Assets/Scripts/ColorButtons.cs
View file @
3b0952c1
...
...
@@ -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
;
}
...
...
Assets/Scripts/CubeSolvable.cs
0 → 100644
View file @
3b0952c1
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
;
}
}
Assets/Scripts/SolveTwoFace.cs
View file @
3b0952c1
...
...
@@ -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 = "";
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment