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
b64b096f
Commit
b64b096f
authored
May 15, 2022
by
Bošániová Monika
Browse files
tutorial update
parent
50a80283
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Assets/CubeImages/solved.png
0 → 100644
View file @
b64b096f
67.8 KB
Assets/Scenes/Tutorial.unity
View file @
b64b096f
This diff is collapsed.
Click to expand it.
Assets/Scripts/Automate.cs
View file @
b64b096f
...
...
@@ -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
=
=
10
0
)
progressOfRotation
++
;
if
(
progressOfRotation
>
=
2
0
)
{
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
"R
i
"
:
side
=
Colors
.
Blue
;
angle
=
-
90
;
break
;
...
...
@@ -192,7 +209,7 @@ public class Automate : MonoBehaviour
side
=
Colors
.
Green
;
angle
=
90
;
break
;
case
"L
'
"
:
case
"L
i
"
:
side
=
Colors
.
Green
;
angle
=
-
90
;
break
;
...
...
@@ -204,7 +221,7 @@ public class Automate : MonoBehaviour
side
=
Colors
.
Orange
;
angle
=
-
90
;
break
;
case
"F
'
"
:
case
"F
i
"
:
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
"B
i
"
:
side
=
Colors
.
Red
;
angle
=
90
;
break
;
...
...
@@ -228,7 +245,7 @@ public class Automate : MonoBehaviour
side
=
Colors
.
Yellow
;
angle
=
90
;
break
;
case
"U
'
"
:
case
"U
i
"
:
side
=
Colors
.
Yellow
;
angle
=
-
90
;
break
;
...
...
@@ -240,7 +257,7 @@ public class Automate : MonoBehaviour
side
=
Colors
.
White
;
angle
=
-
90
;
break
;
case
"D
'
"
:
case
"D
i
"
:
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
(
"F
i
"
);
return
;
case
"B"
:
DoMove
(
"B
'
"
);
DoMove
(
"B
i
"
);
return
;
case
"R"
:
DoMove
(
"R
'
"
);
DoMove
(
"R
i
"
);
return
;
case
"L"
:
DoMove
(
"L
'
"
);
DoMove
(
"L
i
"
);
return
;
case
"U"
:
DoMove
(
"U
'
"
);
DoMove
(
"U
i
"
);
return
;
case
"D"
:
DoMove
(
"D
'
"
);
DoMove
(
"D
i
"
);
return
;
case
"F2"
:
DoMove
(
"F2"
);
...
...
@@ -328,22 +344,22 @@ public class Automate : MonoBehaviour
case
"D2"
:
DoMove
(
"D2"
);
return
;
case
"F
'
"
:
case
"F
i
"
:
DoMove
(
"F"
);
return
;
case
"B
'
"
:
case
"B
i
"
:
DoMove
(
"B"
);
return
;
case
"L
'
"
:
case
"L
i
"
:
DoMove
(
"L"
);
return
;
case
"R
'
"
:
case
"R
i
"
:
DoMove
(
"R"
);
return
;
case
"U
'
"
:
case
"U
i
"
:
DoMove
(
"U"
);
return
;
case
"D
'
"
:
case
"D
i
"
:
DoMove
(
"D"
);
return
;
case
"2"
:
...
...
Assets/Scripts/Enums.cs
0 → 100644
View file @
b64b096f
namespace
Assets.Scripts
{
public
enum
Moves
{
U
,
D
,
L
,
R
,
F
,
B
,
U2
,
D2
,
L2
,
R2
,
F2
,
B2
,
Ui
,
Di
,
Li
,
Ri
,
Fi
,
Bi
,
};
}
Assets/Scripts/TutorialLevel.cs
View file @
b64b096f
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
();
}
p
rivate
void
VisualizeEdges
()
p
ublic
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
();
}
p
rivate
void
VisualizeFaces
(
)
p
ublic
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
(
""
);
}
}
}
Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset
View file @
b64b096f
This diff is collapsed.
Click to expand it.
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