public bool UpdateBagInventory(int BagInventoryId, int ShipperId, int BagId, int Quantity, DateTime StorageDate, bool ActiveBag) { bool isSaved = true; using (WTCCeresEntities db = new WTCCeresEntities()) { try { bi = db.BagInventory.Find(BagInventoryId); bi.ShipperId = ShipperId; bi.BagId = BagId; bi.InitialQuantity = Quantity; bi.StorageDate = StorageDate; bi.ActiveBag = ActiveBag; db.BagInventory.AddOrUpdate(bi); db.SaveChanges(); } catch (Exception ex) { isSaved = false; } } return(isSaved); }
//variables to be saved // public float[] position; //player position at time of save // public int sceneIndex; // public List<OwnedPokemon> ownedPokemon = new List<OwnedPokemon>(); public BagInventoryData(BagInventory inv) { //converts vector3 into a serializable format // position = new float[3]; // position[0] = player.transform.position.x; // position[1] = player.transform.position.y; // position[2] = player.transform.position.z; // //current scene // sceneIndex = player.sceneIndex; }
public static void SaveInventory(BagInventory inv) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/Inventory.fun"; FileStream stream = new FileStream(path, FileMode.Create); BagInventoryData data = new BagInventoryData(inv); formatter.Serialize(stream, data); stream.Close(); Debug.Log("Saved"); }
public void OpenInventory(ItemOther recipeItem) { if (recipeItem.itemOtherType != ItemOtherType.Recipe) { return; } if (isActive) { DestroyItemsObj(); } else { gameObject.SetActive(true); isActive = true; } this.recipeItem = recipeItem; if (playerBag == null) { playerBag = GameObject.FindWithTag("InvBag").GetComponent <BagInventory>(); } XMLStorageRecipes storageRecipes = new XMLStorageRecipes(); XmlStorageItem storagetItem = new XmlStorageItem(); currRecipe = storageRecipes.GetRecipeByRecipeId(recipeItem.RecipeId); if (resultItem == null || resultItem.id != currRecipe.CraftResultID) { resultItem = storagetItem.GetResultItemById(currRecipe.CraftResultID); } ingridients = currRecipe.Ingredients; AddResultItemInObj(resultItem); for (int i = 0; i < ingridients.Count; i++) { Item tempItem = playerBag.GetItemById(ingridients[i].id, true); ingridients[i].item = tempItem; AddItemInObj(ingridients[i], i); } nameResult.text = resultItem.name; chanceResult.text = currRecipe.Сhance + "%"; }
private void Start() { inventory = GameObject.FindGameObjectWithTag("Player").GetComponent <BagInventory>(); }