Example #1
0
	private void DrawActionSlot(Rect rFrame, Rect rIcon, ActionSlot s, int slot)
	{
		if (s == null)
		{
			GUI.Box(rFrame, GUIContent.none, gui.ActionIconEmpty);
			return;
		}

		if (s.IsEmpty)
		{
			GUI.Box(rFrame, GUIContent.none, gui.ActionIconEmpty);
			return;
		}

		// icon
		if (GUI.Button(rIcon, s.GetIcon(0, gui.txNoIcon), gui.ActionIconButton))
		{
			// right mouse button is used to remove something from the slot
			if (Input.GetMouseButtonUp(1))
			{
				UniRPGGlobal.Player.Actor.ClearActionSlot(slot);
			}
			else
			{
				UniRPGGlobal.Player.Actor.UseActionSlot(slot, (UniRPGGlobal.Player.TargetInteract == null ? null : UniRPGGlobal.Player.TargetInteract.gameObject));
			}
		}

		// Cool down GFX
		if (s.IsSkill)
		{
			if (s.Skill.cooldownTimer > 0.0f && gui.txCooldown != null)
			{
				if (gui.showSkillCooldown)
				{
					int idx = Mathf.RoundToInt(gui.txCooldown.Count / s.Skill.cooldownTimeSetting * s.Skill.cooldownTimer) - 1;
					if (idx >= 0) GUI.DrawTexture(rIcon, gui.txCooldown[idx]);
					// fixme, add the cooldown number too? GUI.Label(rIcon, s.cooldownTimer.ToString("F1"));
				}
			}

			// invalid/out-of-range skill
			else if (gui.showWhenCantUseSkill)
			{
				if (!UniRPGGlobal.Player.IsSkillTargetInRange(s.Skill)) GUI.DrawTexture(rIcon, gui.txInvalid);
			}

			// Queue GFX
			if (gui.showSkillQueued && s.Skill == UniRPGGlobal.Player.Actor.nextSkill && queuedSkillShow)
			{
				GUI.DrawTexture(rIcon, gui.txQueued);
			}

		}

		// Frame
		GUI.Box(rFrame, GUIContent.none, gui.ActionIconFrame);
	}