public void CreateItemList() { ItemInList emptyitem = new ItemInList("emtyID", 0); ItemList list = new ItemList(new List <ItemInList> { emptyitem }); JsonData jsonData = JsonMapper.ToJson(list); File.WriteAllText(Application.streamingAssetsPath + "/items.json", jsonData.ToString()); }
private void BookListForm_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (BookListForm.SelectedIndex != -1) { MainGrid.Children.RemoveAt(1); ItemInList elem = (ItemInList)BookListForm.Items.GetItemAt(BookListForm.SelectedIndex); var loader = LoaderManager.GetLoader(elem.Type); GroupBox newGroupBox = FormCreator.CreateGroupBox("MainGroup", "Book", new Thickness(0, 0, 0, 0), 887, 384); Grid g = loader.Load(elem.Data); g.Children.Add(loader.CreateButtonsGroup(elem.Type)); newGroupBox.Content = g; MainGrid.Children.Add(newGroupBox); } }
//Compare the given value in the License with the values found in the server, and gives back if the value has been found #region private bool FoundInList(List<string> ListToSearch, string ValueToSearch) private bool FoundInList(List <string> ListToSearch, string ValueToSearch) { bool blnReturn = false; try { foreach (string ItemInList in ListToSearch) { if (ItemInList.Trim().ToLower() == ValueToSearch.Trim().ToLower()) { blnReturn = true; break; } } } catch (Exception ex) { Debug.WriteLine("BuscarControlar:Controlar.FoundInList - " + ex.ToString()); } return(blnReturn); }
public List <string> GetItemFromList(int _rar, int _count) { string jsonstring = File.ReadAllText(Application.streamingAssetsPath + "/items.json"); JsonData data = JsonMapper.ToObject(jsonstring); int rar = _rar; int count = Random.Range((int)1, _count + 1); List <ItemInList> list = new List <ItemInList>(); List <ItemInList> sorteditem = new List <ItemInList>(); List <string> finalitemID = new List <string>(); for (int i = 0; i < data["items"].Count; i++) { ItemInList item = new ItemInList(data["items"][i]["ID"].ToString(), (int)data["items"][i]["Rare"]); list.Add(item); } foreach (ItemInList item in list) { if (item.Rare <= rar) { sorteditem.Add(item); } else { continue; } } for (int i = 0; i < count; i++) { int indx = Random.Range(0, sorteditem.Count); finalitemID.Add(sorteditem[indx].ID); } return(finalitemID); }