void UpdateAnimator(Animator animator, LocomotionState.State locoState) { // Debug.Log("locoState : "+locoState.ToString()); if (locoState == LocomotionState.State.Idle && !animator.GetCurrentAnimatorStateInfo(0).IsName("idle")) { // animator.CrossFade("idle", 0.2f, 0, Time.deltaTime); animator.Play("idle"); } else if (locoState == LocomotionState.State.Run && !animator.GetCurrentAnimatorStateInfo(0).IsName("run")) { // animator.CrossFade("run", 0.2f, 0, Time.deltaTime); animator.Play("run"); } else if (locoState == LocomotionState.State.BeHit && !animator.GetCurrentAnimatorStateInfo(0).IsName("behit")) { animator.Play("behit"); } else if (locoState == LocomotionState.State.Jump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump")) { animator.Play("jump"); } else if (locoState == LocomotionState.State.DoubleJump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump2")) { animator.Play("jump2"); } else if (locoState == LocomotionState.State.TrebleJump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump3")) { animator.Play("jump3"); } }
void UpdateAnimator(Animator animator, LocomotionState locoData) { LocomotionState.State locoState = locoData.LocoState; string aniName = ""; if (locoState == LocomotionState.State.Idle && !animator.GetCurrentAnimatorStateInfo(0).IsName("idle")) { aniName = "idle"; } else if (locoState == LocomotionState.State.Run && !animator.GetCurrentAnimatorStateInfo(0).IsName("run")) { aniName = "run"; } else if (locoState == LocomotionState.State.BeHit && !animator.GetCurrentAnimatorStateInfo(0).IsName("behit")) { aniName = "behit"; } else if (locoState == LocomotionState.State.Jump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump")) { aniName = "jump"; } else if (locoState == LocomotionState.State.DoubleJump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump2")) { aniName = "jump2"; } else if (locoState == LocomotionState.State.TrebleJump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump3")) { aniName = "jump3"; } else if (locoState == LocomotionState.State.Dead && !animator.GetCurrentAnimatorStateInfo(0).IsName("death")) { aniName = "death"; // Debug.Log("TimeEx.ServerTime:"+TimeEx.ServerTime+" startTime:"+locoData.StartTime+" "+((Time.time - locoData.StartTime))); // if (Time.time - locoData.StartTime <= 1) // { // ------animator.Play("death"); // } // else // { // //have been dead for a long time // animator.Play("death", 0, 1.0f); // } } if (aniName != "") { animator.Play(aniName); if (aniName == "idle" || aniName == "run") { var headTrans = animator.transform.Find("head"); Animator headAnimator = null; if (headTrans != null) { headAnimator = headTrans.GetComponent <Animator>(); animator.Play(aniName); } // Debug.Log("locoState : "+locoState+" headTrans:"+(headTrans!=null)); } } }
void UpdateAnimator(Animator animator, LocomotionState.State locoState) { // Debug.Log("locoState : "+locoState.ToString()); if (locoState == LocomotionState.State.Idle) { // animator.CrossFade("idle", 0.2f, 0, Time.deltaTime); animator.Play("idle"); } else if (locoState == LocomotionState.State.Run) { // animator.CrossFade("run", 0.2f, 0, Time.deltaTime); animator.Play("run"); } }
void UpdateState(Entity entity, LocomotionState locoData, LocomotionStateStack stack) { LocomotionState.State locoState = locoData.LocoState; if (locoData.StateEndType == LocomotionState.EndType.None) { return; } // Debug.Log("be end type : "+locoData.StateEndType+" locoData.EndTime:"+locoData.EndTime); if (locoData.StateEndType == LocomotionState.EndType.PlayAnimationOnce) { if (locoData.EndTime == 0) { //最少要播放动画一帧 locoData.EndTime = 1; EntityManager.SetComponentData <LocomotionState>(entity, locoData); return; } var hasLooks = EntityManager.HasComponent <LooksInfo>(entity); if (!hasLooks) { Debug.LogError("has no looks! uid : " + EntityManager.GetComponentData <UID>(entity).Value); return; } var looksInfo = EntityManager.GetComponentData <LooksInfo>(entity); if (looksInfo.CurState != LooksInfo.State.Loaded) { return; } var looksEntity = looksInfo.LooksEntity; Animator animator = EntityManager.GetComponentObject <Animator>(looksEntity); if (animator == null) { return; } // Debug.Log("animator.GetCurrentAnimatorStateInfo(0).normalizedTime : "+animator.GetCurrentAnimatorStateInfo(0).normalizedTime); if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1.0f) { BackToLastState(entity, stack); } } else if (locoData.StateEndType == LocomotionState.EndType.EndTime) { // Debug.Log("locoData.EndTime >= TimeEx.ServerTime : "+(TimeEx.ServerTime >= locoData.EndTime)+" "+locoData.EndTime+" "+TimeEx.ServerTime); if (TimeEx.ServerTime >= locoData.EndTime) { BackToLastState(entity, stack); } } }
void UpdateAnimator(Animator animator, LocomotionState locoData) { LocomotionState.State locoState = locoData.LocoState; // Debug.Log("locoState : "+locoState); if (locoState == LocomotionState.State.Idle && !animator.GetCurrentAnimatorStateInfo(0).IsName("idle")) { // animator.CrossFade("idle", 0.2f, 0, Time.deltaTime); animator.Play("idle"); } else if (locoState == LocomotionState.State.Run && !animator.GetCurrentAnimatorStateInfo(0).IsName("run")) { // animator.CrossFade("run", 0.2f, 0, Time.deltaTime); animator.Play("run"); } else if (locoState == LocomotionState.State.BeHit && !animator.GetCurrentAnimatorStateInfo(0).IsName("behit")) { animator.Play("behit"); } else if (locoState == LocomotionState.State.Jump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump")) { animator.Play("jump"); } else if (locoState == LocomotionState.State.DoubleJump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump2")) { animator.Play("jump2"); } else if (locoState == LocomotionState.State.TrebleJump && !animator.GetCurrentAnimatorStateInfo(0).IsName("jump3")) { animator.Play("jump3"); } else if (locoState == LocomotionState.State.Dead && !animator.GetCurrentAnimatorStateInfo(0).IsName("death")) { // Debug.Log("TimeEx.ServerTime:"+TimeEx.ServerTime+" startTime:"+locoData.StartTime+" "+((Time.time - locoData.StartTime))); // if (Time.time - locoData.StartTime <= 1) // { animator.Play("death"); // } // else // { // //have been dead for a long time // animator.Play("death", 0, 1.0f); // } } }