This commit is contained in:
Nim XD
2024-08-27 21:01:33 +05:30
parent 99eaf514fd
commit 121a1b7c73
31803 changed files with 623461 additions and 623399 deletions

View File

@@ -1,72 +1,72 @@
using System;
using Assets.HeroEditor4D.Common.Scripts.Data;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
using Newtonsoft.Json;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
/// <summary>
/// Represents item object for storing with game profile (please note, that item params are stored separately in params database).
/// </summary>
[Serializable]
public class Item
{
public string Id; // Id is not unique. Use Hash to compare items!
public Modifier Modifier;
#if TAP_HEROES
public ProtectedInt Count;
#else
public int Count;
#endif
public Item()
{
}
public Item(string id, int count = 1)
{
Id = id;
Count = count;
}
public Item(string id, Modifier modifier, int count = 1)
{
Id = id;
Count = count;
Modifier = modifier;
}
public Item Clone()
{
return new Item(Id, Modifier, Count);
}
[JsonIgnore] public ItemParams Params => ItemCollection.Active.GetItemParams(this);
[JsonIgnore] public ItemSprite Sprite => ItemCollection.Active.GetItemSprite(this);
[JsonIgnore] public ItemIcon Icon => ItemCollection.Active.GetItemIcon(this);
[JsonIgnore] public int Hash => $"{Id}.{Modifier?.Id}.{Modifier?.Level}".GetHashCode();
[JsonIgnore] public bool IsModified => Modifier != null && Modifier.Id != ItemModifier.None;
[JsonIgnore] public bool IsEquipment => Params.Type == ItemType.Helmet || Params.Type == ItemType.Armor || Params.Type == ItemType.Vest || Params.Type == ItemType.Bracers || Params.Type == ItemType.Leggings || Params.Type == ItemType.Weapon || Params.Type == ItemType.Shield;
[JsonIgnore] public bool IsArmor => Params.Type == ItemType.Helmet || Params.Type == ItemType.Armor || Params.Type == ItemType.Vest || Params.Type == ItemType.Bracers || Params.Type == ItemType.Leggings;
[JsonIgnore] public bool IsWeapon => Params.Type == ItemType.Weapon;
[JsonIgnore] public bool IsShield => Params.Type == ItemType.Shield;
[JsonIgnore] public bool IsDagger => Params.Class == ItemClass.Dagger;
[JsonIgnore] public bool IsSword => Params.Class == ItemClass.Sword;
[JsonIgnore] public bool IsAxe => Params.Class == ItemClass.Axe;
[JsonIgnore] public bool IsPickaxe => Params.Class == ItemClass.Pickaxe;
[JsonIgnore] public bool IsWand => Params.Class == ItemClass.Wand;
[JsonIgnore] public bool IsBlunt => Params.Class == ItemClass.Blunt;
[JsonIgnore] public bool IsLance => Params.Class == ItemClass.Lance;
[JsonIgnore] public bool IsMelee => Params.Type == ItemType.Weapon && Params.Class != ItemClass.Bow && Params.Class != ItemClass.Firearm;
[JsonIgnore] public bool IsBow => Params.Class == ItemClass.Bow;
[JsonIgnore] public bool IsFirearm => Params.Class == ItemClass.Firearm;
[JsonIgnore] public bool IsOneHanded => !IsTwoHanded;
[JsonIgnore] public bool IsTwoHanded => Params.Class == ItemClass.Bow || Params.Tags.Contains(ItemTag.TwoHanded);
}
using System;
using Assets.HeroEditor4D.Common.Scripts.Data;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
using Newtonsoft.Json;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
/// <summary>
/// Represents item object for storing with game profile (please note, that item params are stored separately in params database).
/// </summary>
[Serializable]
public class Item
{
public string Id; // Id is not unique. Use Hash to compare items!
public Modifier Modifier;
#if TAP_HEROES
public ProtectedInt Count;
#else
public int Count;
#endif
public Item()
{
}
public Item(string id, int count = 1)
{
Id = id;
Count = count;
}
public Item(string id, Modifier modifier, int count = 1)
{
Id = id;
Count = count;
Modifier = modifier;
}
public Item Clone()
{
return new Item(Id, Modifier, Count);
}
[JsonIgnore] public ItemParams Params => ItemCollection.Active.GetItemParams(this);
[JsonIgnore] public ItemSprite Sprite => ItemCollection.Active.GetItemSprite(this);
[JsonIgnore] public ItemIcon Icon => ItemCollection.Active.GetItemIcon(this);
[JsonIgnore] public int Hash => $"{Id}.{Modifier?.Id}.{Modifier?.Level}".GetHashCode();
[JsonIgnore] public bool IsModified => Modifier != null && Modifier.Id != ItemModifier.None;
[JsonIgnore] public bool IsEquipment => Params.Type == ItemType.Helmet || Params.Type == ItemType.Armor || Params.Type == ItemType.Vest || Params.Type == ItemType.Bracers || Params.Type == ItemType.Leggings || Params.Type == ItemType.Weapon || Params.Type == ItemType.Shield;
[JsonIgnore] public bool IsArmor => Params.Type == ItemType.Helmet || Params.Type == ItemType.Armor || Params.Type == ItemType.Vest || Params.Type == ItemType.Bracers || Params.Type == ItemType.Leggings;
[JsonIgnore] public bool IsWeapon => Params.Type == ItemType.Weapon;
[JsonIgnore] public bool IsShield => Params.Type == ItemType.Shield;
[JsonIgnore] public bool IsDagger => Params.Class == ItemClass.Dagger;
[JsonIgnore] public bool IsSword => Params.Class == ItemClass.Sword;
[JsonIgnore] public bool IsAxe => Params.Class == ItemClass.Axe;
[JsonIgnore] public bool IsPickaxe => Params.Class == ItemClass.Pickaxe;
[JsonIgnore] public bool IsWand => Params.Class == ItemClass.Wand;
[JsonIgnore] public bool IsBlunt => Params.Class == ItemClass.Blunt;
[JsonIgnore] public bool IsLance => Params.Class == ItemClass.Lance;
[JsonIgnore] public bool IsMelee => Params.Type == ItemType.Weapon && Params.Class != ItemClass.Bow && Params.Class != ItemClass.Firearm;
[JsonIgnore] public bool IsBow => Params.Class == ItemClass.Bow;
[JsonIgnore] public bool IsFirearm => Params.Class == ItemClass.Firearm;
[JsonIgnore] public bool IsOneHanded => !IsTwoHanded;
[JsonIgnore] public bool IsTwoHanded => Params.Class == ItemClass.Bow || Params.Tags.Contains(ItemTag.TwoHanded);
}
}

