Ejemplo n.º 1
0
        /// <summary>
        /// Assign the slot by spell info.
        /// </summary>
        /// <param name="spellInfo">Spell info.</param>
        public bool Assign(UISpellInfo spellInfo)
        {
            if (spellInfo == 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(spellInfo.Icon);

            // Set the spell info
            this.m_SpellInfo = spellInfo;

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

            // Success
            return(true);
        }
        /// <summary>
        /// Assign the the spell row by the specified spellInfo.
        /// </summary>
        /// <param name="spellInfo">Spell info.</param>
        public void Assign(UISpellInfo spellInfo)
        {
            if (spellInfo == null)
            {
                return;
            }

            if (this.m_RankText != null)
            {
                this.m_RankText.text = Random.Range(1, 10).ToString();
            }

            if (this.m_NameText != null)
            {
                this.m_NameText.text = spellInfo.Name;
            }

            if (this.m_DescriptionText != null)
            {
                this.m_DescriptionText.text = spellInfo.Description;
            }

            if (this.m_SpellSlot != null)
            {
                this.m_SpellSlot.Assign(spellInfo);
            }
        }
        /// <summary>
        /// Raises the assign spell event.
        /// </summary>
        /// <param name="spellSlot">The spell slot.</param>
        public void OnAssignSpell(UISpellSlot spellSlot)
        {
            // Return if the slot is not valid
            if (spellSlot == null || spellSlot.GetSpellInfo() == null)
            {
                return;
            }

            // Get the spell info
            UISpellInfo spellInfo = spellSlot.GetSpellInfo();

            // Check if this spell still has cooldown
            if (spellCooldowns.ContainsKey(spellInfo.ID))
            {
                float cooldownTill = spellCooldowns[spellInfo.ID].endTime;

                // Check if the cooldown isnt expired
                if (cooldownTill > Time.time)
                {
                    this.m_IsOnCooldown = true;

                    // Resume the cooldown
                    this.ResumeCooldown(spellInfo.ID);
                }
                else
                {
                    // Cooldown already expired, remove the record
                    spellCooldowns.Remove(spellInfo.ID);
                }
            }
        }
        void Start()
        {
            if (this.m_CastBar != null && UISpellDatabase.Instance != null)
            {
                this.spell1 = UISpellDatabase.Instance.Get(0);
                this.spell2 = UISpellDatabase.Instance.Get(2);

                this.StartCoroutine("StartTestRoutine");
            }
        }
Ejemplo n.º 5
0
		void Start()
		{
			if (this.m_CastBar != null && this.m_SpellDatabase != null)
			{
				this.spell1 = this.m_SpellDatabase.Get(0);
				this.spell2 = this.m_SpellDatabase.Get(1);
				
				this.StartCoroutine("StartTestRoutine");
			}
		}
        /// <summary>
        /// Unassign this slot.
        /// </summary>
        public override void Unassign()
        {
            // Remove the icon
            base.Unassign();

            // Clear the talent info
            this.m_TalentInfo = null;

            // Clear the spell info
            this.m_SpellInfo = null;
        }
        public void OnSpellClick(UISpellSlot slot)
        {
            // Make sure we have the cast bar component and the slot is assigned
            if (this.m_CastBar == null || !slot.IsAssigned())
            {
                return;
            }

            // Check if we are already casting
            if (this.m_CastBar.IsCasting)
            {
                return;
            }

            // Get the spell info from the slot
            UISpellInfo spellInfo = slot.GetSpellInfo();

            // Make sure we have spell info
            if (spellInfo == null)
            {
                return;
            }

            // Check if we are on cooldown
            if (spellInfo.Cooldown > 0f && slot.cooldownComponent != null && slot.cooldownComponent.IsOnCooldown)
            {
                return;
            }

            // Check if the spell is not insta cast
            if (!spellInfo.Flags.Has(UISpellInfo_Flags.InstantCast))
            {
                // Start casting
                this.m_CastBar.StartCasting(spellInfo, spellInfo.CastTime, Time.time + spellInfo.CastTime);
            }

            // Handle cooldown just for the demonstration
            if (slot.cooldownComponent != null && spellInfo.Cooldown > 0f)
            {
                // Start the cooldown on all the slots with the specified spell id
                foreach (UISpellSlot s in UISpellSlot.GetSlots())
                {
                    if (s.IsAssigned() && s.GetSpellInfo() != null && s.cooldownComponent != null)
                    {
                        // If the slot IDs match
                        if (s.GetSpellInfo().ID == spellInfo.ID)
                        {
                            // Start the cooldown
                            s.cooldownComponent.StartCooldown(spellInfo.ID, spellInfo.Cooldown);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Unassign this slot.
        /// </summary>
        public override void Unassign()
        {
            // Remove the icon
            base.Unassign();

            // Clear the spell info
            this.m_SpellInfo = null;

            // Invoke the on unassign event
            if (this.onUnassign != null)
            {
                this.onUnassign.Invoke(this);
            }
        }
Ejemplo n.º 9
0
        // <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
            UISpellSlot sourceSlot = (sourceObject as UISpellSlot);

            // Get the source spell info
            UISpellInfo sourceSpellInfo = sourceSlot.GetSpellInfo();

            // Assign the source slot by this one
            bool assign1 = sourceSlot.Assign(this.GetSpellInfo());

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

            // Return the status
            return(assign1 && assign2);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Assign the the spell row by the specified spellInfo.
        /// </summary>
        /// <param name="spellInfo">Spell info.</param>
        public void Assign(UISpellInfo spellInfo)
        {
            if (spellInfo == null)
                return;

            if (this.m_RankText != null)
                this.m_RankText.text = Random.Range(1, 10).ToString();

            if (this.m_NameText != null)
                this.m_NameText.text = spellInfo.Name;

            if (this.m_DescriptionText != null)
                this.m_DescriptionText.text = spellInfo.Description;

            if (this.m_SpellSlot != null)
                this.m_SpellSlot.Assign(spellInfo);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Assign the specified slot by talentInfo and spellInfo.
        /// </summary>
        /// <param name="talentInfo">Talent info.</param>
        /// <param name="spellInfo">Spell info.</param>
        public bool Assign(UITalentInfo talentInfo, UISpellInfo spellInfo)
        {
            if (talentInfo == null || spellInfo == null)
                return false;

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

            // Set the talent info
            this.m_TalentInfo = talentInfo;

            // Set the spell info
            this.m_SpellInfo = spellInfo;

            // Update the points label
            this.UpdatePointsLabel();

            // Return success
            return true;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Assign the specified slot by talentInfo and spellInfo.
        /// </summary>
        /// <param name="talentInfo">Talent info.</param>
        /// <param name="spellInfo">Spell info.</param>
        public bool Assign(UITalentInfo talentInfo, UISpellInfo spellInfo)
        {
            if (talentInfo == null || spellInfo == null)
            {
                return(false);
            }

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

            // Set the talent info
            this.m_TalentInfo = talentInfo;

            // Set the spell info
            this.m_SpellInfo = spellInfo;

            // Update the points label
            this.UpdatePointsLabel();

            // Return success
            return(true);
        }
Ejemplo n.º 13
0
        public static void PrepareTooltip(UISpellInfo spellInfo)
        {
            // Make sure we have spell info, otherwise game might crash
            if (spellInfo == null)
            {
                return;
            }

            // Set the spell name as title
            UITooltip.AddTitle(spellInfo.Name);

            // Prepare some attributes
            if (spellInfo.Flags.Has(UISpellInfo_Flags.Passive))
            {
                UITooltip.AddLine("Passive");
            }
            else
            {
                // Power consumption
                if (spellInfo.PowerCost > 0f)
                {
                    if (spellInfo.Flags.Has(UISpellInfo_Flags.PowerCostInPct))
                    {
                        UITooltip.AddLineColumn(spellInfo.PowerCost.ToString("0") + "% Energy");
                    }
                    else
                    {
                        UITooltip.AddLineColumn(spellInfo.PowerCost.ToString("0") + " Energy");
                    }
                }

                // Range
                if (spellInfo.Range > 0f)
                {
                    if (spellInfo.Range == 1f)
                    {
                        UITooltip.AddLineColumn("Melee range");
                    }
                    else
                    {
                        UITooltip.AddLineColumn(spellInfo.Range.ToString("0") + " yd range");
                    }
                }

                // Cast time
                if (spellInfo.CastTime == 0f)
                {
                    UITooltip.AddLineColumn("Instant");
                }
                else
                {
                    UITooltip.AddLineColumn(spellInfo.CastTime.ToString("0.0") + " sec cast");
                }

                // Cooldown
                if (spellInfo.Cooldown > 0f)
                {
                    UITooltip.AddLineColumn(spellInfo.Cooldown.ToString("0.0") + " sec cooldown");
                }
            }

            // Set the spell description if not empty
            if (!string.IsNullOrEmpty(spellInfo.Description))
            {
                UITooltip.AddDescription(spellInfo.Description);
            }
        }
        /// <summary>
        /// Starts the casting of the specified spell.
        /// </summary>
        /// <param name="spellInfo">Spell info.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="endTime">End time.</param>
        public virtual void StartCasting(UISpellInfo spellInfo, float duration, float endTime)
        {
            // Make sure we can start casting it
            if (this.m_IsCasting)
            {
                return;
            }

            // Stop the coroutine might be still running on the hide delay
            this.StopCoroutine("AnimateCast");
            this.StopCoroutine("DelayHide");

            // Apply the normal colors
            this.ApplyColorStage(this.m_NormalColors);

            // Change the fill pct
            this.SetFillAmount(0f);

            // Set the spell name
            if (this.m_TitleLabel != null)
            {
                this.m_TitleLabel.text = spellInfo.Name;
            }

            // Set the full time cast text
            if (this.m_FullTimeLabel != null)
            {
                this.m_FullTimeLabel.text = spellInfo.CastTime.ToString(this.m_FullTimeFormat);
            }

            // Set the icon if we have enabled icons
            if (this.m_UseSpellIcon)
            {
                // Check if we have a sprite
                if (spellInfo.Icon != null)
                {
                    // Check if the icon image is set
                    if (this.m_IconImage != null)
                    {
                        this.m_IconImage.sprite = spellInfo.Icon;
                    }

                    // Enable the frame
                    if (this.m_IconFrame != null)
                    {
                        this.m_IconFrame.SetActive(true);
                    }
                }
            }

            // Set some info about the cast
            this.currentCastDuration = duration;
            this.currentCastEndTime  = endTime;

            // Define that we start casting animation
            this.m_IsCasting = true;

            // Show the cast bar
            this.Show();

            // Start the cast animation
            this.StartCoroutine("AnimateCast");
        }
Ejemplo n.º 15
0
		/// <summary>
		/// Starts the casting of the specified spell.
		/// </summary>
		/// <param name="spellInfo">Spell info.</param>
		/// <param name="duration">Duration.</param>
		/// <param name="endTime">End time.</param>
		public virtual void StartCasting(UISpellInfo spellInfo, float duration, float endTime)
		{
			// Make sure we can start casting it
			if (this.m_IsCasting)
				return;
			
			// Stop the coroutine might be still running on the hide delay
			this.StopCoroutine("AnimateCast");
			this.StopCoroutine("DelayHide");
			
			// Apply the normal colors
			this.ApplyColorStage(this.m_NormalColors);
			
			// Change the fill pct
			this.SetFillAmount(0f);
			
			// Set the spell name
			if (this.m_TitleLabel != null)
				this.m_TitleLabel.text = spellInfo.Name;
			
			// Set the icon if we have enabled icons
			if (this.m_UseSpellIcon)
			{
				// Check if we have a sprite
				if (spellInfo.Icon != null)
				{
					// Check if the icon image is set
					if (this.m_IconImage != null)
						this.m_IconImage.sprite = spellInfo.Icon;
					
					// Enable the frame
					if (this.m_IconFrame != null)
						this.m_IconFrame.SetActive(true);
				}
			}
			
			// Set some info about the cast
			this.currentCastDuration = duration;
			this.currentCastEndTime = endTime;
			
			// Define that we start casting animation
			this.m_IsCasting = true;
			
			// Show the cast bar
			this.Show();
			
			// Start the cast animation
			this.StartCoroutine("AnimateCast");
		}
Ejemplo n.º 16
0
		/// <summary>
		/// Unassign this slot.
		/// </summary>
		public override void Unassign()
		{
			// Remove the icon
			base.Unassign();
			
			// Clear the talent info
			this.m_TalentInfo = null;
			
			// Clear the spell info
			this.m_SpellInfo = null;
		}