void OnAnimation( AsIMessage _msg) { if( null == _msg) { Debug.LogError( "AsAnimation::OnAnimation()[ null == _msg ] "); return; } Msg_AnimationIndicate msg = _msg as Msg_AnimationIndicate; if( null == msg) { Debug.LogError( "AsAnimation::OnAnimation()[ null == msg ]"); return; } #region - block at specific state - if( m_Entity.AnimEnableViaShop == false) return; if( m_PlayingAnimation != "Idle" && msg.animString_ == "IdleAction") { Debug.LogWarning( "AsAnimation::OnAnimation: animation[" + msg.animString_ + "] is ignored by playing none Idle animation"); return; } if( m_AnimComponent != null) { if( m_Entity.FsmType == eFsmType.MONSTER) { switch( msg.animString_) { case "BattleIdle": if( m_AnimComponent.GetClip( "BattleIdle") == null) msg.animString_ = "Idle"; break; case "IdleAction": if( m_AnimComponent.GetClip( "IdleAction") == null) return; break; case "Walk": case "Run": case "Stun": if( m_AnimComponent.GetClip( msg.animString_) == null) return; break; } if( msg.animString_.Contains("Skill") == true) if( m_AnimComponent.GetClip( msg.animString_) == null) return; } } #endregion if( Entity.ModelObject != null && m_AnimComponent != null) { m_AnimEnded = false; m_TargetLoopState = eTargetLoopState.NONE; StopCoroutine( "WaitForTargetLoop"); try { m_AnimState = m_AnimComponent[msg.animString_]; } catch { AsUtil.ShutDown( "AsAnimation::OnAnimation: <" + gameObject.name + "> Cannot find [ " + msg.animString_ + " ] clip"); StartCoroutine( "ErrorRecovery"); return; } if( m_AnimState == null) { Debug.LogWarning( "AsAnimation::OnAnimation: animation is not found = " + msg.animString_); return; } WrapMode wrapMode = msg.GetWrapMode(); if( wrapMode != WrapMode.Default) m_AnimState.wrapMode = wrapMode; if( m_PlayingAnimation != msg.animString_) { m_AnimState.time = 0; m_PlayingAnimation = msg.animString_; m_AnimComponent.CrossFade( m_PlayingAnimation, m_NextFadeTime); } else { if(m_AnimState.wrapMode == WrapMode.Loop) { } else if(msg.CheckAnimationLoop() == false) { m_AnimState.time = 0; m_AnimComponent.CrossFade( m_PlayingAnimation, m_NextFadeTime); } } if( msg.clampEnd_ == true) m_AnimState.time = m_AnimState.length; m_AnimState.speed = m_CurAnimSpeed = msg.animSpeed_; if( msg.animSpeed_ != 0f) m_PlayTime = m_AnimState.length / msg.animSpeed_;// - msg.fadeTime_; else m_PlayTime = float.MaxValue; m_NextFadeTime = msg.fadeTime_; #region - target loop - if( msg.targetTime_ != float.MaxValue) { m_TargetLoopState = eTargetLoopState.Before; m_PlayTime += msg.targetDuration_ * 0.001f; if( msg.animSpeed_ != 0f) { m_TargetLoopTime = ( ( msg.targetTime_/* + ( msg.fadeTime_ * 500f)*/) / msg.animSpeed_ * 0.001f); m_TargetLoopDuration = msg.targetDuration_ / msg.animSpeed_ * 0.001f; } else { m_TargetLoopTime = float.MaxValue; m_TargetLoopDuration = float.MaxValue; } } #endregion #region - event - if( m_Entity.EntityType == eEntityType.USER) { eCLASS __class = m_Entity.GetProperty<eCLASS>( eComponentProperty.CLASS); eGENDER gender = m_Entity.GetProperty<eGENDER>( eComponentProperty.GENDER); m_listEvent.Clear(); List<AnimationEventInfo> infos = m_EventAsset.GetEventList( __class, gender, m_PlayingAnimation); if( infos != null) { foreach( AnimationEventInfo info in infos) { m_listEvent.Add( info); } } } #endregion } else { m_AnimEnded = true; m_Entity.HandleMessage( new Msg_AnimationEnd( msg.animString_)); } }
IEnumerator WaitForTargetLoop() { m_TargetLoopState = eTargetLoopState.TargetLoop; yield return new WaitForSeconds( m_TargetLoopDuration); m_AnimState.speed = m_CurAnimSpeed; m_TargetLoopState = eTargetLoopState.After; }