Beispiel #1
0
        internal void ValidateVariableListCounts(IO.ICanThrowReadExceptionsWithExtraDetails readExceptionThrower)
        {
            var set = SetType.ToString();

            ProtoData.Traits[MegaloScriptVariableType.Numeric].ValidateListCount(Numerics, set + ".Numerics", readExceptionThrower);
            ProtoData.Traits[MegaloScriptVariableType.Timer].ValidateListCount(Timers, set + ".Timers", readExceptionThrower);
            ProtoData.Traits[MegaloScriptVariableType.Team].ValidateListCount(Teams, set + ".Teams", readExceptionThrower);
            ProtoData.Traits[MegaloScriptVariableType.Player].ValidateListCount(Players, set + ".Players", readExceptionThrower);
            ProtoData.Traits[MegaloScriptVariableType.Object].ValidateListCount(Objects, set + ".Objects", readExceptionThrower);
        }
Beispiel #2
0
        public override string ToString()
        {
            var properties = new Dictionary <string, string>
            {
                { "SetType", SetType.ToString() },
                { "FileGlobs", StringifyList(FileGlobs) }
            };

            return(StringifyValues(GetType().ToString(), properties));
        }
Beispiel #3
0
        /// <summary>
        /// 属性移除
        /// </summary>
        /// <param name="attrName">属性名称</param>
        /// <param name="excludeSetType">排除的节点类型</param>
        public void RemoveAttrList(string attrName, SetType excludeSetType)
        {
            XmlNodeList nodeList = GetList("*", attrName);

            if (nodeList != null && nodeList.Count > 0)
            {
                XmlNode node    = null;
                string  setType = excludeSetType.ToString().ToLower();
                for (int i = 0; i < nodeList.Count; i++)
                {
                    node = nodeList[i];
                    if (node.Name != setType)
                    {
                        node.Attributes.Remove(node.Attributes[attrName]);
                    }
                }
            }
        }
Beispiel #4
0
    /// <summary>
    /// 從資源檔案取得套裝
    /// </summary>
    /// <param name="_setName"></param>
    /// <returns></returns>
    public MeatBallSet GetSet(SetType _set)
    {
        MeatBallSet set = null;

        if (!dataPool.ContainsKey(_set))
        {
            ScriptableObject so = LoadFactory.Instance.LoadScriptableObject(_set.ToString(), "MeatBall", "Set");
            if (so == null)
            {
                throw new Exception(_set + " : This Name is no match any Set.");
            }
            set = so as MeatBallSet;
            //給予資料池此物件
            dataPool.Add(_set, set);
            //遊戲物件池也初始化但沒給值
            objectPool.Add(_set, new List <MeatBallSet>());
        }
        else
        {
            set = dataPool[_set];
        }
        return(set);
    }
Beispiel #5
0
        /// <summary>
        /// 为节点赋值[通常值是在values中赋值]
        /// </summary>
        public void Set(XmlNode node, SetType setType, params string[] values)
        {
            if (node != null && values != null)
            {
                switch (setType)
                {
                case SetType.InnerText:
                    string value = SetValue(node.InnerText, values[0], false);
                    try
                    {
                        node.InnerText = value;
                    }
                    catch
                    {
                        node.InnerText = SetCDATA(value);
                    }
                    break;

                case SetType.InnerXml:
                    node.InnerXml = SetValue(node.InnerXml, values[0], true);
                    break;

                case SetType.Value:
                case SetType.Href:
                case SetType.Src:
                case SetType.Class:
                case SetType.Disabled:
                case SetType.ID:
                case SetType.Name:
                case SetType.Visible:
                case SetType.Title:
                case SetType.Style:
                    string key = setType.ToString().ToLower();
                    SetAttrValue(node, key, values[0]);
                    break;

                case SetType.Custom:
                    for (int i = 0; i < values.Length; i++)
                    {
                        if (i > 0 && i % 2 == 1)
                        {
                            key = values[i - 1].ToLower();
                            switch (key)
                            {
                            case "innertext":
                                Set(node, SetType.InnerText, values[i]);
                                break;

                            case "innerhtml":
                            case "innerxml":
                                Set(node, SetType.InnerXml, values[i]);
                                break;

                            default:
                                SetAttrValue(node, key, values[i]);
                                break;
                            }
                        }
                    }

                    break;

                case SetType.A:
                    node.InnerXml = SetValue(node.InnerXml, values[0], true);
                    if (values.Length > 1)
                    {
                        SetAttrValue(node, "href", values[1]);
                        if (values.Length > 2)
                        {
                            SetAttrValue(node, "title", values[2]);
                            if (values.Length > 3)
                            {
                                SetAttrValue(node, "target", values[3]);
                            }
                        }
                    }
                    break;

                case SetType.Select:
                    if (node.InnerXml.Contains(AppConfig.XHtml.CDataLeft))    //带特殊字符
                    {
                        string innerHtml = node.InnerXml.Replace(string.Format("value=\"{0}\"", values[0]), string.Format("selected=\"selected\" value=\"{0}\"", values[0]));
                        try
                        {
                            node.InnerXml = innerHtml;
                        }
                        catch
                        {
                            node.InnerXml = SetCDATA(innerHtml);
                        }
                    }
                    else
                    {
                        foreach (XmlNode option in node.ChildNodes)
                        {
                            if (option.Attributes["value"] != null && (option.Attributes["value"].Value == values[0] || option.Attributes["value"].Value.Split(',')[0] == values[0]))
                            {
                                SetAttrValue(option, "selected", "selected");
                                break;
                            }
                        }
                    }
                    break;

                case SetType.Checked:
                    if (node.Name == "input" && node.Attributes["type"].Value == "radio")
                    {
                        values[0] = "1";
                    }
                    switch (values[0].ToLower())
                    {
                    case "1":
                    case "true":
                    case "check":
                    case "checked":
                        key = setType.ToString().ToLower();
                        SetAttrValue(node, key, key);
                        break;
                    }
                    break;
                }
            }
        }
