public static BresenhamResults CalculateLine(Vector2Int start, Vector2Int end) { BresenhamResults results = new BresenhamResults(); results.path = new List <CustomTile>(); results.fullPath = new List <CustomTile>(); bool beenBlocked = false; foreach (Vector2Int spot in GetPointsOnLine(start.x, start.y, end.x, end.y)) { //It's assumed that something that blocks movement blocks this line. //TODO: Make sure this assumption actually makes sense CustomTile t = Map.current.GetTile(spot); if (!beenBlocked) { results.path.Add(t); results.fullPath.Add(t); } if (t.BlocksMovement()) { beenBlocked = true; } } results.blocked = beenBlocked; return(results); }
//The main function! This EXACT coroutine will be executed, even across frames. //See GameAction.cs for more information on how this function should work! public override IEnumerator TakeAction() { yield return(GameAction.StateCheck); CustomTile tile = Map.current.GetTile(intendedLocation); if (tile.BlocksMovement()) { Debug.Log("Console Message: You don't can't do that."); yield break; } caller.connections.OnMove.Invoke(); if (tile.currentlyStanding != null) { AttackAction attack = new AttackAction(tile.currentlyStanding); attack.Setup(caller); while (attack.action.MoveNext()) { yield return(attack.action.Current); } yield break; } caller.SetPosition(intendedLocation); if (costs) { caller.energy -= caller.energyPerStep * tile.movementCost; } caller.UpdateLOS(); }
public bool NeedsExploring(Vector2Int location) { CustomTile tile = GetTile(location); if (tile.BlocksMovement()) { return(false); } if (tile.isHidden) { return(true); } //Check the 8 directions! for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { //Skip middle! if (i == 0 && j == 0) { continue; } Vector2Int newLoc = location + new Vector2Int(i, j); if (newLoc.x < 0 || newLoc.y < 0 || newLoc.x >= width || newLoc.y >= height) { continue; } if (GetTile(newLoc).isHidden) { return(true); } } } return(false); }