コード例 #1
0
ファイル: UIEquipSlot.cs プロジェクト: Abyzip/SurvvivalMobile
        // <summary>
        /// Performs a slot swap.
        /// </summary>
        /// <returns><c>true</c>, if slot swap was performed, <c>false</c> otherwise.</returns>
        /// <param name="sourceSlot">Source slot.</param>
        public override bool PerformSlotSwap(Object sourceObject)
        {
            // Get the source item info
            UIItemInfo sourceItemInfo = null;
            bool       assign1        = false;

            // Check the type of the source slot
            if (sourceObject is UIItemSlot)
            {
                sourceItemInfo = (sourceObject as UIItemSlot).GetItemInfo();

                // Assign the source slot by this one
                assign1 = (sourceObject as UIItemSlot).Assign(this.GetItemInfo());
            }
            else if (sourceObject is UIEquipSlot)
            {
                sourceItemInfo = (sourceObject as UIEquipSlot).GetItemInfo();

                // Assign the source slot by this one
                assign1 = (sourceObject as UIEquipSlot).Assign(this.GetItemInfo());
            }
            else
            {
                return(false);
            }

            // Assign this slot by the source slot
            bool assign2 = this.Assign(sourceItemInfo);

            // Return the status
            return(assign1 && assign2);
        }
コード例 #2
0
ファイル: UIEquipSlot.cs プロジェクト: Abyzip/SurvvivalMobile
        /// <summary>
        /// Assign the slot by item info.
        /// </summary>
        /// <param name="itemInfo">The item info.</param>
        public bool Assign(UIItemInfo itemInfo)
        {
            if (itemInfo == null)
            {
                return(false);
            }

            // Check if the equipment type matches the target slot
            if (!this.CheckEquipType(itemInfo))
            {
                return(false);
            }

            // Make sure we unassign first, so the event is called before new assignment
            this.Unassign();

            // Use the base class assign to set the icon
            this.Assign(itemInfo.Icon);

            // Set the spell info
            this.m_ItemInfo = itemInfo;

            // Invoke the on assign event
            if (this.onAssign != null)
            {
                this.onAssign.Invoke(this);
            }

            // Success
            return(true);
        }
コード例 #3
0
ファイル: UIItemSlot.cs プロジェクト: Adarshmihir/Moonstone
        /// <summary>
        /// Assign the slot by new item info while refering to the source.
        /// </summary>
        /// <param name="itemInfo">The item info.</param>
        /// <param name="source">The source slot (Could be null).</param>
        /// <returns><c>true</c> if this instance is assigned; otherwise, <c>false</c>.</returns>
        public bool Assign(UIItemInfo itemInfo, Object source)
        {
            if (itemInfo == null)
            {
                return(false);
            }

            // Make sure we unassign first, so the event is called before new assignment
            this.Unassign();

            // Use the base class assign to set the icon
            this.Assign(itemInfo.Icon);

            // Set the spell info
            this.m_ItemInfo = itemInfo;

            // Invoke the on assign event
            if (this.onAssign != null)
            {
                this.onAssign.Invoke(this);
            }

            // Invoke the on assign event
            if (this.onAssignWithSource != null)
            {
                this.onAssignWithSource.Invoke(this, source);
            }

            // Success
            return(true);
        }
コード例 #4
0
ファイル: UIEquipSlot.cs プロジェクト: Abyzip/SurvvivalMobile
        /// <summary>
        /// Checks if the given item can assigned to this slot.
        /// </summary>
        /// <returns><c>true</c>, if equip type was checked, <c>false</c> otherwise.</returns>
        /// <param name="info">Info.</param>
        public virtual bool CheckEquipType(UIItemInfo info)
        {
            if (info.EquipType != this.equipType)
            {
                return(false);
            }

            return(true);
        }
