コード例 #1
0
        public static new BuffPlayerStatueAction FromXmlElement(XmlElement xmlData)
        {
            BuffPlayerStatueAction resultingAction = new BuffPlayerStatueAction();

            string buffName = xmlData["BuffId"].InnerText;
            int    buffId;

            if (!int.TryParse(buffName, out buffId))
            {
                List <int> buffs = TShock.Utils.GetBuffByName(buffName);
                if (buffs.Count == 0)
                {
                    throw new ArgumentException(string.Format("\"{0}\" is not a valid buff name.", buffName));
                }
                if (buffs.Count > 1)
                {
                    throw new ArgumentException(string.Format("\"{0}\" matches more than one buff.", buffName));
                }

                buffId = buffs[0];
            }

            resultingAction.BuffId   = buffId;
            resultingAction.BuffTime = int.Parse(xmlData["BuffTime"].InnerText);
            resultingAction.Radius   = int.Parse(xmlData["Radius"].InnerText);
            return(resultingAction);
        }
コード例 #2
0
        public static StatueConfig FromXmlElement(XmlElement xmlData)
        {
            StatueConfig resultingStatueConfig = new StatueConfig();

            if (xmlData["PlayerCheckRange"] != null)
            {
                resultingStatueConfig.PlayerCheckRange = int.Parse(xmlData["PlayerCheckRange"].InnerText);
            }
            resultingStatueConfig.Cooldown = int.Parse(xmlData["Cooldown"].InnerText);
            if (xmlData["TriggerPermission"] != null)
            {
                resultingStatueConfig.TriggerPermission = xmlData["TriggerPermission"].InnerText;
            }
            if (xmlData["WirePermission"] != null)
            {
                resultingStatueConfig.WirePermission = xmlData["WirePermission"].InnerText;
            }

            XmlElement actionListNode = xmlData["Actions"];

            resultingStatueConfig.ActionsProcessingMethod = (ActionListProcessingMethod)Enum.Parse(
                typeof(ActionListProcessingMethod), actionListNode.Attributes["ProcessingMethod"].Value
                );
            foreach (XmlElement actionNode in actionListNode.ChildNodes)
            {
                switch (actionNode.LocalName)
                {
                case "NullAction":
                    resultingStatueConfig.Actions.Add(NullStatueAction.FromXmlElement(actionNode));
                    break;

                case "MoveNpcAction":
                    resultingStatueConfig.Actions.Add(MoveNpcStatueAction.FromXmlElement(actionNode));
                    break;

                case "SpawnNpcAction":
                    resultingStatueConfig.Actions.Add(SpawnNpcStatueAction.FromXmlElement(actionNode));
                    break;

                case "SpawnItemAction":
                    resultingStatueConfig.Actions.Add(SpawnItemStatueAction.FromXmlElement(actionNode));
                    break;

                case "BuffPlayerAction":
                    resultingStatueConfig.Actions.Add(BuffPlayerStatueAction.FromXmlElement(actionNode));
                    break;
                }
            }

            return(resultingStatueConfig);
        }
コード例 #3
0
    public static new BuffPlayerStatueAction FromXmlElement(XmlElement xmlData) {
      BuffPlayerStatueAction resultingAction = new BuffPlayerStatueAction();

      string buffName = xmlData["BuffId"].InnerText;
      int buffId;
      if (!int.TryParse(buffName, out buffId)) {
        List<int> buffs = TShock.Utils.GetBuffByName(buffName);
        if (buffs.Count == 0)
          throw new ArgumentException(string.Format("\"{0}\" is not a valid buff name.", buffName));
        if (buffs.Count > 1)
          throw new ArgumentException(string.Format("\"{0}\" matches more than one buff.", buffName));

        buffId = buffs[0];
      }

      resultingAction.BuffId = buffId;
      resultingAction.BuffTime = int.Parse(xmlData["BuffTime"].InnerText);
      resultingAction.Radius = int.Parse(xmlData["Radius"].InnerText);
      return resultingAction;
    }