public SpellTree(List <SpellColliderType> spellDef, string spellName) { if (children == null) { children = new List <SpellTreeNode>(); } children.Add(new SpellTreeNode(spellDef, spellName)); actualNode = null; }
//use to move the actualNode (where we are) public bool advance(SpellColliderType type) { bool isFind = false; if (actualNode == null) { foreach (SpellTreeNode child in children) { if (child.isColliderType(type)) { isFind = true; actualNode = child; //Debug.Log("actual is " + actualNode.spellColliderType); break; } } //if(!isFind) //Debug.Log("can't Advance to " + type); return(isFind); } else { if (actualNode.spellColliderType != type) { SpellTreeNode newNode = actualNode.getChildOfType(type); if (newNode == null) { //Debug.Log("can't Advance to " + type); return(false); } else { actualNode = newNode; //Debug.Log("actual is " + actualNode.spellColliderType); return(true); } } return(true); } }
//use to reset the actualNode at the start, i.e. no collision register public void resetActualNode() { //Debug.Log("actual is reset"); actualNode = null; }
public SpellTree() { children = new List <SpellTreeNode>(); actualNode = null; }