Ejemplo n.º 1
0
    private void UpdateMovement()
    {
        if (_unitSelected && !_spellSelected)
        {
            EnableUnitMovement();
        }

        if (_unitSelected && _spellSelected)
        {
            DisableUnitMovement();
        }

        if (!_unitSelected || !_unitMovement)
        {
            if (!pathAlreadyHidden)
            {
                HidePath();
            }
            return;
        }


        pathAlreadyHidden = false;

        ShowPath(MOV);


        // if the position is the same as the last tile sown, then move, otherwise, th player wanted to deselect by clicking anywhere
        if (Input.GetMouseButtonDown(0))
        {
            Vector3 pos      = mousePosition.GetAimedPosition();
            bool    sameTile = pos.x == highlightedPath[highlightedPath.Count - 1].transform.position.x && pos.z == highlightedPath[highlightedPath.Count - 1].transform.position.z;
            if (sameTile && CombatManager.instance.CanMoveAt(highlightedPath[highlightedPath.Count - 1].transform.position))
            {
                Debug.Log("Clicked");
                CreatePath();
                FollowPath();
            }
            PreShowNextTile();
        }
    }