Example #1
0
        // CONSTRUCTOR: ---------------------------------------------------------------------------

        public ComboSystem(CharacterMelee melee, List <Combo> combos)
        {
            this.melee           = melee;
            this.startAttackTime = -100;

            this.root = new TreeCombo <CharacterMelee.ActionKey, Combo>(CharacterMelee.ActionKey.A);

            foreach (Combo combo in combos)
            {
                CharacterMelee.ActionKey[] actions = combo.combo;
                TreeCombo <CharacterMelee.ActionKey, Combo> node = this.root;

                for (int i = 0; i < actions.Length; ++i)
                {
                    if (node.HasChild(actions[i]))
                    {
                        node = node.GetChild(actions[i]);
                    }
                    else
                    {
                        node = node.AddChild(new TreeCombo <CharacterMelee.ActionKey, Combo>(
                                                 actions[i]
                                                 ));
                    }

                    if (i == actions.Length - 1)
                    {
                        node.SetData(combo);
                    }
                }
            }
        }
Example #2
0
        public void Stop()
        {
            this.startAttackTime = -100f;

            this.current      = this.root;
            this.currentCombo = null;
        }
Example #3
0
        public static string BuildString(TreeCombo <TKey, TValue> tree)
        {
            StringBuilder sb = new StringBuilder();

            BuildString(sb, tree, 0);

            return(sb.ToString());
        }
Example #4
0
        private static void BuildString(StringBuilder sb, TreeCombo <TKey, TValue> node, int depth)
        {
            string id = node.id.ToString();

            sb.AppendLine(id.PadLeft(id.Length + depth));

            foreach (TreeCombo <TKey, TValue> child in node)
            {
                BuildString(sb, child, depth + 1);
            }
        }
Example #5
0
        public TreeCombo <TKey, TValue> AddChild(TreeCombo <TKey, TValue> item)
        {
            if (item.parent != null)
            {
                item.parent.children.Remove(item.id);
            }

            item.parent = this;
            this.children.Add(item.id, item);
            return(this.GetChild(item.id));
        }
Example #6
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);
        }