public void exec() { CubeTiersRotateRoutine.SequenceAutoRotateItem[] items = new CubeTiersRotateRoutine.SequenceAutoRotateItem[12]; Cube cube = GameObject.Find("cube").GetComponent <Cube>(); int cubeRank = cube.GetComponent <Cube>().rank; System.Random random = new System.Random(); System.Array faces = System.Enum.GetValues(typeof(Face)); System.Array signs = System.Enum.GetValues(typeof(Sign)); for (int i = 0; i < items.Length; i++) { Face face = (Face)faces.GetValue(random.Next(0, 3)); int level = random.Next(0, cubeRank); TierId id = new TierId(face, level); Sign sign = (Sign)signs.GetValue(random.Next(0, 2)); items[i] = new CubeTiersRotateRoutine.SequenceAutoRotateItem(id, sign); } cube.SequenceAutoRotateTier(items); }
public string Serialize(GameState gameState) { string resultStr = ""; { LinkedList <CubeRecord> records = gameState.records; LinkedListNode <CubeRecord> recordNode = records.First; while (recordNode != null) { resultStr += "|records"; { CubeTiersRotateRoutine.SequenceAutoRotateItem tierRotation = recordNode.Value.tierRotation; if (tierRotation != null) { resultStr += "|-tierRotation"; { resultStr += "|--id"; TierId id = tierRotation.id; { { resultStr += "|---face"; Face face = id.face; resultStr += ("|---" + face.ToString()); resultStr += "|---face"; } { resultStr += "|---level"; int level = id.level; resultStr += ("|---" + level); resultStr += "|---level"; } } resultStr += "|--id"; } { resultStr += "|--sign"; Sign sign = tierRotation.sign; resultStr += ("|--" + sign); resultStr += "|--sign"; } resultStr += "|-tierRotation"; } } { resultStr += "|-boxesState"; BoxState[] boxesState = recordNode.Value.boxesState; for (int i = 0; i < boxesState.Length; i++) { resultStr += "|--boxState"; BoxState boxState = boxesState[i]; { resultStr += "|---cubeCoord"; Vector3Int cubeCoord = boxState.cubeCoord; resultStr += ("|---" + cubeCoord.x + " " + cubeCoord.y + " " + cubeCoord.z); resultStr += "|---cubeCoord"; } { resultStr += "|---localRotation"; Quaternion localRotation = boxState.localRotation; resultStr += ("|---" + localRotation.x + " " + localRotation.y + " " + localRotation.z + " " + localRotation.w); resultStr += "|---localRotation"; } { Dictionary <String, Direction> squareDirections = boxState.squareDirections; if (squareDirections != null && squareDirections.Keys.Count > 0) { resultStr += "|---squareDirections"; foreach (string key in squareDirections.Keys) { resultStr += ("|----" + key + " " + squareDirections[key]); } resultStr += "|---squareDirections"; } } resultStr += "|--boxState"; } resultStr += "|-boxesState"; } recordNode = recordNode.Next; resultStr += "|records"; } } { LinkedListNode <CubeRecord> currentRecord = gameState.currentRecord; int currentInxFromLast = 0; LinkedListNode <CubeRecord> searchingRecord = gameState.records.Last; while (searchingRecord != currentRecord) { currentInxFromLast++; searchingRecord = searchingRecord.Previous; } resultStr += "|currentInxFromLast"; resultStr += "|" + currentInxFromLast; resultStr += "|currentInxFromLast"; } return(resultStr); }