/// <summary> /// Used to test what kind of tile the current testNode in CalculateAllTiles. /// This is the Interact specific variety. That means, nodes will be appended regardless of what is at that tile. /// It also means that we test for only 2 different interactions: attacking and interactables (movement has been done already). /// If the attack range is more than 0, all these tiles will become attack tiles. /// </summary> /// <param name="testPos">Position of the node being tested</param> /// <param name="testedNodes">Reference to the List of Nodes that have been tested before</param> /// <param name="currentNodes">Reference to the List of Nodes that still need to be tested</param> private void InteractTestNode(Vector2Int testPos, List <Node> testedNodes, List <Node> currentNodes) { Node testNode = _mAContRef.GetNodeAtPosition(testPos); // If there is a node there are we have not tested it before if (testNode != null && !testedNodes.Contains(testNode)) { // If the tile is occupied by an interactable if (testNode.Occupying == CharacterType.Interactable) { // Get the interactable at that node Interactable interactAtNode = _mAContRef.GetInteractableByNode(testNode); // Only add the interactable to interact tiles if it can currently be interacted with if (interactAtNode != null && interactAtNode.GetCanInteractWith()) { _interactTiles.Add(testNode); } } // If I can reach with an attack else if (_attackRange >= 1) { _attackTiles.Add(testNode); } // Add the node to the tested nodes testedNodes.Add(testNode); // Only add the node to the current nodes if the character's attack range is above 1 if (_attackRange > 1) { currentNodes.Add(testNode); } } }
/// <summary> /// When the user tries to interact with something after moving /// </summary> /// <param name="selNode">The node that was selected</param> /// <returns>Returns true if the interaction was successful, false otherwise</returns> private bool AttemptInteract(Node selNode) { // If there is an interactable at that location and it is in the selected character's interact tiles Interactable interact = _mAContRef.GetInteractableByNode(selNode); if (_charSelected.InteractTiles.Contains(selNode) && selNode.Occupying == CharacterType.Interactable && interact != null) { // Set the node to interact with _nodeToAttack = selNode; // When the ally finishes their interaction, return control to the user Interactable.OnFinishInteraction += ReturnControlAfterInteract; // Have the ally interact with that node DoInteract(); } return(false); }