Exemple #1
0
	/// <summary>checks if the character can use the skill. does it need a target and is target in range?</summary>
	public virtual bool IsSkillTargetInRange(RPGSkill s)
	{
		if (s == null) return false;
		if (s.targetMech == RPGSkill.TargetingMechanic.AroundOwner || s.targetMech == RPGSkill.TargetingMechanic.AroundLocation) return true;
		if (s.validTargetsMask == 0) return true; // "Nothing"
		if (s.validTargetsMask == UniRPGGlobal.Target.Self) return true;
		if (((int)UniRPGGlobal.Target.Self & (int)s.validTargetsMask) != 0) return true;
		if (s.validTargetsMask == 0 && TargetInteract == null) return true;
		if (TargetInteract == null) return false;
		if (s.IsValidTarget(TargetInteract.gameObject))
		{
			return (Mathf.Abs((TargetInteract.transform.position - _tr.position).sqrMagnitude) <= (s.onUseMaxTargetDistance * s.onUseMaxTargetDistance));
		}
		return false;
	}
Exemple #2
0
	/// <summary>
	/// will queue the skill to be used as soon as current skill is done and/or queued skill is avail for use (cool down might be running)
	/// setAsAutoQueueSkill=true will cause the skill to be queued and performed as long as target is valid or stopped by an action by the player
	/// </summary>
	public void UseSkill(RPGSkill skill, GameObject target, bool setAsAutoQueueSkill)
	{
		if (skill.targetMech == RPGSkill.TargetingMechanic.AroundLocation)
		{
			// the player must first select a spot with the mouse
			InAOESelectMode = true;
			AOESkill = skill;
			nextSkill = null;
			autoSkill = null;
			nextSkillTarget = null;
			autoSkillTarget = null;
		}

		else if ((skill.targetMech == RPGSkill.TargetingMechanic.SingleTarget || skill.targetMech == RPGSkill.TargetingMechanic.AroundTargeted) &&
				skill.validTargetsMask != 0 && ((int)UniRPGGlobal.Target.Self & (int)skill.validTargetsMask) == 0)
		{
			if (skill.IsValidTarget(target))
			{
				if (setAsAutoQueueSkill) { autoSkill = skill; autoSkillTarget = target; }
				nextSkill = skill;
				nextSkillTarget = target;
				if (target == null) nextSkillLocation = transform.position;
				else nextSkillLocation = target.transform.position;
				nextSkillMaxDistance = nextSkill.onUseMaxTargetDistance;
				nextSkillMaxDistance = nextSkillMaxDistance * nextSkillMaxDistance; // cause I'm using sqrMagnitude for distance check				
			}
			else
			{
				nextSkill = null;
				autoSkill = null;
				nextSkillTarget = null;
				autoSkillTarget = null;
				InAOESelectMode = false;
				AOESkill = null;
			}
		}
		else
		{
			if (setAsAutoQueueSkill) { autoSkill = skill; autoSkillTarget = target; }
			nextSkill = skill;

			if (skill.targetMech == RPGSkill.TargetingMechanic.AroundOwner)
			{
				nextSkillTarget = null;
				nextSkillLocation = transform.position; //UniRPGGlobal.Player.transform.position;
			}
			else
			{
				nextSkillTarget = target;
				nextSkillLocation = Vector3.zero;
			}

			if (skill.validTargetsMask == 0 || ((int)UniRPGGlobal.Target.Self & (int)skill.validTargetsMask) != 0)
			{
				nextSkillTarget = ((int)UniRPGGlobal.Target.Self & (int)skill.validTargetsMask) != 0 ? gameObject : null;
				nextSkillLocation = transform.position;
				nextSkillMaxDistance = 0;
			}
			else
			{
				nextSkillMaxDistance = nextSkill.onUseMaxTargetDistance;
				nextSkillMaxDistance = nextSkillMaxDistance * nextSkillMaxDistance; // cause I'm using sqrMagnitude for distance check
			}
		}
	}