Exemple #1
0
    public void TrySetIsWall(bool _isWall)
    {
        if (IsWall == _isWall)
        {
            return;
        }

        IsWall = _isWall;

        if (_isWall)
        {
            NeighborFinder.TryCacheNeighbor(GridPos, Direction.All);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.TL]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.T]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.TR]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.R]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.BR]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.B]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.BL]);
            LampManager.GetInstance().SetNodeLightingDirty(NeighborFinder.CachedNeighbors[Direction.L]);
        }
        else
        {
            LampManager.GetInstance().SetNodeLightingDirty(this);
        }

        RoomManager.GetInstance().ScheduleUpdateForRoomOfNode(GridPos);
        ScheduleUpdateGraphicsForSurroundingTiles();
    }
Exemple #2
0
        public override bool CanUseOnNode(Node _node)
        {
            if (!_node.IsWall)
            {
                return(false);
            }

            NeighborFinder.TryCacheNeighbor(_node.GridPos, Direction.T);
            NeighborFinder.TryCacheNeighbor(_node.GridPos, Direction.B);
            Node _nodeT = NeighborFinder.CachedNeighbors[Direction.T];
            Node _nodeB = NeighborFinder.CachedNeighbors[Direction.B];

            if (_nodeT != null && _nodeB != null && _nodeT.IsWall && _nodeB.IsWall && _nodeT.AttachedInteractiveObject == null && _nodeB.AttachedInteractiveObject == null)
            {
                currentRotation = Rotation.Left;
                return(true);
            }

            NeighborFinder.TryCacheNeighbor(_node.GridPos, Direction.L);
            NeighborFinder.TryCacheNeighbor(_node.GridPos, Direction.R);
            Node _nodeL = NeighborFinder.CachedNeighbors[Direction.L];
            Node _nodeR = NeighborFinder.CachedNeighbors[Direction.R];

            if (_nodeL != null && _nodeR != null && _nodeL.IsWall && _nodeR.IsWall && _nodeL.AttachedInteractiveObject == null && _nodeR.AttachedInteractiveObject == null)
            {
                currentRotation = Rotation.Down;
                return(true);
            }

            return(false);
        }
Exemple #3
0
    Color32 GetLightingFromDirection(Direction _direction)
    {
        Direction _directionY = Direction.None;
        Direction _directionX = Direction.None;

        switch (_direction)
        {
        case Direction.None:
        case Direction.All:
        case Direction.T:
        case Direction.R:
        case Direction.B:
        case Direction.L:
            Debug.LogError(_direction + " isn't supported by GetLightingFromDirection()!");
            break;

        case Direction.TL:
            _directionY = Direction.T;
            _directionX = Direction.L;
            break;

        case Direction.TR:
            _directionY = Direction.T;
            _directionX = Direction.R;
            break;

        case Direction.BR:
            _directionY = Direction.B;
            _directionX = Direction.R;
            break;

        case Direction.BL:
            _directionY = Direction.B;
            _directionX = Direction.L;
            break;

        default:
            Debug.LogError(_direction + " hasn't been properly implemented yet!");
            break;
        }

        NeighborFinder.TryCacheNeighbor(GridPos, _direction);
        NeighborFinder.TryCacheNeighbor(GridPos, _directionX);
        NeighborFinder.TryCacheNeighbor(GridPos, _directionY);

        Node _neighborXY = NeighborFinder.CachedNeighbors[_direction];
        Node _neighborX  = NeighborFinder.CachedNeighbors[_directionY];
        Node _neighborY  = NeighborFinder.CachedNeighbors[_directionX];

        Color32 _lightingFromNeighborXY = new Color32();

        if (_neighborXY != null && !_neighborXY.IsWall)
        {
            _lightingFromNeighborXY = _neighborXY.GetLighting(NeighborFinder.GetDirectionMirrored(_direction));
        }

        Color32 _lightingFromNeighborX = new Color32();

        if (_neighborX != null && !_neighborX.IsWall)
        {
            _lightingFromNeighborX = _neighborX.GetLighting(NeighborFinder.GetDirectionMirroredInX(_direction));
        }

        Color32 _lightingFromNeighborY = new Color32();

        if (_neighborY != null && !_neighborY.IsWall)
        {
            _lightingFromNeighborY = _neighborY.GetLighting(NeighborFinder.GetDirectionMirroredInY(_direction));
        }

        Color32 _newLighting = new Color32(
            (byte)Mathf.Max(_lightingFromNeighborXY.r, Mathf.Max(_lightingFromNeighborY.r, _lightingFromNeighborX.r)),
            (byte)Mathf.Max(_lightingFromNeighborXY.g, Mathf.Max(_lightingFromNeighborY.r, _lightingFromNeighborX.r)),
            (byte)Mathf.Max(_lightingFromNeighborXY.b, Mathf.Max(_lightingFromNeighborY.r, _lightingFromNeighborX.r)),
            (byte)Mathf.Max(_lightingFromNeighborXY.a, Mathf.Max(_lightingFromNeighborY.r, _lightingFromNeighborX.r))
            );

        return(_newLighting);
    }