public ActionRotateZYClockWise(GameObject magicCube, MagicCubeManager manager, List <GameObject> cubeTileList, bool bStartImmediately = false) : base(magicCube, manager, cubeTileList, bStartImmediately) { if (bStartImmediately) { undoAction = new ActionRotateZYCounterClockWise(magicCube, manager, cubeTileList, false); } }
public CubeAction generateRandomAction() { int random = UnityEngine.Random.Range(0, 5); CubeAction action = null; if (random == 0) { action = new ActionRotateZXClockWise(ownHolder, this, new List <GameObject>(collectionHelper.GetRowTiles(cubeTiles[UnityEngine.Random.Range(0, cubeTiles.Count - 1)])), true); } else if (random == 1) { action = new ActionRotateZXCounterClockWise(ownHolder, this, new List <GameObject>(collectionHelper.GetRowTiles(cubeTiles[UnityEngine.Random.Range(0, cubeTiles.Count - 1)])), true); } else if (random == 2) { action = new ActionRotateZYClockWise(ownHolder, this, new List <GameObject>(collectionHelper.GetColumnXTiles(cubeTiles[UnityEngine.Random.Range(0, cubeTiles.Count - 1)])), true); } else if (random == 3) { action = new ActionRotateZYCounterClockWise(ownHolder, this, new List <GameObject>(collectionHelper.GetColumnXTiles(cubeTiles[UnityEngine.Random.Range(0, cubeTiles.Count - 1)])), true); } else if (random == 4) { action = new ActionRotateYXClockWise(ownHolder, this, new List <GameObject>(collectionHelper.GetColumnZTiles(cubeTiles[UnityEngine.Random.Range(0, cubeTiles.Count - 1)])), true); } else if (random == 5) { action = new ActionRotateYXCounterClockWise(ownHolder, this, new List <GameObject>(collectionHelper.GetColumnZTiles(cubeTiles[UnityEngine.Random.Range(0, cubeTiles.Count - 1)])), true); } if (action == null) { Debug.Log("ERROR"); } action.SetTimeToComplete(0.3f); return(action); }
internal void LoadGame(MagicCubeSaveData savedata) { bIsLoading = true; foreach (var item in cubeTiles) { UnityEngine.Object.Destroy(item); } cubeTiles.Clear(); collectionHelper = new CubeCollectionHelper(0); for (int i = 0; i < savedata.positions.Count; i++) { var temp = GameObject.Instantiate(cubeTileRef, savedata.positions[i].ToVector3() , savedata.rotations[i].ToQuaternion()); collectionHelper.ProcessCubeTile(temp, temp.transform.position); temp.transform.SetParent(ownHolder.transform); cubeTiles.Add(temp); temp.GetComponent <CubeTileInfo>().SetID(savedata.cubeTileIDs[i]); } actionList.Clear(); for (int i = 0; i < savedata.undoActions.Count; i++) { CubeAction action = null; List <GameObject> cubeTilesForAction = new List <GameObject>(); foreach (var cubeID in savedata.undoActions[i].cubeCollection) { cubeTilesForAction.Add(cubeTiles.Find(ct => ct.GetComponent <CubeTileInfo>().GetID() == cubeID)); } switch (savedata.undoActions[i].action) { case (int)ActionSaveData.ActionType.ZXClock: action = new ActionRotateZXClockWise(ownHolder, this, cubeTilesForAction, true); break; case (int)ActionSaveData.ActionType.ZXCounterClock: action = new ActionRotateZXCounterClockWise(ownHolder, this, cubeTilesForAction, true); break; case (int)ActionSaveData.ActionType.YXClock: action = new ActionRotateYXClockWise(ownHolder, this, cubeTilesForAction, true); break; case (int)ActionSaveData.ActionType.YXCounterClock: action = new ActionRotateYXCounterClockWise(ownHolder, this, cubeTilesForAction, true); break; case (int)ActionSaveData.ActionType.ZYClock: action = new ActionRotateZYClockWise(ownHolder, this, cubeTilesForAction, true); break; case (int)ActionSaveData.ActionType.ZYCounterClock: action = new ActionRotateZYCounterClockWise(ownHolder, this, cubeTilesForAction, true); break; } if (action == null) { actionList.Clear(); break; } action.CompleteActionNoAnimation(); actionList.Add(action); } timePassed = savedata.time; seconds = savedata.time; updateTime(seconds); processUndoRedoPossible(actionList.Count > 0); bIsLoading = false; }