コード例 #5
0
ファイル: UIItemSlot.cs プロジェクト: Adarshmihir/Moonstone
        /// <summary>
        /// Prepares the tooltip with the specified item info.
        /// </summary>
        /// <param name="itemInfo">Item info.</param>
        public static void PrepareTooltip(UIItemInfo itemInfo)
        {
            if (itemInfo == null)
            {
                return;
            }

            // Set the tooltip width
            if (UITooltipManager.Instance != null)
            {
                UITooltip.SetWidth(UITooltipManager.Instance.itemTooltipWidth);
            }

            // Set the title and description
            UITooltip.AddTitle("<color=#" + UIItemQualityColor.GetHexColor(itemInfo.Quality) + ">" + itemInfo.Name + "</color>");

            // Spacer
            UITooltip.AddSpacer();

            // Item types
            UITooltip.AddLineColumn(itemInfo.Type, "ItemAttribute");
            UITooltip.AddLineColumn(itemInfo.Subtype, "ItemAttribute");

            if (itemInfo.ItemType == 1)
            {
                UITooltip.AddLineColumn(itemInfo.Damage.ToString() + " Damage", "ItemAttribute");
                UITooltip.AddLineColumn(itemInfo.AttackSpeed.ToString("0.0") + " Attack speed", "ItemAttribute");

                UITooltip.AddLine("(" + ((float)itemInfo.Damage / itemInfo.AttackSpeed).ToString("0.0") + " damage per second)", "ItemAttribute");
            }
            else
            {
                UITooltip.AddLineColumn(itemInfo.Armor.ToString() + " Armor", "ItemAttribute");
                UITooltip.AddLineColumn(itemInfo.Block.ToString() + " Block", "ItemAttribute");
            }

            UITooltip.AddSpacer();

            UITooltip.AddLine("+" + itemInfo.Stamina.ToString() + " Stamina", "ItemStat");
            UITooltip.AddLine("+" + itemInfo.Strength.ToString() + " Strength", "ItemStat");

            UITooltip.AddSpacer();

            UITooltip.AddLine("Durability " + itemInfo.Durability + "/" + itemInfo.Durability, "ItemAttribute");

            if (itemInfo.RequiredLevel > 0)
            {
                UITooltip.AddLine("Requires Level " + itemInfo.RequiredLevel, "ItemAttribute");
            }

            // Set the item description if not empty
            if (!string.IsNullOrEmpty(itemInfo.Description))
            {
                UITooltip.AddSpacer();
                UITooltip.AddLine(itemInfo.Description, "ItemDescription");
            }
        }
コード例 #6
0
ファイル: UIItemSlot.cs プロジェクト: Xdisme8120/TEST_PROJECT
		/// <summary>
		/// Unassign this slot.
		/// </summary>
		public override void Unassign()
		{
			// Remove the icon
			base.Unassign();
			
			// Clear the spell info
			this.m_ItemInfo = null;
			
			// Invoke the on unassign event
			if (this.onUnassign != null)
				this.onUnassign.Invoke(this);
		}
コード例 #7
0
ファイル: UIItemSlot.cs プロジェクト: Adarshmihir/Moonstone
        // <summary>
        /// Performs a slot swap.
        /// </summary>
        /// <returns><c>true</c>, if slot swap was performed, <c>false</c> otherwise.</returns>
        /// <param name="sourceSlot">Source slot.</param>
        public override bool PerformSlotSwap(Object sourceObject)
        {
            // Get the source slot
            IUIItemSlot sourceSlot = (sourceObject as IUIItemSlot);

            // Get the source item info
            UIItemInfo sourceItemInfo = sourceSlot.GetItemInfo();

            // Assign the source slot by this slot
            bool assign1 = sourceSlot.Assign(this.GetItemInfo(), this);

            // Assign this slot by the source slot
            bool assign2 = this.Assign(sourceItemInfo, sourceObject);

            // Return the status
            return(assign1 && assign2);
        }
コード例 #8
0
ファイル: UIItemSlot.cs プロジェクト: Abyzip/SurvvivalMobile
        /// <summary>
        /// Prepares the tooltip with the specified item info.
        /// </summary>
        /// <param name="itemInfo">Item info.</param>
        public static void PrepareTooltip(UIItemInfo itemInfo)
        {
            if (itemInfo == null)
            {
                return;
            }

            // Set the title and description
            UITooltip.AddTitle(itemInfo.Name);

            // Item types
            UITooltip.AddLineColumn(itemInfo.Type);
            UITooltip.AddLineColumn(itemInfo.Subtype);

            if (itemInfo.ItemType == 1)
            {
                UITooltip.AddLineColumn(itemInfo.Damage.ToString() + " Damage");
                UITooltip.AddLineColumn(itemInfo.AttackSpeed.ToString("0.0") + " Attack speed");

                UITooltip.AddLine("(" + ((float)itemInfo.Damage / itemInfo.AttackSpeed).ToString("0.0") + " damage per second)");
            }
            else
            {
                UITooltip.AddLineColumn(itemInfo.Block.ToString() + " Block");
                UITooltip.AddLineColumn(itemInfo.Armor.ToString() + " Armor");
            }

            UITooltip.AddLine("+" + itemInfo.Stamina.ToString() + " Stamina", new RectOffset(0, 0, 6, 0));
            UITooltip.AddLine("+" + itemInfo.Strength.ToString() + " Strength");

            // Set the item description if not empty
            if (!string.IsNullOrEmpty(itemInfo.Description))
            {
                UITooltip.AddDescription(itemInfo.Description);
            }
        }
コード例 #9
0
ファイル: UIItemSlot.cs プロジェクト: Adarshmihir/Moonstone
 /// <summary>
 /// Assign the slot by item info.
 /// </summary>
 /// <param name="itemInfo">The item info.</param>
 public bool Assign(UIItemInfo itemInfo)
 {
     return(this.Assign(itemInfo, null));
 }