Ejemplo n.º 1
0
        public void MoveGameObject(int targetX, int targetY)
        {
            int range = FindObjects.PC.GetComponent <FieldOfView>().MaxRange;

            int[] source = coord.Convert(FindObjects.PC.transform.position);
            int[] target = new int[] { targetX, targetY };

            if (dungeon.IsInsideRange(FOVShape.Square, range, source, target))
            {
                transform.position = coord.Convert(targetX, targetY);
            }
            else
            {
                return;
            }

            if (fov.CheckFOV(FOVStatus.Insight, target) &&
                actor.HasActor(target) &&
                !actor.CheckActorTag(SubObjectTag.PC, target[0], target[1]))
            {
                mode.SwitchUIExamineMessage(true);
            }
            else
            {
                mode.SwitchUIExamineMessage(false);
            }
            return;
        }
Ejemplo n.º 2
0
        private void UpdateFOVBoard()
        {
            bool passable;
            bool gridChecked;

            if (checkPosition.Count < 1)
            {
                return;
            }

            position = checkPosition.Pop();
            x        = position[0];
            y        = position[1];

            surround = coordinate.SurroundCoord(Surround.Diagonal, x, y);

            foreach (var grid in surround)
            {
                if (!board.IsInsideRange(FOVShape.Rhombus,
                                         maxRange,
                                         coordinate.Convert(transform.position),
                                         grid))
                {
                    continue;
                }

                passable = board.CheckBlock(SubObjectTag.Floor, grid) ||
                           board.CheckBlock(SubObjectTag.Pool, grid);

                gridChecked = fovTest
                    ? (!fov.CheckFOV(FOVStatus.TEST, grid))
                    : (!fov.CheckFOV(FOVStatus.Insight, grid));

                if (passable && gridChecked)
                {
                    checkPosition.Push(grid);
                }

                if (fovTest)
                {
                    fov.ChangeFOVBoard(FOVStatus.TEST, grid);
                }
                else
                {
                    fov.ChangeFOVBoard(FOVStatus.Insight, grid);
                }
            }

            UpdateFOVBoard();
        }
Ejemplo n.º 3
0
        private void ShadowWall()
        {
            bool shape;
            bool distance;
            bool darkness;

            if (wallGrid.Count < 1)
            {
                return;
            }

            position = wallGrid.Pop();
            surround = coordinate.SurroundCoord(Surround.Diagonal, position);

            foreach (var grid in surround)
            {
                gridX = grid[0];
                gridY = grid[1];

                // Wall grid casts a rhombus shadow.
                shape = board.IsInsideRange(FOVShape.Rhombus,
                                            rangeWall, position, grid);

                // Shadow makes surrounding grids which are farther away from the
                // source darker.

                //* Source: @.
                //* Wall: #.
                //* Distance: 3.

                //* 3 3 3 3  |  3 4 4 4
                //* 2 2 2 3  |  2 2 # 4
                //* 1 1 2 3  |  1 1 2 4
                //* @ 1 2 3  |  @ 1 2 3

                distance = board.GetDistance(source, grid)
                           > board.GetDistance(source, position);

                // 1) Shadow from the same type of source do not stack. Two walls
                // do not make one grid even darker.
                // 2) When there are multiple dark sources, only the darkest
                // shadow takes effect.
                // 3) For example, if the distance (X) is increased by 2 from one
                // wall grid (#) and 4 from one fog grid ($), the final
                // modification is +4.

                //* # X $
                //* # $ $

                darkness = shape
                    ? (distanceBoard[gridX, gridY]
                       < board.GetDistance(source, grid) + shadowWall)
                    : false;

                if (shape && distance && darkness)
                {
                    distanceBoard[gridX, gridY] += shadowWall;
                    wallGrid.Push(grid);
                }
            }

            ShadowWall();
        }