public void OnRoll(int index) { isCompleteCreatePlayerCard = false; GameObject gObj = GetInvisibleCard(index); Sequence seq = Util.PlayRotation(gObj, 0.2f); Vector3 playerCardPos = PlayerCardManager.GetInstance().GetNextPosPlayerCard(); seq.Append(gObj.transform.DOMove(playerCardPos, 0.2f)); seq.OnComplete(() => { CardInVisibleScript cardInvisible = gObj.GetComponent <CardInVisibleScript>(); if (cardInvisible != null) { cardInvisible.isHide = true; } gObj.SetActive(false); if (SoundManager.getInstance()) { SoundManager.getInstance().PlaySound(SoundId.TOUCH); } if (PlayerCardManager.GetInstance() != null) { PlayerCardManager.GetInstance().OnCreatePlayerCard(index); } isCompleteCreatePlayerCard = true; }); }
public Dictionary <int, GameObject> GetRemainInvisibleCards() { if (dicInvisibleCards == null || dicInvisibleCards.Count <= 0) { return(null); } Dictionary <int, GameObject> dicResult = new Dictionary <int, GameObject>(); foreach (KeyValuePair <int, GameObject> data in dicInvisibleCards) { CardInVisibleScript card = data.Value.GetComponent <CardInVisibleScript>(); if (!card.isHide) { dicResult[data.Key] = data.Value; } } return(dicResult); }
private void OnCloneAndMoveCard(GameObject prefab, int index) { if (prefab == null) { Debug.LogError("Missing Prefab"); return; } if (dicPostCardInvisible == null) { Debug.LogError("Missing dicPostCardInvisible"); return; } //Create new card GameObject cardClone = Instantiate(prefab, Vector3.zero, Quaternion.identity, rootTrans.transform) as GameObject; CardInVisibleScript cardInvisible = cardClone.GetComponent <CardInVisibleScript>(); if (cardInvisible == null) { Debug.LogError("Missing CardInvisibleScript"); return; } dicInvisibleCards[index] = cardClone; cardInvisible.OnUpdateCardVisible(index); Button btnCardInvisible = cardInvisible.GetComponent <Button>(); if (btnCardInvisible == null) { Debug.LogError("Missing btnCardInvisible"); return; } btnCardInvisible.interactable = false; Sequence seq = DOTween.Sequence(); Vector3 localPosition = Vector3.zero; localPosition.x = -(Screen.width / 2); localPosition.y = 0; localPosition.z = 0; cardClone.transform.localPosition = localPosition; Vector3 localScale = prefab.transform.localScale; cardClone.transform.localScale = Vector3.zero; seq.Append(cardClone.transform.DOScale(new Vector3(0.3f, 0.5f, 0.3f), 0.3f)); Vector3 newPostCard = dicPostCardInvisible[index]; Tween posTween = cardClone.transform.DOLocalMove(newPostCard, 0.5f); posTween.OnComplete(() => { btnCardInvisible.interactable = true; if (SoundManager.getInstance()) { SoundManager.getInstance().PlaySound(SoundId.FLY); } if (index == ConstantManager.MAX_CARD_INITIALIZE - 1) { if (SoundManager.getInstance()) { SoundManager.getInstance().PlaySound(SoundId.NORMAL, true); } } }); seq.Append(posTween); seq.Append(cardClone.transform.DOScale(new Vector3(localScale.x, localScale.y, localScale.z), 0.2f)); }