Пример #1
0
        // CONSTRUCTOR: ---------------------------------------------------------------------------

        public InputBuffer(float timeWindow)
        {
            this.timeWindow = timeWindow;

            this.inputTime = -100f;
            this.key       = CharacterMelee.ActionKey.A;
        }
Пример #2
0
        public MeleeClip Select(CharacterMelee.ActionKey actionkey)
        {
            int currentPhase = this.GetCurrentPhase();

            if (currentPhase == -1 && this.melee.Character.characterLocomotion.isBusy)
            {
                return(null);
            }

            if (currentPhase == 0)
            {
                return(null);
            }
            if (currentPhase == 1)
            {
                return(null);
            }

            TreeCombo <CharacterMelee.ActionKey, Combo> next = this.current;

            if (next == null || this.currentCombo == null)
            {
                next = this.root;
            }

            if (!next.HasChild(actionkey))
            {
                return(null);
            }
            next = next.GetChild(actionkey);

            this.startAttackTime = Time.time;
            this.current         = next;

            this.currentCombo = this.SelectMeleeClip();;

            this.isBlock        = false;
            this.isPerfectBlock = false;

            if (this.currentCombo == null)
            {
                return(null);
            }
            return(this.currentCombo.meleeClip);
        }
Пример #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty spCombo     = property.FindPropertyRelative("combo");
            SerializedProperty spCondition = property.FindPropertyRelative("condition");
            SerializedProperty spMeleeClip = property.FindPropertyRelative("meleeClip");
            SerializedProperty spIsEnabled = property.FindPropertyRelative("isEnabled");

            float comboLabelWidth = position.width - (
                (spCombo.arraySize * COMBO_KEY_WIDTH) +
                (2 * COMBO_BTN_WIDTH) +
                EditorGUIUtility.standardVerticalSpacing
                );

            Rect rectComboLabel = new Rect(
                position.x,
                position.y,
                comboLabelWidth,
                EditorGUIUtility.singleLineHeight
                );

            EditorGUI.LabelField(rectComboLabel, spCombo.displayName);

            Rect rectComboItem = new Rect(rectComboLabel);

            for (int i = 0; i < spCombo.arraySize; ++i)
            {
                rectComboItem = new Rect(
                    rectComboItem.x + rectComboItem.width,
                    rectComboItem.y,
                    COMBO_KEY_WIDTH,
                    EditorGUIUtility.singleLineHeight
                    );

                SerializedProperty       spComboItem = spCombo.GetArrayElementAtIndex(i);
                CharacterMelee.ActionKey item        = (CharacterMelee.ActionKey)spComboItem.enumValueIndex;

                GUIStyle comboItemStyle = GUI.skin.button;
                if (spCombo.arraySize > 1)
                {
                    if (i == spCombo.arraySize - 1)
                    {
                        comboItemStyle = CoreGUIStyles.GetButtonRight();
                    }
                    else if (i == 0)
                    {
                        comboItemStyle = CoreGUIStyles.GetButtonLeft();
                    }
                    else
                    {
                        comboItemStyle = CoreGUIStyles.GetButtonMid();
                    }
                }

                if (GUI.Button(rectComboItem, item.ToString(), comboItemStyle))
                {
                    this.spComboItemSelected = spComboItem;
                    GenericMenu comboMenu = new GenericMenu();
                    CharacterMelee.ActionKey[] options = Enum.GetValues(typeof(CharacterMelee.ActionKey))
                                                         .Cast <CharacterMelee.ActionKey>()
                                                         .Select(x => x)
                                                         .ToArray();

                    for (int j = 0; j < options.Length; ++j)
                    {
                        comboMenu.AddItem(
                            new GUIContent(options[j].ToString()),
                            item == options[j],
                            this.SelectOption,
                            j
                            );
                    }

                    comboMenu.ShowAsContext();
                }
            }

            Rect rectComboButtonRmv = new Rect(
                rectComboItem.x + rectComboItem.width + EditorGUIUtility.standardVerticalSpacing,
                rectComboItem.y,
                COMBO_BTN_WIDTH,
                EditorGUIUtility.singleLineHeight
                );

            Rect rectComboButtonAdd = new Rect(
                rectComboButtonRmv.x + rectComboButtonRmv.width,
                rectComboButtonRmv.y,
                COMBO_BTN_WIDTH,
                EditorGUIUtility.singleLineHeight
                );

            EditorGUI.BeginDisabledGroup(spCombo.arraySize <= MIN_NUM_COMBOS);
            if (GUI.Button(rectComboButtonRmv, "-", CoreGUIStyles.GetButtonLeft()))
            {
                spCombo.DeleteArrayElementAtIndex(spCombo.arraySize - 1);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(spCombo.arraySize >= MAX_NUM_COMBOS);
            if (GUI.Button(rectComboButtonAdd, "+", CoreGUIStyles.GetButtonRight()))
            {
                spCombo.InsertArrayElementAtIndex(spCombo.arraySize);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.indentLevel += 1;

            Rect rectCondition = new Rect(
                position.x,
                rectComboLabel.y + rectComboLabel.height + EditorGUIUtility.standardVerticalSpacing,
                position.width,
                EditorGUIUtility.singleLineHeight
                );

            EditorGUI.PropertyField(rectCondition, spCondition);

            Rect rectMeleeClip = new Rect(
                rectCondition.x,
                rectCondition.y + rectCondition.height + EditorGUIUtility.standardVerticalSpacing,
                rectCondition.width,
                EditorGUIUtility.singleLineHeight
                );

            Rect rectIsEnabled = new Rect(
                rectMeleeClip.x,
                rectMeleeClip.y + rectMeleeClip.height + EditorGUIUtility.standardVerticalSpacing,
                rectMeleeClip.width,
                EditorGUIUtility.singleLineHeight
                );

            EditorGUI.PropertyField(rectMeleeClip, spMeleeClip);
            EditorGUI.PropertyField(rectIsEnabled, spIsEnabled);

            EditorGUI.indentLevel -= 1;
        }
Пример #4
0
        // PUBLIC METHODS: ------------------------------------------------------------------------

        public void AddInput(CharacterMelee.ActionKey key)
        {
            this.key       = key;
            this.inputTime = Time.time;
        }