protected override void OnShow() { GameObject panel = GUIManager.FindPanel("DicePanel"); for (int i = 0; i < DiceNumerArray.Length; i++) { GameObject go = ResourcesManager.Instance.LoadDiceCard(DiceNumerArray[i].ToString()); GameObject diceCard = GameObject.Instantiate(go); UIButton button = diceCard.GetComponent <UIButton>(); button.tweenTarget = diceCard; diceCard.transform.SetParent(Container.transform, false); diceCard.transform.localPosition = new Vector3(30, 0, 0); TweenPosition tp = diceCard.AddComponent <TweenPosition>(); tp.from = diceCard.transform.localPosition; tp.to = new Vector3(0, i * 0.1f, 0); tp.delay = 0.2f * i + 0.2f; diceCard.name = go.name; diceCard.AddComponent <SlerpRun>().stopSlerp = true; SlerpRun slerp = diceCard.GetComponent <SlerpRun>(); slerp.rate = rate; DiceCardDic.Add(DiceNumerArray[i], diceCard); if (i == DiceNumerArray.Length - 1) { tp.onFinished.Add(new EventDelegate(StartSlerp)); } else { tp.onFinished.Add(new EventDelegate(PlayerCardMoveAudio)); } } }
void OnButtonClick() { isClickCard = true; Transform parent = transform.parent; for (int i = 0; i < parent.childCount; i++) { GameObject go = parent.GetChild(i).gameObject; UIButton btn = go.GetComponent <UIButton>(); btn.onClick.Clear(); btn.enabled = false; if (go.name == gameObject.name) { continue; } SlerpRun slerpRun = go.transform.GetComponent <SlerpRun>(); slerpRun.stopSlerp = true; slerpRun.isDrift = true; } int number = CommonHelper.Str2Int(this.name); DicePanel.diceValue = number; ShowNumberDicCard(); }
IEnumerator StartSlerp_IEnumerator() { yield return(new WaitForSeconds(1)); SlerpRun slerpRun = DiceCardDic[DiceNumerArray[0]].gameObject.GetComponent <SlerpRun>(); slerpRun.stopSlerp = false; }
void HideDiceCards() { TweenPosition tp; Transform parent = transform.parent; for (int i = 0; i < parent.childCount; i++) { GameObject go = parent.GetChild(i).gameObject; tp = go.GetComponent <TweenPosition>(); tp.onFinished.Clear(); SlerpRun slerpRun = go.GetComponent <SlerpRun>(); slerpRun.isDrift = false; if (!slerpRun.isClickCard) { tp.enabled = true; tp.from = go.transform.localPosition; tp.to = new Vector3(0, i * 0.1f, 0); tp.duration = 2.0f; tp.delay = 0.15f * i; tp.ignoreTimeScale = true; tp.ResetToBeginning(); } else { tp.enabled = true; tp.onFinished.Clear(); tp.from = go.transform.localPosition; tp.to = new Vector3(0, i * 0.1f, 0); tp.duration = 2.0f; tp.delay = 0.2f * i; tp.ignoreTimeScale = true; ReturnRotateFrist(); tp.ResetToBeginning(); } if (i == parent.childCount - 1) { tp.onFinished.Add(new EventDelegate(ReturnTweenPositionToScan)); } else { tp.onFinished.Add(new EventDelegate(PlayCardMoveAudio)); } } }
void DiceCardDeep() { for (int i = 0; i < Container.transform.childCount; i++) { GameObject go = Container.transform.GetChild(i).gameObject; SlerpRun slerpRun = go.GetComponent <SlerpRun>(); if (slerpRun.stopSlerp == true) { TweenPosition tp = go.GetComponent <TweenPosition>(); tp.enabled = true; tp.onFinished.Clear(); tp.from = go.transform.localPosition; tp.delay = 0; tp.duration = 0.1f; tp.to = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y - 0.1f, go.transform.localPosition.z); tp.ResetToBeginning(); } } PlayerCardMoveAudio(); }
void ReturnTweenPositionToScan() { if (ReturnTweenPositionToScanIsOver) { return; } Transform parent = transform.parent; int temp_j = 0; for (int i = parent.childCount - 1; i >= 0; i--) { GameObject go = parent.GetChild(i).gameObject; TweenPosition tp = go.GetComponent <TweenPosition>(); tp.enabled = true; tp.from = go.transform.localPosition; tp.to = new Vector3(-30, go.transform.localPosition.y, go.transform.localPosition.z); tp.duration = 0.7f; tp.delay = temp_j * 0.2f + 0.2f; SlerpRun slerp = go.GetComponent <SlerpRun>(); slerp.stopRotate = false; tp.ignoreTimeScale = false; tp.onFinished.Clear(); if (i == 0) { tp.onFinished.Add(new EventDelegate(LastTPHidePanel)); tp.onFinished.Add(new EventDelegate(PlayCardMoveAudio)); } else { tp.onFinished.Add(new EventDelegate(PlayCardMoveAudio)); } tp.ResetToBeginning(); temp_j++; } ReturnTweenPositionToScanIsOver = true; }