// given node is <define type="event".../> internal EconomicalEvent(XmlNode node) : base(node) { _id = node.Attributes["id"].Value; if (_id == null) { throw new FormatException("event id is missing"); } IEnumerator ie = node.ChildNodes.GetEnumerator(); while (ie.MoveNext()) { XmlNode cn = (XmlNode)ie.Current; if (cn.Name.Equals("frequency")) { string str = cn.InnerText; if (str == null) { str = "0"; } try { frequency = int.Parse(str); } catch {} if (frequency == -1 || frequency > 7) { throw new FormatException("invalid <frequency> :" + str); } } else if (cn.Name.Equals("follow_events")) { follows = new ArrayedAction(cn); } } }
private object Parse(XmlNode node, RandTableType rtType) { switch (rtType) { case RandTableType.ACTION: ArrayedAction aArray = new ArrayedAction(node); // if single action, regists non-arrayed action object. if (aArray.Count == 1) { return(aArray[0]); } else { return(aArray); } case RandTableType.EFFECT: ArrayedEffect eArray = new ArrayedEffect(node); // if single action, regists non-arrayed action object. if (eArray.Count == 1) { return(eArray[0]); } else { return(eArray); } case RandTableType.TARGET: ArrayedTarget tArray = new ArrayedTarget(node); // if single action, regists non-arrayed action object. if (tArray.Count == 1) { return(tArray[0]); } else { return(tArray); } default: throw new FormatException("Invalid type attribute in the randomized tag"); break; } return(null); }