public void CellClicked(DijkstraTestGridCell cell, bool leftClick) { if (_targetPointsToggle.isOn) { if (OnSetTargetNode != null) { OnSetTargetNode.Invoke(cell, leftClick); } } else if (_wallsToggle.isOn) { if (OnSetWalkable != null) { OnSetWalkable.Invoke(cell, !leftClick); } } else if (_sourcePointsToggle.isOn) { if (OnSetSourceNodeNode != null) { OnSetSourceNodeNode.Invoke(cell, leftClick); } } else if (_terrainCostToggle.isOn) { if (OnSetNodeCost != null) { OnSetNodeCost.Invoke(cell, leftClick); } } }
private void NodeClicked(DijkstraTestGridCell cell, int button) { if (OnNodeClicked != null) { OnNodeClicked.Invoke(cell, button == 0); } }
public void SetWalkable(DijkstraTestGridCell cell, bool isWalkable) { var node = _map.GetNodeAt(cell.node.x, cell.node.y); node.isWalkable = isWalkable; UpdateCells(); }
public void SetSourceNode(DijkstraTestGridCell cell, bool isAdd) { var node = _map.GetNodeAt(cell.node.x, cell.node.y); if (isAdd) { _sourceCells.Add(node); } else { _sourceCells.Remove(node); } UpdateCells(); }
public void SetTerrainCost(DijkstraTestGridCell cell, bool isIncrease) { var node = _map.GetNodeAt(cell.node.x, cell.node.y); if (!isIncrease) { while (node.cost <= 1) { // bump up all costs because dijkstra doesnt work on negative costs _map.GetAllNodes().ForEach(n => n.cost += 1); } } node.cost += isIncrease ? 1 : -1; UpdateCells(); }