public void UpdateAnimationState(Animator anim, StateComponent stateComp) { if (stateComp.Dirty) { if (anim == null) { return; } if (!anim.gameObject.activeInHierarchy) { return; } while (stateComp.Dirty) { EntityState entityState = stateComp.DequeuePrevState(); if (entityState == EntityState.AttackingReset) { anim.Play("", 0, 0f); } } switch (stateComp.CurState) { case EntityState.Idle: anim.SetInteger("Motivation", 0); return; case EntityState.Moving: anim.SetInteger("Motivation", 1); return; case EntityState.Tracking: break; case EntityState.Turning: anim.SetInteger("Motivation", 1); return; case EntityState.WarmingUp: anim.SetInteger("Motivation", 4); return; case EntityState.Attacking: case EntityState.AttackingReset: anim.SetInteger("Motivation", 3); return; case EntityState.CoolingDown: anim.SetInteger("Motivation", 4); return; case EntityState.Dying: anim.SetInteger("Motivation", 2); break; default: return; } } }
public void UpdateAnimationState(GameObjectViewComponent view, StateComponent stateComp, bool isAbilityModeActive) { if (stateComp.Dirty || stateComp.ForceUpdateAnimation) { stateComp.ForceUpdateAnimation = false; if (!view.MainGameObject.activeInHierarchy) { return; } Animator component = view.MainGameObject.GetComponent <Animator>(); if (component == null) { return; } while (stateComp.Dirty) { EntityState entityState = stateComp.DequeuePrevState(); if (entityState == EntityState.AttackingReset) { component.Play("", 0, 0f); } } switch (stateComp.CurState) { case EntityState.Disable: component.SetInteger("Motivation", 0); return; case EntityState.Idle: component.SetInteger("Motivation", 0); return; case EntityState.Moving: if (stateComp.IsRunning) { component.SetInteger("Motivation", 9); return; } component.SetInteger("Motivation", 1); return; case EntityState.Tracking: break; case EntityState.Turning: component.SetInteger("Motivation", 1); return; case EntityState.WarmingUp: if (isAbilityModeActive) { component.SetInteger("Motivation", 5); return; } component.SetInteger("Motivation", 4); return; case EntityState.Attacking: case EntityState.AttackingReset: if (isAbilityModeActive) { component.SetInteger("Motivation", 6); return; } component.SetInteger("Motivation", 3); return; case EntityState.CoolingDown: if (isAbilityModeActive) { component.SetInteger("Motivation", 7); return; } component.SetInteger("Motivation", 4); return; case EntityState.Dying: component.SetInteger("Motivation", stateComp.DeathAnimationID); break; default: return; } } }