/// <summary> /// Moves the controller towards the next point /// </summary> protected virtual void MoveGridObject() { if ((m_DestinationTile == null) || (m_NextPathpointIndex < 0) || Path.Count <= 0) { return; } else { _gridMovement.TryMoveTo(Path[m_NextPathpointIndex], m_AnimateMovement, m_RotateTowardsDirection); } }
/// <summary> /// Moves the controller towards the next point /// </summary> protected virtual void MoveGridObject() { if ((m_NextPathIndex < 0) || m_Path.Count <= 0) { return; } else { _gridMovement.TryMoveTo(m_Path[m_NextPathIndex], m_AnimateMovement, m_RotateTowardsDirection, m_ChecksMovementCooldown); } }
/// <summary> /// Moves the controller towards the next point /// </summary> protected virtual void MoveGridObject() { if ((m_TargetGridTile == null) || (m_NextPathpointIndex < 0) || Path.Count <= 0) { return; } else { _gridMovement.TryMoveTo(Path[m_NextPathpointIndex], m_AnimateMovement, m_RotateTowardsDirection, m_ChecksMovementCooldown); } }
protected virtual IEnumerator ActivateRoutine(GridTile destinationTile, GridMovement gridMovement) { yield return(null); // Stop the current movement gridMovement.TryStop(); // Wait for 1 frame till the movement actually stops //yield return null; gridMovement.TryMoveTo(destinationTile, false, false, false); gridMovement.RotateTo(m_TargetTeleport.m_GridObject.m_GridPosition + m_DirectionToFaceOnTeleport, false); }
protected virtual void ChaseTarget() { m_PathToTarget.Clear(); if (m_CurrentTarget == null) { GetTargetInRange(); } if (m_CurrentTarget == null) { return; } // Attack if (TryToAttackWhenPossible) { var targetPosition = m_CurrentTarget.m_GridPosition; var gridObjectAtPosition = GridManager.Instance.GetGridObjectAtPosition(targetPosition); if (gridObjectAtPosition != null && m_Attack != null) { var healthComponents = m_Attack.GetVictimsFromTriggerAtPosition(targetPosition); if (healthComponents != null && healthComponents.Count > 0) { var attkResult = m_Attack.TryAttack(targetPosition); if (attkResult == AttackResult.Success) { return; } } } } // Movement if (_gridObject.m_GridPosition.GridDistance(m_CurrentTarget.m_GridPosition) > 1) { // Calculate a path and try moving towards the target m_PathToTarget = AStar.Search(_gridObject.m_CurrentGridTile, m_CurrentTarget.m_CurrentGridTile); if (m_PathToTarget != null && m_PathToTarget.Count > 0 && m_PathToTarget.Contains(m_CurrentTarget.m_CurrentGridTile)) { _gridMovement.TryMoveTo(m_PathToTarget[0]); } } else // Rotation { var targetDirection = m_CurrentTarget.m_GridPosition; var rotated = _gridMovement.TryRotateTo(targetDirection); } }