Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using SharpDX.Direct2D1;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using VoidwalkerEngine.Framework.Collections;
- using VoidwalkerEngine.Framework.DataTypes;
- using VoidwalkerEngine.Framework.Logic;
- using VoidwalkerEngine.Framework.Systems.Enchanting;
- using VoidwalkerEngine.Framework.Systems.GameProperties;
- namespace VoidwalkerEngine.Framework.Systems.Items.Base
- {
- public class GameItem
- {
- public string Identifier { get; set; }
- public string Header { get; set; }
- public string Name { get; set; }
- public string Description { get; set; }
- public ItemType Category { get; set; }
- public int Icon { get; set; }
- public string FlavorText { get; set; }
- public QualityType Quality { get; set; }
- public int Level { get; set; }
- public int Capacity { get; set; }
- public int Durability { get; set; }
- public List<Enchantment> Enchantments { get; set; }
- public GamePrice BaseSellPrice { get; set; }
- public int BaseDamage { get; set; }
- public int BaseBlockChance { get; set; }
- public int BaseArmorRating { get; set; }
- public int BaseDurability { get; set; }
- public bool IsSpawnable { get; set; }
- public bool IsEthereal { get; set; }
- public bool IsNew { get; set; }
- public bool IsConjured { get; set; }
- public int Quantity { get; set; } = 1;
- public bool IsStackable
- {
- get
- {
- return Category.IsStackable();
- }
- }
- public bool IsEnchantable
- {
- get
- {
- return Category.IsEnchantable();
- }
- }
- public bool IsStackableWith(GameItem other)
- {
- return this.Identifier.Equals(other.Identifier) && this.IsStackable;
- }
- public GameItem()
- {
- }
- public bool IsEnchanted
- {
- get
- {
- return Enchantments != null && this.Enchantments.Count > 0;
- }
- }
- public bool IsIndestructible
- {
- get
- {
- if (this.Enchantments != null)
- {
- foreach (Enchantment enchantment in this.Enchantments)
- {
- if (enchantment.Properties != null)
- {
- foreach (GameProperty property in enchantment.Properties)
- {
- if (property is IndestructibleProperty)
- {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- }
- public void Break()
- {
- this.Durability = 0;
- }
- public void Repair()
- {
- this.Durability = GetMaximumDurability();
- }
- public double GetAttackSpeed()
- {
- if (this.Category.IsWeapon())
- {
- return this.Category.ToWeaponCategory().GetAttackSpeed();
- }
- return 0;
- }
- public int GetMaximumDamage()
- {
- int multiplier = 100;
- foreach (Enchantment enchantment in this.Enchantments)
- {
- foreach (GameProperty effect in enchantment.Properties)
- {
- if (effect is ModifyGameItemProperty itemEffect)
- {
- if (itemEffect.Attribute == GameItemAttributeType.WeaponDamage)
- {
- multiplier += itemEffect.Value;
- }
- }
- }
- }
- if (this.IsEthereal)
- {
- multiplier += 25;
- }
- return (int)Math.Floor(this.BaseDamage * (multiplier / 100D));
- }
- public int GetMaximumArmorRating()
- {
- int multiplier = 100;
- foreach (Enchantment enchantment in this.Enchantments)
- {
- foreach (GameProperty effect in enchantment.Properties)
- {
- if (effect is ModifyGameItemProperty itemEffect)
- {
- if (itemEffect.Attribute == GameItemAttributeType.ArmorRating)
- {
- multiplier += itemEffect.Value;
- }
- }
- }
- }
- if (this.IsEthereal)
- {
- multiplier += 25;
- }
- return (int)Math.Round(this.BaseArmorRating * (multiplier / 100D));
- }
- public int GetMaximumDurability()
- {
- int multiplier = 100;
- foreach (Enchantment enchantment in this.Enchantments)
- {
- foreach (GameProperty effect in enchantment.Properties)
- {
- if (effect is ModifyGameItemProperty itemEffect)
- {
- if (itemEffect.Attribute == GameItemAttributeType.Durability)
- {
- multiplier += itemEffect.Value;
- }
- }
- }
- }
- if (this.IsEthereal)
- {
- multiplier += 25;
- }
- return (int)Math.Round(this.BaseArmorRating * (multiplier / 100D));
- }
- public int GetMaximumBlockChance()
- {
- int multiplier = 100;
- foreach (Enchantment enchantment in this.Enchantments)
- {
- foreach (GameProperty effect in enchantment.Properties)
- {
- if (effect is ModifyGameItemProperty itemEffect)
- {
- if (itemEffect.Attribute == GameItemAttributeType.BlockChance)
- {
- multiplier += itemEffect.Value;
- }
- }
- }
- }
- return (int)Math.Round(this.BaseBlockChance * (multiplier / 100D));
- }
- public GamePrice GetMaximumSellPrice()
- {
- // Include price multipliers from enchantments
- // Include Ethereal price multiplier,
- // Include Quality Type Price Multiplier
- return BaseSellPrice;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="other"></param>
- public void Copy(GameItem other)
- {
- this.Identifier = other.Identifier;
- this.Header = other.Header;
- this.Name = other.Name;
- this.Description = other.Description;
- this.Category = other.Category;
- this.Icon = other.Icon;
- this.FlavorText = other.FlavorText;
- this.Quality = other.Quality;
- this.Level = other.Level;
- this.Capacity = other.Capacity;
- this.Durability = other.Durability;
- this.Enchantments = other.Enchantments?.ToList();
- this.BaseSellPrice = other.BaseSellPrice;
- this.BaseDamage = other.BaseDamage;
- this.BaseBlockChance = other.BaseBlockChance;
- this.Quantity = other.Quantity;
- this.BaseArmorRating = other.BaseArmorRating;
- this.BaseDurability = other.BaseDurability;
- this.IsSpawnable = other.IsSpawnable;
- this.IsEthereal = other.IsEthereal;
- this.IsNew = other.IsNew;
- this.IsConjured = other.IsConjured;
- }
- public GameItem MakeCopy()
- {
- GameItem copy = new GameItem();
- copy.Copy(this);
- return copy;
- }
- #region Static Item Prototype Creation
- public static GameItem CreateWeapon(WeaponType category, string identifier, string header, string name, QualityType quality, int icon, List<Enchantment> enchantments,
- string flavorText, int level, int baseDamage, int baseDurability, bool isSpawnable, bool isEthereal)
- {
- return new GameItem
- {
- Category = category.ToItemCategory(),
- Identifier = identifier,
- Header = header,
- Name = name,
- Quality = quality,
- Icon = icon,
- Enchantments = enchantments,
- FlavorText = flavorText,
- Level = level,
- BaseDamage = baseDamage,
- BaseDurability = baseDurability,
- IsSpawnable = isSpawnable,
- IsEthereal = isEthereal
- };
- }
- public static GameItem CreateArmor(ArmorType category, string identifier, string header, string name, QualityType quality, int icon, List<Enchantment> enchantments,
- string flavorText, int level, int baseArmorRating, int baseDurability, bool isSpawnable, bool isEthereal)
- {
- return new GameItem
- {
- Category = category.ToItemCategory(),
- Identifier = identifier,
- Header = header,
- Name = name,
- Quality = quality,
- Icon = icon,
- Enchantments = enchantments,
- FlavorText = flavorText,
- Level = level,
- BaseArmorRating = baseArmorRating,
- BaseDurability = baseDurability,
- IsSpawnable = isSpawnable,
- IsEthereal = isEthereal
- };
- }
- public static GameItem CreateJewelry(JewelryType category, string identifier, string header, string name, QualityType quality, int icon, List<Enchantment> enchantments,
- string flavorText, int level, int baseDurability, bool isSpawnable, bool isEthereal)
- {
- return new GameItem
- {
- Category = category.ToItemCategory(),
- Identifier = identifier,
- Header = header,
- Name = name,
- Quality = quality,
- Icon = icon,
- Enchantments = enchantments,
- FlavorText = flavorText,
- Level = level,
- BaseDurability = baseDurability,
- IsSpawnable = isSpawnable,
- IsEthereal = isEthereal
- };
- }
- public static GameItem CreateHeldItem(HeldItemType category, string identifier, string header, string name, QualityType quality, int icon, List<Enchantment> enchantments,
- string flavorText, int level, int baseArmorRating, int baseDurability, bool isSpawnable, bool isEthereal)
- {
- return new GameItem
- {
- Category = category.ToItemCategory(),
- Identifier = identifier,
- Header = header,
- Name = name,
- Quality = quality,
- Icon = icon,
- Enchantments = enchantments,
- FlavorText = flavorText,
- Level = level,
- BaseArmorRating = baseArmorRating,
- BaseDurability = baseDurability,
- IsSpawnable = isSpawnable,
- IsEthereal = isEthereal
- };
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement