/// <summary> /// 设置局部UI动画,animationType要设置为None /// </summary> protected void SetPart(Transform tf, EAnimationType animationType, Vector3?startPos = null, float delay = 0, Ease openEase = Ease.OutQuad, Ease closeEase = Ease.Linear, float openDuration = 0.25f, float closeDuration = 0.2f) { CreateSequences(tf, animationType, startPos, delay, openEase, closeEase, openDuration, closeDuration); }
private static async Task DoAnimationByType(EAnimationType animationType, View obj, Easing easing, double scale) { LoginAnimationStackLayout stack = obj as LoginAnimationStackLayout; if (stack == null) { return; } switch (animationType) { case EAnimationType.Translation: await DoTranslation(stack, obj, easing); break; case EAnimationType.Scale: await DoScale(stack, easing, scale); break; default: stack.IsVisible = stack.Visible; break; } }
public void setAnimation(EAnimationType Type) { switch (Type) { case EAnimationType.Resize: _Animation = new CAnimationResize(); break; } }
public override void OnEnterState() { base.OnEnterState(); m_animator = curFSM.entityview.animator; entityview = curFSM.entityview; object obj = Enum.Parse(typeof(EAnimationType), m_animation); if (obj != null) { m_animType = (EAnimationType)obj; } else { m_animType = EAnimationType.Stand; } }
private Vector3 GetStartPos(EAnimationType animationType) { switch (animationType) { case EAnimationType.MoveFromDown: case EAnimationType.PopupFromDown: return(new Vector3(0, -_screenHeight, 0)); case EAnimationType.MoveFromUp: case EAnimationType.PopupFromUp: return(new Vector3(0, _screenHeight, 0)); case EAnimationType.MoveFromLeft: case EAnimationType.PopupFromLeft: return(new Vector3(-_screenWidth, 0, 0)); case EAnimationType.MoveFromRight: case EAnimationType.PopupFromRight: return(new Vector3(_screenWidth, 0, 0)); default: return(Vector3.zero); } }
public void OnDisable() { m_eAnimType = EAnimationType.EAT_Idle; }
public void PlayAnimation(EAnimationType eType, bool bRefresh = false) { if (null != m_pAnim && (EAnimationType.EAT_Born == eType || EAnimationType.EAT_Die == eType) && AnimationCullingType.AlwaysAnimate != m_pAnim.cullingType) { m_pAnim.cullingType = AnimationCullingType.AlwaysAnimate; } else if (null != m_pAnim && AnimationCullingType.BasedOnRenderers != m_pAnim.cullingType) { m_pAnim.cullingType = AnimationCullingType.BasedOnRenderers; } if (null == m_sAnimList || (int)EAnimationType.EAT_Max != m_sAnimList.Length) { return; } if ((eType != m_eAnimType || bRefresh) && null != m_pAnim) { // ReSharper disable ReplaceWithSingleAssignment.False bool bIgnore = false; // ReSharper disable once ConvertIfToOrExpression if ((EAnimationType.EAT_Idle == eType || EAnimationType.EAT_Run == eType || EAnimationType.EAT_Attack == eType) && ( EAnimationType.EAT_KnockDown == m_eAnimType || EAnimationType.EAT_Skill == m_eAnimType || EAnimationType.EAT_SkillHold == m_eAnimType || EAnimationType.EAT_Dash == m_eAnimType ) && m_fOnceAnimTime > 0.0f ) { bIgnore = true; } // ReSharper restore ReplaceWithSingleAssignment.False if (EAnimationType.EAT_Born == eType || EAnimationType.EAT_Die == eType ) { bIgnore = false; } EAnimationType eTypePlayed = eType; if (!bIgnore) { //CRuntimeLogger.Log(eType); switch (eType) { case EAnimationType.EAT_Idle: if (null == m_pAnim[m_sAnimList[(int)eType]]) { CRuntimeLogger.LogWarning("Animation list has animation not in Model:" + m_pOwner.gameObject.name + "@" + eType); return; } m_pAnim.CrossFade(m_sAnimList[(int)eType], 0.5f, PlayMode.StopAll); m_pAnim[m_sAnimList[(int)eType]].wrapMode = WrapMode.Loop; m_pAnim[m_sAnimList[(int)eType]].speed = Random.Range(0.85f, 1.15f) * m_fAnimSpeed[(int)eType]; break; case EAnimationType.EAT_Run: if (null == m_pAnim[m_sAnimList[(int)eType]]) { CRuntimeLogger.LogWarning("Animation list has animation not in Model:" + m_pOwner.gameObject.name + "@" + eType); return; } m_pAnim.CrossFade(m_sAnimList[(int)eType], 0.5f, PlayMode.StopAll); m_pAnim[m_sAnimList[(int)eType]].wrapMode = WrapMode.Loop; m_pAnim[m_sAnimList[(int)eType]].speed = Random.Range(0.85f, 1.15f) * m_fAnimSpeed[(int)eType]; break; case EAnimationType.EAT_Born: string sAnim = ""; if (null == m_pAnim[m_sAnimList[(int)eType]]) { sAnim = m_sAnimList[(int)EAnimationType.EAT_Idle]; } m_pAnim.CrossFade(sAnim, 0.01f, PlayMode.StopAll); m_pAnim[sAnim].normalizedTime = 0.0f; m_pAnim[sAnim].wrapMode = WrapMode.Clamp; m_pAnim[sAnim].speed = Random.Range(0.8f, 1.0f) * m_fAnimSpeed[(int)EAnimationType.EAT_Idle]; m_fOnceAnimTime = m_pAnim[m_sAnimList[(int)EAnimationType.EAT_Idle]].length * 0.99f / m_pAnim[m_sAnimList[(int)EAnimationType.EAT_Idle]].speed; m_pAnim.Sample(); break; case EAnimationType.EAT_Attack: case EAnimationType.EAT_Skill: //Only Avatar will enter this, for normal unit, will use PlayAttackAnimation function to play eTypePlayed = eType; if (null == m_pAnim[m_sAnimList[(int)eType]]) { eTypePlayed = EAnimationType.EAT_Attack; } if (null == m_pAnim[m_sAnimList[(int)eTypePlayed]]) { CRuntimeLogger.LogWarning("Animation list has animation not in Model:" + m_pOwner.gameObject.name + "@" + eTypePlayed); return; } m_pAnim.CrossFade(m_sAnimList[(int)eTypePlayed], 0.1f, PlayMode.StopAll); m_pAnim[m_sAnimList[(int)eTypePlayed]].normalizedTime = Random.Range(0.0f, 0.1f); m_pAnim[m_sAnimList[(int)eTypePlayed]].wrapMode = WrapMode.Once; m_pAnim[m_sAnimList[(int)eTypePlayed]].speed = Random.Range(0.9f, 1.1f) * m_fAnimSpeed[(int)eTypePlayed]; m_fOnceAnimTime = m_pAnim[m_sAnimList[(int)eTypePlayed]].length / m_pAnim[m_sAnimList[(int)eTypePlayed]].speed; break; case EAnimationType.EAT_Dash: case EAnimationType.EAT_SkillHold: //Only Avatar will enter this, for normal unit, will use PlayAttackAnimation function to play if (null == m_pAnim[m_sAnimList[(int)eType]]) { return; } m_pAnim.CrossFade(m_sAnimList[(int)eType], 0.1f, PlayMode.StopAll); m_pAnim[m_sAnimList[(int)eType]].normalizedTime = Random.Range(0.0f, 0.1f); m_pAnim[m_sAnimList[(int)eType]].wrapMode = WrapMode.Loop; m_pAnim[m_sAnimList[(int)eType]].speed = Random.Range(0.9f, 1.1f) * m_fAnimSpeed[(int)eType]; //TODO how to give a length for these? m_fOnceAnimTime = 1.0f; break; case EAnimationType.EAT_Die: if (null == m_pAnim[m_sAnimList[(int)eType]]) { CRuntimeLogger.LogWarning("Animation list has animation not in Model:" + m_pOwner.gameObject.name + "@" + eType); return; } m_pAnim.CrossFade(m_sAnimList[(int)eType], 0.1f, PlayMode.StopAll); m_pAnim[m_sAnimList[(int)eType]].normalizedTime = Random.Range(0.0f, 0.05f); m_pAnim[m_sAnimList[(int)eType]].wrapMode = WrapMode.Clamp; m_pAnim[m_sAnimList[(int)eType]].speed = Random.Range(0.85f, 1.15f) * m_fAnimSpeed[(int)eType]; m_fOnceAnimTime = m_pAnim[m_sAnimList[(int)eType]].length / m_pAnim[m_sAnimList[(int)eType]].speed; break; case EAnimationType.EAT_KnockDown: if (null == m_pAnim[m_sAnimList[(int)eType]]) { return; } m_pAnim.CrossFade(m_sAnimList[(int)eType], 0.1f, PlayMode.StopAll); m_pAnim[m_sAnimList[(int)eType]].normalizedTime = Random.Range(0.0f, 0.05f); m_pAnim[m_sAnimList[(int)eType]].wrapMode = WrapMode.Clamp; m_pAnim[m_sAnimList[(int)eType]].speed = Random.Range(0.85f, 1.15f) * m_fAnimSpeed[(int)eTypePlayed]; m_fOnceAnimTime = m_pAnim[m_sAnimList[(int)eType]].length / m_pAnim[m_sAnimList[(int)eType]].speed; break; } m_eAnimType = eType; } } }
public AnimationTypeAttribute(string labelName, EAnimationType type) { AnimationName = labelName; AnimationType = type; }
public void PlayAnimation(EAnimationType type) { m_Animator.Play(m_AnimationMap[type]); }
public CAnimation(EAnimationType Type) { setAnimation(Type); }
private void CreateSequences(Transform tf, EAnimationType animationType, Vector3?startPos, float delay, Ease openEase, Ease closeEase, float openDuration, float closeDuration) { var openPartSequence = DOTween.Sequence(); var closePartSequence = DOTween.Sequence(); if (delay > 0) { openPartSequence.AppendInterval(delay); } if (null == startPos) { startPos = GetStartPos(animationType); } switch (animationType) { case EAnimationType.MoveFromDown: case EAnimationType.MoveFromUp: case EAnimationType.MoveFromLeft: case EAnimationType.MoveFromRight: //开始动画 openPartSequence.Append( tf.DOBlendableMoveBy(startPos.Value, openDuration).From().SetEase(openEase) ); //结束动画 closePartSequence.Append( tf.DOBlendableMoveBy(startPos.Value, closeDuration).SetEase(closeEase) ); break; case EAnimationType.PopupFromCenter: //开始动画 openPartSequence.Append( tf.DOScale(Vector3.zero, openDuration).From().SetEase(Ease.OutBack) ); //结束动画 closePartSequence.Append( tf.DOScale(Vector3.zero, closeDuration).SetEase(closeEase) ); break; case EAnimationType.PopupFromDown: case EAnimationType.PopupFromUp: case EAnimationType.PopupFromLeft: case EAnimationType.PopupFromRight: //开始动画 openPartSequence.Append( tf.DOBlendableMoveBy(startPos.Value * 0.5f, openDuration).From().SetEase(Ease.OutBack) ); openPartSequence.Join( tf.DOScale(Vector3.zero, openDuration).From().SetEase(Ease.OutBack) ); //结束动画 closePartSequence.Append( tf.DOBlendableMoveBy(startPos.Value * 0.5f, closeDuration).SetEase(closeEase) ); closePartSequence.Join( tf.DOScale(Vector3.zero, closeDuration).SetEase(closeEase) ); break; case EAnimationType.Fade: //开始动画 Image img = tf.GetComponent <Image>(); if (img != null) { openPartSequence.Append(img.DOFade(0, openDuration).From().SetEase(openEase)); //结束动画 closePartSequence.Append(img.DOFade(0, closeDuration).SetEase(closeEase)); } break; } _openSequence.Join(openPartSequence); _closeSequence.Join(closePartSequence); }
/// <summary> /// 设置动画类型 /// </summary> protected virtual void SetAnimationType() { _animationType = EAnimationType.None; }
public void Play(EAnimationType type, float speed) { switch (type) { case EAnimationType.Stand: { ResetTriggers(); m_triggerMgr.OnTrigger("isIdle"); } break; case EAnimationType.LPunch: { ResetTriggers(); m_triggerMgr.OnTrigger("isPunchL"); } break; case EAnimationType.RPunch: { ResetTriggers(); m_triggerMgr.OnTrigger("isPunchR"); } break; case EAnimationType.LPunchMove: { ResetTriggers(); m_triggerMgr.OnTrigger("isPunchMoveL"); } break; case EAnimationType.RPunchMove: { ResetTriggers(); m_triggerMgr.OnTrigger("isPunchMoveR"); } break; case EAnimationType.LKick: { ResetTriggers(); m_triggerMgr.OnTrigger("isFrontKickL"); } break; case EAnimationType.RKick: { ResetTriggers(); m_triggerMgr.OnTrigger("isFrontKickR"); } break; case EAnimationType.Move: { ResetTriggers(); m_triggerMgr.OnTrigger("isMove"); } break; } }