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

Merge branch 'CelkovaZmenaKodu' into 'master'

Merge zmeny celeho programu

See merge request !1
parents 870ad82a e56c9782
......@@ -39,3 +39,12 @@ sysinfo.txt
# Crashlytics generated file
Assets/StreamingAssets/crashlytics-build.properties
# Ignore Tables folder and contents.
/Tables
/Tables/*
# Ignore meta files
/.vs
/.vs/*
*.meta
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//UROBIT setters a getters!!!
public class Automate : MonoBehaviour
{
public static List<string> moveList = new List<string>() { };
//static List<string> undoMoveList = new List<string>() { };
public static int actualPosition = 0;
public static bool shuffleDone = false;
bool AutomatePlaying = false;
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;
private ReadCube readCube;
// Start is called before the first frame update
void Start()
{
cubeState = FindObjectOfType<CubeState>();
readCube = FindObjectOfType<ReadCube>();
}
// Update is called once per frame
void Update()
{
if (moveList.Count > 0 && !CubeState.autoRotating && CubeState.started && (shuffleDone || AutomatePlaying) && actualPosition < moveList.Count)
{
//do the move at the first index;
DoMove(moveList[actualPosition]);
actualPosition += 1;
//remove the move at the first index
//moveList.Remove(moveList[0]);
}
if (shuffleDone && actualPosition == moveList.Count)
{
shuffleDone = false;
actualPosition = 0;
moveList.Clear();
}
}
public void AutomatePlayStart()
{
if(moveList.Count > 0)
AutomatePlaying = true;
}
public void AutomatePLayStop()
{
AutomatePlaying = false;
}
public void ForwardMove()
{
AutomatePlaying = false;
if (moveList.Count > 0 && !CubeState.autoRotating && CubeState.started && actualPosition != moveList.Count)
{
//do the move at the first index;
DoMove(moveList[actualPosition]);
actualPosition += 1;
print("Forward:" + moveList.Count + (actualPosition -1));
//remove the move at the first index
//moveList.Remove(moveList[0]);
}
}
public void UndoMove()
{
AutomatePlaying = false;
if (moveList.Count > 0 && !CubeState.autoRotating && CubeState.started && actualPosition != 0)
{
//do the move at the first index;
DoOppositeMove(moveList[actualPosition - 1]);
actualPosition -= 1;
print("Undo:" + moveList.Count + (actualPosition + 1));
//remove the move at the first index
//undoMoveList.Remove(undoMoveList[0]);
}
}
public void Shuffle()
{
AutomatePlaying = false;
//dopisat aby sa negenerovali opacne
List<string> moves = new List<string>();
int shuffleLength = Random.Range(10, 30);
for (int i = 0; i < shuffleLength; i++)
{
int randomMove = Random.Range(0, allMoves.Count);
moves.Add(allMoves[randomMove]);
}
moveList = moves;
string tmp = "";
for (int i = 0; i < moveList.Count; i++)
{
tmp += moveList[i];
tmp += " ";
}
print(tmp);
shuffleDone = true;
actualPosition = 0;
//moveList = new List<string>();
//moveList = new List<string>() { "F'","L2","D'","B","U'","F","U","L'","F2", "U'", "R2", "L'", "D2", "D2", "R2", "R", "B'", "L", "F2", "F", "D2", "L'", "U", "R2", "R'", "L'", "B2", "L", "U'","R'","R2"};
}
void DoMove(string move)
{
readCube.ReadState();
CubeState.autoRotating = true;
if(move == "U")
{
RotateSide(cubeState.up, -90);
}
if(move == "U'")
{
RotateSide(cubeState.up, 90);
}
if(move == "U2")
{
RotateSide(cubeState.up, -180);
}
if (move == "D")
{
RotateSide(cubeState.down, -90);
}
if (move == "D'")
{
RotateSide(cubeState.down, 90);
}
if (move == "D2")
{
RotateSide(cubeState.down, -180);
}
if (move == "L")
{
RotateSide(cubeState.left, -90);
}
if (move == "L'")
{
RotateSide(cubeState.left, 90);
}
if (move == "L2")
{
RotateSide(cubeState.left, -180);
}
if (move == "R")
{
RotateSide(cubeState.right, -90);
}
if (move == "R'")
{
RotateSide(cubeState.right, 90);
}
if (move == "R2")
{
RotateSide(cubeState.right, -180);
}
if (move == "F")
{
RotateSide(cubeState.front, -90);
}
if (move == "F'")
{
RotateSide(cubeState.front, 90);
}
if (move == "F2")
{
RotateSide(cubeState.front, -180);
}
if (move == "B")
{
RotateSide(cubeState.back, -90);
}
if (move == "B'")
{
RotateSide(cubeState.back, 90);
}
if (move == "B2")
{
RotateSide(cubeState.back, -180);
}
}
void DoOppositeMove(string moveToMakeOpposite)
{
switch (moveToMakeOpposite)
{
case "F":
DoMove("F'");
return;
case "B":
DoMove("B'");
return;
case "R":
DoMove("R'");
return;
case "L":
DoMove("L'");
return;
case "U":
DoMove("U'");
return;
case "D":
DoMove("D'");
return;
case "F2":
DoMove("F2");
return;
case "B2":
DoMove("B2");
return;
case "R2":
DoMove("R2");
return;
case "L2":
DoMove("L2");
return;
case "U2":
DoMove("U2");
return;
case "D2":
DoMove("D2");
return;
case "F'":
DoMove("F");
return;
case "B'":
DoMove("B");
return;
case "L'":
DoMove("L");
return;
case "R'":
DoMove("R");
return;
case "U'":
DoMove("U");
return;
case "D'":
DoMove("D");
return;
default:
return;
}
}
void RotateSide(List<GameObject> side, float angle)
{
//automatically rotate the side by the angle
PivotRotation pr = side[4].transform.parent.GetComponent<PivotRotation>();
pr.StartAutoRotate(side, angle);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CubeMap : MonoBehaviour
{
CubeState cubeState;
public Transform up;
public Transform down;
public Transform left;
public Transform right;
public Transform front;
public Transform back;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Set()
{
cubeState = FindObjectOfType<CubeState>();
UpdateMap(cubeState.front, front);
UpdateMap(cubeState.back, back);
UpdateMap(cubeState.left, left);
UpdateMap(cubeState.right, right);
UpdateMap(cubeState.up, up);
UpdateMap(cubeState.down, down);
}
void UpdateMap(List<GameObject> face, Transform side)
{
int i = 0;
foreach(Transform map in side)
{
if(face[i].name[0] == 'F')
{
map.GetComponent<Image>().color = Color.blue;
}
if (face[i].name[0] == 'B')
{
map.GetComponent<Image>().color = Color.green;
}
if (face[i].name[0] == 'U')
{
map.GetComponent<Image>().color = Color.white;
}
if (face[i].name[0] == 'D')
{
map.GetComponent<Image>().color = Color.yellow;
}
if (face[i].name[0] == 'L')
{
map.GetComponent<Image>().color = Color.red;
}
if (face[i].name[0] == 'R')
{
map.GetComponent<Image>().color = new Color(1, 0.5f, 0, 1);
}
i++;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeState : MonoBehaviour
{
//sides
public List<GameObject> front = new List<GameObject>();
public List<GameObject> back = new List<GameObject>();
public List<GameObject> up = new List<GameObject>();
public List<GameObject> down = new List<GameObject>();
public List<GameObject> left = new List<GameObject>();
public List<GameObject> right = new List<GameObject>();
public static bool autoRotating = false;
public static bool started = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void PickUp(List<GameObject> cubeSide)
{
foreach (GameObject face in cubeSide)
{
//Attack the parent of each face (the little cube)
// to the parent of the 4th index (the little cube in the middle)
// unless it is already the 4th index
if (face != cubeSide[4])
{
face.transform.parent.transform.parent = cubeSide[4].transform.parent;
}
}
}
public void PutDown(List<GameObject> littleCubes, Transform pivot)
{
foreach(GameObject littleCube in littleCubes)
{
if(littleCube != littleCubes[4])
{
littleCube.transform.parent.transform.parent = pivot;
}
}
}
string GetSideString(List<GameObject> side)
{
string sideString = "";
foreach (GameObject face in side)
{
sideString += face.name[0].ToString();
}
return sideString;
}
public string GetStateString()
{
string stateString = "";
stateString += GetSideString(up);
stateString += GetSideString(left);
stateString += GetSideString(front);
stateString += GetSideString(right);
stateString += GetSideString(back);
stateString += GetSideString(down);
return stateString;
}
}
fileFormatVersion: 2
guid: 5b896fe58aad69549b92a5ca04d7996a
guid: 1c29ba8545e9635429faa04a1f216659
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
fileFormatVersion: 2
guid: b6df4bf5defab1046b1c0585447d7043
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5bf8474cc2ece8a44af2a637cdccf090
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings: