|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using SiegeSong;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SiegeSong
|
|
|
|
|
{
|
|
|
|
|
public class Container : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
//public int OwnerActorID;
|
|
|
|
|
public Dictionary<int, int> Contents = new Dictionary<int, int>();
|
|
|
|
|
public string Name;
|
|
|
|
|
public InventoryManager InventoryManager;
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update() { }
|
|
|
|
|
|
|
|
|
|
public void AddItem(int itemID, int amount)
|
|
|
|
|
{
|
|
|
|
|
if (Contents.ContainsKey(itemID))
|
|
|
|
|
Contents[itemID] += amount;
|
|
|
|
|
else
|
|
|
|
|
Contents.Add(itemID, amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveItem(int itemID, int amount, InventoryManager inventoryManager = null)
|
|
|
|
|
{
|
|
|
|
|
if (Contents.ContainsKey(itemID))
|
|
|
|
|
{
|
|
|
|
|
var currentlyOwnedCount = Contents[itemID];
|
|
|
|
|
if (inventoryManager != null)
|
|
|
|
|
{
|
|
|
|
|
if (InventoryManager.EquipmentManager.LeftHandCurrentEquipIndex == itemID)
|
|
|
|
|
InventoryManager.EquipmentManager.LeftHandCurrentEquipIndex = 0;
|
|
|
|
|
if (InventoryManager.EquipmentManager.AbilityCurrentEquipIndex == itemID)
|
|
|
|
|
InventoryManager.EquipmentManager.AbilityCurrentEquipIndex = 0;
|
|
|
|
|
if (InventoryManager.EquipmentManager.RightHandCurrentEquipIndex == itemID)
|
|
|
|
|
InventoryManager.EquipmentManager.RightHandCurrentEquipIndex = 0;
|
|
|
|
|
if (InventoryManager.ApparrelManager.CurrentlyActiveIDs.Contains(itemID))
|
|
|
|
|
{
|
|
|
|
|
var newList = new List<int>();
|
|
|
|
|
for (var i = 0; i < InventoryManager.ApparrelManager.CurrentlyActiveIDs.Length; i++)
|
|
|
|
|
if (InventoryManager.ApparrelManager.CurrentlyActiveIDs[i] != itemID)
|
|
|
|
|
newList.Add(InventoryManager.ApparrelManager.CurrentlyActiveIDs[i]);
|
|
|
|
|
InventoryManager.ApparrelManager.CurrentlyActiveIDs = newList.ToArray();
|
|
|
|
|
InventoryManager.ApparrelManager.UpdateApparrel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentlyOwnedCount - amount > 0)
|
|
|
|
|
Contents[itemID] = currentlyOwnedCount - amount;
|
|
|
|
|
else
|
|
|
|
|
Contents.Remove(itemID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|