Exemple #1
0
        public bool AddEnemy()
        {
            Enemy e;

            if (Util.NextDouble() > 0.5)
            {
                e       = new Enemy(Util.OctoTexture);
                e.Color = Color.Brown;
            }
            else
            {
                e = new SquareEnemy();
            }

            int x = Util.Next(1, Width);
            int y = Util.Next(1, Height);

            // Only add enemy if not on solid tile
            if (!GetTile(x, y).IsSolid())
            {
                e.Position = new Vector2(x * Tile.Size, y * Tile.Size);
                e.Path     = Pathfinder.FindPath(new Point(e.X / Tile.Size, e.Y / Tile.Size), new Point(Player.X / Tile.Size, Player.Y / Tile.Size));
                e.Target   = Player;
                AddEntity(e);
                return(true);
            }
            return(false);
        }
Exemple #2
0
        public bool AddEnemy()
        {
            Enemy e;
            if (Util.NextDouble() > 0.5)
            {
                e = new Enemy(Util.OctoTexture);
                e.Color = Color.Brown;
            }
            else
            {
                e = new SquareEnemy();
            }

            int x = Util.Next(1, Width);
            int y = Util.Next(1, Height);

            // Only add enemy if not on solid tile
            if (!GetTile(x, y).IsSolid())
            {
                e.Position = new Vector2(x * Tile.Size, y * Tile.Size);
                e.Path = Pathfinder.FindPath(new Point(e.X / Tile.Size, e.Y / Tile.Size), new Point(Player.X / Tile.Size, Player.Y / Tile.Size));
                e.Target = Player;
                AddEntity(e);
                return true;
            }
            return false;
        }