Пример #1
0
    // Everything starts from root node
    void CheckAttack(int attackType)
    {
        int finalAttack = attackType;

        if (CurrentNode.CheckChildren(finalAttack))
        {
            //set the current node to be the valid child
            CurrentNode = CurrentNode.GetChild(finalAttack);

            //check if it's one of the finisher moves
            if (CurrentNode.isFinisher)
            {
                //add it to four to get the forceful versions
                finalAttack = 4 + attackType;
                CurrentNode = RootNode;
            }
            ExecuteAttack(finalAttack);
            print("Valid continuer");
        }
        else
        {
            CurrentNode = RootNode;
            print("Not a valid continuer");
        }
    }
Пример #2
0
 public ComboNodeTransition(ComboNode targetNode, float transitionBegin, float transitionEnd, ComboInput input)
 {
     this.targetNode      = targetNode;
     this.transitionBegin = transitionBegin;
     this.transitionEnd   = transitionEnd;
     this.input           = input;
 }
    void RecursiveAddNode(ComboNode ao, Vector2 last_position)
    {
        if (ao.attack_object.valid_moves == null)
        {
            return;
        }

        int counter = ao.attack_object.valid_moves.Count - 1;

        foreach (AttackObject c in ao.attack_object.valid_moves)
        {
            Vector2 new_postion = new Vector2(last_position.x + NODE_WIDTH + 100, last_position.y + (NODE_HEIGHT * counter));
            nodes.Add(new ComboNode(new_postion, NODE_WIDTH, NODE_HEIGHT, node_style, in_style, out_style, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, c));

            //Add connections
            select_out_point = ao.out_point;
            select_in_point  = nodes[nodes.Count - 1].in_point;
            CreateConnection(false);
            ClearConnectionSelection();

            //Recurse
            RecursiveAddNode(nodes[nodes.Count - 1], new_postion);
            counter--;
        }
    }
 public ConnectionPoint(ComboNode node, ConnectionPointType type, GUIStyle style, Action <ConnectionPoint> OnClickConnectionPoint)
 {
     this.node  = node;
     this.type  = type;
     this.style = style;
     this.OnClickConnectionPoint = OnClickConnectionPoint;
     rect = new Rect(0, 0, 10f, 20f);
 }
Пример #5
0
    void PrintComboTree(ComboNode node)
    {
        if (node.children.Count == 0)
        {
            print("Final hit: " + node.attackType);
            return;
        }

        for (int i = 0; i < node.children.Count; ++i)
        {
            print(node.attackType);
            print("children count: " + node.children.Count);
            PrintComboTree(node.children[i]);
        }
    }
Пример #6
0
    void InitializeCombos()
    {
        //start tree
        RootNode = new ComboNode(0, 0, false);

        //define temp to help with initializing children
        ComboNode parent = RootNode;
        ComboNode childToBeAdded;

        //add first combo root
        //-----------------------------------
        //light punch
        childToBeAdded = new ComboNode(1, 10, false);
        parent.AddChild(childToBeAdded);

        //light punch
        parent         = childToBeAdded;
        childToBeAdded = new ComboNode(1, 10, false);
        parent.AddChild(childToBeAdded);

        //push light punch
        parent         = childToBeAdded;
        childToBeAdded = new ComboNode(1, 15, true);
        parent.AddChild(childToBeAdded);
        //-----------------------------------


        //add second combo root
        //-----------------------------------
        //light punch
        parent         = RootNode;
        childToBeAdded = new ComboNode(2, 15, false);
        parent.AddChild(childToBeAdded);

        parent         = childToBeAdded;
        childToBeAdded = new ComboNode(2, 15, false);
        parent.AddChild(childToBeAdded);

        parent         = childToBeAdded;
        childToBeAdded = new ComboNode(2, 20, true);
        parent.AddChild(childToBeAdded);
        //-----------------------------------



        CurrentNode = RootNode;
    }
