Пример #1
0
    private void ReadEndingsFromNode(XmlNode node)
    {
        if (node == null)
        {
            return;
        }
        foreach (XmlNode childNode in node.ChildNodes)
        {
            if (childNode.LocalName != "endings")
            {
                continue;
            }
            Ending newEnding = new Ending();
            newEnding.id = uint.Parse(childNode.Attributes[IDATTR_NAME].Value);

            ReadLangStringFromNode(childNode, new LangStringPair(newEnding.name, NAMENODE_NAME),
                                   new LangStringPair(newEnding.description, DESCNODE_NAME));

            foreach (XmlNode condChildNode in childNode.ChildNodes)
            {
                if (condChildNode.LocalName != "condition")
                {
                    continue;
                }
                EndingCondition newCondition = new EndingCondition();
                newCondition.cState = bool.Parse(SafeGetNodeValue(FindFirstChildNode(node, "type"), "false"));
                newCondition.cType  = (ConditionType)int.Parse(SafeGetNodeValue(FindFirstChildNode(node, "state"), "0"));
                newCondition.cValue = SafeGetNodeValue(FindFirstChildNode(node, "value"), "0");
                newEnding.conditions.Add(newCondition);
            }

            endings.Add(newEnding.id, newEnding);
        }
    }
Пример #2
0
 public static EndingConditionModel ToEndingConditionModel(this EndingCondition endingCondition)
 {
     if (endingCondition.GetType() == typeof(TimeLimit))
     {
         return(new TimeLimitModel()
         {
             Minutes = ((TimeLimit)endingCondition).Minutes
         });
     }
     else
     {
         return(new NumberOfActionsModel()
         {
             Number = ((NumberOfActions)endingCondition).Number
         });
     }
 }