// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-10 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using UnityEngine; namespace G { /// /// 宝石实体类 /// public sealed class EntityItemGem : EntityItem { #region Field private ItemGem _item; /// /// 属性 /// public CombatAttribute attribute; /// /// /// private int _combatValue; /// /// /// public int combatValue { get { return _combatValue; } } /// /// /// public override ItemGem item => _item; /// /// 排序规则 /// public override int sortOrder => _itemId; /// /// /// public override int level => _item.grade; private const int MAX_GEM_LEVEL = 12; /// /// 升级 /// /// 0 -1 no money public EntityItemGem Upgrade(int amount = int.MaxValue) { if (this.level < MAX_GEM_LEVEL) { var tmp = this.count; if (tmp >= 2 && amount > 0) { int result = Mathf.Min(tmp / 2, amount); this.count = tmp - result * 2; return ItemProxy.Instance.AddGem(_itemId + 1, result); } } return default; } /// /// /// /// /// public Item.ItemInfo GetUpdgradeCost(int amount = int.MaxValue) { if (this.level < MAX_GEM_LEVEL) { var tmp = this.count; if (tmp >= 2 && amount > 0) { int result = Mathf.Min(tmp / 2, amount); var cost = _item.costInfo; cost.count *= result; return cost; } } return default; } #endregion #region Method /// /// /// protected override void Init() { base.Init(); _item = ItemProxy.Instance.GetStaticItem(_itemId); this.attribute = CombatAttribute.Convert(_item.attribute); _combatValue = this.attribute.combatValue; } /// /// /// /// public override string ToString() { return attribute.ToString(); } #endregion } }