Exemple #1
0
 public AtbNode(excel_atb_data excel, AtbTree tree)
 {
     AtbType    = (AtbType)excel.id;
     this.excel = excel;
     value      = excel.defValue;
     atbTree    = tree;
 }
    public static void DefaultCalcFunc(AtbNode node)
    {
        int value = node.GetValue();

        for (int i = 0; i < node.children.Count; ++i)
        {
            if (i == 0)
            {
                value = 0;
            }
            AtbNode        child = node.children[i];
            excel_atb_data excel = child.excel;

            value += child.GetValue();
        }

        node.SetValue(value);
    }
Exemple #3
0
    public AtbTree(Character cha)
    {
        mCharacter = cha;

        List <AtbNode> nodes = new List <AtbNode>();
        List <bool>    token = new List <bool>();

        for (int i = 0; i < excel_atb_data.Count; ++i)
        {
            excel_atb_data excel = excel_atb_data.GetByIndex(i);
            AtbNode        node  = new AtbNode(excel, this);

            AtbNode.CalcFunc func = null;
            if (AtbCalcFuncRegister.mFuncs.TryGetValue(node.AtbType, out func))
            {
                node.mCalcFunc = func;
            }
            else
            {
                node.mCalcFunc = AtbCalcFuncRegister.DefaultCalcFunc;
            }

            atbNodes.Add(node.AtbType, node);
            nodes.Add(node);
            token.Add(false);
        }

        // Build Tree
        for (int i = 0; i < nodes.Count; ++i)
        {
            AtbNode node = nodes[i];
            if (node.excel.inflAtbs == null)
            {
                continue;
            }
            for (int j = 0; j < node.excel.inflAtbs.Length; ++j)
            {
                int     inflID   = node.excel.inflAtbs[j];
                AtbType childAtb = (AtbType)inflID;

                // 获取被影响节点;
                AtbNode inflNode = null;
                if (!atbNodes.TryGetValue(childAtb, out inflNode))
                {
                    continue;
                }
                inflNode.children.Add(node);
                node.parents.Add(inflNode);
            }
        }

        // Update Tree
        for (int i = 0; i < nodes.Count; ++i)
        {
            AtbNode node = nodes[i];
            if (node.parents.Count == 0)
            {
                node.UpdateAtbTreeDown();
            }
        }
    }