View File

@@ -1,12 +1,12 @@
fileFormatVersion: 2
guid: 01cf7f5172991a64ca1723e1869888d7
timeCreated: 1508494931
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 01cf7f5172991a64ca1723e1869888d7
timeCreated: 1508494931
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,83 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Assets.HeroEditor4D.Common.Scripts.Common;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
using Newtonsoft.Json;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
/// <summary>
/// Represents generic item params (common for all items).
/// </summary>
[Serializable]
public class ItemParams
{
public string Id;
public int Level;
public ItemRarity Rarity;
public ItemType Type;
public ItemClass Class;
public List<ItemTag> Tags = new List<ItemTag>();
public List<Property> Properties = new List<Property>();
public int Price;
public int Weight;
public ItemMaterial Material;
public string IconId;
public string SpriteId;
public string Meta;
/// <summary>
/// Use this property to provide localization values for items.
/// </summary>
[JsonIgnore, NonSerialized] public List<LocalizedValue> Localization = new List<LocalizedValue>();
public char Grade => (char) (65 + Level);
public Property FindProperty(PropertyId id)
{
var target = Properties.SingleOrDefault(i => i.Id == id && i.Element == ElementId.Physic);
return target;
}
public Property FindProperty(PropertyId id, ElementId element)
{
var target = Properties.SingleOrDefault(i => i.Id == id && i.Element == element);
return target;
}
public string GetLocalizedName(string language)
{
var localized = Localization.SingleOrDefault(i => i.Language == language) ?? Localization.SingleOrDefault(i => i.Language == "English");
return localized == null ? Id : localized.Value;
}
public List<string> MetaToList()
{
return Meta.IsEmpty() ? new List<string>() : JsonConvert.DeserializeObject<List<string>>(Meta);
}
public ItemParams Copy()
{
return new ItemParams
{
Id = Id,
Level = Level,
Rarity = Rarity,
Type = Type,
Class = Class,
Tags = Tags.ToList(),
Properties = Properties.Select(i => i.Copy()).ToList(),
Price = Price,
Weight = Weight,
Material = Material,
IconId = IconId,
SpriteId = SpriteId,
Meta = Meta
};
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using Assets.HeroEditor4D.Common.Scripts.Common;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
using Newtonsoft.Json;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
/// <summary>
/// Represents generic item params (common for all items).
/// </summary>
[Serializable]
public class ItemParams
{
public string Id;
public int Level;
public ItemRarity Rarity;
public ItemType Type;
public ItemClass Class;
public List<ItemTag> Tags = new List<ItemTag>();
public List<Property> Properties = new List<Property>();
public int Price;
public int Weight;
public ItemMaterial Material;
public string IconId;
public string SpriteId;
public string Meta;
/// <summary>
/// Use this property to provide localization values for items.
/// </summary>
[JsonIgnore, NonSerialized] public List<LocalizedValue> Localization = new List<LocalizedValue>();
public char Grade => (char) (65 + Level);
public Property FindProperty(PropertyId id)
{
var target = Properties.SingleOrDefault(i => i.Id == id && i.Element == ElementId.Physic);
return target;
}
public Property FindProperty(PropertyId id, ElementId element)
{
var target = Properties.SingleOrDefault(i => i.Id == id && i.Element == element);
return target;
}
public string GetLocalizedName(string language)
{
var localized = Localization.SingleOrDefault(i => i.Language == language) ?? Localization.SingleOrDefault(i => i.Language == "English");
return localized == null ? Id : localized.Value;
}
public List<string> MetaToList()
{
return Meta.IsEmpty() ? new List<string>() : JsonConvert.DeserializeObject<List<string>>(Meta);
}
public ItemParams Copy()
{
return new ItemParams
{
Id = Id,
Level = Level,
Rarity = Rarity,
Type = Type,
Class = Class,
Tags = Tags.ToList(),
Properties = Properties.Select(i => i.Copy()).ToList(),
Price = Price,
Weight = Weight,
Material = Material,
IconId = IconId,
SpriteId = SpriteId,
Meta = Meta
};
}
}
}

View File

@@ -1,12 +1,12 @@
fileFormatVersion: 2
guid: 5f035382d1422314fb79b87287d6dbad
timeCreated: 1508494931
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5f035382d1422314fb79b87287d6dbad
timeCreated: 1508494931
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,17 +1,17 @@
using System;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
[Serializable]
public class LocalizedValue
{
public string Language;
public string Value;
public LocalizedValue(string language, string value)
{
Language = language;
Value = value;
}
}
using System;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
[Serializable]
public class LocalizedValue
{
public string Language;
public string Value;
public LocalizedValue(string language, string value)
{
Language = language;
Value = value;
}
}
}

