private void RefreshWaste(Transform wasteTransform) { Waste waste = wasteTransform.GetComponent <Waste>(); if (waste) { //If previous parent is Waste refresh it waste.RegisterOnRefreshWasteAction(null); waste.RefreshChildren(); stock.RefreshStockRefreshImage(); } }
public void GetCard() { int cards = MatchStatistics.instance.isDraw3 ? 3 : 1; waste.RegisterOnRefreshWasteAction(FinishReturnWasteAnimation); noOfAnimations = 1; SaveManager.instance.Save(); MatchStatistics.instance.moves++; for (int i = 0; i < cards; i++) { if (transform.childCount > 0) { if (transform.childCount == 1) { RefreshStockState(false); } animationQueueController.SetAnimationStatus(AnimationStatus.inProgress); SoundManager.instance.PlayPickCardSound(); Card card = transform.GetChild(0).GetComponent <Card>(); card.transform.SetParent(undoHolder); card.SetReturnPoint(waste.transform, Constants.vectorZero); card.RegisterOnReverseAnimationFinishCB(FinishReturnWasteAnimation); noOfAnimations++; card.RotateCard(Constants.STOCK_ANIM_TIME); card.RegisterOnAnimationFinishCB(FinishReturnWasteAnimation); noOfAnimations++; card.MoveCard(Constants.STOCK_ANIM_TIME * 2); } else { if (i == 0) //If first card return stock { ReturnCardsFromWasteToStock(); } break; } } }
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; }