private void Undo() { noOfAnimations = 0; waste.RegisterOnRefreshWasteAction(null); allMovesSet = false; animationQueueController.SetAnimationStatus(AnimationStatus.inProgress); if (saveList.Count > 0) { cardsToAnimate.Clear(); cardsToRotate.Clear(); SaveState lastSave = saveList[saveList.Count - 1]; MatchStatistics.instance.score = lastSave.score; MatchStatistics.instance.moves = lastSave.moves; MatchStatistics.instance.vegasScore = lastSave.vegasScore; stock.stockLimit = lastSave.stockLimit; for (int i = 0; i < lastSave.cardsInfo.Count; i++) { Card myCard = gameCardsSet[i]; CardInfo myCardInfo = lastSave.cardsInfo[myCard]; myCard.gameObject.SetActive(true); CheckIfCardNeedRotateAnim(myCard, myCardInfo); //trasfrom local position to world pos Vector3 prevPos = myCardInfo.GetParent().TransformPoint(myCardInfo.GetPos()); //if card change position play anim if (myCard.transform.parent != myCardInfo.GetParent()) { if (cardsToAnimate.ContainsKey(myCard)) { Debug.LogError("Dictionary has already key " + myCard.name); } else { myCard.lastGoodParametres.lastCardAbove = myCardInfo.GetCardAbove(); myCard.SetReturnPoint(myCardInfo.GetParent(), prevPos - myCardInfo.GetParent().position); cardsToAnimate.Add(myCard, myCardInfo); } } else { myCard.transform.SetParent(myCardInfo.GetParent(), true); myCard.transform.position = new Vector3(myCard.transform.position.x, prevPos.y, myCard.transform.position.z); } myCard.transform.parent.SendMessage("RefreshZone", SendMessageOptions.DontRequireReceiver); } saveList.Remove(lastSave); AnimCards(); stock.RefreshStockState(lastSave.stockState, false); } else { Debug.Log("No moves to undo"); animationQueueController.CastNextAnimation(); } allMovesSet = true; }