public void ChangeAnimation(RTS.EAnimation action, bool toggle) { if (!animator) { return; } switch (action) { case EAnimation.Idle: if (toggle == true) { animator.SetFloat("MoveSpeed", 0); animator.SetBool("Attack", false); animator.SetBool("Spawn", false); animator.SetBool("Build", false); animator.SetBool("Die", false); animator.SetBool("Revive", false); } break; case EAnimation.Move: if (toggle == true) { animator.SetFloat("MoveSpeed", paramManager.MoveSpeed); } else { animator.SetFloat("MoveSpeed", 0); } break; case EAnimation.Rotate: if (toggle == true) { animator.SetBool("Rotate", true); } else { animator.SetBool("Rotate", false); } break; case EAnimation.Attack: if (toggle == true) { float animationScaleFactor = (attackAnimationDuration) / (paramManager.AttackAnimationDuration); animator.SetFloat("AttackSpeed", animationScaleFactor); animator.SetBool("Attack", true); } else { animator.SetBool("Attack", false); } break; case EAnimation.Spawn: if (toggle == true) { float animationScaleFactor = (spawnAnimationDuration) / (paramManager.SpawnAnimationDuration); animator.SetFloat("SpawnSpeed", animationScaleFactor); animator.SetBool("Spawn", true); if (spawnAnimationDuration < 0.01f) { SpawnExecutionEvent(); } } else { animator.SetBool("Spawn", false); } break; case EAnimation.SpawnerSpecial: if (toggle == true) { float animationScaleFactor = (specialAttackAnimationDuration) / (paramManager.GetSpawnerSpecialDuration()); animator.SetFloat("SpecialAttackSpeed", animationScaleFactor); animator.SetBool("Special", true); } else { animator.SetBool("Special", false); } break; case EAnimation.Build: if (toggle == true) { animator.SetBool("Build", true); } else { animator.SetBool("Build", false); } break; case EAnimation.Die: if (toggle == true) { animator.SetBool("Die", true); } else { animator.SetBool("Die", false); } break; case EAnimation.Revive: if (toggle == true) { animator.SetBool("Revive", true); } else { animator.SetBool("Revive", false); } break; case EAnimation.Sit: if (toggle == true) { animator.SetBool("Sit", true); } else { animator.SetBool("Sit", false); } break; } }