Example #1
0
    /// <summary>
    /// Runs on startup.
    /// </summary>
    void Start()
    {
        boardLayout = BoardReader.GetSymbols("Assets/Resources/chessBoard.txt");
        pieceLayout = BoardReader.GetSymbols("Assets/Resources/testPieces.txt", ',');

        gridSizeX = boardLayout.GetLength(0);
        gridSizeY = boardLayout.GetLength(1);

        emptySpace = Resources.Load("prefabs/Spaces/EmptySpace") as GameObject;
        var whiteSpace = Resources.Load("prefabs/Spaces/WhiteSpace") as GameObject;
        var blackSpace = Resources.Load("prefabs/Spaces/BlackSpace") as GameObject;

        var pawnPiece   = Resources.Load("prefabs/Pieces/Pawn") as GameObject;
        var bishopPiece = Resources.Load("prefabs/Pieces/Bishop") as GameObject;

        spaceDictionary = new Dictionary <char, GameObject> {
            { 'W', whiteSpace },
            { 'B', blackSpace }
        };

        pieceDictionary = new Dictionary <string, GameObject> {
            { "WP", pawnPiece },
            { "BP", pawnPiece },
            { "WB", bishopPiece },
            { "BB", bishopPiece }
        };

        SetupBoard();
    }
Example #2
0
        private static void Main()
        {
            Board board = BoardReader.ReadFromFile(@"Puzzles\25x30.txt");

            //Board board = BoardReader.ReadFromConsole();
            board.Solve();
            Console.WriteLine(board.Print(true, true));
        }
        public void Test1()
        {
            Board board = BoardReader.ReadFromFile(@"..\PuzzleBot.App\Puzzles\25x30.txt");

            board.Solve();
            string solution = board.Print(false, false).ToString();

            Assert.AreEqual(solution, );
        }
        /// <summary>
        /// Loads a board from the specified file and updates bitboard.
        /// </summary>
        /// <param name="command">The Load command.</param>
        private void LoadBoard(Command command)
        {
            var boardNameArgument = command.GetArgument <string>(0);

            var boardReader = new BoardReader();
            var path        = $"Boards\\{boardNameArgument}.board";

            if (!boardReader.BoardExists(path))
            {
                ConsoleManager.WriteLine($"$rBoard {path} not found");
                return;
            }

            CalculateBitboard(boardReader.Read(path), false);
        }
