public override void DealEffects(Unit target, Unit source) { if (target != null) { Vector2Int origin = target.GetMapPosition(); target.ChangeHealth((GetDamage() * (-1)), source, this); foreach (Vector2Int tile in MapMath.GetNeighbors(origin).Keys) { Unit searchResult = source.globalPositionalData.SearchLocation(tile); if (searchResult != null) { Vector2Int diff = tile - origin; AttackHelper.DisplaceUnit(searchResult, source, this, 1, MapMath.LocToDirection(diff)); } } } }
public override void DealEffects(Unit target, Unit source) { int pushback = 5; if (target != null) { target.ChangeHealth((GetDamage() * (-1)), source, this); Vector2Int diff = target.GetMapPosition() - source.GetMapPosition(); Vector2Int absDiff = new Vector2Int(Mathf.Abs(diff.x), Mathf.Abs(diff.y)); Debug.Assert(source.GetDirection() != Direction.NO_DIR); Vector2Int newLocation = source.GetMapPosition(); //Debug.Log(newLocation); switch (source.GetDirection()) { case Direction.N: newLocation = new Vector2Int(source.GetMapPosition().x, source.GetMapPosition().y + (absDiff.y - 1)); break; case Direction.S: newLocation = new Vector2Int(source.GetMapPosition().x, source.GetMapPosition().y - (absDiff.y - 1)); break; case Direction.W: newLocation = new Vector2Int(source.GetMapPosition().x - (absDiff.x - 1), source.GetMapPosition().y); break; case Direction.E: newLocation = new Vector2Int(source.GetMapPosition().x + (absDiff.x - 1), source.GetMapPosition().y); break; } //Debug.Log(newLocation); //check new location for issues, if so, stay at current loc // ********************************** source.Move(newLocation.x, newLocation.y, MovementType.DASH); AttackHelper.DisplaceUnit(target, source, this, pushback, source.GetDirection()); } else { Vector2Int newLocation = source.GetMapPosition() + (MapMath.DirToRelativeLoc(source.GetDirection()) * pushback); // ********************************** source.Move(newLocation.x, newLocation.y, MovementType.DASH); } }