/// <summary> /// Begins the selected ally moving /// </summary> /// <param name="startNode">Node to start moving from</param> /// <param name="endNode">Node to move to</param> private void DoMove(Node startNode, Node endNode) { // Make it so that the player cannot select whilst something is moving ToggleSelect(false); // Calculate the pathing _mAContRef.Pathing(startNode, endNode, _charSelected.WhatAmI); // Start moving the character _charSelected.StartMove(); _mAContRef.TurnOffVisuals(_charSelected); }
/// <summary> /// Tells the character to move /// </summary> /// <param name="nodeToMoveTo"></param> private void MoveToTile(Node nodeToMoveTo) { // Path to the tile if (!_mAContRef.Pathing(_standingNode, nodeToMoveTo, CharacterType.Enemy)) { //Debug.Log("Pathing failed for " + this.name + ". Wanted to move from " + _standingNode.Position + " to " + nodeToMoveTo.Position); _standingNode.WhereToGo = _standingNode; } // Start moving along that path _mARef.StartMove(); }
/// <summary> /// Moves the current enemy and makes them attack /// </summary> private void TakeSingleTurn() { // Try to get the current enemy we should move _currentEnemy = _enemiesMA[_enemyIndex]; // If the enemy does not exist, do not try to move it if (_currentEnemy == null) { Debug.Log("We done bois, I'm don't exist"); return; } //Debug.Log("Moving " + currentEnemy.name); Node startNode = _mAContRef.GetNodeByWorldPosition(_currentEnemy.transform.position); // Reset this enemies movement _currentEnemy.CalculateAllTiles(); // Get the node this character should try to attack and the node this character should move to _curAttackNodePos = FindDesiredAttackNodePos(); //Debug.Log("Found node to attack at " + curAttackNodePos); Node desiredNode = FindDesiredMovementNode(); // If the node returns null, it means we cannot do anything with this enemy if (desiredNode == null) { // Debug.Log(currentEnemy.name + " Attack Node: " + curAttackNodePos); Debug.Log("Desired node is null"); AttemptAttack(); EndSingleTurn(); return; } // See if they are trying to move where a character already is else if (desiredNode.Occupying != CharacterType.None) { Debug.Log("Desired Node is at " + desiredNode.Position); Debug.Log("Trying to move to where a character already is"); if (desiredNode != startNode) { Debug.Log("Wrong move pal"); Debug.Log(_currentEnemy.name + " Start Node: " + startNode.Position + ". End Node: " + desiredNode.Position); Debug.Log(_currentEnemy.name + " Attack Node: " + _curAttackNodePos); } // Come back bool didAttack = AttemptAttack(); EndSingleTurn(); if (!didAttack) { StartNextEnemy(); } return; } Debug.Log("Desired Node is at " + desiredNode.Position); // Debug.Log(currentEnemy.name + " Start Node: " + startNode.position + ". End Node: " + desiredNode.position); // Debug.Log(currentEnemy.name + " Attack Node: " + curAttackNodePos); // Calculate the pathing // If they successfully pathed if (_mAContRef.Pathing(startNode, desiredNode, _currentEnemy.WhatAmI)) { // Start moving the character _currentEnemy.StartMove(); } // If they didn't just attempt an attack else { _mAContRef.ResetPathing(); AttemptAttack(); } // Attacking will be called after the enemy has moved // End the single turn EndSingleTurn(); }