void TimeComboChange() { if (activeTimer) { current_time -= Time.deltaTime; if (current_time <= 0f) { current_state_attack = AttackCombo.NONE; activeTimer = false; } } }
private void DidReceiveAttackCombo(AttackCombo attackCombo) { if (!isAllowedToAttack) { return; } currentAttack = attackCombo; currentAttackDuration = 0.5f; // a default attack length. TODO - Grab this from the model. playerState |= PlayerState.Attacking; // Halt all movement on initiating an attack. rigidBody.velocity = new Vector2(0.0f, 0.0f); rigidBody.isKinematic = false; rigidBody.constraints = RigidbodyConstraints2D.FreezeAll; // While attacking, the player isn't susceptible to gravity! rigidBody.gravityScale = 0.0f; // Add movement to attacks that require it. switch (attackCombo) { case AttackCombo.LoPunch: audioSource.clip = soundLowPunch; audioSource.Play(); currentAttackDuration = 1.5f; spriteRenderer.sprite = jumpingSprite; StartCoroutine(HandleMovementsForLoPunch()); break; case AttackCombo.LoKick: audioSource.clip = soundLowKick; audioSource.Play(); currentAttackDuration = 1.5f; if (!isGrounded) { spriteRenderer.sprite = fallingSprite; } StartCoroutine(HandleMovementsForLoKick()); break; case AttackCombo.HiPunch: audioSource.clip = soundHighPunch; audioSource.Play(); break; case AttackCombo.HiKick: audioSource.clip = soundHighKick; audioSource.Play(); break; default: break; } }