Beispiel #6
0
        string ToVariableIndexName(MegaloScriptVariableType type, int index)
        {
            if (index < 0 || !VarIndexIsValid(type, index))
            {
                throw new System.IO.InvalidDataException(string.Format("#{0} is not a valid {1}.{2} variable index",
                                                                       index.ToString(), SetType.ToString(), type.ToString()));
            }

            switch (type)
            {
            case MegaloScriptVariableType.Numeric: return(Numerics[index].CodeName);

            case MegaloScriptVariableType.Timer: return(Timers[index].CodeName);

            case MegaloScriptVariableType.Team: return(Teams[index].CodeName);

            case MegaloScriptVariableType.Player: return(Players[index].CodeName);

            case MegaloScriptVariableType.Object: return(Objects[index].CodeName);

            default: throw new KSoft.Debug.UnreachableException(type.ToString());
            }
        }
Beispiel #7
0
        /// <summary>
        /// Ϊ�ڵ㸳ֵ[ͨ��ֵ����values�и�ֵ]
        /// </summary>
        public void Set(XmlNode node, SetType setType, params string[] values)
        {
            if (node != null && values != null)
            {
                switch (setType)
                {
                    case SetType.InnerText:
                        string value = SetValue(node.InnerText, values[0], false);
                        try
                        {
                            node.InnerText = value;
                        }
                        catch
                        {
                            node.InnerText = SetCDATA(value);
                        }
                        break;
                    case SetType.InnerXml:
                        node.InnerXml = SetValue(node.InnerXml, values[0], true);
                        break;
                    case SetType.Value:
                    case SetType.Href:
                    case SetType.Src:
                    case SetType.Class:
                    case SetType.Disabled:
                    case SetType.ID:
                    case SetType.Name:
                    case SetType.Visible:
                    case SetType.Title:
                    case SetType.Style:
                        string key = setType.ToString().ToLower();
                        SetAttrValue(node, key, values[0]);
                        break;
                    case SetType.Custom:
                        for (int i = 0; i < values.Length; i++)
                        {
                            if (i > 0 && i % 2 == 1)
                            {
                                key = values[i - 1].ToLower();
                                switch (key)
                                {
                                    case "innertext":
                                        Set(node, SetType.InnerText, values[i]);
                                        break;
                                    case "innerhtml":
                                    case "innerxml":
                                        Set(node, SetType.InnerXml, values[i]);
                                        break;
                                    default:
                                        SetAttrValue(node, key, values[i]);
                                        break;
                                }
                            }
                        }

                        break;
                    case SetType.A:
                        node.InnerXml = SetValue(node.InnerXml, values[0], true);
                        if (values.Length > 1)
                        {
                            SetAttrValue(node, "href", values[1]);
                            if (values.Length > 2)
                            {
                                SetAttrValue(node, "title", values[2]);
                                if (values.Length > 3)
                                {
                                    SetAttrValue(node, "target", values[3]);
                                }
                            }
                        }
                        break;
                    case SetType.Select:
                        if (node.InnerXml.Contains(AppConfig.XHtml.CDataLeft))//�������ַ�
                        {
                            string innerHtml = node.InnerXml.Replace(string.Format("value=\"{0}\"", values[0]), string.Format("selected=\"selected\" value=\"{0}\"", values[0]));
                            try
                            {
                                node.InnerXml = innerHtml;
                            }
                            catch
                            {
                                node.InnerXml = SetCDATA(innerHtml);
                            }
                        }
                        else
                        {
                            foreach (XmlNode option in node.ChildNodes)
                            {
                                if (option.Attributes["value"] != null && (option.Attributes["value"].Value == values[0] || option.Attributes["value"].Value.Split(',')[0] == values[0]))
                                {
                                    SetAttrValue(option, "selected", "selected");
                                    break;
                                }
                            }
                        }
                        break;
                    case SetType.Checked:
                        switch (values[0].ToLower())
                        {
                            case "1":
                            case "true":
                            case "check":
                            case "checked":
                                key = setType.ToString().ToLower();
                                SetAttrValue(node, key, key);
                                break;
                        }
                        break;
                }
            }
        }
