Exemple #1
0
    private void SetRelevantCombos(AttackStruct.InputButton input, int tryIndex = 0)
    {
        List <Combo> newCombos = new List <Combo>();


        foreach (Combo relevantCombo in RelevantCombos)
        {
            if (AttackIndex >= relevantCombo.Attacks.Length)
            {
                continue;
            }

            if (relevantCombo.Attacks[AttackIndex].Input == input)
            {
                newCombos.Add(relevantCombo);
                if (AttackIndex == relevantCombo.Attacks.Length - 1)
                {
                    OnComboExecuted?.Invoke(relevantCombo.Name);
                }
            }
        }



        if (newCombos.Count == 0 && tryIndex < 1)
        {
            AttackIndex    = 0;
            RelevantCombos = Combos.ToList();
            SetRelevantCombos(input, tryIndex + 1);
            return;
        }

        RelevantCombos = newCombos;
    }
Exemple #2
0
    private void Attacking()
    {
        if (timer <= CurrentAttack.attackWindow.y / CurrentAttack.Clip.frameRate - CurrentAttack.InputBuffer)
        {
            return;
        }

        if (Input.GetButtonDown("LightAttack"))
        {
            _bufferdInput = AttackStruct.InputButton.Light;
            hasGivenInput = true;
        }
        else if (Input.GetButtonDown("HeavyAttack"))
        {
            _bufferdInput = AttackStruct.InputButton.Heavy;
            hasGivenInput = true;
        }
        else if (Input.GetButtonDown("Dash"))
        {
            _bufferdInput = AttackStruct.InputButton.Dash;
            hasGivenInput = true;
        }


        if (firstFrame || currentFrame <= CurrentAttacks[AttackIndex].attackWindow.y || !hasGivenInput)
        {
            return;
        }



        switch (_bufferdInput)
        {
        case AttackStruct.InputButton.Light:
            AttackIndex++;
            SetRelevantCombos(AttackStruct.InputButton.Light);
            break;

        case AttackStruct.InputButton.Heavy:
            AttackIndex++;
            SetRelevantCombos(AttackStruct.InputButton.Heavy);
            break;

        case AttackStruct.InputButton.Dash:
            AttackIndex++;
            SetRelevantCombos(AttackStruct.InputButton.Dash);
            if (RelevantCombos.Count == 0)
            {
                AttackIndex = 0;
                SetRelevantCombos(AttackStruct.InputButton.Light);
                TransitionTo <PlayerDashState>();
                return;
            }
            break;
        }


        hasGivenInput = false;

        DoAttack();
    }