//下一句 private void NextStoryItem() { //剧情对话框处于活跃状态时,处理单击操作 if (m_IsStoryDlgActive == true) { CancelInvoke("NextStoryItem"); if (null != m_StoryDlgGO) { bool isActive = NGUITools.GetActive(m_StoryDlgGO); if (isActive == true) { if (m_Count < m_StepNumber) { StoryDlgItem item = m_StoryInfo.StoryItems[m_Count]; UpdateStoryDlg(m_StoryDlgGO.transform, item, m_Count); NGUITools.SetActive(m_StoryDlgGO, true); m_Count++; float RealIntervalTime = item.IntervalTime; if (m_StoryDlgType == StoryDlgType.Big) { RealIntervalTime = GetRealIntervalTime(item); } if (RealIntervalTime > 0.0f) { Invoke("NextStoryItem", RealIntervalTime); } } else { FinishStoryDlg(); } } } } }
/*TweenAlpha*/ private void TweenTexAnimationAlpha(StoryDlgItem dlg_item, UITexture texAnimation) { TweenAlpha tw = texAnimation.GetComponent <TweenAlpha>(); if (tw != null) { Destroy(tw); } if (dlg_item == null) { return; } TweenAlpha tween = texAnimation.gameObject.AddComponent <TweenAlpha>(); tween.duration = dlg_item.TweenAlphaDuration; tween.delay = dlg_item.TweenAlphaDelay; tween.from = dlg_item.FromAlpha; tween.to = dlg_item.ToAlpha; }
/*缩放TexAnimation*/ private void TweenTexAnimationScale(StoryDlgItem dlg_item, UITexture texAnimation) { if (dlg_item == null) { return; } if (dlg_item.ToScale < 0 || dlg_item.ToScale > 1) { return; } UnityEngine.Vector3 toScale = new UnityEngine.Vector3(dlg_item.ToScale, dlg_item.ToScale, 0); TweenScale tween = TweenScale.Begin(texAnimation.gameObject, dlg_item.TweenScaleDuration, toScale); if (tween != null) { tween.delay = dlg_item.TweenScaleDelay; tween.from = new UnityEngine.Vector3(dlg_item.FromScale, dlg_item.FromScale, 0); } }
public void OnTriggerStory(StoryDlgArgs arg) { if (m_IsStoryDlgActive == false) { m_StoryInfo = StoryDlgManager.Instance.GetStoryInfoByID(arg.m_StoryId); if (m_StoryInfo != null) { //Debug.LogError("===== Trigger A New Story !!! " + arg.m_IntervalTime); m_StoryId = arg.m_StoryId; m_StoryDlgType = arg.m_StoryDlgType; m_IntervalTime = arg.m_IntervalTime; m_IsStoryDlgActive = true; m_StoryDlgGO = this.gameObject; m_Count = 0; //剧情对话计数器,触发一个新的剧情时重置为0 m_StepNumber = m_StoryInfo.StoryItems.Count; StoryDlgItem item = m_StoryInfo.StoryItems[m_Count]; UpdateStoryDlg(m_StoryDlgGO.transform, item); NGUITools.SetActive(m_StoryDlgGO, true); if (m_StoryDlgType == StoryDlgType.Big) { TouchManager.TouchEnable = false; JoyStickInputProvider.JoyStickEnable = false; GameObject dfmUIRootGO = this.transform.parent.gameObject; if (dfmUIRootGO != null) { dfmUIRootGO.GetComponent <DFMUiRoot>().SetUIVisible(false); } } m_Count++; if (m_IntervalTime > 0.0f) { Invoke("NextStoryItem", m_IntervalTime); } } else { Debug.LogError("Wrong Story id = " + arg.m_StoryId); } } }
/*在 DlgPanelBig下,IntervaTime需要重新计算,即加上动画播放时间*/ private float GetRealIntervalTime(StoryDlgItem item) { if (item == null) { return(0f); } float totle = 0f; //float alpha = item.TweenAlphaDelay + item.TweenAlphaDuration; float scale = item.TweenScaleDelay + item.TweenScaleDuration; float pos = item.TweenPosDelay + item.TweenPosDuration; float words = item.WordDuration; if (scale > totle) { totle = scale; } if (pos + words > totle) { totle = pos + words; } return(totle + item.IntervalTime); }
private void UpdateStoryDlg(Transform storyTrans, StoryDlgItem item) { UILabel lblName = storyTrans.Find("SpeakerName").GetComponent <UILabel>(); UILabel lblWords = storyTrans.Find("SpeakerWords").GetComponent <UILabel>(); UISprite spriteLeft = storyTrans.Find("SpeakerImageLeft").GetComponent <UISprite>(); UISprite spriteRight = storyTrans.Find("SpeakerImageRight").GetComponent <UISprite>(); if (m_StoryDlgType == StoryDlgType.Small) { lblName.text = string.Format("[c9b2ae]{0}:[-]", item.SpeakerName); lblWords.text = item.Words; spriteLeft.spriteName = item.ImageLeftSmall; spriteRight.spriteName = item.ImageRightSmall; } else { lblName.text = string.Format("[c9b2ae]{0}:[-]", item.SpeakerName); lblWords.text = item.Words; spriteLeft.spriteName = item.ImageLeftBig; spriteRight.spriteName = item.ImageRightBig; } }
public void OnTriggerStory(StoryDlgInfo storyInfo) { StoryDlgManager.Instance.FireStoryStartMsg(); if (m_IsStoryDlgActive) { //剧情对话中途被打断,中止当前对话 KillStoryDlg(); } if (m_IsStoryDlgActive == false) { m_StoryInfo = storyInfo; if (m_StoryInfo != null) { //Debug.LogError("===== Trigger A New Story !!! " + arg.m_IntervalTime); m_StoryId = m_StoryInfo.ID; m_StoryDlgType = m_StoryInfo.DlgType; m_IsStoryDlgActive = true; m_StoryDlgGO = this.gameObject; m_Count = 0; //剧情对话计数器,触发一个新的剧情时重置为0 m_StepNumber = m_StoryInfo.StoryItems.Count; StoryDlgItem item = m_StoryInfo.StoryItems[m_Count]; UpdateStoryDlg(m_StoryDlgGO.transform, item, m_Count); NGUITools.SetActive(m_StoryDlgGO, true); ShowWordDuration = item.WordDuration; m_Count++; float RealIntervalTime = item.IntervalTime; if (m_StoryDlgType == StoryDlgType.Big) { RealIntervalTime = GetRealIntervalTime(item); } if (RealIntervalTime > 0.0f) { Invoke("NextStoryItem", RealIntervalTime); } } } }
/*移动TexAnimation*/ private void TweenTexAnimationPos(UnityEngine.Vector3 from, UnityEngine.Vector3 to, StoryDlgItem dlg_item, UITexture texAnimation) { TweenPosition tweenPos = texAnimation.GetComponent <TweenPosition>(); if (tweenPos != null) { Destroy(tweenPos); } if (dlg_item == null) { return; } TweenPosition tween = texAnimation.gameObject.AddComponent <TweenPosition>(); if (tween != null) { tween.from = from; tween.to = to; tween.delay = dlg_item.TweenPosDelay; tween.duration = dlg_item.TweenPosDuration; tween.AddOnFinished(OnTweenPositionFinished); } }
private void UpdateStoryDlg(UnityEngine.Transform storyTrans, StoryDlgItem item, int count) { if (m_StoryDlgType == StoryDlgType.Big) { //大对话 ExchangeDepth(count); if (lblWords != null) { lblWords.text = ""; } m_DescriptionWords = item.Words; ShowWordDuration = item.WordDuration; m_StoryDlgItem = item; UITexture texAnimation = texAnimationArr[count % 2]; m_TexAnimation = texAnimation; TweenAlphaAtStart(texAnimation); SetTexAnimaitionImage(item.TextureAnimationPath, texAnimation); EnlargerTexAnimation(2f, texAnimation); UnityEngine.Vector3 fromPos = GetAnimationTexWorldPos(item.FromOffsetLeft, item.FromOffsetBottom, texAnimation); UnityEngine.Vector3 toPos = GetAnimationTexWorldPos(item.ToOffsetLeft, item.ToOffsetBottom, texAnimation); texAnimation.transform.position = fromPos; fromPos = texAnimation.transform.localPosition; texAnimation.transform.position = toPos; toPos = texAnimation.transform.localPosition; TweenTexAnimationPos(fromPos, toPos, item, texAnimation); TweenTexAnimationScale(item, texAnimation); //TweenTexAnimationAlpha(item, texAnimation); } else { //小对话 PlayParticleByUnitId(item.UnitId); if (lblName != null) { lblName.text = string.Format("[c9b2ae]{0}:[-]", item.SpeakerName); } item.Words = item.Words.Replace("[\\n]", "\n"); //if(lblWords!=null) lblWords.text = item.Words; UnityEngine.GameObject goAtlas = ArkCrossEngine.ResourceSystem.GetSharedResource(item.ImageLeftAtlas) as UnityEngine.GameObject; bool isMonsterSpeaker = true;//判断是否为小怪 if (goAtlas != null && spriteLeft != null) { NGUITools.SetActive(spriteLeft.gameObject, true); UIAtlas atlas = goAtlas.GetComponent <UIAtlas>(); if (atlas != null) { spriteLeft.atlas = atlas; spriteLeft.spriteName = item.ImageLeft; } if (lblSpeakerNameLeft01 != null) { lblSpeakerNameLeft01.text = item.SpeakerName; } if (lblSpeakerNameLeft02 != null) { lblSpeakerNameLeft02.text = item.SpeakerName; } if (lblWordsLeft != null) { lblWordsLeft.text = item.Words; } isMonsterSpeaker = false; } else { if (spriteLeft != null) { NGUITools.SetActive(spriteLeft.gameObject, false); } #if DEBUG Debug.Log("!!!ImageLeftAtlas or spriteLeft is null."); #endif } try { goAtlas = ArkCrossEngine.ResourceSystem.GetSharedResource(item.ImageRightAtlas) as UnityEngine.GameObject; } catch (System.Exception ex) { goAtlas = null; } if (goAtlas != null && spriteRight != null) { NGUITools.SetActive(spriteRight.gameObject, true); UIAtlas atlas = goAtlas.GetComponent <UIAtlas>(); if (atlas != null) { spriteRight.atlas = atlas; spriteRight.spriteName = item.ImageRight; } if (lblSpeakerNameLeft01 != null) { lblSpeakerNameRight01.text = item.SpeakerName; } if (lblSpeakerNameLeft02 != null) { lblSpeakerNameRight02.text = item.SpeakerName; } if (lblWordsRight != null) { lblWordsRight.text = item.Words; } isMonsterSpeaker = false; } else { if (spriteRight != null) { NGUITools.SetActive(spriteRight.gameObject, false); } #if DEBUG Debug.Log("!!!ImageLeftAtlas or spriteRight is null."); #endif } if (isMonsterSpeaker) { if (lblSpeakerMonsterName != null) { lblSpeakerMonsterName.text = item.SpeakerName; } if (lblSpeakerMonsterWords != null) { lblSpeakerMonsterWords.text = item.Words; } } else { if (lblSpeakerMonsterName != null) { lblSpeakerMonsterName.text = ""; } if (lblSpeakerMonsterWords != null) { lblSpeakerMonsterWords.text = ""; } } } }