예제 #1
0
    public bool CheckConnection(OctoDirXZ odxz, LayerMask layerWalls)
    {
        GridNode target = GetNeighbour(odxz);

        if (!target)
        {
            return(false);
        }

        Vector3 midPos = Vector3.Lerp(transform.position, target.transform.position, 0.5F);

        Collider[] colliders = Physics.OverlapBox(midPos, transform.localScale / 3.001F, Quaternion.identity, layerWalls);
        if (colliders.Length > 0)
        {
            return(false);
        }

        if (odxz.IsDiagonal())
        {
            return(CheckConnectionDiagonal(target));
        }
        else
        {
            return(CheckConnection(target));
        }
    }
예제 #2
0
    /* This comment is here just to remind me of this:
     * There can be too many GridNodes on a Scene at any given time. Having an Update function ON EACH AND EVERY ONE may not be the best idea.
     * public void Update()
     * {
     *
     * }
     */

    public List <OctoDirXZ> GetNeighboursConnected()
    {
        List <OctoDirXZ> result          = new List <OctoDirXZ>();
        bool             connectionCheck = bl_Blocked;
        OctoDirXZ        dir             = OctoDirXZ.BACK_LEFT;

        if (connectionCheck)
        {
            result.Add(dir);
        }
        connectionCheck = b__Blocked;
        dir             = OctoDirXZ.BACK;
        if (connectionCheck)
        {
            result.Add(dir);
        }
        connectionCheck = br_Blocked;
        dir             = OctoDirXZ.BACK_RIGHT;
        if (connectionCheck)
        {
            result.Add(dir);
        }
        connectionCheck = l__Blocked;
        dir             = OctoDirXZ.LEFT;
        if (connectionCheck)
        {
            result.Add(dir);
        }
        connectionCheck = r__Blocked;
        dir             = OctoDirXZ.RIGHT;
        if (connectionCheck)
        {
            result.Add(dir);
        }
        connectionCheck = fl_Blocked;
        dir             = OctoDirXZ.FRONT_LEFT;
        if (connectionCheck)
        {
            result.Add(dir);
        }
        connectionCheck = f__Blocked;
        dir             = OctoDirXZ.FRONT;
        if (connectionCheck)
        {
            result.Add(dir);
        }
        connectionCheck = fr_Blocked;
        dir             = OctoDirXZ.FRONT_RIGHT;
        if (connectionCheck)
        {
            result.Add(dir);
        }
        return(result);
    }
예제 #3
0
    public void UpdateConnections(LayerMask layerWalls)
    {
        OctoDirXZ dir = OctoDirXZ.BACK_LEFT;

        bl_Blocked = CheckConnection(dir, layerWalls);
        dir        = OctoDirXZ.BACK;
        b__Blocked = CheckConnection(dir, layerWalls);
        dir        = OctoDirXZ.BACK_RIGHT;
        br_Blocked = CheckConnection(dir, layerWalls);
        dir        = OctoDirXZ.LEFT;
        l__Blocked = CheckConnection(dir, layerWalls);
        dir        = OctoDirXZ.RIGHT;
        r__Blocked = CheckConnection(dir, layerWalls);
        dir        = OctoDirXZ.FRONT_LEFT;
        fl_Blocked = CheckConnection(dir, layerWalls);
        dir        = OctoDirXZ.FRONT;
        f__Blocked = CheckConnection(dir, layerWalls);
        dir        = OctoDirXZ.FRONT_RIGHT;
        fr_Blocked = CheckConnection(dir, layerWalls);
    }
예제 #4
0
    public GridNode GetNeighbour(OctoDirXZ odxz)
    {
        GridNode result = null;

        switch (odxz)
        {
        case OctoDirXZ.BACK_LEFT:
            result = bl;
            break;

        case OctoDirXZ.BACK:
            result = b;
            break;

        case OctoDirXZ.BACK_RIGHT:
            result = br;
            break;

        case OctoDirXZ.LEFT:
            result = l;
            break;

        case OctoDirXZ.RIGHT:
            result = r;
            break;

        case OctoDirXZ.FRONT_LEFT:
            result = fl;
            break;

        case OctoDirXZ.FRONT:
            result = f;
            break;

        case OctoDirXZ.FRONT_RIGHT:
            result = fr;
            break;
        }
        return(result);
    }