コード例 #1
0
    private static void ReadExcelDecks()
    {
        DataRowCollection collect = ExcelAccess.ReadExcel("Res/Excel/GameData.xlsx", "decks");

        for (int i = 2; i < collect.Count; i++)
        {
            DeckProperty role = new DeckProperty
            {
                id = int.Parse(collect[i][0].ToString())
            };
            string   value = collect[i][1].ToString();
            string[] array = value.Split(',');
            if (array == null || array.Length == 0)
            {
                role.Deck = new int[] { int.Parse(value) }
            }
            ;
            else
            {
                role.Deck = new int[array.Length];
                for (int k = 0; k < array.Length; k++)
                {
                    role.Deck[k] = int.Parse(array[k]);
                }
            }
            AssetDatabase.CreateAsset(role, "Assets/Res/DataAsset/deck/deck" + role.id + ".asset");
        }
    }
コード例 #2
0
    public static List <ExcelTableEntity> SelectTables(string tableName)
    {
        DataRowCollection       collect = ExcelAccess.ReadExcel(tableName, SheetNames[0]);
        List <ExcelTableEntity> list    = new List <ExcelTableEntity>();

        for (int i = 1; i < collect.Count; i++)
        {
            ExcelTableEntity e = new ExcelTableEntity();
            if (collect[i][0].ToString() == "")
            {
                continue;
            }
            e.ID   = collect[i][0].ToString();
            e.Type = collect[i][1].ToString();
            if (tableName == ExcelName)
            {
                e.Time             = collect[i][2].ToString();
                e.TimeContent      = collect[i][3].ToString();
                e.WinningContent   = collect[i][4].ToString();
                e.FailContent      = collect[i][5].ToString();
                e.FialContentDrop  = collect[i][6].ToString();
                e.WinTime          = collect[i][7].ToString();
                e.FailTime         = collect[i][8].ToString();
                e.WinningAfter     = collect[i][9].ToString();
                e.WinningAfterTime = collect[i][10].ToString();
            }
            list.Add(e);
        }
        return(list);
    }
コード例 #3
0
    //查询menu表
    public static List <Menu> SelectMenuTable()
    {
        string            excelName = Excel + ".xlsx";
        string            sheetName = "sheet1";
        DataRowCollection collect   = ExcelAccess.ReadExcel(excelName, sheetName);

        List <Menu> menuArray = new List <Menu>();

        for (int i = 1; i < collect.Count; i++)
        {
            if (collect[i][1].ToString() == "")
            {
                continue;
            }

            Menu menu = new Menu
            {
                m_Id       = collect[i][0].ToString(),
                m_level    = collect[i][1].ToString(),
                m_parentId = collect[i][2].ToString(),
                m_name     = collect[i][3].ToString()
            };
            menuArray.Add(menu);
        }
        return(menuArray);
    }
コード例 #4
0
    private static void ReadExcelRounds()
    {
        DataRowCollection collect = ExcelAccess.ReadExcel("Res/Excel/GameData.xlsx", "rounds");

        for (int i = 2; i < collect.Count; i++)
        {
            RoundProperty role = new RoundProperty
            {
                id        = int.Parse(collect[i][0].ToString()),
                maxRound  = int.Parse(collect[i][1].ToString()),
                NeedPerse = collect[i][2].ToString() == "1"?true:false,
                Des       = collect[i][3].ToString(),
                TargetDes = collect[i][4].ToString(),
                playerId  = int.Parse(collect[i][5].ToString()),
                npcId     = int.Parse(collect[i][6].ToString()),
                title     = collect[i][7].ToString(),
                title0    = collect[i][8].ToString(),
                title1    = collect[i][9].ToString(),
            };
            List <string> rules = new List <string>();
            if (!collect[i].IsNull(10))
            {
                rules.Add(collect[i][10].ToString());
            }
            if (!collect[i].IsNull(11))
            {
                rules.Add(collect[i][11].ToString());
            }
            role.Rules = rules.ToArray();
            List <RoundGoal> funcList = new List <RoundGoal>();

            int N = (collect[i].ItemArray.Length - 11) / 4;
            for (int j = 0; j < N; j++)
            {
                if (collect[i].IsNull(12 + j * 4))
                {
                    j = N;
                    break;
                }
                RoundGoal temp = new RoundGoal();

                temp.GoalType      = (RoundGoalType)int.Parse(collect[i][12 + j * 4].ToString());
                temp.Target        = (TargetType)int.Parse(collect[i][13 + j * 4].ToString());
                temp.GoalCondition = (RoundGoalCondition)int.Parse(collect[i][14 + j * 4].ToString());
                temp.Value         = int.Parse(collect[i][15 + j * 4].ToString());

                funcList.Add(temp);
            }
            role.Goals = funcList.ToArray();
            AssetDatabase.CreateAsset(role, "Assets/Res/DataAsset/round/round" + role.id + ".asset");
        }
    }
