Пример #1
0
        string GetComboSequenceItemName(ComboSequenceItem item)
        {
            string itemName = "";

            string[] names = GetComboEnumNames();

            item.inputIndex = Mathf.Clamp(item.inputIndex, 0, Mathf.Max(names.Length - 1, 0));
            itemName        = names[item.inputIndex];

            return(itemName);
        }
Пример #2
0
        public void Input(int input)
        {
            if (!comboStarted)
            {
                BeginCombo();
            }

            currentInput.Add(input);

            for (int i = validCombos.Count - 1; i >= 0; i--)
            {
                ComboSequence sequence = validCombos[i];

                if (currentInputIndex >= sequence.items.Length)
                {
                    validCombos.RemoveAt(i);
                    continue;
                }

                ComboSequenceItem sequenceItem = sequence.items[currentInputIndex];

                if (sequenceItem.inputIndex == input && sequenceItem.TimingIsValid(inputCounter))
                {
                    if (currentInputIndex == sequence.items.Length - 1)
                    {
                        lastSuccessfulCombo = validCombos.Pop(i);
                        comboSystem.messenger.SendOnComboSuccess(sequence);
                    }
                }
                else if (currentInputIndex > 0)
                {
                    validCombos.RemoveAt(i);
                    comboSystem.messenger.SendOnComboFail(sequence);
                }
                else
                {
                    validCombos.RemoveAt(i);
                }
            }

            inputCounter       = 0;
            currentInputIndex += 1;

            if (validCombos.Count == 0)
            {
                EndCombo();
            }
        }
Пример #3
0
        void ShowComboSequenceItems()
        {
            if (AddFoldOut(sequenceItemsProperty, "Input".ToGUIContent()))
            {
                currentSequence.items[currentSequence.items.Length - 1] = new ComboSequenceItem(comboSystem);
            }

            if (sequenceItemsProperty.isExpanded)
            {
                EditorGUI.indentLevel += 1;

                for (int i = 0; i < sequenceItemsProperty.arraySize; i++)
                {
                    currentSequenceItem         = currentSequence.items[i];
                    currentSequenceItemProperty = sequenceItemsProperty.GetArrayElementAtIndex(i);
                    currentSequenceItemIndex    = i;

                    BeginBox();

                    Rect rect = EditorGUILayout.BeginHorizontal();

                    currentSequenceItem.inputIndex = EditorGUILayout.Popup(currentSequenceItem.inputIndex, GetComboEnumNames(), GUILayout.Width(Screen.width - EditorGUI.indentLevel * 16 - 32));

                    if (DeleteButton(sequenceItemsProperty, i))
                    {
                        break;
                    }

                    EditorGUILayout.EndHorizontal();

                    Reorderable(sequenceItemsProperty, i, true, EditorGUI.IndentedRect(rect));

                    ShowComboSequenceItem();

                    EndBox();
                }

                Separator();
                EditorGUI.indentLevel -= 1;
            }
        }
Пример #4
0
        public void Update()
        {
            if (!comboStarted)
            {
                return;
            }

            inputCounter += Time.deltaTime;

            for (int i = validCombos.Count - 1; i >= 0; i--)
            {
                ComboSequence sequence = validCombos[i];

                if (currentInputIndex >= sequence.items.Length)
                {
                    validCombos.RemoveAt(i);
                    continue;
                }

                ComboSequenceItem sequenceItem = sequence.items[currentInputIndex];

                if (sequenceItem.timeConstraints && inputCounter > sequenceItem.maxDelay)
                {
                    validCombos.RemoveAt(i);
                    comboSystem.messenger.SendOnComboFail(sequence);
                }
            }

            if (validCombos.Count == 0)
            {
                EndCombo();
            }
            else
            {
                comboSystem.messenger.SendOnComboStay();
            }
        }
Пример #5
0
        void ShowComboSequenceItems()
        {
            if (AddFoldOut(sequenceItemsProperty, "Input".ToGUIContent())) {
                currentSequence.items[currentSequence.items.Length - 1] = new ComboSequenceItem(comboSystem);
            }

            if (sequenceItemsProperty.isExpanded) {
                EditorGUI.indentLevel += 1;

                for (int i = 0; i < sequenceItemsProperty.arraySize; i++) {
                    currentSequenceItem = currentSequence.items[i];
                    currentSequenceItemProperty = sequenceItemsProperty.GetArrayElementAtIndex(i);
                    currentSequenceItemIndex = i;

                    BeginBox();

                    Rect rect = EditorGUILayout.BeginHorizontal();

                    currentSequenceItem.inputIndex = EditorGUILayout.Popup(currentSequenceItem.inputIndex, GetComboEnumNames(), GUILayout.Width(Screen.width - EditorGUI.indentLevel * 16 - 32));

                    if (DeleteButton(sequenceItemsProperty, i)) {
                        break;
                    }

                    EditorGUILayout.EndHorizontal();

                    Reorderable(sequenceItemsProperty, i, true, EditorGUI.IndentedRect(rect));

                    ShowComboSequenceItem();

                    EndBox();
                }

                Separator();
                EditorGUI.indentLevel -= 1;
            }
        }
Пример #6
0
        string GetComboSequenceItemName(ComboSequenceItem item)
        {
            string itemName = "";
            string[] names = GetComboEnumNames();

            item.inputIndex = Mathf.Clamp(item.inputIndex, 0, Mathf.Max(names.Length - 1, 0));
            itemName = names[item.inputIndex];

            return itemName;
        }
 public void SetComboTimeConstraints(ComboSequenceItem item, bool enable, float minDelay, float maxDelay)
 {
     item.timeConstraints = enable;
     item.minDelay        = minDelay;
     item.maxDelay        = maxDelay;
 }
        public void SetComboTimeConstraints(string comboName, int inputIndex, bool enable)
        {
            ComboSequenceItem item = GetCombo(comboName).items[inputIndex];

            SetComboTimeConstraints(item, enable, item.minDelay, item.maxDelay);
        }