Beispiel #1
0
        public void OnMoveResetsShieldToMaxIfNoMonstersInFov()
        {
            // Arrange
            var shield = new KlogborgShield();

            shield.Damage(24);

            var fov = new GoRogue.FOV(new ArrayMap <bool>(10, 10));

            fov.Calculate(5, 5, 5);

            var monsters = new List <Entity>()
            {
                Entity.CreateFromTemplate("Zug", 0, 2), Entity.CreateFromTemplate("Slink", 9, 8)
            };

            // Act
            shield.OnMove(fov, monsters);

            // Assert
            Assert.That(shield.CurrentShield, Is.EqualTo(KlogborgShield.MaxShield));
        }
Beispiel #2
0
        public void OnMoveLeavesShieldValueIntactIfMonstersAreInFov()
        {
            // Arrange
            var shield = new KlogborgShield();

            shield.Damage(24);

            var fov = new GoRogue.FOV(new ArrayMap <bool>(10, 10));

            fov.Calculate(5, 5, 5);

            var monsters = new List <Entity>()
            {
                Entity.CreateFromTemplate("Zug", 6, 6)
            };

            // Act
            shield.OnMove(fov, monsters);

            // Assert
            Assert.That(shield.CurrentShield, Is.Not.EqualTo(KlogborgShield.MaxShield));
        }
        public void RefreshVisibilityTiles()
        {
            // Check to see if have left a room
            if (currentRegion != null && !currentRegion.InnerPoints.Contains(Position))
            {
                // If player, handle room lighting
                if (this == map.ControlledGameObject)
                {
                    foreach (var point in currentRegion.InnerPoints)
                    {
                        map[point].UnsetFlag(TileFlags.Lighted, TileFlags.InLOS);
                    }
                    foreach (var point in currentRegion.OuterPoints)
                    {
                        map[point].UnsetFlag(TileFlags.Lighted, TileFlags.InLOS);
                    }

                    foreach (var tile in FOVSight.CurrentFOV)
                    {
                        map[tile].SetFlag(TileFlags.InLOS);
                    }

                    foreach (var tile in FOVLighted.CurrentFOV)
                    {
                        map[tile].SetFlag(TileFlags.Lighted);
                    }
                }

                // We're not in this region anymore
                currentRegion = null;
            }

            // Not in a region, so find one.
            if (currentRegion == null)
            {
                // See if we're in a different region
                foreach (var region in map.Regions)
                {
                    if (region.InnerPoints.Contains(Position))
                    {
                        currentRegion = region;
                        break;
                    }
                }
            }

            // TODO: This code was placed here, got working, but the region code and
            //       newly unused variables have not been scrubbed.

            // BUG: If I exit a region and stand on the doorway, the tiles in the room
            //      that should be visible are not.

            // Visibility
            FOVSight.Calculate(Position, VisibilityDistance);

            // If player, handle LOS flags for tiles.
            if (this == map.ControlledGameObject)
            {
                foreach (var tile in FOVSight.NewlyUnseen)
                {
                    map[tile].UnsetFlag(TileFlags.InLOS);
                }

                foreach (var tile in FOVSight.NewlySeen)
                {
                    map[tile].SetFlag(TileFlags.InLOS);
                }
            }

            // Lighting
            FOVLighted.Calculate(Position, LightSourceDistance);

            if (this == map.ControlledGameObject)
            {
                foreach (var tile in FOVLighted.NewlyUnseen)
                {
                    map[tile].UnsetFlag(TileFlags.Lighted);
                }

                foreach (var tile in FOVLighted.NewlySeen)
                {
                    map[tile].SetFlag(TileFlags.Lighted, TileFlags.Seen);
                }
            }


            // Check and see if we're in a region, ensure these tiles are always visible and lighted.
            if (currentRegion != null)
            {
                Tile tile;

                // Make sure these are lit
                foreach (var point in currentRegion.InnerPoints)
                {
                    tile = map[point];

                    // If player, handle room lighting
                    if (this == map.ControlledGameObject)
                    {
                        tile.SetFlag(TileFlags.Lighted, TileFlags.InLOS, TileFlags.Seen);
                    }

                    // Add tile to visible list, for calculating if the player can see.
                    VisibleTiles.Add(tile);
                }

                foreach (var point in currentRegion.OuterPoints)
                {
                    tile = map[point];

                    // If player, handle room lighting
                    if (this == map.ControlledGameObject)
                    {
                        tile.SetFlag(TileFlags.Lighted, TileFlags.InLOS, TileFlags.Seen);
                    }

                    // Add tile to visible list, for calculating if the player can see.
                    VisibleTiles.Add(tile);
                }
            }
        }