Ejemplo n.º 1
0
        internal static Point GetNewPointFrom(GameConstants.Direction8 direction, Point fromPoint)
        {
            var newX = fromPoint.X;
            var newY = fromPoint.Y;

            switch (direction)
            {
            case GameConstants.Direction8.UpLeft: newX--; newY--; break;

            case GameConstants.Direction8.Up: newY--; break;

            case GameConstants.Direction8.UpRight: newX++; newY--; break;

            case GameConstants.Direction8.Right: newX++; break;

            case GameConstants.Direction8.DownRight: newX++; newY++; break;

            case GameConstants.Direction8.Down: newY++; break;

            case GameConstants.Direction8.DownLeft: newX--; newY++; break;

            case GameConstants.Direction8.Left: newX--; break;

            default: break;
            }
            return(new Point(newX, newY));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reveals any non-blocking tile in a straight line but stops at doors because the light in
        /// a lit room doesn't light up a hallway.
        /// </summary>
        /// <param name="startingPoint"></param>
        /// <param name="direction"></param>
        private void LightTilesInRow(Point startingPoint, GameConstants.Direction8 direction)
        {
            bool  blocked      = false;
            Point currentPoint = startingPoint;

            FloorTile.Surfaces currentSurface;
            while (!blocked)
            {
                currentSurface = FloorGenerator.GetTileAt(currentPoint);
                FloorGenerator.FloorRevealed[currentPoint.X, currentPoint.Y] = true;

                if (!FloorGenerator.TileIsPassible(currentSurface))
                {
                    blocked = true;
                }
                if (currentPoint == startingPoint)
                {
                    blocked = false; // Allows effect if standing in doorway to split both ways
                }
                if (blocked)
                {
                    break;
                }

                // Move to next tile
                currentPoint = FloorGenerator.PointInDirection(currentPoint, direction);
            }
        }
Ejemplo n.º 3
0
        }                              // Monsters won't gain XP in this game

        internal void Roam()
        {
            // TODO: Make another Move method with path finding to get a monster moving toward a given point
            // For when an effect triggers all monsters to detect the hero or behavior should be less eratic.
            // This method should actually be used in the HeroStrikable method to move towards the hero.
            bool  monsterMoved = false;
            Point checkPoint;

            while (!monsterMoved)
            {
                GameConstants.Direction8 moveDirection = (GameConstants.Direction8)rand.Next(8);
                checkPoint = FloorGenerator.PointInDirection(location, moveDirection);
                if (FloorGenerator.TileIsPassible(FloorGenerator.GetTileAt(checkPoint)))
                {
                    location     = checkPoint;
                    monsterMoved = true;
                }
            }
            CheckVisibility();
        }