void SetCurrentUnit(NodeUnit value) { _currentUnit = value; if (CurrentUnit) { ControllingSide = CurrentUnit.Side; } }
private void SetSelectedUnit_BaseMethod(NodeUnit value) { if (SelectedUnit) { SelectedUnit.Highlighted = false; } _selectedUnit = value; UnitSelectedAction.Invoke(SelectedUnit); if (SelectedUnit) { SelectedUnit.Highlighted = true; CameraManager.Instance.FocusOn(SelectedUnit); } }
internal void UnitClicked(NodeUnit nodeUnit) { Debug.Log($"Unit Clicked: {nodeUnit}"); if ((!CardBase.Selected_Card || !CardBase.Selected_Card.CanBePlayedOn(nodeUnit._standardMovement.CurrentNode)) && nodeUnit.Side == HumanPlayerManager.Instance) { CardBase.Selected_Card = null; SelectedUnit = nodeUnit; } else if (nodeUnit._standardMovement) { NodeClicked(nodeUnit._standardMovement.CurrentNode); } }
private void MovableUnitNodeSet(StandardMovement unitMovement, Node node) { // TODO Refactor if (unitMovement) { // TODO Refactor expensive GetComponent call NodeUnit unit = unitMovement.GetComponent <NodeUnit>(); // var pathToNode = Pathfinder.GetPathOfTypeForUnit ( unitMovement.CurrentNode, this, Pathfinder.PathfindingType.Ground, unit ); _nodeVisuals.SetMovableToVisualState(pathToNode != null); } else { _nodeVisuals.SetMovableToVisualState(true); } }
private void SetSelectedUnit(NodeUnit value) { SetSelectedUnit_BaseMethod(value); SetSelectedUnit_OverrideMethod(value); }
protected override void SetSelectedUnit_OverrideMethod(NodeUnit value) { //TODO Implement }
protected override void HighlightUnit(NodeUnit unit) { //TODO Implement }
public bool BlocksUnit(NodeUnit unit) { return(unit && CurrentUnit && CurrentUnit.Side == unit.Side); }
public override bool GetIsMoveBlocked(NodeUnit unit) { return(_unitTypesBlocked[(int)Type - 1].Contains(unit._unitType) && !unit._standardMovement._canTraverseTerrainMap.ContainsKey(Type)); }
private void UnitSelected(NodeUnit unit) { var unitMovement = unit?._standardMovement; MovableUnitNodeSet(unitMovement, unitMovement?.CurrentNode); }
public static Path GetPathOfTypeForUnit(IPathfindingNode startNode, IPathfindingNode endNode, PathfindingType pathfindingType, NodeUnit unit) { IPathfindingNode[] neighbourNodes = null; IPathfindingNode neighbourNode; cameFromArray.Clear(); costSoFarArray.Clear(); frontier.Clear(); currentNode = null; frontier.Enqueue(startNode, 0); cameFromArray[startNode] = null; costSoFarArray[startNode] = 0.0; while (frontier.NumItems > 0) { currentNode = frontier.Dequeue(); //float startTime = Time.realtimeSinceStartup; if (currentNode == endNode) { //float endTime = Time.realtimeSinceStartup; //float totalTime = endTime - startTime; path = new Path(startNode, currentNode, cameFromArray, costSoFarArray); return(path); } neighbourNodes = currentNode.GetConnectedNodes().ToArray(); for (int i = 0; i < neighbourNodes.Length; i++) { neighbourNode = neighbourNodes[i]; if (neighbourNode != null && neighbourNode != startNode && (!neighbourNode.BlocksUnit(unit) || pathfindingType == PathfindingType.Air)) { stepCost = currentNode.GetConnectionToNode(neighbourNode)._movementPointCost; bool hasFoundCost = costSoFarArray.TryGetValue(neighbourNode, out currentLowestCost); var costSoFar = costSoFarArray[currentNode]; newCost = costSoFar + stepCost; if (currentLowestCost <= 0 || newCost < currentLowestCost) { costSoFarArray[neighbourNode] = newCost; //if (pathfindingType == PathfindingType.Tile) //{ //priority = 1.0 / (newCost + heuristic(endPathfindingNode, neighbourPathfindingNode)); //} else //{ priority = 1.0 / newCost; //} frontier.Enqueue(neighbourNode, priority); cameFromArray[neighbourNode] = currentNode; } } } } return(null); }
public abstract bool GetIsMoveBlocked(NodeUnit unit);
public override bool GetIsMoveBlocked(NodeUnit unit) { return(false); }
public override void ActivateOn(Node node) { NodeUnit unit = Instantiate(_unitPrefab, MapManager.Instance._unitParent); unit.Initialise(node); }
protected abstract void HighlightUnit(NodeUnit unit);
protected abstract void SetSelectedUnit_OverrideMethod(NodeUnit value);
internal void FocusOn(NodeUnit selectedUnit) { //TODO Implement }