Example #5
0
        public async Task TestLoadBoardFromFile()
        {
            const string sampleBoardName = "SampleBoard";

            var directory = Path.Combine(this.TestContext.TestDir, "Boards");
            await Task.Run(() => Directory.CreateDirectory(directory));

            using (var stream = new FileStream(Path.Combine(directory, sampleBoardName), FileMode.CreateNew))
            {
                await stream.WriteAsync(BoardSampleData.sampleBoard, 0, BoardSampleData.sampleBoard.Length);
            }

            var board = await BoardReader.LoadFromFileAsync(sampleBoardName, directory);

            Assert.IsTrue(((byte[])board).SequenceEqual(BoardSampleData.sampleBoard));
        }
        private void CreateEntities()
        {
            entityManager.SpawnPrefab("Prefabs/skybox.txt");
            var floor = entityManager.SpawnPrefab("Prefabs/floor.txt");

            floor.Transform.Position = new Vector3(25, -1, 25);
            BoardReader.SetBoard("Scenes/pac.txt");
            AIManager.Instance.SpawnGhosts();
            GameManager.Instance.SpawnPlayer();

            ////Heart Prefab
            //var heart = new Entity("Heart");
            //heart.AddComponent(new ComponentRenderer("Geometry/SquareGeometry.txt", "Textures/heart.png"));
            //heart.GetComponent<ComponentRenderer>().ComponentUI = true;
            //heart.Transform.Position = new Vector3(0.5f, 0.5f, 0);
            //heart.Transform.Scale = new Vector3(0.036f, 0.05f, 0.1f);
            //heart.CreatePrefab("Prefabs/heart.txt");

            ////Skybox Prefab
            //var skybox = new Entity("Skybox");
            //skybox.AddComponent(new ComponentRenderer("Geometry/CubeGeometry.txt", "Textures/starsky.png"));
            //skybox.AddComponent(new ComponentSkybox());
            //skybox.CreatePrefab("Prefabs/skybox.txt");

            ////floor Prefab
            //var floor = new Entity("Floor");
            //floor.Transform.Scale = new Vector3(25, 0.5f, 25);
            //floor.AddComponent(new ComponentRenderer("Geometry/CubeGeometry.txt", "Textures/floor.jpg"));
            //floor.GetComponent<ComponentRenderer>().RepeatTexture = true;
            //floor.CreatePrefab("Prefabs/floor.txt");

            ////Wall Prefab
            //var e = new Entity("Wall");
            //e.Transform.Position = new Vector3(0.0f, 0.0f, 0.0f);
            //e.Transform.Scale = new Vector3(0.5f, 0.5f, 0.5f);
            //e.AddComponent(new ComponentRenderer("Geometry/CubeGeometry.txt", "Textures/wall.png"));
            //e.AddComponent(new ComponentColliderCube());
            //e.CreatePrefab("Prefabs/wall.txt");

            ////Player Prefab
            //Entity player = new Entity("Player");
            //player.AddComponent(new ComponentColliderSphere(0.25f, false));
            //player.AddComponent(new ComponentPlayerController(120.0f, 2.5f));
            //player.AddComponent(new ComponentRigidbody(Vector3.Zero));
            //player.AddComponent(new ComponentCamera(new Vector3(0, 1f, 0)));
            //player.AddComponent(new ComponentAudioListener());
            //player.AddComponent(new ComponentLives("Prefabs/onlifelost.txt"));
            //player.CreatePrefab("Prefabs/player.txt");

            ////PickupItem Prefab
            //var pickup = new Entity("pickup");
            //pickup.AddComponent(new ComponentRenderer("Geometry/sphere.bin", "Textures/yellowtext.jpg"));
            //pickup.AddComponent(new ComponentColliderSphere(0.5f, true));
            //pickup.AddComponent(new ComponentPointPickup("Prefabs/pointpicksound.txt"));
            //pickup.Transform.Scale = Vector3.One * 0.15f;
            //pickup.CreatePrefab("Prefabs/pickup.txt");

            ////Powerup Prefab
            //var powerup = new Entity("PowerUp");
            //powerup.Transform.Scale = Vector3.One * 0.15f;
            //powerup.AddComponent(new ComponentRenderer("Geometry/sphere.bin", "Textures/purpletext.jpg"));
            //powerup.AddComponent(new ComponentColliderSphere(0.5f, true));
            //powerup.AddComponent(new ComponentPowerUp("Prefabs/pointpicksound.txt"));
            //powerup.AddComponent(new ComponentAudio("Audio/beep.wav", true, powerup.Transform.Position));
            //powerup.CreatePrefab("Prefabs/powerup.txt");

            ////AI Prefab
            //var aI = new Entity("Ghost");
            //aI.Transform.Scale = new Vector3(0.25f, 0.75f, 0.25f);
            //aI.AddComponent(new ComponentRenderer("Geometry/model.bin", "Textures/modeltext.jpg"));
            //aI.AddComponent(new ComponentAI(4f, "Prefabs/eatghost.txt"));
            //aI.AddComponent(new ComponentColliderSphere(0.25f, true));
            //aI.CreatePrefab("Prefabs/ghost.txt");

            ////#region soundprefab
            //var pickupSound = new Entity("pickupsound");
            //pickupSound.AddComponent(new ComponentAudio("Audio/pickup.wav", false, Vector3.Zero));
            //pickupSound.AddComponent(new ComponentTimedDestroy(1f));
            //pickupSound.CreatePrefab("Prefabs/pointpicksound.txt");

            //var powerupSound = new Entity("powerupsound");
            //powerupSound.AddComponent(new ComponentAudio("Audio/alienspaceship.wav", false, Vector3.Zero));
            //powerupSound.AddComponent(new ComponentTimedDestroy(1f));
            //powerupSound.CreatePrefab("Prefabs/powerupsound.txt");

            //var onLifeLost = new Entity("lifelost");
            //onLifeLost.AddComponent(new ComponentAudio("Audio/lifelost.wav", false, Vector3.Zero));
            //onLifeLost.AddComponent(new ComponentTimedDestroy(1f));
            //onLifeLost.CreatePrefab("Prefabs/onlifelost.txt");

            //var powerUpActive = new Entity("powerupactive");
            //powerUpActive.AddComponent(new ComponentAudio("Audio/buzz.wav", true, Vector3.Zero));
            //powerUpActive.AddComponent(new ComponentTimedDestroy(15.0f));
            //powerUpActive.AddComponent(new ComponentFollow());
            //powerUpActive.CreatePrefab("Prefabs/powerupactive.txt");

            //var eatGhost = new Entity("eatGhost");
            //eatGhost.AddComponent(new ComponentAudio("Audio/eatghost.wav", false, Vector3.Zero));
            //eatGhost.AddComponent(new ComponentTimedDestroy(1f));
            //eatGhost.CreatePrefab("Prefabs/eatghost.txt");
            //#endregion

            //BoardReader.ReadBoard(@"\Scenes\PacmanMap.xlsx", "Scenes/pac.txt");
        }