Esempio n. 1
0
        static public Event Parse(XElement node)
        {
            Event aEvent = new Event();

            //推荐进入等级
            if (node.Attribute("lv") != null)
            {
                aEvent.lv = Tools.GetXmlAttributeInt(node, "lv");
            }
            if (node.Attribute("image") != null)
            {
                aEvent.image = Tools.GetXmlAttribute(node, "image");
            }
            else
            {
                aEvent.image = "";
            }
            if (node.Attribute("description") != null)
            {
                aEvent.description = Tools.GetXmlAttribute(node, "description");
            }

            aEvent.Value = Tools.GetXmlAttribute(node, "value");
            aEvent.Type  = Tools.GetXmlAttribute(node, "type");
            if (node.Attribute("probability") == null)
            {
                aEvent.probability = 100;
            }
            else
            {
                aEvent.probability = Tools.GetXmlAttributeInt(node, "probability");
            }

            if (node.Attribute("repeat") != null && node.Attribute("repeat").Value == "once")
            {
                aEvent.RepeatType = EventRepeatType.Once;
            }
            else
            {
                aEvent.RepeatType = EventRepeatType.Unlimited;
            }
            aEvent.conditions = new List <EventCondition>();
            foreach (XElement eventCondition in node.Elements("condition"))
            {
                EventCondition eventCont = new EventCondition();
                eventCont.type  = Tools.GetXmlAttribute(eventCondition, "type");
                eventCont.value = Tools.GetXmlAttribute(eventCondition, "value");
                if (eventCondition.Attribute("number") != null)
                {
                    eventCont.number = Tools.GetXmlAttributeInt(eventCondition, "number");
                }
                else
                {
                    eventCont.number = 1;
                }
                aEvent.conditions.Add(eventCont);
            }
            return(aEvent);
        }
        public static bool judge(EventCondition condition)
        {
            //XXX必须在队中的判定,按照roleName判断,非roleKey
            if (condition.type == "in_team")
            {
                if (!RuntimeData.Instance.NameInTeam(condition.value))
                {
                    return(false);
                }
            }

            //XXX必须不在队中的判定,按照roleName判断,非roleKey
            if (condition.type == "not_in_team")
            {
                if (RuntimeData.Instance.NameInTeam(condition.value))
                {
                    return(false);
                }
            }

            //XXX必须在队中的判定,按照roleKey
            if (condition.type == "key_in_team")
            {
                if (!RuntimeData.Instance.InTeam(condition.value))
                {
                    return(false);
                }
            }

            //XXX必须不在队中的判定,按照roleKey
            if (condition.type == "key_not_in_team")
            {
                if (RuntimeData.Instance.InTeam(condition.value))
                {
                    return(false);
                }
            }

            //XXX剧情必须已经完成的判定
            if (condition.type == "should_finish")
            {
                if (!RuntimeData.Instance.KeyValues.ContainsKey(condition.value))
                {
                    return(false);
                }
            }

            //必须没有完成
            if (condition.type == "should_not_finish")
            {
                if (RuntimeData.Instance.KeyValues.ContainsKey(condition.value))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
0
        public static EventCondition Parse(XElement node)
        {
            EventCondition rst = new EventCondition();

            rst.type  = Tools.GetXmlAttribute(node, "type");
            rst.value = Tools.GetXmlAttribute(node, "value");
            if (node.Attribute("number") != null)
            {
                rst.number = Tools.GetXmlAttributeInt(node, "number");
            }
            return(rst);
        }
Esempio n. 4
0
        public static ScriptControl Parse(XElement node)
        {
            ScriptControl rst = new ScriptControl();

            rst.Type  = Tools.GetXmlAttribute(node, "type");
            rst.Value = Tools.GetXmlAttribute(node, "value");
            if (node.Elements("condition") != null)
            {
                foreach (var conditionNode in node.Elements("condition"))
                {
                    rst.Conditions.Add(EventCondition.Parse(conditionNode));
                }
            }
            return(rst);
        }