示例#1
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));
            }
        }