Esempio n. 1
0
    public void Push(Directions dir)
    {
        if (isMoving)
        {
            return;
        }
        if (_isDisabled)
        {
            return;
        }

        Vector3 desiredDir = Script_Utils.GetDirectionToVectorDict()[dir];

        // check for collisions
        // if no collisions then able to push, return true
        GetComponent <Script_InteractionBoxController>().HandleActiveInteractionBox(dir);
        bool isCollision = GetComponent <Script_CheckCollisions>().CheckCollisions(
            transform.position, dir, ref desiredDir
            );

        if (isCollision)
        {
            return;
        }

        startLocation = transform.position;
        endLocation   = transform.position + desiredDir;
        Move();
    }
Esempio n. 2
0
    /// <summary>
    /// Check if allowed to move to desired grid tile
    /// </summary>
    /// <param name="desiredDirection"></param>
    /// <returns>true if collision (not allowed to move to that space)</returns>
    public bool CheckCollisions(Vector3 currentLocation, Directions dir, ref Vector3 desiredMove)
    {
        Vector3    desiredDirection  = Script_Utils.GetDirectionToVectorDict()[dir];
        Vector3Int tileWorldLocation = (currentLocation + desiredDirection).ToVector3Int();

        bool isStairs = ModifyElevation(currentLocation, dir, ref desiredMove);

        if (isStairs)
        {
            return(false);
        }

        if (CheckNotOffTilemap(tileWorldLocation))
        {
            Debug.Log($"{name} Tilemap Collision at tileWorldLocation {tileWorldLocation}");
            return(true);
        }

        if (CheckInteractableBlocking(dir))
        {
            Debug.Log($"{name} Interactable Collision at dir {dir}");
            return(true);
        }
        if (CheckPushableBlocking(dir))
        {
            Debug.Log($"{name} Pushable Collision at dir {dir}");
            return(true);
        }
        if (CheckUniqueBlocking(dir))
        {
            Debug.Log($"{name} Unique Collision at dir {dir}");
            return(true);
        }

        return(false);
    }
 void Awake()
 {
     interactionBoxes  = interactionBoxController.InteractionBoxes;
     directionToVector = Script_Utils.GetDirectionToVectorDict();
 }