public void Do(Entity with) { //define how we heal ahead of time, to avoid code repetition Action healAction = () => { healTarget.Health.ApplyHealing(healAmount); LeanTween.moveLocal(with.gameObject, healTarget.transform.position, 0.1f).setEaseInCubic().setLoopPingPong(1); LeanTween.delayedCall(0.2f, () => { OnActionFinish?.Invoke(); OnActionFinish = null; healTarget = null; }); }; //if we're not adjacent if (with.Position.DistanceTo(healTarget.Position) > 1) { List <Hex> path = GridHelper.GetPathToHex(GameplayContext.Grid, with.Position, healTarget.Position); path.Remove(GameplayContext.Player.Position); //step forward first, and THEN do the heal action once we're adjacent with.MoveAlong(path, maxSteps: 2, callback: healAction); } else { //we're already adjacent, just do the healing action healAction.Invoke(); } }
void IAIAction.Do(Entity with) { HexGrid grid = GameplayContext.Grid; if (InlineWithPlayer(with)) { List <Hex> adjacents = with.Position.GetAllNeighbours(); GridHelper.RemoveOccupiedHexes(grid, adjacents); GameplayContext.Player.MoveTo(GridHelper.GetNearestHexInList(adjacents, GameplayContext.Player.Position)); LeanTween.delayedCall(0.2f, () => { OnActionFinish?.Invoke(); OnActionFinish = null; }); } else { Hex nearest = GetNearestInlinePosition(with); List <Hex> path = GridHelper.GetPathToHex(GameplayContext.Grid, with.Position, nearest); with.MoveAlong(path, maxSteps: movementRange, callback: () => { OnActionFinish?.Invoke(); OnActionFinish = null; }); } }
public void Do(Entity with) { List <Hex> path = GridHelper.GetPathToHex(GameplayContext.Grid, with.Position, navTarget.Position); path.Remove(navTarget.Position); with.MoveAlong(path, maxSteps: speed, callback: () => { OnActionFinish?.Invoke(); OnActionFinish = null; }); }
public void Do(Entity with) { with.DealDamageTo(GameplayContext.Player, baseDamage); with.TriggerAttackEvent(GameplayContext.Player); LeanTween.moveLocal(with.gameObject, GameplayContext.Player.transform.position, 0.1f) .setEaseInCubic().setLoopPingPong(1); FXHelper.PlaySound(attackSound); LeanTween.delayedCall(0.2f, () => { OnActionFinish?.Invoke(); OnActionFinish = null; }); }
public void Do(Entity with) { List <Hex> path = GridHelper.GetPathToHex(GameplayContext.Grid, with.Position, GameplayContext.Player.Position); path.Remove(GameplayContext.Player.Position); //this is gross, it works but make it cleaner later with.MoveAlong(path, maxSteps: range, callback: () => { with.DealDamageTo(GameplayContext.Player, baseDamage); with.TriggerAttackEvent(GameplayContext.Player); LeanTween.moveLocal(with.gameObject, GameplayContext.Player.transform.position, 0.1f) .setEaseInCubic().setLoopPingPong(1); FXHelper.PlaySound("MetalHit"); LeanTween.delayedCall(0.2f, () => { OnActionFinish?.Invoke(); OnActionFinish = null; }); }); }