You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.1 KiB
C#
139 lines
4.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.Events;
|
|
using SiegeSong;
|
|
|
|
namespace SiegeSong
|
|
{
|
|
|
|
public class InventoryItem : MonoBehaviour
|
|
{
|
|
public int ID;
|
|
public string WardrobeKey;
|
|
public string DroppableKey;
|
|
public bool VisibleToPlayer;
|
|
public int MonetaryValue;
|
|
public float PhysicalWeight;
|
|
public float PhysicalCondition;
|
|
public float MaxPhysicalCondition;
|
|
public bool Broken;
|
|
public string FriendlyName;
|
|
public string Description;
|
|
public string[] Effects;
|
|
public InventoryCategory Category;
|
|
public ItemType Type;
|
|
public EquipableType EquipableType;
|
|
public AparrelSlot AparrelSlot;
|
|
public UnityEvent OpenReadMenu;
|
|
public UnityEvent Use;
|
|
public UnityEvent UseStart;
|
|
public UnityEvent UseEnd;
|
|
|
|
public Dictionary<DamageWeight, Dictionary<DamageType, bool>> FullProtection;
|
|
public Dictionary<DamageWeight, Dictionary<DamageType, bool>> PartialProtection;
|
|
|
|
public DamageType[] FullProtectedDamageTypes;
|
|
public DamageWeight[] FullyProtectedDamageWeights;
|
|
public DamageType[] PartiallyProtectedDamageTypes;
|
|
public DamageWeight[] PartiallyProtectedDamageWeights;
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void Degrade(PhysicalMaterial senderMaterial, PhysicalMaterial receiverMaterial, int amount, float momentum)
|
|
{
|
|
// TO DO - need to add the correct math for physics materials
|
|
if (MaxPhysicalCondition > amount)
|
|
{
|
|
PhysicalCondition -= amount;
|
|
}
|
|
else
|
|
{
|
|
PhysicalCondition = 0;
|
|
Broken = true;
|
|
}
|
|
}
|
|
|
|
public void Activate(ApparrelManager apparrelManager)
|
|
{
|
|
var activeIdsList = new List<int>(apparrelManager.CurrentlyActiveIDs);
|
|
switch (Type)
|
|
{
|
|
case ItemType.Equipable:
|
|
if (EquipableType == EquipableType.Aparrel)
|
|
{
|
|
if (!activeIdsList.Contains(ID))
|
|
{
|
|
if (UseStart != null)
|
|
UseStart.Invoke();
|
|
}
|
|
else
|
|
{
|
|
if (UseEnd != null)
|
|
UseEnd.Invoke();
|
|
}
|
|
if (activeIdsList.Contains(ID))
|
|
activeIdsList.Remove(ID);
|
|
else
|
|
activeIdsList.Add(ID);
|
|
apparrelManager.CurrentlyActiveIDs = activeIdsList.ToArray();
|
|
apparrelManager.InventoryManager.Actor.Stats.ActiveInventoryItemIDs = activeIdsList;
|
|
apparrelManager.UpdateApparrel();
|
|
}
|
|
|
|
break;
|
|
|
|
case ItemType.Readable:
|
|
|
|
//readMenu.SelectedBookID = ID;
|
|
//readMenu.Open();
|
|
|
|
break;
|
|
|
|
case ItemType.Consumable:
|
|
|
|
apparrelManager.InventoryManager.SelectedItemID = ID;
|
|
apparrelManager.InventoryManager.SelectedAmount = 1;
|
|
apparrelManager.InventoryManager.RemoveItem();
|
|
|
|
if (Use != null)
|
|
Use.Invoke();
|
|
|
|
break;
|
|
|
|
case ItemType.Useable:
|
|
|
|
if (Use != null)
|
|
Use.Invoke();
|
|
|
|
if (UseStart != null && !activeIdsList.Contains(ID))
|
|
{
|
|
UseStart.Invoke();
|
|
}
|
|
|
|
if (UseEnd != null && activeIdsList.Contains(ID))
|
|
{
|
|
UseEnd.Invoke();
|
|
}
|
|
|
|
break;
|
|
|
|
case ItemType.Material:
|
|
|
|
return;
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|