Exemplo n.º 1
0
 public SwordsManContainer(int nSize, PACK_TYPE nType)
 {
     m_ContainerSize = nSize;
     m_ContainerType = nType;
     for (int i = 0; i < m_ContainerSize; ++i)
     {
         m_Items.Add(new SwordsMan());
     }
 }
    static void ImportedAssets(string path, string [] lines)
    {
        PACK_TYPE pack_type = PACK_TYPE.END;
        string    line, header_name = "", class_name = "", header_line;

        string []     splits;
        List <string> split_list = new List <string>();
        List <string> var_list   = new List <string>();
        List <string> code_list  = new List <string>();
        bool          derived    = false;

        string [] sep_basic = { "\t", " ", ":" };

        for (int i = 0; i < lines.Length; i++)
        {
            line = lines[i].Trim();

            switch (pack_type)
            {
            case PACK_TYPE.END:
                if (line.Contains("//<Binary_Pack>") == true)
                {
                    pack_type   = PACK_TYPE.INIT;
                    derived     = false;
                    header_name = "";
                    class_name  = "";
                    var_list.Clear();
                }
                break;

            case PACK_TYPE.INIT:
                if (line.Contains("//<Binary_Pack_Start>") == true)
                {
                    pack_type = PACK_TYPE.START;
                }
                else if (class_name.Length == 0)
                {
                    header_line = line;
                    if (header_line.Contains("where") == true)
                    {
                        header_line = header_line.Substring(0, header_line.IndexOf("where") + 1);
                    }

                    splits = header_line.Split(sep_basic, System.StringSplitOptions.RemoveEmptyEntries);

                    split_list.Clear();
                    split_list.AddRange(splits);

                    int    finds    = 0;
                    string cls_name = "";
                    for (int j = 0; j < split_list.Count; j++)
                    {
                        if (split_list[j].StartsWith("//") == true)
                        {
                            break;
                        }

                        switch (split_list[j])
                        {
                        case "public":
                            break;

                        case "partial":
                            break;

                        case "class":
                            cls_name = split_list[j + 1];
                            break;

                        default:
                            continue;
                        }

                        finds++;
                    }
                    if (finds == 3)
                    {
                        if (header_line.Contains(":") == true)
                        {
                            derived = true;
                        }
                        header_name = line;
                        class_name  = cls_name;
                    }
                }
                break;

            case PACK_TYPE.START:
                if (line.Contains("//<Binary_Pack_End>") == true)
                {
                    pack_type = PACK_TYPE.END;

                    ChangeData(ref code_list, derived, header_name, class_name, var_list);

                    var_list.Clear();
                }
                else
                {
                    var_list.Add(line);
                }
                break;
            }
        }

        if (code_list.Count > 0)
        {
            CreateFile(path, code_list);
        }
    }