private void Start() { playerIn = FindObjectOfType <PlayerInventory>(); mainInventory = FindObjectOfType <MainInventory>(); playerQ = FindObjectOfType <PlayerQuickSlot>(); quickSlot = FindObjectOfType <QuickSlot>(); }
public virtual IEnumerator <float> FleeBattleSequence() { Timing.RunCoroutine(BattleMusicManager.StopAudio(1)); BattleEvents.FleeBattleEvent.Raise(); BattleInput._controls.Disable(); EventSystem.current.sendNavigationEvents = false; yield return(Timing.WaitForSeconds(0.5f)); foreach (var member in membersForThisBattle.Where(member => !member.IsDead)) { var position = member.Unit.transform.position; var newPosition = new Vector3(position.x, position.y, position.z - 15); member.Unit.EmptyAnimations(); member.Unit.anim.SetInteger(AnimationHandler.AnimState, 0); member.Unit.anim.SetFloat(AnimationHandler.HorizontalHash, -1); member.Unit.anim.SetBool(AnimationHandler.IsWalkingHash, true); member.Unit.anim.SetBool(AnimationHandler.IsRunningHash, true); member.Unit.transform.DOMove(newPosition, 2); } //yield return Timing.WaitForSeconds(1.5f); MainInventory.ResetHealingItems(); SceneLoadManager.LoadOverworld(); }
private static void SetupMainInventory() { var inventory = GameObject.Find("Main Inventory").GetComponent <Inventory>(); var items = MainInventory.GetInventoryItems(); items.ForEach(i => inventory.AddItem(i, 1)); }
private void InitializeVariables() { saveData = FindObjectOfType <SaveData>(); playerCamera = FindObjectOfType <PlayerCamera>(); dialogueManager = FindObjectOfType <DialogueManager>(); quickSlot = FindObjectOfType <QuickSlot>(); mainInventory = FindObjectOfType <MainInventory>(); }
public override void CopyToInventory(IWindow inventoryWindow) { var window = (InventoryWindow)inventoryWindow; Copying = true; MainInventory.CopyTo(window.MainInventory); Hotbar.CopyTo(window.Hotbar); Copying = false; }
public override bool Use() { base.Use(); var target = Battle.Engine.activeUnit.CurrentTarget; target.CureAilments(ailmentsToCure); CommonMMFeedbacks.HealFeedback.PlayFeedbacks(); MainInventory.RemoveItem(this); return(true); }
public override bool Use() { base.Use(); var target = Battle.Engine.activeUnit.CurrentTarget; target.CureAilments(ailmentsToCure); AudioController.PlayAudio(CommonAudioTypes.Heal); MainInventory.RemoveItem(this); return(true); }
/// <summary> /// Adds a quantity onto a selected item into the inventory dictionary. /// </summary> /// <param name="item">The item to add more to</param> /// <param name="amount">The amount to add onto that item</param> public void AddItem(ItemType item, int amount) { if (MainInventory.ContainsKey(item)) { MainInventory[item] += amount; } else { Debug.Log("Add Item: Item is not in inventory dictionary"); } }
protected virtual void EndOfBattle() { MainInventory.ResetHealingItems(); if (AllEnemiesDead) { BattleEvents.NormalEvent.Raise(BattleEvent.WonBattle); } else if (AllMembersDead) { BattleEvents.NormalEvent.Raise(BattleEvent.LostBattle); } }
/// <summary> /// Views the count of a selected item. /// </summary> /// <param name="item">The item to view the count for</param> /// <returns>The amount of the selected item remaining in the inventory</returns> public int ViewItemCount(ItemType item) { if (MainInventory.ContainsKey(item)) { return(MainInventory[item]); } else { Debug.Log("View Item Count: Item is not in the inventory dictionary"); return(0); } }
/// <summary> /// Loads the inventory from the file specified at object creation and populates /// the inventory dictionary. /// </summary> public void LoadInventory() { //load the inventory if the file exists if (File.Exists(file)) { //open stream using (Stream fs = File.OpenRead(file)) { //create reader BinaryFormatter bf = new BinaryFormatter(); //create deserializing list and get data List <int> listToDeserialize = (List <int>)bf.Deserialize(fs); //setup the inventory dictonary for (int i = 0; i < listToDeserialize.Count; i++) { MainInventory.Add((ItemType)i, listToDeserialize[i]); } } //print out contents if (Constants.IS_DEVELOPER_BUILD) { foreach (KeyValuePair <ItemType, int> item in MainInventory) { Debug.Log(item.Key + " " + item.Value); } } } else { Debug.Log("Inventory: File does not exist. Creating file..."); //setup the inventory dictonary with default 0 values for (int i = 0; i < Enum.GetNames(typeof(ItemType)).Length; i++) { MainInventory.Add((ItemType)i, 0); } //create the file and save the data SaveInventory(); if (File.Exists(file)) { Debug.Log("File now exists"); } } }
public bool HarvestCollectable(MainInventory inventory) { bool answer = inventory.TryAddItem(collectable.GetComponent <CollectableSystem>().inventoryName); if (answer) { PlayerPrefs.DeleteKey(tileData.collectableID); Destroy(collectable); tileData.collectableID = "-1"; tileData.collectableType = ""; } print("i think that i am collecting: " + answer); return(answer); }
/// <summary> /// Removes a quantity from a selected item in the inventory dictionary. /// Items do not go below 0 amount. /// </summary> /// <param name="item">The item to remove amount from</param> /// <param name="amount">The amount to subtract in the inventory</param> public void RemoveItem(ItemType item, int amount) { if (MainInventory.ContainsKey(item)) { if (MainInventory[item] > 0 && (MainInventory[item] - amount >= 0)) { MainInventory[item] -= amount; } else { Debug.Log("Item goes below 0 amount"); } } else { Debug.Log("Remove Item: Item is not in the inventory dictionary"); } }
/// <summary> /// Fills a list with all available weapons in the inventories /// </summary> protected virtual void FillAvailableWeaponsLists() { _availableWeaponsIDs = new List <string> (); if ((CharacterHandleWeapon == null) || (WeaponInventory == null)) { return; } _availableWeapons = MainInventory.InventoryContains(ItemClasses.Weapon); foreach (int index in _availableWeapons) { _availableWeaponsIDs.Add(MainInventory.Content [index].ItemID); } if (!InventoryItem.IsNull(WeaponInventory.Content[0])) { _availableWeaponsIDs.Add(WeaponInventory.Content [0].ItemID); } _availableWeaponsIDs.Sort(); }
/// <summary> /// Grabs references to all inventories /// </summary> protected virtual void GrabInventories() { if (MainInventory == null) { GameObject mainInventoryTmp = GameObject.Find(MainInventoryName); if (mainInventoryTmp != null) { MainInventory = mainInventoryTmp.GetComponent <Inventory> (); } } if (WeaponInventory == null) { GameObject weaponInventoryTmp = GameObject.Find(WeaponInventoryName); if (weaponInventoryTmp != null) { WeaponInventory = weaponInventoryTmp.GetComponent <Inventory> (); } } if (HotbarInventory == null) { GameObject hotbarInventoryTmp = GameObject.Find(HotbarInventoryName); if (hotbarInventoryTmp != null) { HotbarInventory = hotbarInventoryTmp.GetComponent <Inventory> (); } } if (MainInventory != null) { MainInventory.SetOwner(this.gameObject); MainInventory.TargetTransform = this.transform; } if (WeaponInventory != null) { WeaponInventory.SetOwner(this.gameObject); WeaponInventory.TargetTransform = this.transform; } if (HotbarInventory != null) { HotbarInventory.SetOwner(this.gameObject); HotbarInventory.TargetTransform = this.transform; } }
public virtual void RemoveUnarmed() { for (int i = 0; i < MainInventory.Content.Length; i++) { { if (InventoryItem.IsNull(MainInventory.Content[i])) { { continue; } } if (MainInventory.Content[i].ItemID == "InventoryUnarmed") { { MainInventory.DestroyItem(i); } } } } }
private void Awake() { if (rf == null) { rf = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } healthBar = GameObject.Find("HealthBar").GetComponent <Bar>(); staminaBar = GameObject.Find("StaminaBar").GetComponent <Bar>(); playerEquipment = FindObjectOfType <PlayerEquipment>(); playerMovement = FindObjectOfType <PlayerMovement>(); statsDetails = FindObjectOfType <StatsDetails>(); mainInventory = FindObjectOfType <MainInventory>(); weaponSlot = FindObjectOfType <WeaponSlot>(); enemyManager = FindObjectOfType <EnemyManager>(); inventoryScreenCharacter = FindObjectOfType <InventoryScreenCharacter>(); mainInventory.gameObject.SetActive(false); mainCamera = Camera.main; }
/// <summary> /// Automatically adds items and equips a weapon if needed /// </summary> /// <returns></returns> protected virtual IEnumerator AutoAddAndEquip() { yield return(MMCoroutine.WaitForFrames(1)); if (_autoAdded) { yield break; } foreach (InventoryItemsToAdd item in AutoAddItemsMainInventory) { MainInventory?.AddItem(item.Item, item.Quantity); } foreach (InventoryItemsToAdd item in AutoAddItemsHotbar) { HotbarInventory?.AddItem(item.Item, item.Quantity); } if (AutoEquipWeapon != null) { MainInventory.AddItem(AutoEquipWeapon, 1); EquipWeapon(AutoEquipWeapon.ItemID); } _autoAdded = true; }
public static Response NewCollectionTmp(OpenDay view, string userName) { using (var transacction = db.Database.BeginTransaction()) { try { var user = db.Users.Where(u => u.UserName == userName).FirstOrDefault(); var mainWareHouses = db.MainWarehouses.Where(w => w.CompanyId == user.CompanyId).ToList(); var wareHouses = db.Warehouses.Where(w => w.CompanyId == view.CompanyId).ToList(); var disbursedLoans = db.DisbursedLoans.Where(wH => wH.CompanyId == view.CompanyId).Where(cA => cA.StateId == 2).ToList(); //var lastOpenDay = db.OpenDays.Where(od => od.CompanyId == view.CompanyId).Where(of => of.OnOff == true).FirstOrDefault(); //lastOpenDay.OnOff = false; //db.Entry(lastOpenDay).State = EntityState.Modified; var openDay = new OpenDay { OpenDate = DateTime.Today, CompanyId = user.CompanyId, UserName = user.UserName, OnOff = true, }; db.OpenDays.Add(openDay); db.SaveChanges(); foreach (MainWarehouse mainWarehouse in mainWareHouses) { var mainInventory = new MainInventory { MainWarehouseId = mainWarehouse.MainWarehouseId, CompanyId = view.CompanyId, Date = openDay.OpenDate, Collection = 0, Pettycash = 0, Administrativeexpense = 0, Subtotal = 0, Renewedcredit = 0, Total = 0, WareHouseInitialLoan = 0, WareHouseTotalLoan = 0, WareHouseTotalBalance = 0, }; db.MainInventories.Add(mainInventory); } foreach (Warehouse warehouse in wareHouses) { var inventory = new Inventory { WarehouseId = warehouse.WarehouseId, CompanyId = view.CompanyId, Date = openDay.OpenDate, Collection = 0, Pettycash = 0, Administrativeexpense = 0, Subtotal = 0, Renewedcredit = 0, Total = 0, InitialLoan = 0, TotalLoan = 0, TotalBalance = 0, }; db.Inventories.Add(inventory); } foreach (DisbursedLoan detailDL in disbursedLoans) { var collectionTmp = new CollectionTmp { CompanyId = detailDL.CompanyId, WarehouseId = detailDL.WarehouseId, DisbursedLoanId = detailDL.DisbursedLoanId, UserName = userName, LoanState = detailDL.LoanState, CollectionDate = openDay.OpenDate, Payment = 0, CurrentBalance = detailDL.Balance, }; db.CollectionTmps.Add(collectionTmp); } db.SaveChanges(); transacction.Commit(); return(new Response { Succeeded = true, }); } catch (Exception ex) { transacction.Rollback(); return(new Response { Message = ex.Message, Succeeded = false, }); } } }