public IEnumerable <CastSkillAction> CalculateCastSkillTile(Entity entity, int skillID, Location target, bool isPrediction = false) { var skill = entity.SkillHashes[skillID].GetBaseSkill(); int availableAP = isPrediction ? Mathf.Clamp(entity.ActionPoints + entity.ActionPointsPerTurn, 0, 8) : entity.ActionPoints - skill.actionPointsCost; if (availableAP < 0) { yield break; } for (int i = 0; i < availableAP / entity.MoveCost + 1; i++) { foreach (var loc in Nav.GetGivenDistancePoints(entity.Loc, i)) { foreach (var cp in skill.CastPattern) { foreach (var el in skill.GetSubEffectZone(loc, cp)) { if (el.Equals(target)) { yield return(new CastSkillAction(loc, loc + cp)); } } } } } }
/// <summary> /// Has Duplication checked /// </summary> /// <param name="entity"></param> /// <param name="isPrediction"></param> /// <param name="skill"></param> /// <returns></returns> public IEnumerable <Location> CalculateEntityGivenSkillEffectZone(Entity entity, bool isPrediction, int skillID, HashSet <Location> avoidZone) { var skill = entity.SkillHashes[skillID].GetBaseSkill(); var zone = new HashSet <Location>(); int entityAP = isPrediction ? Mathf.Clamp(entity.ActionPoints + entity.ActionPointsPerTurn, 0, 8) : entity.ActionPoints; int entityMoveStep = entityAP / entity.MoveCost; for (int i = 0; i < entityMoveStep + 1; i++) { if (skill.actionPointsCost <= entityAP - i * entity.MoveCost) { foreach (var loc in Nav.GetGivenDistancePoints(entity.Loc, i, false)) { if (avoidZone.Contains(loc)) { continue; } foreach (var effectLoc in skill.GetEffectZone(loc)) { if (!zone.Contains(effectLoc)) { zone.Add(effectLoc); yield return(effectLoc); } } } } } }
public IEnumerable <Location> TryGetLocationOutsideZone(Entity self, Entity caster, HashSet <Location> zone) { foreach (var reachableLoc in Nav.GetGivenDistancePoints(self.Loc, self.ActionPoints / self.MoveCost)) { if (!zone.Contains(reachableLoc) && IsUnblockedLocation(reachableLoc)) { yield return(reachableLoc); } } }
public bool TryGetTileOutsideZone(Entity self, HashSet <Location> zone, out TileController safeTile) { foreach (var reachableLoc in Nav.GetGivenDistancePoints(self.Loc, self.ActionPoints / self.MoveCost)) { if (!zone.Contains(reachableLoc) && IsUnblockedLocation(reachableLoc)) { safeTile = TileDic[reachableLoc]; return(true); } } safeTile = null; return(false); }