Пример #7
0
    public int CompareTo(object obj)
    {
        if (obj == null)
        {
            return(1);
        }

        ComboNode otherNode = obj as ComboNode;

        if (otherNode != null)
        {
            return(this._weightValue.CompareTo(otherNode._weightValue));
        }
        else
        {
            throw new ArgumentException("Object is not a combonode");
        }
    }
    void OnClickRemoveNode(ComboNode n)
    {
        //Remove it from parents valid moves
        if (n.attack_object.parent != null)
        {
            n.attack_object.parent.valid_moves.Remove(n.attack_object);
        }

        //Remove the parent from the children
        if (n.attack_object.valid_moves != null)
        {
            foreach (AttackObject a in n.attack_object.valid_moves)
            {
                a.parent = null;
            }
        }

        AssetDatabase.DeleteAsset("Assets/Attack Objects/" + n.attack_object.name + ".asset");
        AssetDatabase.SaveAssets();

        //Visual indications
        if (connections != null)
        {
            List <Connection> connectionsToRemove = new List <Connection>();

            for (int i = 0; i < connections.Count; i++)
            {
                if (connections[i].in_point == n.in_point || connections[i].out_point == n.out_point)
                {
                    connectionsToRemove.Add(connections[i]);
                }
            }

            for (int i = 0; i < connectionsToRemove.Count; i++)
            {
                connections.Remove(connectionsToRemove[i]);
            }

            connectionsToRemove = null;
        }

        nodes.Remove(n);
    }
