接上文,因为懒得自己手动打乱魔方,所以写了一个打乱魔方的脚本,还有魔方复原方法,以下是代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CubePlayer : MonoBehaviour {
private enum Model {
Puzzle = 1,
Recover = 2
}
public Button PuzzleButton;
public Button RecoverButton;
private const int STEPS = 20;
private const float CD_TIME = 0.5f;
private int index = 0;
private Dictionary<string, string> StepsDict = new Dictionary<string, string>();
private Stack<string> StepsStack = new Stack<string>();
private List<string> StepsList = new List<string>();
private bool isInCDTime = false;
private float timer = 0f;
private Model model;
void Start () {
PuzzleButton.onClick.AddListener(OnClickPuzzleButton);
RecoverButton.on