protected override IEnumerator InternalExecuteRoutine(Effector effect, Result <bool> result) { DirectionCursor cursor = battle.SpawnDirectionCursor(actor.location); Result <EightDir> dirResult = new Result <EightDir>(); yield return(cursor.SelectTargetDirRoutine(dirResult, actor, (Vector2Int v) => { float d = Mathf.Abs(actor.battler.transform.position.y - map.terrain.HeightAt(v.x, v.y)); return d <= BattleEvent.AttackHeightMax && DefaultSelectRule(effect)(v); }, true)); battle.DespawnDirCursor(); if (dirResult.canceled) { result.Cancel(); } else { float d = Mathf.Abs(actor.battler.transform.position.y - map.terrain.HeightAt(actor.battler.location + dirResult.value.XY())); if (d <= BattleEvent.AttackHeightMax) { yield return(effect.ExecuteDirectionRoutine(dirResult.value)); result.value = true; } else { result.Cancel(); } } }
protected override IEnumerator InternalExecuteRoutine(Effector effect, Result <bool> result) { Func <Vector2Int, bool> rangeRule = (Vector2Int loc) => { return(Vector2Int.Distance(loc, actor.location) <= radius); }; Vector2Int origin = new Vector2Int( (int)actorEvent.positionPx.x - Mathf.CeilToInt(radius), (int)actorEvent.positionPx.z - Mathf.CeilToInt(radius)); SelectionGrid grid = battle.SpawnSelectionGrid(); grid.ConfigureNewGrid(actor.location, Mathf.CeilToInt(radius), map.terrain, rangeRule, rangeRule); Result <Vector2Int> locResult = new Result <Vector2Int>(); battle.SpawnCursor(actor.location); yield return(battle.cursor.AwaitSelectionRoutine(locResult, _ => true, null, loc => { return loc == actor.location; })); battle.DespawnCursor(); Destroy(grid.gameObject); if (locResult.canceled) { result.Cancel(); } else { List <Vector2Int> cells = new List <Vector2Int>(); int r = Mathf.CeilToInt(radius); for (int y = locResult.value.y - r; y <= locResult.value.y + r; y += 1) { for (int x = locResult.value.x - r; x <= locResult.value.x + r; x += 1) { Vector2Int cell = new Vector2Int(x, y); if (DefaultSelectRule(effect)(cell)) { cells.Add(cell); } } } yield return(effect.ExecuteCellsRoutine(cells)); result.value = true; } }
private bool IsSelected(Effector effect, Vector2Int toCheck) { Vector2Int otherLoc = battle.cursor.GetComponent <MapEvent>().location; if (toCheck != otherLoc) { return(false); } if (map.terrain.HeightAt(toCheck) != map.terrain.HeightAt(actor.location)) { //return false; } if (!DefaultSelectRule(effect)(toCheck)) { return(false); } if (!penetrates && !forTeleport) { foreach (Vector2Int v2 in map.PointsAlongPath(actor.location, otherLoc)) { if (v2 != toCheck && DefaultSelectRule(effect)(v2)) { return(false); } } } if (forTeleport) { foreach (Vector2Int v2 in map.PointsAlongPath(actor.location, otherLoc)) { if (map.GetEventAt <BattleEvent>(v2) != null) { return(false); } } } return(true); }