Пример #9
0
    public void LoadPartyCombatData()
    {
        XmlDocument xmlDoc = new XmlDocument();                               // xmlDoc is the new xml document.

        xmlDoc.LoadXml(_pcCombatData.text);                                   // load the file.
        XmlNodeList characterList = xmlDoc.GetElementsByTagName("Character"); // array of the level nodes.

        CharacterInfo[] characterArray = new CharacterInfo[3];
        int             charCounter    = 0;

        //Debug.Log(characterList.Count);
        foreach (XmlNode characterInfo in characterList)
        {
            //create a temp character and a temp pathlist to be stored into the temp character
            CharacterInfo tempChar = new CharacterInfo();

            //set default modifier values
            tempChar._moveSpeedModifier = 1.0f;

            XmlNodeList characterContent = characterInfo.ChildNodes;
            //Debug.Log(characterContent.Count);
            foreach (XmlNode charItem in characterContent)
            {
                if (charItem.Name == "Title")
                {
                    Debug.Log(charItem.Name + " :: " + charItem.InnerText);
                    tempChar._title = charItem.InnerText;
                }
                else if (charItem.Name == "Name")
                {
                    Debug.Log(charItem.Name + " :: " + charItem.InnerText);
                    tempChar._name = charItem.InnerText;
                }
                else if (charItem.Name == "MoveSpeed")
                {
                    Debug.Log(charItem.Name + " :: " + charItem.InnerText);
                    tempChar._moveSpeed = ConvertStringToInt(charItem.InnerText);
                }
                else if (charItem.Name == "JumpSpeed")
                {
                    Debug.Log(charItem.Name + " :: " + charItem.InnerText);
                    tempChar._jumpSpeed = ConvertStringToInt(charItem.InnerText);
                }
                //when it gets to the combat trees, first make a list of combat trees, each combat tree has a name and a list of nodes
                else if (charItem.Name == "CombatPaths")
                {
                    Debug.Log(charItem.Name);
                    List <CombatPath> tempPathList = new List <CombatPath>();
                    XmlNodeList       combatPaths  = charItem.ChildNodes;
                    foreach (XmlNode combatPath in combatPaths)
                    {
                        //create a temp path to store all the information into
                        CombatPath  tempPath  = new CombatPath();
                        XmlNodeList pathAttrs = combatPath.ChildNodes;                        //make a list of path attributes
                        foreach (XmlNode pathAttr in pathAttrs)
                        {
                            if (pathAttr.Name == "Name")
                            {
                                Debug.Log(pathAttr.Name + " :: " + pathAttr.InnerText);
                                tempPath._pathName = pathAttr.InnerText;
                            }
                            //when the combat tree encounters its nodes, first make a list of them and then start adding them into the temp tree
                            else if (pathAttr.Name == "Nodes")
                            {
                                BinaryTree <ComboNode> tempTree       = new BinaryTree <ComboNode>();
                                XmlNodeList            combatTreeList = pathAttr.ChildNodes;                      //gets the list of nodes

                                foreach (XmlNode node in combatTreeList)
                                {
                                    //within each node, is a list of node attributes which are stored into a temp node
                                    //calculate the insert value of the node from the ID
                                    XmlNodeList nodeAttributes = node.ChildNodes;                                     //gets the list of the nodes attributes
                                    ComboNode   tempNode       = new ComboNode();
                                    foreach (XmlNode attr in nodeAttributes)
                                    {
                                        if (attr.Name == "ID")
                                        {
                                            tempNode._id = attr.InnerText;
                                            char[] charArr   = attr.InnerText.ToCharArray();
                                            float  weight    = 0.0f;
                                            float  weightMod = 0.1f;

                                            for (int i = 3; i < charArr.Length; i++)
                                            {
                                                if (i == 3)
                                                {
                                                    weight = 0.0f;
                                                }
                                                else
                                                {
                                                    if (charArr[i] == 'a')
                                                    {
                                                        weight    += weightMod;
                                                        weightMod /= 10.0f;
                                                    }
                                                    else if (charArr[i] == 'p')
                                                    {
                                                        weight    -= weightMod;
                                                        weightMod /= 10.0f;
                                                    }
                                                }
                                            }
                                            Debug.Log("ID: " + attr.InnerText + " weight: " + weight);
                                            tempNode._weightValue = weight;
                                        }
                                        else if (attr.Name == "Damage")
                                        {
                                            tempNode._damage = ConvertStringToInt(attr.InnerText);
                                            Debug.Log("Attack Damage: " + tempNode._damage);
                                        }
                                        else if (attr.Name == "Duration")
                                        {
                                            tempNode._attackDuration = ConvertStringToFloat(attr.InnerText);
                                            Debug.Log("Attack Duration: " + tempNode._attackDuration);
                                        }
                                        else if (attr.Name == "Movements")
                                        {
                                            XmlNodeList      movements = attr.ChildNodes;                                        //gets the list of movements
                                            AttackMovement[] atkmovArr = new AttackMovement[movements.Count];
                                            int counter = 0;
                                            foreach (XmlNode movement in movements)
                                            {
                                                AttackMovement tempMov   = new AttackMovement();
                                                XmlNodeList    moveAttrs = movement.ChildNodes;                                              //gets the list of the nodes attributes
                                                foreach (XmlNode moveAttr in moveAttrs)
                                                {
                                                    if (moveAttr.Name == "Speed")
                                                    {
                                                        tempMov.speed = ConvertStringToFloat(moveAttr.InnerText);
                                                        Debug.Log(moveAttr.Name + " " + tempMov.speed);
                                                    }
                                                    else if (moveAttr.Name == "Duration")
                                                    {
                                                        tempMov.duration = ConvertStringToFloat(moveAttr.InnerText);
                                                        Debug.Log(moveAttr.Name + " " + tempMov.duration);
                                                    }
                                                }
                                                atkmovArr[counter] = tempMov;
                                                counter++;
                                            }
                                            tempNode._attackMovements = atkmovArr;
                                        }
                                    }
                                    //once all the attributes are added into the temp node, add the temp node to the temp tree
                                    //TODO: add tempnode to the tree here!
                                }
                                //then store the temp tree into the combatPath's combat tree
                                tempPath._combatTree = tempTree;
                            }
                        }
                        tempPathList.Add(tempPath);
                    }
                }
            }
            characterArray[charCounter] = tempChar;
            charCounter++;
        }

        GameState._party = characterArray;
    }
Пример #10
0
 //adds child
 public void AddChild(ComboNode attack)
 {
     children.Add(attack);
 }
Пример #11
0
 void ResetCombo()
 {
     CurrentNode          = RootNode;
     playerData.pauseTime = 0f;
 }