Beispiel #8
0
 /// <summary>
 /// �����Ƴ�
 /// </summary>
 /// <param name="attrName">��������</param>
 /// <param name="excludeSetType">�ų��Ľڵ�����</param>
 public void RemoveAttrList(string attrName, SetType excludeSetType)
 {
     XmlNodeList nodeList = GetList("*", attrName);
     if (nodeList != null && nodeList.Count > 0)
     {
         XmlNode node = null;
         string setType = excludeSetType.ToString().ToLower();
         for (int i = 0; i < nodeList.Count; i++)
         {
             node = nodeList[i];
             if (node.Name != setType)
             {
                 node.Attributes.Remove(node.Attributes[attrName]);
             }
         }
     }
 }
 public Settable(SetType type)
 {
     mKey = type.ToString();
     SettableList.Add(type, this);
 }
 public LoreweaveRecipe(SetType setType = SetType.Normal) : base(10)
 {
     _setType = setType;
     Name     = $"{_setType.ToString()} Loreweave";
 }
Beispiel #11
0
 public void SetForeach(string id, SetType setType, params object[] formatValues)
 {
     string text = string.Empty;
     XmlNode node = GetByID(id);
     if (node == null)
     {
         return;
     }
     switch (setType)
     {
         case SetType.InnerText:
             text = node.InnerText;
             break;
         case SetType.InnerXml:
             text = node.InnerXml;
             break;
         case SetType.Value:
         case SetType.Href:
         case SetType.Src:
         case SetType.Class:
             string key = setType.ToString().ToLower();
             if (node.Attributes[key] != null)
             {
                 text = node.Attributes[key].Value;
             }
             break;
     }
     SetForeach(node, text, formatValues);
 }
Beispiel #12
0
 public void Set(XmlNode node, SetType setType, params string[] values)
 {
     if (node != null)
     {
         switch (setType)
         {
             case SetType.InnerText:
                 node.InnerText = SetValue(node.InnerText, values[0], false);
                 break;
             case SetType.InnerXml:
                 node.InnerXml = SetValue(node.InnerXml, values[0], true);
                 break;
             case SetType.Value:
             case SetType.Href:
             case SetType.Src:
             case SetType.Class:
             case SetType.Disabled:
             case SetType.ID:
             case SetType.Name:
                 string key = setType.ToString().ToLower();
                 SetAttrValue(node, key, values[0]);
                 break;
             case SetType.Custom:
                 SetAttrValue(node, values[0], values[1]);
                 break;
             case SetType.A:
                 node.InnerXml = SetValue(node.InnerXml, values[0], true);
                 if (values.Length > 1)
                 {
                     SetAttrValue(node, "href", values[1]);
                 }
                 break;
             case SetType.Select:
                 foreach (XmlNode option in node.ChildNodes)
                 {
                     if (option.Attributes["value"] != null && option.Attributes["value"].Value == values[0])
                     {
                         SetAttrValue(option, "selected", "selected");
                         break;
                     }
                 }
                 break;
             case SetType.Checked:
                 if (values[0] == "1" || values[0].ToLower() == "true")
                 {
                     key = setType.ToString().ToLower();
                     SetAttrValue(node, key, key);
                 }
                 break;
         }
     }
 }