private void buttonDone_Click(object sender, RoutedEventArgs e) { try { ClothesData editClothes = XApp.db.ClothesData.FirstOrDefault(item => item.ID == selectItem.ID); editClothes.Size = int.Parse(txtSize.Text); editClothes.Title = txtTitle.Text; editClothes.Structure = txtStructured.Text; editClothes.Style = comboBoxStyle.Text; editClothes.Country = comboBoxCountry.Text; editClothes.Brend = comboBoxBrend.Text; editClothes.Price = Convert.ToDouble(txtPrice.Text); editClothes.Date = (DateTime)dateOfDelivery.SelectedDate; editClothes.Category = comboBoxCategory.Text; editClothes.Gender = comboBoxGender.Text; editClothes.ProviderTitle = comboBoxProviderTitle.Text; // Разбиваем изображение на массив байтов MemoryStream stream = new MemoryStream(); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create((BitmapImage)photos.Source)); encoder.Save(stream); editClothes.Photo = stream.ToArray(); XApp.db.SaveChanges(); MessageBox.Show("Данные успешно сохранены", "Итог опреции добавления.", MessageBoxButton.OK, MessageBoxImage.Information); NavigationService.GoBack(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CloneItemClothesType(List <Sprite> sp, int type) { for (int i = 0; i < sp.Count; i++) { //SaveSystem.A_AddClothes(i, type); GameObject clone = Instantiate(item.gameObject, parent); clone.name = i.ToString(); ClothesData data = clone.AddComponent <ClothesData>(); data.id = i; data.type = type; data.price = priceListData[i]; clone.SetActive(true); clone.transform.GetChild(0).GetComponent <Image>().sprite = sp[i]; clone.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = priceListData[i].ToString(); for (int t = 0; t < player.inventory.clothes.Count; t++) { if (player.inventory.clothes[t].type == type) { if (player.inventory.clothes[t].id == i) { data.count = player.inventory.clothes[t].count; } } } clone.transform.GetChild(2).GetComponent <Text>().text = data.count <= 0 ? "" : data.count.ToString(); } }
private void LoadData() { string jsonString = userDataManager.LoadClothes(); if (jsonString != "") { var temp = GetComponent <ClothesSwitcher>(); ClothesData data = new ClothesData(); data = JsonConvert.DeserializeObject <ClothesData>(jsonString); temp.ChangeClothes(ClotheType.Hat, data.hat); temp.ChangeClothes(ClotheType.Glasses, data.glasses); temp.ChangeClothes(ClotheType.Accessory, data.accessory); temp.ChangeClothes(ClotheType.Shirt, data.shirt); Color color; if (ColorUtility.TryParseHtmlString(data.color, out color)) { this.transform.GetChild(1).gameObject.GetComponent <Image>().color = color; this.transform.GetChild(2).gameObject.GetComponent <Image>().color = color; } } else { Debug.LogWarning("Save data not found!"); } }
public clothesEditPage(ClothesData selectItem) { InitializeComponent(); this.selectItem = selectItem; txtTitle.Text = selectItem.Title; txtSize.Text = selectItem.Size.ToString(); txtStructured.Text = selectItem.Structure; comboBoxStyle.Text = selectItem.Style; comboBoxCountry.Text = selectItem.Country; comboBoxBrend.Text = selectItem.Brend; txtPrice.Text = selectItem.Price.ToString(); dateOfDelivery.SelectedDate = (DateTime)selectItem.Date; comboBoxGender.Text = selectItem.Gender; comboBoxCategory.Text = selectItem.Category; comboBoxProviderTitle.Text = selectItem.ProviderTitle; if (selectItem.Photo != null) { BitmapImage bitmap = new BitmapImage(); using (MemoryStream stream = new MemoryStream(selectItem.Photo)) { bitmap.BeginInit(); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.StreamSource = stream; bitmap.EndInit(); } photos.Source = bitmap; } }
private void Awake() { playerHealth = stat.health; playerMagic = stat.magic; playerName = stat.name; weapon = stat.weapons; shirt = stat.shirt; pants = stat.pants; }
public void Preview(GameObject obj) { SoundManager.Ins.PlaySound(SoundManager.Ins._Select); furnitureData = obj.transform.parent.GetComponent <FurnitureData>(); clothesData = obj.transform.parent.GetComponent <ClothesData>(); foodData = obj.transform.parent.GetComponent <FoodData>(); price = furnitureData != null ? furnitureData.price : price; price = clothesData != null ? clothesData.price : price; price = foodData != null ? foodData.price : price; coin = SaveSystem.A_Coin(); previewImage.sprite = obj.GetComponent <Image>().sprite; cost.text = obj.transform.parent.GetChild(1).GetChild(0).GetComponent <Text>().text; previewObj.SetActive(true); }
public void SaveData() { ClothesData data = new ClothesData(); data.hat = Hat; data.glasses = Glasses; data.accessory = Accessory; data.shirt = Shirt; string colorHTML = ColorUtility.ToHtmlStringRGB(this.transform.GetChild(1).gameObject.GetComponent <Image>().color); data.color = "#" + colorHTML; string json = JsonConvert.SerializeObject(data); userDataManager.SaveClothes(json); SceneSwitcher.GoToHomeScreen(); }
public async Task OnGetAsync(int?id, int?categoryID) { ClothesD = new ClothesData(); ClothesD.Clothes = await _context.Clothes .Include(b => b.Brand) .Include(b => b.ClothesCategories) .ThenInclude(b => b.Category) .AsNoTracking() .OrderBy(b => b.Name) .ToListAsync(); if (id != null) { ClothesID = id.Value; Clothes clothes = ClothesD.Clothes .Where(i => i.ID == id.Value).Single(); ClothesD.Categories = clothes.ClothesCategories.Select(s => s.Category); } }
// Передаем выбранные данные в страницу редактирования для внесения изменений private void buttonEdit_Click(object sender, RoutedEventArgs e) { try { ClothesData editClothes = (ClothesData)clothesDataView.SelectedItem; if (editClothes != null) { NavigationService.Navigate(new clothesEditPage(editClothes)); } else { throw new Exception("Пожалуйста, выберите запись, которую хотите отредактировать!"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } }
// Удаления выбранной записи private void buttonRemove_Click(object sender, RoutedEventArgs e) { try { ClothesData selectedItem = (ClothesData)clothesDataView.SelectedItem; if (MessageBox.Show("Вы действительно хотите удалить выбранную вами запись? Данные будут удалены без возможности восстановления!", "Внимание!", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { ClothesData removeClothes = XApp.db.ClothesData.FirstOrDefault(item => item.ID == selectedItem.ID); XApp.db.ClothesData.Remove(removeClothes); XApp.db.SaveChanges(); Page_Loaded(null, null); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CallbackPreview(bool bo) { if (bo) { if (coin >= price)//check coin { PopupWaiting(); avatarPreview.SetActive(false); previewObj.SetActive(false); SaveSystem.A_MinusCoin(price); if (furnitureData != null) { SaveSystem.A_AddFurniture(furnitureData.id, furnitureData.type); //List<Furniture> furnitures = SaveSystem.A_LoadFurniture(); //var furCount = from f in furnitures // where f.id == furnitureData.id && f.type == furnitureData.type // select f; string ttt = furnitureData.transform.GetChild(2).GetComponent <Text>().text; if (ttt == "") { ttt = "0"; } int count = int.Parse(ttt); count += 1; furnitureData.transform.GetChild(2).GetComponent <Text>().text = count.ToString(); if (furnitureData.type == (int)FurnitureType.Wallpaper || furnitureData.type == (int)FurnitureType.Floor) { furnitureData.gameObject.GetComponentInChildren <Button>().interactable = false; } } else if (clothesData != null) { SaveSystem.A_AddClothes(clothesData.id, clothesData.type); clothesData.count++; clothesData.transform.GetChild(2).GetComponent <Text>().text = clothesData.count.ToString(); } else if (foodData != null) { SaveSystem.A_AddFood(foodData.id); foodData.count++; foodData.transform.GetChild(2).GetComponent <Text>().text = foodData.count.ToString(); } else { Debug.Log("Can not add the item"); } furnitureData = null; clothesData = null; } else { Popup.Ins.PopupOne("Not enough money", "OK", null); } } else { avatarPreview.SetActive(false); previewObj.SetActive(false); } }
public void LoadItem() { itemList = new List <Sprite>(); switch (pathLoad) { case "Ac": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.ac)); break; case "Shirt": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.shirt)); break; case "Pant": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.pant)); break; case "Shoe": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothesPre.shoe)); break; case "Bed": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.bed)); break; case "Decoration": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.decoration)); break; case "Floor": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.floor)); break; case "Furniture": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.furniture)); break; case "Other": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.other)); break; case "Wallpaper": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.furPre.wallpaper)); break; case "Food": itemList.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.food.food)); break; } for (int i = 0; i < itemList.Count; i++) { ClothesData c = new ClothesData(); FurnitureData f = new FurnitureData(); FoodData fo = new FoodData(); Player player = SaveSystem.A_LoadSaveGame(); item.GetComponent <Image>().sprite = itemList[i]; GameObject clone = Instantiate(item, parent); clone.name = i.ToString(); if (clothesType != ClothesType.None) { c = clone.AddComponent <ClothesData>(); c.id = i; } else if (furnitureType != FurnitureType.None) { f = clone.AddComponent <FurnitureData>(); f.id = i; } else if (foodType != FoodType.None) { fo = clone.AddComponent <FoodData>(); fo.id = i; } switch (furnitureType) { case FurnitureType.Decoration: for (int y = 0; y < player.inventory.furniture.Count; y++) { if (player.inventory.furniture[y].type == (int)FurnitureType.Decoration) { if (player.inventory.furniture[y].id == i) { clone.SetActive(true); f.CloneData(player.inventory.furniture[y]); } } } break; case FurnitureType.Bed: for (int y = 0; y < player.inventory.furniture.Count; y++) { if (player.inventory.furniture[y].type == (int)FurnitureType.Bed) { if (player.inventory.furniture[y].id == i) { clone.SetActive(true); f.CloneData(player.inventory.furniture[y]); } } } break; case FurnitureType.Windows: for (int y = 0; y < player.inventory.furniture.Count; y++) { if (player.inventory.furniture[y].type == (int)FurnitureType.Windows) { if (player.inventory.furniture[y].id == i) { clone.SetActive(true); f.CloneData(player.inventory.furniture[y]); } } } break; case FurnitureType.Floor: for (int y = 0; y < player.inventory.furniture.Count; y++) { if (player.inventory.furniture[y].type == (int)FurnitureType.Floor) { if (player.inventory.furniture[y].id == i) { clone.SetActive(true); f.CloneData(player.inventory.furniture[y]); } } } break; case FurnitureType.Wallpaper: for (int y = 0; y < player.inventory.furniture.Count; y++) { if (player.inventory.furniture[y].type == (int)FurnitureType.Wallpaper) { if (player.inventory.furniture[y].id == i) { clone.SetActive(true); f.CloneData(player.inventory.furniture[y]); } } } break; case FurnitureType.Toy: for (int y = 0; y < player.inventory.furniture.Count; y++) { if (player.inventory.furniture[y].type == (int)FurnitureType.Toy) { if (player.inventory.furniture[y].id == i) { clone.SetActive(true); f.CloneData(player.inventory.furniture[y]); } } } break; } if (furnitureType != FurnitureType.None) { int t = (from tt in player.inventory.furniture where f.id == tt.id && f.type == tt.type && !tt.furnitureIsUsing select tt).Count(); Text txt = clone.GetComponentInChildren <Text>(); if (t > 0) { txt.text = t.ToString(); } else { txt.text = "0"; } } switch (clothesType) { case ClothesType.Accessories: for (int y = 0; y < player.inventory.clothes.Count; y++) { if (player.inventory.clothes[y].type == (int)ClothesType.Accessories) { if (player.inventory.clothes[y].id == i) { clone.SetActive(true); c.CloneData(player.inventory.clothes[y]); } } } break; case ClothesType.Shirts: for (int y = 0; y < player.inventory.clothes.Count; y++) { if (player.inventory.clothes[y].type == (int)ClothesType.Shirts) { if (player.inventory.clothes[y].id == i) { clone.SetActive(true); c.CloneData(player.inventory.clothes[y]); } } } break; case ClothesType.Pants: for (int y = 0; y < player.inventory.clothes.Count; y++) { if (player.inventory.clothes[y].type == (int)ClothesType.Pants) { if (player.inventory.clothes[y].id == i) { clone.SetActive(true); c.CloneData(player.inventory.clothes[y]); } } } break; case ClothesType.Shoes: for (int y = 0; y < player.inventory.clothes.Count; y++) { if (player.inventory.clothes[y].type == (int)ClothesType.Shoes) { if (player.inventory.clothes[y].id == i) { clone.SetActive(true); c.CloneData(player.inventory.clothes[y]); } } } break; } if (clothesType != ClothesType.None) { try { Clothes t = (from tt in player.inventory.clothes where c.id == tt.id && c.type == tt.type select tt).First(); Text txt = clone.GetComponentInChildren <Text>(); if (t.count > 0) { txt.text = t.count.ToString(); foreach (Pet p in player.pets) { if (clothesType == ClothesType.Shirts && p.shirtWearing == c.id) { txt.text = (int.Parse(txt.text) - 1).ToString(); } else if (clothesType == ClothesType.Pants && p.pantWearing == c.id) { txt.text = (int.Parse(txt.text) - 1).ToString(); } else if (clothesType == ClothesType.Shoes && p.shoeWearing == c.id) { txt.text = (int.Parse(txt.text) - 1).ToString(); } else if (clothesType == ClothesType.Accessories && p.accessoriesWearing == c.id) { txt.text = (int.Parse(txt.text) - 1).ToString(); } } } else { txt.text = "0"; } } catch { } } switch (foodType) { case FoodType.Food: for (int y = 0; y < player.inventory.foods.Count; y++) { if (player.inventory.foods[y].id == i && player.inventory.foods[y].count > 0) { clone.SetActive(true); fo.CloneData(player.inventory.foods[y]); } } break; } if (foodType != FoodType.None) { try { Food t = (from tt in player.inventory.foods where fo.id == tt.id select tt).First(); Text txt = clone.GetComponentInChildren <Text>(); if (t.count > 0) { txt.text = t.count.ToString(); } else { txt.text = "0"; } } catch { } } } }
public void SelectClothes(GameObject obj) { if (petAI == null) { return; } int count = int.Parse(obj.GetComponentInChildren <Text>().text); ClothesData data = obj.GetComponent <ClothesData>(); List <Sprite> sprite = new List <Sprite>(); //petData = SaveSystem.A_LoadPet(petAI.id); if (data.type == (int)ClothesType.Shirts) { if (count <= 0 && petData.shirtWearing != data.id) { return; } if (petData.shirtWearing != -1) { ClothesData[] clothesDatas = obj.transform.parent.GetComponentsInChildren <ClothesData>(); foreach (ClothesData c in clothesDatas) { if (petData.shirtWearing == c.id) { int cc = int.Parse(c.GetComponentInChildren <Text>().text); c.GetComponentInChildren <Text>().text = (cc + 1).ToString(); if (petData.shirtWearing == data.id) { petData.shirtWearing = -1; petAI.shirtBody.sprite = null; petAI.shirtLeft.sprite = null; petAI.shirtRight.sprite = null; //SaveSystem.A_EditPet(petData, false); return; } if (count <= 0) { return; } } } } petData.shirtWearing = data.id; sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.shirt.number[data.id])); if (sprite.Count > 1) { foreach (Sprite s in sprite) { if (s.name.ToLower().Contains("body")) { petAI.shirtBody.sprite = s; } else if (s.name.ToLower().Contains("left")) { petAI.shirtLeft.sprite = s; } else if (s.name.ToLower().Contains("right")) { petAI.shirtRight.sprite = s; } } } else { petAI.shirtBody.sprite = sprite[0]; petAI.shirtLeft.sprite = null; petAI.shirtRight.sprite = null; } } else if (data.type == (int)ClothesType.Pants) { if (count <= 0 && petData.pantWearing != data.id) { return; } if (petData.pantWearing != -1) { ClothesData[] clothesDatas = obj.transform.parent.GetComponentsInChildren <ClothesData>(); foreach (ClothesData c in clothesDatas) { if (petData.pantWearing == c.id) { int cc = int.Parse(c.GetComponentInChildren <Text>().text); c.GetComponentInChildren <Text>().text = (cc + 1).ToString(); if (petData.pantWearing == data.id) { petData.pantWearing = -1; petAI.pantBody.sprite = null; petAI.pantLeft.sprite = null; petAI.pantRight.sprite = null; //SaveSystem.A_EditPet(petData, false); return; } if (count < 0) { return; } } } } petData.pantWearing = data.id; sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.pant.number[data.id])); if (sprite.Count > 1) { foreach (Sprite s in sprite) { if (s.name.ToLower().Contains("body")) { petAI.pantBody.sprite = s; } else if (s.name.ToLower().Contains("left")) { petAI.pantLeft.sprite = s; } else if (s.name.ToLower().Contains("right")) { petAI.pantRight.sprite = s; } } } else { petAI.pantBody.sprite = sprite[0]; petAI.pantLeft.sprite = null; petAI.pantRight.sprite = null; } } else if (data.type == (int)ClothesType.Shoes) { if (count <= 0 && petData.shoeWearing != data.id) { return; } if (petData.shoeWearing != -1) { ClothesData[] clothesDatas = obj.transform.parent.GetComponentsInChildren <ClothesData>(); foreach (ClothesData c in clothesDatas) { if (petData.shoeWearing == c.id) { int cc = int.Parse(c.GetComponentInChildren <Text>().text); c.GetComponentInChildren <Text>().text = (cc + 1).ToString(); if (petData.shoeWearing == data.id) { petData.shoeWearing = -1; petAI.shoeLeft.sprite = null; petAI.shoeRight.sprite = null; //SaveSystem.A_EditPet(petData, false); return; } if (count < 0) { return; } } } } petData.shoeWearing = data.id; sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.shoe.number[data.id])); foreach (Sprite s in sprite) { if (s.name.ToLower().Contains("left")) { petAI.shoeLeft.sprite = s; } else if (s.name.ToLower().Contains("right")) { petAI.shoeRight.sprite = s; } } } else if (data.type == (int)ClothesType.Accessories) { if (count <= 0 && petData.accessoriesWearing != data.id) { return; } if (petData.accessoriesWearing != -1) { ClothesData[] clothesDatas = obj.transform.parent.GetComponentsInChildren <ClothesData>(); foreach (ClothesData c in clothesDatas) { if (petData.accessoriesWearing == c.id) { int cc = int.Parse(c.GetComponentInChildren <Text>().text); c.GetComponentInChildren <Text>().text = (cc + 1).ToString(); if (petData.accessoriesWearing == data.id) { petData.accessoriesWearing = -1; petAI.ac.sprite = null; //SaveSystem.A_EditPet(petData, false); return; } if (count < 0) { return; } } } } petData.accessoriesWearing = data.id; sprite.AddRange(Atlas.Ins.GetSprites(Atlas.Ins.clothes.ac)); petAI.ac.sprite = sprite[data.id]; } obj.GetComponentInChildren <Text>().text = (count - 1).ToString(); //SaveSystem.A_EditPet(petData,true); }