コード例 #5
0
    private static void ReadExcelCards()
    {
        DataRowCollection collect = ExcelAccess.ReadExcel("Res/Excel/GameData.xlsx", "cards");

        for (int i = 2; i < collect.Count; i++)
        {
            CardProperty role = new CardProperty
            {
                id       = int.Parse(collect[i][0].ToString()),
                tid      = int.Parse(collect[i][1].ToString()),
                CardName = collect[i][2].ToString(),
                Des      = collect[i][3].ToString(),
            };
            List <FunctionData> funcList = new List <FunctionData>();

            int N = (collect[i].ItemArray.Length - 4) / 4;
            for (int j = 0; j < N; j++)
            {
                if (collect[i].IsNull(4 + j * 4))
                {
                    j = N;
                    break;
                }
                FunctionData temp = new FunctionData();

                temp.type   = (CardType)int.Parse(collect[i][4 + j * 4].ToString());
                temp.func   = (CardFunc)int.Parse(collect[i][5 + j * 4].ToString());
                temp.target = (TargetType)int.Parse(collect[i][6 + j * 4].ToString());
                string   value = collect[i][7 + j * 4].ToString();
                string[] array = value.Split(',');
                if (array == null || array.Length == 0)
                {
                    temp.Values = new int[] { int.Parse(value) }
                }
                ;
                else
                {
                    temp.Values = new int[array.Length];
                    for (int k = 0; k < array.Length; k++)
                    {
                        temp.Values[k] = int.Parse(array[k]);
                    }
                }
                funcList.Add(temp);
            }
            role.functions = funcList.ToArray();
            AssetDatabase.CreateAsset(role, "Assets/Res/DataAsset/card/card" + role.id + ".asset");
        }
    }
コード例 #6
0
    private static void ReadExcelRoles()
    {
        DataRowCollection collect = ExcelAccess.ReadExcel("Res/Excel/GameData.xlsx", "roles");

        for (int i = 2; i < collect.Count; i++)
        {
            RoleProperty role = new RoleProperty
            {
                id     = int.Parse(collect[i][0].ToString()),
                Money  = int.Parse(collect[i][1].ToString()),
                Honor  = int.Parse(collect[i][2].ToString()),
                Amity  = int.Parse(collect[i][3].ToString()),
                DeckId = int.Parse(collect[i][4].ToString())
            };
            AssetDatabase.CreateAsset(role, "Assets/Res/DataAsset/role/role" + role.id + ".asset");
        }
    }
コード例 #7
0
    public static void ParseXlsToPrto(string xmlFile, string outDirectory)
    {
        if (!xmlFile.ToLower().Contains("cfg_"))
        {
            return;
        }
        xmlFile = xmlFile.Replace("\\", "/");

        DataRowCollection data = ExcelAccess.ReadExcel(xmlFile, 0, ExcelAccess.ExcelType.xls);

        string name = Path.GetFileNameWithoutExtension(xmlFile);

        JCExcel excel = new JCExcel(xmlFile);

        StringBuilder sb = new StringBuilder();

        sb.AppendLine("package TABLE;");
        sb.AppendLine("import \"table_common.proto\";");
        sb.AppendLine("");
        sb.AppendLine(string.Format("message {0}", name.ToUpper()));

        sb.AppendLine("{");

        ContentType type         = ContentType.None;
        string      typeName     = string.Empty;
        string      protoName    = string.Empty;
        string      typeProperty = string.Empty;

        List <string> idLidst = new List <string>();

        for (int i = 0; i < excel.ColumnCount; i++)
        {
            if (excel.IsConformTypeNameNorm(i, out type, out protoName, out typeProperty))
            {
                if (type == ContentType.stringValue)
                {
                    typeName = "string";
                }
                else if (type == ContentType.floatValue)
                {
                    typeName = "float";
                }
                else
                {
                    typeName = type.ToString();
                }

                //每列数据的检查
                if (!excel.CheckColumnContent(i, type))
                {
                    continue;
                }

                if (string.IsNullOrEmpty(protoName))
                {
                    continue;
                }

                //避免同名的出现
                if (idLidst.Contains(protoName))
                {
                    MessageBox.Show(string.Format("{0} {1}列出现重复名称{2}", xmlFile, i + 1, protoName));
                    continue;
                }

                idLidst.Add(protoName);
                if (excel.GetTitle(i) == "合并字段")
                {
                    sb.AppendLine("    //" + excel.GetDesc(i));
                    sb.AppendLine(string.Format("\t{0}{1} {2} {3} = {4};",
                                                (excel.IsClientUse(i) ? "" : "//"), "required", typeName, protoName, i + 1));
                }
                else
                {
                    sb.AppendLine(string.Format("\t{0}{1} {2} {3} = {4};//{5}  {6}",
                                                (excel.IsClientUse(i) ? "" : "//"), typeProperty, typeName, protoName, i + 1, excel.GetTitle(i), excel.GetDesc(i)));
                }
            }
        }

        sb.AppendLine("}");

        sb.AppendLine("");

        sb.AppendLine(string.Format("message {0}", name.ToUpper() + "ARRAY"));

        sb.AppendLine("{");
        sb.AppendLine(string.Format("\trepeated {0} rows = 1;", name.ToUpper()));
        sb.AppendLine("}");

        Utility.SaveFileContent(outDirectory + "/c_table_" + name.ToLower() + ".proto", sb.ToString());
    }