using UnityEngine;
public class ComboSystem : MonoBehaviour
{
public float comboWindow = 0.5f; // الوقت المسموح بين الضغطة والضغطة التالية
public string[] comboActions = { "Light Attack", "Heavy Attack", "Special
Attack" };
private float timeSinceLastPress = 0f;
private int currentComboStep = 0;
private bool isComboActive = false;
private Animator animator;
void Start()
{
animator = GetComponent<Animator>();
}
void Update()
{
timeSinceLastPress += [Link];
if ([Link]("Fire1"))
{
ExecuteCombo();
}
if (timeSinceLastPress > comboWindow && isComboActive)
{
ResetCombo();
}
}
void ExecuteCombo()
{
if (timeSinceLastPress < comboWindow)
{
currentComboStep++;
}
else
{
currentComboStep = 1;
}
if (currentComboStep > [Link])
{
currentComboStep = 1;
}
PerformAttack(currentComboStep - 1);
timeSinceLastPress = 0f;
isComboActive = true;
}
void PerformAttack(int comboIndex)
{
string attackType = comboActions[comboIndex];
[Link](attackType);
}
void ResetCombo()
{
currentComboStep = 0;
isComboActive = false;
}
}