Пример #1
0
        public static ITTrigger Parse(XElement xml)
        {
            ITTrigger rst = new ITTrigger();

            rst.Name = Tools.GetXmlAttribute(xml, "name");
            if (xml.Elements("param") != null)
            {
                foreach (var node in xml.Elements("param"))
                {
                    rst.Params.Add(ITParam.Parse(node));
                }
            }
            if (xml.Attribute("w") != null)
            {
                rst.Weight = Tools.GetXmlAttributeInt(xml, "w");
            }
            return(rst);
        }
Пример #2
0
        public static ITParam Parse(XElement xml)
        {
            ITParam rst = new ITParam();

            if (xml.Attribute("min") != null)
            {
                rst.Min = Tools.GetXmlAttributeInt(xml, "min");
            }
            if (xml.Attribute("max") != null)
            {
                rst.Max = Tools.GetXmlAttributeInt(xml, "max");
            }
            if (xml.Attribute("pool") != null)
            {
                rst.Pool = Tools.GetXmlAttribute(xml, "pool");
            }
            return(rst);
        }
Пример #3
0
        public ItemTrigger GenerateItemTrigger()
        {
            ItemTrigger rst = new ItemTrigger();

            rst.Name = this.Name;
            for (int i = 0; i < this.Params.Count; ++i) //赋值
            {
                ITParam param = this.Params[i];
                if (param.Min != -1)
                {
                    rst.Argvs.Add((Tools.GetRandomInt(param.Min, param.Max)).ToString());
                }
                if (param.Pool != string.Empty) //多选一
                {
                    string poolSelect = param.PoolList[Tools.GetRandomInt(0, param.PoolList.Length - 1)];
                    rst.Argvs.Add(poolSelect);
                }
            }
            return(rst);
        }
Пример #4
0
        public bool IsCheat(int itemLevel)
        {
            ITTriggerDb db        = ItemManager.GetTriggerDb(itemLevel);
            bool        findMatch = false;

            foreach (var t in db.Triggers)
            {
                if (t.Name == this.Name)
                {
                    for (int i = 0; i < Argvs.Count; ++i)
                    {
                        string  argv = Argvs[i];
                        ITParam p    = t.Params[i];
                        if (p.Min != -1 && (int.Parse(argv) >= p.Min && int.Parse(argv) <= p.Max))
                        {
                            findMatch = true;
                        }
                        else if (p.Pool != string.Empty)
                        {
                            bool find = false;
                            foreach (var pp in p.PoolList)
                            {
                                if (pp == argv)
                                {
                                    find = true;
                                }
                            }
                            if (find)
                            {
                                findMatch = true;
                            }
                        }
                    }
                }
            }
            return(!findMatch);
        }