Beispiel #1
0
 private void RetrievingData()
 {
     ReadExcelOnline.Connect();
     data.botNames = new List <CountryBotName>();
     ReadExcelOnline.GetTable(ID, SheetName, delegate(IDictionary <int, Dictionary <int, string> > dictionary)
     {
         var max = dictionary[0].Count;
         for (int i = 1; i < max; i += 2)
         {
             var c         = new CountryBotName();
             var s         = dictionary[0][i].ToString();
             c.countryName = GetSubString(s, '/');
             c.countryCode = s.Replace(c.countryName, "").Replace("/", "");
             var path      = "Assets/Games/Sprites/Flag/" + c.countryName + ".png";
             c.icon        = AssetDatabase.LoadAssetAtPath <Sprite>(path);
             //PingObj(path);
             c.botName = new List <string>();
             var count = 1;
             for (int j = 1;; j++)
             {
                 if (dictionary.ContainsKey(j))
                 {
                     if (dictionary[j].ContainsKey(i))
                     {
                         if (dictionary[j][i] != "")
                         {
                             c.botName.Add(dictionary[j][i]);
                         }
                     }
                     else
                     {
                         break;
                     }
                 }
                 else
                 {
                     break;
                 }
             }
             data.botNames.Add(c);
         }
     });
 }
    public void RetrievingData()
    {
        // var path = "Assets/Skin";
        // Object[] data = Resources.LoadAll(path, typeof(Sprite));
        // Debug.Log(data.Length);
        // foreach (var item in data)
        // {
        //     Debug.Log(item);
        // }
        var sp = GameHelper.GetAllAssetAtPath <Sprite>("", "Assets/Skin");

        ReadExcelOnline.Connect();
        ReadExcelOnline.GetTable(ID, sheetName, d =>
        {
            // foreach (var key in d.Keys)
            // {
            //     var rows = d[key];
            //     foreach (var item in rows.Keys)
            //     {
            //         Debug.Log(rows[item] + "  " + key + "  " + item);
            //     }
            // }

            if (data.figures.Count > 0)
            {
                int c = 0;

                foreach (var key in d.Keys)
                {
                    if (c < data.figures.Count)
                    {
                        if (key < 1)
                        {
                            continue;
                        }

                        var rows          = d[key];
                        var temp          = new InfoFigure();
                        temp.heroName     = rows[1];
                        temp.figureSprite = sp.Find(n => n.name.ToLower().Contains(temp.heroName.ToLower()));

                        var dataSke = GameHelper.GetAllAssetAtPath <SkeletonDataAsset>(null, "Assets/skin-animation/" + temp.heroName + "-ani");
                        temp.asset  = dataSke[5];

                        temp.idFigure = int.Parse(rows[0]) - 1;
                        var s         = rows[2];
                        if (s.Contains("enemy"))
                        {
                            temp.costType = CostType.KillEnemy;
                            temp.mission  = s;

                            // find and convert
                            string numericString = "";
                            foreach (char ch in s)
                            {
                                // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces.
                                if ((ch >= '0' && ch <= '9') || ch == ' ' || ch == '-')
                                {
                                    numericString = string.Concat(numericString, ch);
                                }
                            }
                            if (int.TryParse(numericString, out int j))
                            {
                                temp.number = j;
                            }
                        }
                        else if (s.Contains("videos"))
                        {
                            temp.costType = CostType.Video;

                            // find and convert
                            string numericString = "";
                            foreach (char ch in s)
                            {
                                // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces.
                                if ((ch >= '0' && ch <= '9') || ch == ' ' || ch == '-')
                                {
                                    numericString = string.Concat(numericString, ch);
                                }
                            }
                            if (int.TryParse(numericString, out int j))
                            {
                                temp.number = j;
                            }
                        }
                        else if (s.Contains("Tournament"))
                        {
                            temp.costType = CostType.Tournament;
                            temp.mission  = "Phần thưởng vô địch Tournament";
                        }
                        else if (s.Contains("Rate"))
                        {
                            temp.costType = CostType.Rate;
                            temp.mission  = s;
                        }
                        else if (s.Contains("Free"))
                        {
                            temp.costType = CostType.Free;
                        }
                        else if (s.Contains("ngày"))
                        {
                            temp.costType = CostType.Day;
                            temp.mission  = s;
                        }
                        else if (s.Contains("Top"))
                        {
                            temp.costType = CostType.Top;
                            temp.mission  = s;

                            // find and convert
                            string numericString = "";
                            foreach (char ch in s)
                            {
                                // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces.
                                if ((ch > '1' && ch <= '9') || ch == ' ' || ch == '-')
                                {
                                    numericString = string.Concat(numericString, ch);
                                }
                            }
                            if (int.TryParse(numericString, out int j))
                            {
                                temp.number = j;
                            }
                        }
                        else if (s.Contains("Chạy"))
                        {
                            temp.costType = CostType.Run;
                            temp.mission  = s;

                            // find and convert
                            string numericString = "";
                            foreach (char ch in s)
                            {
                                // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces.
                                if ((ch >= '0' && ch <= '9') || ch == ' ' || ch == '-')
                                {
                                    numericString = string.Concat(numericString, ch);
                                }
                            }
                            if (int.TryParse(numericString, out int j))
                            {
                                temp.number = j;
                            }
                        }
                        else if (s.Contains("VIP"))
                        {
                            temp.costType = CostType.Vip;
                            temp.mission  = s;
                        }
                        else
                        {
                            temp.costType = CostType.Coin;
                        }

                        if (temp.costType == CostType.Coin)
                        {
                            temp.cost = int.Parse(s);
                        }

                        data.figures[c] = temp;
                        c++;
                    }
                }
            }
        });

        EditorUtility.SetDirty(data);
        AssetDatabase.SaveAssets();
    }