using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; // AnimationNames is defined in AnimationManager.cs public enum ComboState { NONE, PUNCH_1, PUNCH_2, PUNCH_3, PUNCH_4, PUNCH_5, PUNCH_6, KICK_1, KICK_2, KICK_3, KICK_4, KICK_5, KICK_6, KICK_7, VICIOUS_1, // Adding states for vicious attacks VICIOUS_2, VICIOUS_3, SPECIAL_1, // Adding states for special/finisher attacks SPECIAL_2, SPECIAL_3 } public class CharacterAttacks : MonoBehaviour { public Animator anim; private AnimationManager animationManager; public event Action AnimationAboutToPlay; private bool activateTimerToReset; //medium dufficulty to get the combo right private float default_Combo_Timer = 0.6f; //easy difficulty to get the combo right //private float default_Combo_Timer = 1.0f; private float current_Combo_Timer; private ComboState current_Combo_State; private CharacterSoundFXManager soundScript; public float nextAnimationTime; public float animationInterval; public ComboDisplay comboDisplay; InputBuffer inputBuffer; // New properties for vicious and special moves private bool canPerformViciousMove = false; private bool canPerformSpecialMove = false; private float viciousMoveCooldown = 5.0f; private float specialMoveCooldown = 10.0f; private float lastViciousMoveTime = -5.0f; private float lastSpecialMoveTime = -10.0f; private void Start() { anim = GetComponent(); soundScript = GetComponent(); comboDisplay = GetComponent(); //normal //animationInterval = 0.7f; //slow //animationInterval = 1.5f; //fast animationInterval = 0.35f; inputBuffer = GetComponent(); // Get or add AnimationManager animationManager = GetComponent(); if (animationManager == null) { animationManager = gameObject.AddComponent(); } } // Update is called once per frame void Update() { ResetComboState(); // Update cooldowns for vicious and special moves canPerformViciousMove = (Time.time - lastViciousMoveTime >= viciousMoveCooldown); canPerformSpecialMove = (Time.time - lastSpecialMoveTime >= specialMoveCooldown); } void ResetComboState() { if (activateTimerToReset) { current_Combo_Timer -= Time.deltaTime; if (current_Combo_Timer <= 0f) { current_Combo_State = ComboState.NONE; activateTimerToReset = false; current_Combo_Timer = default_Combo_Timer; } } // reset combo state } // Helper method to play animations using AnimationManager when available private void PlayAnimation(string animationName) { AnimationAboutToPlay?.Invoke(animationName); if (animationManager != null) { animationManager.PlayAnimation(animationName); } else { anim.Play(animationName); } } public void PunchAttacks(string punchAttack) { if (current_Combo_State == ComboState.KICK_7 || current_Combo_State == ComboState.PUNCH_6) return; StaminaSystem staminaSystem = GetComponent(); if (staminaSystem.currentStamina < 5f) { animationInterval = 2.0f; } else animationInterval = 0.35f; string punchAnimation = null; switch (punchAttack) { case "Jab": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.PUNCH_1; punchAnimation = AnimationNames.Jab; staminaSystem.UseStamina(0.5f); break; case "RightBody": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.PUNCH_1; punchAnimation = AnimationNames.RightBody; staminaSystem.UseStamina(0.5f); break; case "SupermanPunch": current_Combo_State = ComboState.PUNCH_1; punchAnimation = AnimationNames.SupermanPunch; staminaSystem.UseStamina(2.0f); inputBuffer.CleanUpBuffer(); break; case "SpecialBackfist": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.PUNCH_1; punchAnimation = AnimationNames.SpecialBackfist; staminaSystem.UseStamina(2.0f); break; case "Right": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.PUNCH_1; punchAnimation = AnimationNames.Right; staminaSystem.UseStamina(0.5f); break; case "LeftHook": inputBuffer.CleanUpBuffer(); punchAnimation = AnimationNames.LeftHook; staminaSystem.UseStamina(0.5f); break; case "RightHook": inputBuffer.CleanUpBuffer(); punchAnimation = AnimationNames.RightHook; staminaSystem.UseStamina(0.5f); break; case "LeftElbow": inputBuffer.CleanUpBuffer(); punchAnimation = AnimationNames.LeftElbow; staminaSystem.UseStamina(0.5f); break; case "RightElbow": inputBuffer.CleanUpBuffer(); punchAnimation = AnimationNames.RightElbow; staminaSystem.UseStamina(0.5f); break; case "PowerPunchLeft": inputBuffer.CleanUpBuffer(); punchAnimation = AnimationNames.PowerPunchLeft; staminaSystem.UseStamina(0.5f); break; } if (!string.IsNullOrEmpty(punchAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; // Use the helper method instead of direct anim.Play PlayAnimation(punchAnimation); print("anim.play " + punchAnimation); nextAnimationTime = Time.time + animationInterval; soundScript.PlayWhooshSound(); inputBuffer.CleanUpBuffer(); switch (current_Combo_State) { case ComboState.PUNCH_1: current_Combo_State = ComboState.PUNCH_2; comboDisplay.ShowComboText("COMBO x2"); break; case ComboState.PUNCH_2: current_Combo_State = ComboState.PUNCH_3; comboDisplay.ShowComboText("COMBO x3"); break; case ComboState.PUNCH_3: current_Combo_State = ComboState.PUNCH_4; comboDisplay.ShowComboText("COMBO x4"); break; case ComboState.PUNCH_4: current_Combo_State = ComboState.PUNCH_5; comboDisplay.ShowComboText("COMBO x5"); break; case ComboState.PUNCH_5: current_Combo_State = ComboState.PUNCH_6; comboDisplay.ShowComboText("COMBO x6"); break; } } } public void PunchAttacksMobile(float verticalValue, float horizontalValue, string punchDirection) { if (current_Combo_State == ComboState.KICK_7 || current_Combo_State == ComboState.PUNCH_6) return; StaminaSystem staminaSystem = GetComponent(); //prevent player from punching when he has no stamina if (staminaSystem.currentStamina < 5.0f) { animationInterval = 2.0f; } else animationInterval = 0.35f; // Determine the type of punch based on the joystick direction string punchAnimation = null; switch (punchDirection) { case "up": // Upward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.KICK_1 || current_Combo_State == ComboState.KICK_2 || current_Combo_State == ComboState.KICK_3 || current_Combo_State == ComboState.KICK_4 || current_Combo_State == ComboState.KICK_5) { current_Combo_State = ComboState.PUNCH_1; } punchAnimation = AnimationNames.Jab; // Reduce the stamina for each punch staminaSystem.UseStamina(0.5f); break; case "down": // Downward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.KICK_1 || current_Combo_State == ComboState.KICK_2 || current_Combo_State == ComboState.KICK_3 || current_Combo_State == ComboState.KICK_4 || current_Combo_State == ComboState.KICK_5) { current_Combo_State = ComboState.PUNCH_1; } punchAnimation = AnimationNames.RightBody; // Reduce the stamina for each punch staminaSystem.UseStamina(0.5f); break; case "left": // Leftward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.KICK_1 || current_Combo_State == ComboState.KICK_2 || current_Combo_State == ComboState.KICK_3 || current_Combo_State == ComboState.KICK_4 || current_Combo_State == ComboState.KICK_5) { current_Combo_State = ComboState.PUNCH_1; } int option = Random.Range(0, 2); if (option == 0) punchAnimation = AnimationNames.SupermanPunch; else if (option == 1) punchAnimation = AnimationNames.SpecialBackfist; // Reduce the stamina for each punch staminaSystem.UseStamina(2.0f); break; case "right": // Rightward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.KICK_1 || current_Combo_State == ComboState.KICK_2 || current_Combo_State == ComboState.KICK_3 || current_Combo_State == ComboState.KICK_4 || current_Combo_State == ComboState.KICK_5) { current_Combo_State = ComboState.PUNCH_1; } punchAnimation = AnimationNames.Right; // Reduce the stamina for each punch staminaSystem.UseStamina(0.5f); break; case "upleft": punchAnimation = AnimationNames.LeftHook; // Reduce the stamina for each punch staminaSystem.UseStamina(0.5f); break; case "upright": punchAnimation = AnimationNames.RightHook; // Reduce the stamina for each punch staminaSystem.UseStamina(0.5f); break; case "downleft": punchAnimation = AnimationNames.LeftElbow; // Reduce the stamina for each punch staminaSystem.UseStamina(0.5f); break; case "downright": punchAnimation = AnimationNames.RightElbow; // Reduce the stamina for each punch staminaSystem.UseStamina(0.5f); break; } // Execute the punch if a valid animation is determined if (!string.IsNullOrEmpty(punchAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; if (Time.time > nextAnimationTime) { // Use the helper method instead of direct anim.Play PlayAnimation(punchAnimation); nextAnimationTime = Time.time + animationInterval; soundScript.PlayWhooshSound(); // Advance the combo state switch (current_Combo_State) { case ComboState.PUNCH_1: current_Combo_State = ComboState.PUNCH_2; comboDisplay.ShowComboText("COMBO x2"); break; case ComboState.PUNCH_2: current_Combo_State = ComboState.PUNCH_3; comboDisplay.ShowComboText("COMBO x3"); break; case ComboState.PUNCH_3: current_Combo_State = ComboState.PUNCH_4; comboDisplay.ShowComboText("COMBO x4"); break; case ComboState.PUNCH_4: current_Combo_State = ComboState.PUNCH_5; comboDisplay.ShowComboText("COMBO x5"); break; case ComboState.PUNCH_5: current_Combo_State = ComboState.PUNCH_6; comboDisplay.ShowComboText("COMBO x6"); break; } } } } public void KickAttacks(string kickAttack) { // if the current combo is punch 3 or kick 2 // return meaning exit because we have no combos to perform if (current_Combo_State == ComboState.KICK_7 || current_Combo_State == ComboState.PUNCH_6) return; StaminaSystem staminaSystem = GetComponent(); //prevent player from kicking when he has no stamina if (staminaSystem.currentStamina < 5f) { animationInterval = 2.0f; } else animationInterval = 0.35f; // if the current combo state is NONE, or punchl or punch2 // then we can set current combo state to kick 1 to chain the combo string kickAnimation = null; switch (kickAttack) { case "FrontKickRight": // Upward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } inputBuffer.CleanUpBuffer(); kickAnimation = AnimationNames.FrontKickRight; staminaSystem.UseStamina(0.7f); break; case "BodyKickRight": // Downward punches inputBuffer.CleanUpBuffer(); if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } kickAnimation = AnimationNames.BodyKickRight; staminaSystem.UseStamina(0.7f); break; case "LegPowerKickRight": // Leftward punches inputBuffer.CleanUpBuffer(); if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } kickAnimation = AnimationNames.LegPowerKickRight; staminaSystem.UseStamina(0.7f); break; case "BackSideKick": // Rightward punches inputBuffer.CleanUpBuffer(); if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } kickAnimation = AnimationNames.BackSideKick; staminaSystem.UseStamina(0.7f); break; case "LegKickRight": // Rightward punches inputBuffer.CleanUpBuffer(); if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } kickAnimation = AnimationNames.LegKickRight; staminaSystem.UseStamina(0.7f); break; case "KneeRight": // Rightward punches inputBuffer.CleanUpBuffer(); if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } //kneeright needs to be changed kickAnimation = ""; staminaSystem.UseStamina(0.7f); break; } // Execute the punch if a valid animation is determined if (!string.IsNullOrEmpty(kickAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; // Use the helper method instead of direct anim.Play PlayAnimation(kickAnimation); nextAnimationTime = Time.time + animationInterval; soundScript.PlayWhooshSound(); inputBuffer.CleanUpBuffer(); // Advance the combo state switch (current_Combo_State) { case ComboState.KICK_1: current_Combo_State = ComboState.KICK_2; comboDisplay.ShowComboText("COMBO x2"); break; case ComboState.KICK_2: current_Combo_State = ComboState.KICK_3; comboDisplay.ShowComboText("COMBO x3"); break; case ComboState.KICK_3: current_Combo_State = ComboState.KICK_4; comboDisplay.ShowComboText("COMBO x4"); break; case ComboState.KICK_4: current_Combo_State = ComboState.KICK_5; comboDisplay.ShowComboText("COMBO x5"); break; case ComboState.KICK_5: current_Combo_State = ComboState.KICK_6; comboDisplay.ShowComboText("COMBO x6"); break; } } } public void KickAttacksMobile(float verticalValue, float horizontalValue, string kickDirection) { if (current_Combo_State == ComboState.KICK_7 || current_Combo_State == ComboState.PUNCH_6) return; // Reduce the stamina for each punch StaminaSystem staminaSystem = GetComponent(); //prevent player from kicking when he has no stamina if (staminaSystem.currentStamina < 5f) { animationInterval = 2.0f; } else animationInterval = 0.35f; // Determine the type of punch based on the joystick direction string punchAnimation = null; switch (kickDirection) { case "up": // Upward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } punchAnimation = AnimationNames.FrontKickRight; staminaSystem.UseStamina(0.7f); break; case "down": // Downward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } punchAnimation = AnimationNames.BodyKickRight; staminaSystem.UseStamina(0.7f); break; case "left": // Leftward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } punchAnimation = AnimationNames.LegPowerKickRight; staminaSystem.UseStamina(0.7f); break; case "right": // Rightward punches if (current_Combo_State == ComboState.NONE || current_Combo_State == ComboState.PUNCH_1 || current_Combo_State == ComboState.PUNCH_2 || current_Combo_State == ComboState.PUNCH_3 || current_Combo_State == ComboState.PUNCH_4 || current_Combo_State == ComboState.PUNCH_5) { current_Combo_State = ComboState.KICK_1; } punchAnimation = AnimationNames.BackSideKick; staminaSystem.UseStamina(0.7f); break; case "upleft": //punchAnimation = "LeftHook"; break; case "upright": //punchAnimation = "RightHook"; break; case "downleft": //punchAnimation = "LeftElbow"; break; case "downright": //punchAnimation = "RightElbow"; break; } // Execute the punch if a valid animation is determined if (!string.IsNullOrEmpty(punchAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; if (Time.time > nextAnimationTime) { // Use the helper method instead of direct anim.Play PlayAnimation(punchAnimation); nextAnimationTime = Time.time + animationInterval; soundScript.PlayWhooshSound(); // Advance the combo state switch (current_Combo_State) { case ComboState.KICK_1: current_Combo_State = ComboState.KICK_2; comboDisplay.ShowComboText("COMBO x2"); break; case ComboState.KICK_2: current_Combo_State = ComboState.KICK_3; comboDisplay.ShowComboText("COMBO x3"); break; case ComboState.KICK_3: current_Combo_State = ComboState.KICK_4; comboDisplay.ShowComboText("COMBO x4"); break; case ComboState.KICK_4: current_Combo_State = ComboState.KICK_5; comboDisplay.ShowComboText("COMBO x5"); break; case ComboState.KICK_5: current_Combo_State = ComboState.KICK_6; comboDisplay.ShowComboText("COMBO x6"); break; } } } } public void DodgeMobile(string direction, Vector2 target) { string punchAnimation = null; switch (direction) { case "up": // Upward punches punchAnimation = AnimationNames.JumpBack; break; case "down": // Downward punches punchAnimation = AnimationNames.JumpBack; break; case "left": // Leftward punches punchAnimation = AnimationNames.JumpLeft; break; case "right": // Rightward punches punchAnimation = AnimationNames.JumpRight; break; case "upleft": //punchAnimation = "LeftHook"; break; case "upright": //punchAnimation = "RightHook"; break; case "downleft": //punchAnimation = "LeftElbow"; break; case "downright": //punchAnimation = "RightElbow"; break; } // Execute the punch if a valid animation is determined if (!string.IsNullOrEmpty(punchAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; if (Time.time > nextAnimationTime) { // Use the helper method instead of direct anim.Play PlayAnimation(punchAnimation); // Move the character in the target direction transform.Translate(target * 10 * Time.deltaTime, Space.World); nextAnimationTime = Time.time + animationInterval; } } } public void BlockMobile(string direction) { string punchAnimation = null; switch (direction) { case "up": // Upward punches punchAnimation = AnimationNames.BlockStepBack; break; case "down": // Downward punches punchAnimation = AnimationNames.BlockLeg; break; case "left": // Leftward punches punchAnimation = AnimationNames.BlockStepBack; break; case "right": // Rightward punches punchAnimation = AnimationNames.BlockBodyLeft; break; case "upleft": punchAnimation = AnimationNames.BlockStepBack; break; case "upright": punchAnimation = AnimationNames.BlockBodyLeft; break; case "downleft": punchAnimation = AnimationNames.BlockStepBack; break; case "downright": punchAnimation = AnimationNames.BlockLeg; break; } // Execute the punch if a valid animation is determined if (!string.IsNullOrEmpty(punchAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; if (Time.time > nextAnimationTime) { // Use the helper method instead of direct anim.Play PlayAnimation(punchAnimation); nextAnimationTime = Time.time + animationInterval; } } } public void Dodge(string dodgeMove, Vector2 target) { string dodgeAnimation = null; switch (dodgeMove) { case "JumpBack": // Upward punches inputBuffer.CleanUpBuffer(); dodgeAnimation = AnimationNames.JumpBack; break; case "JumpLeft": // Leftward punches inputBuffer.CleanUpBuffer(); dodgeAnimation = AnimationNames.JumpLeft; break; case "JumpRight": // Rightward punches inputBuffer.CleanUpBuffer(); dodgeAnimation = AnimationNames.JumpRight; break; } // Execute the punch if a valid animation is determined if (!string.IsNullOrEmpty(dodgeAnimation)) { inputBuffer.CleanUpBuffer(); activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; /*if (Time.time > nextAnimationTime) {*/ // Use the helper method instead of direct anim.Play PlayAnimation(dodgeAnimation); // Move the character in the target direction transform.Translate(target * 10 * Time.deltaTime, Space.World); nextAnimationTime = Time.time + animationInterval; //} } } public void Block(string blockMove) { string blockAnimation = null; switch (blockMove) { case "BlockStepBack": // Upward punches inputBuffer.CleanUpBuffer(); blockAnimation = AnimationNames.BlockStepBack; break; case "BlockLeg": // Downward punches inputBuffer.CleanUpBuffer(); blockAnimation = AnimationNames.BlockLeg; break; case "BlockBodyLeft": // Rightward punches inputBuffer.CleanUpBuffer(); blockAnimation = AnimationNames.BlockBodyLeft; break; } // Execute the punch if a valid animation is determined if (!string.IsNullOrEmpty(blockAnimation)) { inputBuffer.CleanUpBuffer(); activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; /*if (Time.time > nextAnimationTime) {*/ // Use the helper method instead of direct anim.Play PlayAnimation(blockAnimation); nextAnimationTime = Time.time + animationInterval; //} } } public void ViciousAttacks(string viciousAttack) { if (!canPerformViciousMove) return; if (current_Combo_State == ComboState.KICK_7 || current_Combo_State == ComboState.PUNCH_6) return; StaminaSystem staminaSystem = GetComponent(); if (staminaSystem.currentStamina < 25f) // Vicious moves require more stamina { // Not enough stamina return; } string viciousAnimation = null; // Process the vicious attack input switch (viciousAttack) { case "Chokeslam": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.Chokeslam; staminaSystem.UseStamina(25.0f); break; case "Suplex": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.Suplex; staminaSystem.UseStamina(25.0f); break; case "GiantSwing": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.GiantSwing; staminaSystem.UseStamina(25.0f); break; case "DiamondCrusher": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.DiamondCrusher; staminaSystem.UseStamina(25.0f); break; case "SumoSlap": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.SumoSlap; staminaSystem.UseStamina(25.0f); break; case "Uppercut": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.Uppercut; staminaSystem.UseStamina(25.0f); break; case "JavelinTackle": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.JavelinTackle; staminaSystem.UseStamina(25.0f); break; case "RocketJump": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.RocketJump; staminaSystem.UseStamina(25.0f); break; case "BullRush": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.VICIOUS_1; viciousAnimation = AnimationNames.BullRush; staminaSystem.UseStamina(25.0f); break; } if (!string.IsNullOrEmpty(viciousAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; // Play the animation PlayAnimation(viciousAnimation); print("anim.play vicious: " + viciousAnimation); nextAnimationTime = Time.time + animationInterval * 2; // Vicious moves take longer soundScript.PlayWhooshSound(); inputBuffer.CleanUpBuffer(); // Set the last vicious move time for cooldown lastViciousMoveTime = Time.time; // Upgrade combo state current_Combo_State = ComboState.VICIOUS_2; comboDisplay.ShowComboText("VICIOUS ATTACK!"); } } public void SpecialAttacks(string specialAttack) { if (!canPerformSpecialMove) return; if (current_Combo_State == ComboState.KICK_7 || current_Combo_State == ComboState.PUNCH_6) return; StaminaSystem staminaSystem = GetComponent(); if (staminaSystem.currentStamina < 50f) // Special moves require a lot of stamina { // Not enough stamina return; } string specialAnimation = null; // Process the special attack input switch (specialAttack) { case "Clothesline": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.Clothesline; staminaSystem.UseStamina(50.0f); break; case "Spear": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.Spear; staminaSystem.UseStamina(50.0f); break; case "SuperKick": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.SuperKick; staminaSystem.UseStamina(50.0f); break; case "RKO": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.RKO; staminaSystem.UseStamina(50.0f); break; case "Claymore": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.Claymore; staminaSystem.UseStamina(50.0f); break; case "RockBottom": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.RockBottom; staminaSystem.UseStamina(50.0f); break; case "F5": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.F5; staminaSystem.UseStamina(50.0f); break; case "TroubleInParadise": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.TroubleInParadise; staminaSystem.UseStamina(50.0f); break; case "SwantomBomb": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.SwantomBomb; staminaSystem.UseStamina(50.0f); break; case "Headbutt": inputBuffer.CleanUpBuffer(); current_Combo_State = ComboState.SPECIAL_1; specialAnimation = AnimationNames.Headbutt; staminaSystem.UseStamina(50.0f); break; } if (!string.IsNullOrEmpty(specialAnimation)) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; // Play the animation PlayAnimation(specialAnimation); print("anim.play special: " + specialAnimation); nextAnimationTime = Time.time + animationInterval * 3; // Special moves take much longer soundScript.PlayWhooshSound(); inputBuffer.CleanUpBuffer(); // Set the last special move time for cooldown lastSpecialMoveTime = Time.time; // Upgrade combo state current_Combo_State = ComboState.SPECIAL_2; comboDisplay.ShowComboText("SPECIAL FINISHER!"); } } // Optional: Add mobile versions of these methods if needed public void ViciousAttacksMobile(float verticalValue, float horizontalValue, string direction) { // Implementation similar to PunchAttacksMobile but for vicious attacks if (!canPerformViciousMove) return; StaminaSystem staminaSystem = GetComponent(); if (staminaSystem.currentStamina < 25f) return; string viciousAnimation = null; // Map joystick directions to vicious moves switch (direction) { case "up": viciousAnimation = AnimationNames.Uppercut; break; case "down": viciousAnimation = AnimationNames.Chokeslam; break; case "left": viciousAnimation = AnimationNames.GiantSwing; break; case "right": viciousAnimation = AnimationNames.JavelinTackle; break; case "upleft": viciousAnimation = AnimationNames.Suplex; break; case "upright": viciousAnimation = AnimationNames.DiamondCrusher; break; case "downleft": viciousAnimation = AnimationNames.SumoSlap; break; case "downright": viciousAnimation = AnimationNames.BullRush; break; } if (!string.IsNullOrEmpty(viciousAnimation) && Time.time > nextAnimationTime) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; // Play the animation PlayAnimation(viciousAnimation); nextAnimationTime = Time.time + animationInterval * 2; soundScript.PlayWhooshSound(); // Set the cooldown lastViciousMoveTime = Time.time; // Use stamina staminaSystem.UseStamina(25.0f); // Set combo display comboDisplay.ShowComboText("VICIOUS ATTACK!"); // Set combo state current_Combo_State = ComboState.VICIOUS_2; } } public void SpecialAttacksMobile(float verticalValue, float horizontalValue, string direction) { // Implementation similar to PunchAttacksMobile but for special attacks if (!canPerformSpecialMove) return; StaminaSystem staminaSystem = GetComponent(); if (staminaSystem.currentStamina < 50f) return; string specialAnimation = null; // Map joystick directions to special moves switch (direction) { case "up": specialAnimation = AnimationNames.SuperKick; break; case "down": specialAnimation = AnimationNames.RockBottom; break; case "left": specialAnimation = AnimationNames.Clothesline; break; case "right": specialAnimation = AnimationNames.Spear; break; case "upleft": specialAnimation = AnimationNames.RKO; break; case "upright": specialAnimation = AnimationNames.Claymore; break; case "downleft": specialAnimation = AnimationNames.F5; break; case "downright": specialAnimation = AnimationNames.SwantomBomb; break; } if (!string.IsNullOrEmpty(specialAnimation) && Time.time > nextAnimationTime) { activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; // Play the animation PlayAnimation(specialAnimation); nextAnimationTime = Time.time + animationInterval * 3; soundScript.PlayWhooshSound(); // Set the cooldown lastSpecialMoveTime = Time.time; // Use stamina staminaSystem.UseStamina(50.0f); // Set combo display comboDisplay.ShowComboText("SPECIAL FINISHER!"); // Set combo state current_Combo_State = ComboState.SPECIAL_2; } } // Additional direct methods for our 8 core animations public void PunchAttacksDirectly(string animationName) { StaminaSystem staminaSystem = GetComponent(); if (staminaSystem.currentStamina < 5f) { animationInterval = 2.0f; } else { animationInterval = 0.35f; } if (Time.time > nextAnimationTime) { // Play the animation directly using the specific animation name PlayAnimation(animationName); // Apply appropriate stamina cost based on the animation float staminaCost = 0.5f; // More powerful moves cost more stamina if (animationName == AnimationNames.Haymaker || animationName == AnimationNames.SpinningBackfist || animationName == AnimationNames.ChargedPunch) { staminaCost = 1.0f; } else if (animationName == AnimationNames.ElbowSmash || animationName == AnimationNames.AirPunch) { staminaCost = 1.5f; } staminaSystem.UseStamina(staminaCost); nextAnimationTime = Time.time + animationInterval; // Update combo state activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; current_Combo_State = ComboState.PUNCH_1; } } public void KickAttacksDirectly(string animationName) { StaminaSystem staminaSystem = GetComponent(); if (staminaSystem.currentStamina < 5f) { animationInterval = 2.0f; } else { animationInterval = 0.35f; } if (Time.time > nextAnimationTime) { // Play the animation directly using the specific animation name PlayAnimation(animationName); // Apply appropriate stamina cost based on the animation float staminaCost = 0.7f; // More powerful kicks cost more stamina if (animationName == AnimationNames.DropKick) { staminaCost = 1.5f; } staminaSystem.UseStamina(staminaCost); nextAnimationTime = Time.time + animationInterval; // Update combo state activateTimerToReset = true; current_Combo_Timer = default_Combo_Timer; current_Combo_State = ComboState.KICK_1; } } }