コード例 #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);
         }
     });
 }
コード例 #2
0
    private void OnGUI()
    {
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Refresh"))
        {
            curPlayer = new CountryBotName();
            Refresh();

            if (CountryBotNames.Count != 0)
            {
                curPlayer = CountryBotNames[0];
            }
        }

        // if (GUILayout.Button("Add Brobot"))
        // {
        //     BrobotData bd = GameHelper.GetAllAssetAtPath<BrobotData>(string.Empty, "Assets/Game/Resources/Brobots")[0];
        //     bd.brobotsInfo.Add(new BrobotInfo());
        //     AssetDatabase.Refresh();
        //     Refresh();
        //     Brobots[Brobots.Count - 1].name = BrobotName.BR1;
        //     EditorUtility.SetDirty(bd);
        //     AssetDatabase.SaveAssets();
        // }

        GUILayout.EndHorizontal();

        if (CountryBotNames.Count <= 0)
        {
            return;
        }

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Back"))
        {
            if (PlayerIndex > 0)
            {
                PlayerIndex--;
            }

            curPlayerIndex = PlayerIndex;
            curPlayer      = CountryBotNames[curPlayerIndex];
        }

        PlayerIndex = EditorGUILayout.Popup(curPlayerIndex, CountryBotNames.Select(s => s.countryName.ToString()).ToArray());

        if (GUILayout.Button("Next"))
        {
            if (PlayerIndex < CountryBotNames.Count - 1)
            {
                PlayerIndex++;
            }
            curPlayerIndex = PlayerIndex;
            curPlayer      = CountryBotNames[curPlayerIndex];
        }

        GUILayout.EndHorizontal();

        // if (BrobotIndex != curBrobotIndex)
        // {
        //     curBrobotIndex = BrobotIndex;
        //     curBrobot = Brobots[curBrobotIndex];
        // }


        // if (curBrobot != null)
        // {
        //     DisplayData();
        // }

        // GUILayout.BeginHorizontal();

        //        if (GUILayout.Button("Reset"))
        //        {
        //            foreach (var item in Brobots)
        //            {
        //                item.ResetData();
        //            }
        //            Refresh();
        //        }

        if (GUILayout.Button("Save"))
        {
            EditorUtility.SetDirty(GameHelper.GetAllAssetAtPath <BotNameData>(string.Empty, "Assets/Game/Resources/BotNameData")[0]);
            AssetDatabase.SaveAssets();
        }

        GUILayout.EndHorizontal();
    }