View File

@@ -1,11 +1,11 @@
fileFormatVersion: 2
guid: d8ef5b0ac3054d147bfab72638f28e88
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d8ef5b0ac3054d147bfab72638f28e88
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,22 +1,22 @@
using System;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
[Serializable]
public class Modifier
{
public ItemModifier Id;
public int Level;
public Modifier()
{
}
public Modifier(ItemModifier id, int level)
{
Id = id;
Level = level;
}
}
using System;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
[Serializable]
public class Modifier
{
public ItemModifier Id;
public int Level;
public Modifier()
{
}
public Modifier(ItemModifier id, int level)
{
Id = id;
Level = level;
}
}
}

View File

@@ -1,11 +1,11 @@
fileFormatVersion: 2
guid: 298c0d188a3892d45aa56a41de5ae22a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 298c0d188a3892d45aa56a41de5ae22a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,160 +1,160 @@
using System;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using Assets.HeroEditor4D.Common.Scripts.Common;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
using UnityEngine;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
/// <summary>
/// Represents key-value pair for storing item params.
/// Supported value formats:
/// "[VALUE]"
/// "[VALUE_MIN]-[VALUE_MAX]"
/// "[VALUE]/[ELEMENT]"
/// "[VALUE]/[ELEMENT]/[DURATION]"
/// </summary>
[Serializable]
public class Property
{
public PropertyId Id;
public string Value;
[HideInInspector] [NonSerialized] public int ValueInt;
[HideInInspector] [NonSerialized] public int Min;
[HideInInspector] [NonSerialized] public int Max;
[HideInInspector] [NonSerialized] public int Duration;
[HideInInspector] [NonSerialized] public ElementId Element;
[HideInInspector] [NonSerialized] public bool Percentage;
public Property()
{
}
public Property(PropertyId id, object value)
{
Id = id;
Value = value.ToString();
ParseValue();
}
public void ParseValue()
{
var parts = Value.Split('/');
if (Id == PropertyId.Damage || Id == PropertyId.Resistance)
{
switch (parts.Length)
{
case 2:
Element = parts[1].ToEnum<ElementId>();
break;
case 3:
Element = parts[1].ToEnum<ElementId>();
Duration = int.Parse(parts[2]);
break;
default:
Element = ElementId.Physic;
break;
}
}
if (Regex.IsMatch(parts[0], @"^\d+-\d+$"))
{
parts = parts[0].Split('-');
Min = int.Parse(parts[0]);
Max = int.Parse(parts[1]);
}
else if (parts[0].EndsWith("%"))
{
ValueInt = int.Parse(parts[0].Replace("%", null));
Percentage = true;
}
else
{
if (int.TryParse(parts[0], out var valueInt))
{
ValueInt = valueInt;
}
}
}
public void ReplaceValue(string value)
{
Value = value;
ParseValue();
}
public void ReplaceValue(float value)
{
ReplaceValue(Mathf.RoundToInt(value));
}
public void ReplaceValue(int value)
{
Value = value.ToString();
ParseValue();
}
public void Add(float value)
{
Add(Mathf.RoundToInt(value));
}
public void Add(int value)
{
if (Min > 0)
{
Min += value;
Max += value;
Value = $"{Min}-{Max}" + (Element == ElementId.Physic ? null : "/" + Element);
}
else
{
ValueInt += value;
Value = ValueInt + (Element == ElementId.Physic ? null : "/" + Element);
}
}
public void AddInPercentage(float value)
{
if (Min > 0)
{
Min = Mathf.RoundToInt(Min * (1 + value / 100f));
Max = Mathf.RoundToInt(Max * (1 + value / 100f));
Value = $"{Min}-{Max}" + (Element == ElementId.Physic ? null : "/" + Element);
}
else
{
ValueInt = Mathf.RoundToInt(ValueInt * (1 + value / 100f));
Value = ValueInt + (Element == ElementId.Physic ? null : "/" + Element);
}
}
public static Property Parse(string value)
{
var parts = value.Split('=');
var property = new Property
{
Id = parts[0].ToEnum<PropertyId>(),
Value = parts[1]
};
property.ParseValue();
return property;
}
[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context)
{
ParseValue();
}
public Property Copy()
{
return new Property(Id, Value);
}
}
using System;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using Assets.HeroEditor4D.Common.Scripts.Common;
using Assets.HeroEditor4D.InventorySystem.Scripts.Enums;
using UnityEngine;
namespace Assets.HeroEditor4D.InventorySystem.Scripts.Data
{
/// <summary>
/// Represents key-value pair for storing item params.
/// Supported value formats:
/// "[VALUE]"
/// "[VALUE_MIN]-[VALUE_MAX]"
/// "[VALUE]/[ELEMENT]"
/// "[VALUE]/[ELEMENT]/[DURATION]"
/// </summary>
[Serializable]
public class Property
{
public PropertyId Id;
public string Value;
[HideInInspector] [NonSerialized] public int ValueInt;
[HideInInspector] [NonSerialized] public int Min;
[HideInInspector] [NonSerialized] public int Max;
[HideInInspector] [NonSerialized] public int Duration;
[HideInInspector] [NonSerialized] public ElementId Element;
[HideInInspector] [NonSerialized] public bool Percentage;
public Property()
{
}
public Property(PropertyId id, object value)
{
Id = id;
Value = value.ToString();
ParseValue();
}
public void ParseValue()
{
var parts = Value.Split('/');
if (Id == PropertyId.Damage || Id == PropertyId.Resistance)
{
switch (parts.Length)
{
case 2:
Element = parts[1].ToEnum<ElementId>();
break;
case 3:
Element = parts[1].ToEnum<ElementId>();
Duration = int.Parse(parts[2]);
break;
default:
Element = ElementId.Physic;
break;
}
}
if (Regex.IsMatch(parts[0], @"^\d+-\d+$"))
{
parts = parts[0].Split('-');
Min = int.Parse(parts[0]);
Max = int.Parse(parts[1]);
}
else if (parts[0].EndsWith("%"))
{
ValueInt = int.Parse(parts[0].Replace("%", null));
Percentage = true;
}
else
{
if (int.TryParse(parts[0], out var valueInt))
{
ValueInt = valueInt;
}
}
}
public void ReplaceValue(string value)
{
Value = value;
ParseValue();
}
public void ReplaceValue(float value)
{
ReplaceValue(Mathf.RoundToInt(value));
}
public void ReplaceValue(int value)
{
Value = value.ToString();
ParseValue();
}
public void Add(float value)
{
Add(Mathf.RoundToInt(value));
}
public void Add(int value)
{
if (Min > 0)
{
Min += value;
Max += value;
Value = $"{Min}-{Max}" + (Element == ElementId.Physic ? null : "/" + Element);
}
else
{
ValueInt += value;
Value = ValueInt + (Element == ElementId.Physic ? null : "/" + Element);
}
}
public void AddInPercentage(float value)
{
if (Min > 0)
{
Min = Mathf.RoundToInt(Min * (1 + value / 100f));
Max = Mathf.RoundToInt(Max * (1 + value / 100f));
Value = $"{Min}-{Max}" + (Element == ElementId.Physic ? null : "/" + Element);
}
else
{
ValueInt = Mathf.RoundToInt(ValueInt * (1 + value / 100f));
Value = ValueInt + (Element == ElementId.Physic ? null : "/" + Element);
}
}
public static Property Parse(string value)
{
var parts = value.Split('=');
var property = new Property
{
Id = parts[0].ToEnum<PropertyId>(),
Value = parts[1]
};
property.ParseValue();
return property;
}
[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context)
{
ParseValue();
}
public Property Copy()
{
return new Property(Id, Value);
}
}
}

View File

@@ -1,12 +1,12 @@
fileFormatVersion: 2
guid: 79c1405f54e6a5947b6a79f23714d5a4
timeCreated: 1508511989
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 79c1405f54e6a5947b6a79f23714d5a4
timeCreated: 1508511989
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: