Example #1
0
 //Checks combo to see if it matches a combination
 public bool continueCombo(ComboInput i)
 {
     if (inputs[curInput].isSameAs(i))
     {
         curInput++;
         if (curInput >= inputs.Count) // Finished the inputs and we should do the attack
         {
             onInputted.Invoke();
             curInput = 0;
         }
         return(true);
     }
     else
     {
         curInput = 0;
         return(false);
     }
 }
Example #2
0
        void Update()
        {
            if (curAttack != null)
            {
                if (timer > 0)
                {
                    timer -= Time.deltaTime;
                }
                else
                {
                    curAttack = null;
                }
                return;
            }

            if (currentCombos.Count > 0)
            {
                leeway += Time.deltaTime;
                if (leeway >= comboLeeway)
                {
                    if (lastInput != null)
                    {
                        Attack(GetAttackFromType(lastInput.type));
                        lastInput = null;
                    }
                    ResetCombos();
                }
            }
            else
            {
                leeway = 0;
            }

            ComboInput input = null;

            if (Input.GetKeyDown(heavyKey))
            {
                input = new ComboInput(AttackType.heavy);
            }
            if (Input.GetKeyDown(lightKey))
            {
                input = new ComboInput(AttackType.light);
            }
            if (Input.GetKeyDown(kickKey))
            {
                input = new ComboInput(AttackType.kick);
            }

            if (input == null)
            {
                return;
            }

            lastInput = input;

            List <int> remove = new List <int>();

            for (int i = 0; i < currentCombos.Count; i++)
            {
                ComboTypes c = combos[currentCombos[i]];
                if (c.continueCombo(input))
                {
                    leeway = 0;
                }
                else
                {
                    remove.Add(i);
                }
            }

            foreach (int i in remove)
            {
                currentCombos.RemoveAt(i);
            }


            for (int i = 0; i < combos.Count; i++)
            {
                if (currentCombos.Contains(i))
                {
                    continue;
                }
                if (combos[i].continueCombo(input))
                {
                    currentCombos.Add(i);
                    leeway = 0;
                }
            }

            if (currentCombos.Count <= 0)
            {
                Attack(GetAttackFromType(input.type));
            }
        }
Example #3
0
 public bool isSameAs(ComboInput test)
 {
     return(type == test.type); // Add && movement == test.movement
 }