Example #1
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(this.gameObject);
        }

        gameBoard = new Tile[boardSize, boardSize];

        // i = row, j = column
        for (int row = 0; row < boardSize; row++)
        {
            for (int column = 0; column < boardSize; column++)
            {
                gameBoard[row, column]           = tileArray[column + (row * 10)];
                gameBoard[row, column].blankTile = 0;
                gameBoard[row, column].ConnectTile(gameBoard);
                gameBoard[row, column].x = row;
                gameBoard[row, column].z = column;
            }
        }
    }
Example #2
0
 public BoardDisplay(GameBoardManager board, Canvas backgroundCanvas, Canvas foregroundCanvas)
 {
     //Todo null reference check
     this.board            = board;
     this.backgroundCanvas = backgroundCanvas;
     this.foregroundCanvas = foregroundCanvas;
 }
        public void PrintGameBoard()
        {
            GameBoardManager gameBoardManager = new GameBoardManager();

            gameBoardManager.GenerateNewGameBoard();
            StringBuilder gameBoardAsString = new StringBuilder();
            StringBuilder printed           = new StringBuilder();
            StringBuilder current           = new StringBuilder();

            gameBoardAsString.AppendLine();
            for (int col = 0; col < 8; col++)
            {
                for (int row = 0; row < 25; row++)
                {
                    gameBoardAsString.Append(gameBoardManager.GameBoard[row, col]);
                }

                gameBoardAsString.AppendLine();
            }

            Console.SetOut(new System.IO.StringWriter(printed));
            gameBoardManager.PrintGameBoard();
            Console.SetOut(new System.IO.StringWriter(current));
            Console.WriteLine(gameBoardAsString);

            Assert.AreEqual(current.ToString(), printed.ToString());
        }
        //#####################################################################################

        public int Run(GameBoardManager boardDirector, UserManager userDirector, Chip chip, string cmdName, List <string> parameter,
                       Tile hereTile, Point herePos)
        {
            if (m_workMap.ContainsKey(cmdName) &&
                m_minParamCountMap.ContainsKey(cmdName))
            {
                int minParamCount = m_minParamCountMap[cmdName];

                if (parameter.Count >= minParamCount)
                {
                    var cloneParam = new List <string>(parameter);

                    for (int i = 0; i < minParamCount; ++i)
                    {
                        if (IsVar(cloneParam[i]))
                        {
                            cloneParam[i] = GetVar(cloneParam[i]);
                        }
                    }

                    int next = m_workMap[cmdName](boardDirector, userDirector, chip, cloneParam, hereTile, herePos);


                    return(next);
                }
            }


            return(1);
        }
    // Start is called before the first frame update
    void Awake()
    {
        cam = Camera.main;

        deckManager  = GameObject.FindGameObjectWithTag("Deck Manager").GetComponent <DeckManager>();
        boardManager = GameObject.FindGameObjectWithTag("Game Board").GetComponent <GameBoardManager>();
        gameManager  = GameObject.FindObjectOfType(typeof(GameManager)) as GameManager;
    }
 void Start()
 {
     start_finished     = true;
     game_board_manager = GameObject.Find("GameBoard").GetComponent <GameBoardManager>();
     Debug.Log("enable card script in start function");
     script_enabled = true;
     start_finished = false;
 }
Example #7
0
 private void SetScriptReferences()
 {
     gameBoardManager = FindObjectOfType(typeof(GameBoardManager)) as GameBoardManager;
     deckManager      = FindObjectOfType(typeof(DeckManager)) as DeckManager;
     canvasManager    = FindObjectOfType(typeof(CanvasManager)) as CanvasManager;
     playerBehaviour  = FindObjectOfType(typeof(PlayerBehaviour)) as PlayerBehaviour;
     partyBehaviour   = FindObjectOfType(typeof(PartyBehaviour)) as PartyBehaviour;
     combatManager    = FindObjectOfType(typeof(CombatManager)) as CombatManager;
     shopManager      = FindObjectOfType(typeof(ShopManager)) as ShopManager;
 }
Example #8
0
        public void GameManagerReceivesCorrectMessagesWhenPlacingFirstTown(UInt32[] townLocations)
        {
            Jabberwocky.SoC.Service.GameSessionManager gameSessionManager = null;
            try
            {
                var board           = new GameBoardManager(BoardSizes.Standard);
                var mockGameManager = Substitute.For <IGameSession>();
                mockGameManager.GetFirstSetupPassOrder().Returns(new UInt32[] { 0u, 1u, 2u, 3u });
                mockGameManager.Board.Returns(board);

                var mockGameManagerFactory = Substitute.For <IGameSessionManager>();
                mockGameManagerFactory.Create().Returns(mockGameManager);

                var mockLogger        = Substitute.For <ILogger>();
                var mockLoggerFactory = Substitute.For <ILoggerFactory>();
                mockLoggerFactory.Create(Arg.Any <String>()).Returns(mockLogger);

                gameSessionManager = GameSessionManagerTestExtensions.CreateGameSessionManagerForTest(4)
                                     .AddGameManagerFactory(mockGameManagerFactory)
                                     .AddLoggerFactory(mockLoggerFactory)
                                     .WaitUntilGameSessionManagerHasStarted();

                var testPlayer1 = new TestClient(TestPlayer1UserName, gameSessionManager);
                var testPlayer2 = new TestClient(TestPlayer2UserName, gameSessionManager);
                var testPlayer3 = new TestClient(TestPlayer3UserName, gameSessionManager);
                var testPlayer4 = new TestClient(TestPlayer4UserName, gameSessionManager);

                var testScript = new TestScript(testPlayer1, testPlayer2, testPlayer3, testPlayer4);
                testScript.RunUntil(TestScript.RunPoints.RunUntilEnd);
                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), testPlayer1);
                testScript.SendTownPlacementFromClient(testPlayer1, townLocations[0]);

                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), testPlayer2);
                mockGameManager.Received().PlaceTown(townLocations[0]);
                testScript.SendTownPlacementFromClient(testPlayer2, townLocations[1]);

                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), testPlayer3);
                mockGameManager.Received().PlaceTown(townLocations[1]);
                testScript.SendTownPlacementFromClient(testPlayer3, townLocations[2]);

                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), testPlayer4);
                mockGameManager.Received().PlaceTown(townLocations[2]);
                testScript.SendTownPlacementFromClient(testPlayer4, townLocations[3]);

                testScript.WaitUntilClientsReceiveMessageOfType(typeof(GameOverMessage), testPlayer1, testPlayer2, testPlayer3, testPlayer4);
                mockGameManager.Received().PlaceTown(townLocations[3]);
                mockLogger.DidNotReceive().Exception(Arg.Any <String>());
            }
            finally
            {
                gameSessionManager?.WaitUntilGameSessionManagerHasStopped();
            }
        }
        public void ShootCounter_OneShoot()
        {
            GameBoardManager gameBoardManager = new GameBoardManager();

            gameBoardManager.GenerateNewGameBoard();
            string      input       = "0 1";
            Coordinates coordinates = new Coordinates();

            Coordinates.TryParse(input, ref coordinates);
            gameBoardManager.ShootBaloons(coordinates);
            Assert.AreEqual(1, gameBoardManager.ShootCounter);
        }
        public void RemainingBaloons_OneShot()
        {
            GameBoardManager gameBoardManager = new GameBoardManager();

            gameBoardManager.GenerateNewGameBoard();
            string      input       = "0 0";
            Coordinates coordinates = new Coordinates();

            Coordinates.TryParse(input, ref coordinates);
            gameBoardManager.ShootBaloons(coordinates);
            Assert.IsTrue(gameBoardManager.RemainingBaloons < 50);
        }
Example #11
0
    private void AssignPlayers()
    {
        int counter = 0;

        GameBoardManager = GameObject.Find("GameBoardManager").GetComponent <GameBoardManager>();

        foreach (var Player in GameBoardManager.PlayerList)
        {
            players[counter].MainPlayerInfo = Player.GetComponent <GamePlayerInformation>();
            counter++;
        }
    }
Example #12
0
    void Awake()
    {
        Instance = this;
        var gameFieldSpriteRenderer = gameField.GetComponent <SpriteRenderer>();
        var ballSpriteRenderer      = ballExample.GetComponent <SpriteRenderer>();

        leftTopAngle = Helpers.GetTopLeftPosition(gameFieldSpriteRenderer, ballSpriteRenderer);

        xPadding = gameFieldSpriteRenderer.bounds.size.x / 9;
        yPadding = -gameFieldSpriteRenderer.bounds.size.y / 9;

        PrepareField();
    }
        public void Build_StandardBoard_ReturnsCorrectInitializationData()
        {
            // Arrange
            var board = new GameBoardManager(BoardSizes.Standard);

            // Act
            var data = GameInitializationDataBuilder.Build(board);

            // Assert
            // 0 = desert, 1 = brick, 2 = grain, 3 = lumber, 4 = ore, 5 = wool
            // 20 = 2 on dice, 30 = 3 on dice, 40 = 4 on dice, .... 110 = 11 on dice, 120 = 12 on dice

            const Byte brick  = 1;
            const Byte grain  = 2;
            const Byte lumber = 3;
            const Byte ore    = 4;
            const Byte wool   = 5;

            const Byte diceroll2  = 20;
            const Byte diceroll3  = 30;
            const Byte diceroll4  = 40;
            const Byte diceroll5  = 50;
            const Byte diceroll6  = 60;
            const Byte diceroll8  = 80;
            const Byte diceroll9  = 90;
            const Byte diceroll10 = 100;
            const Byte diceroll11 = 110;
            const Byte diceroll12 = 120;

            data.BoardData.Length.ShouldBe(19);
            data.BoardData[0].ShouldBe <Byte>(0);
            data.BoardData[1].ShouldBe <Byte>(diceroll8 + brick);
            data.BoardData[2].ShouldBe <Byte>(diceroll5 + ore);
            data.BoardData[3].ShouldBe <Byte>(diceroll4 + brick);
            data.BoardData[4].ShouldBe <Byte>(diceroll3 + lumber);
            data.BoardData[5].ShouldBe <Byte>(diceroll10 + wool);
            data.BoardData[6].ShouldBe <Byte>(diceroll2 + grain);
            data.BoardData[7].ShouldBe <Byte>(diceroll11 + lumber);
            data.BoardData[8].ShouldBe <Byte>(diceroll6 + ore);
            data.BoardData[9].ShouldBe <Byte>(diceroll11 + grain);
            data.BoardData[10].ShouldBe <Byte>(diceroll9 + wool);
            data.BoardData[11].ShouldBe <Byte>(diceroll6 + lumber);
            data.BoardData[12].ShouldBe <Byte>(diceroll12 + wool);
            data.BoardData[13].ShouldBe <Byte>(diceroll5 + brick);
            data.BoardData[14].ShouldBe <Byte>(diceroll4 + lumber);
            data.BoardData[15].ShouldBe <Byte>(diceroll3 + ore);
            data.BoardData[16].ShouldBe <Byte>(diceroll9 + grain);
            data.BoardData[17].ShouldBe <Byte>(diceroll10 + wool);
            data.BoardData[18].ShouldBe <Byte>(diceroll8 + grain);
        }
    private void Awake()
    {
        // Singleton for this class. This manager is intended to be used in all levels.
        if (GameBoardManagerInstance == null)
        {
            GameBoardManagerInstance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(this);
    }
        public void ShootBaloons_HitPosition()
        {
            GameBoardManager gameBoardManager = new GameBoardManager();

            gameBoardManager.GenerateNewGameBoard();
            string      input       = "2 1";
            Coordinates coordinates = new Coordinates();

            Coordinates.TryParse(input, ref coordinates);
            gameBoardManager.ShootBaloons(coordinates);
            input = "0 1";
            Coordinates.TryParse(input, ref coordinates);
            gameBoardManager.ShootBaloons(coordinates);
        }
Example #16
0
        public void ClientsReceivePlaceTownMessageInCorrectOrder(UInt32[] firstSetupPassOrder)
        {
            Jabberwocky.SoC.Service.GameSessionManager gameSessionManager = null;
            try
            {
                var board           = new GameBoardManager(BoardSizes.Standard);
                var mockGameManager = Substitute.For <IGameSession>();
                mockGameManager.GetFirstSetupPassOrder().Returns(firstSetupPassOrder);
                mockGameManager.Board.Returns(board);

                var mockGameManagerFactory = Substitute.For <IGameSessionManager>();
                mockGameManagerFactory.Create().Returns(mockGameManager);

                gameSessionManager = GameSessionManagerTestExtensions.CreateGameSessionManagerForTest(4)
                                     .AddGameManagerFactory(mockGameManagerFactory)
                                     .WaitUntilGameSessionManagerHasStarted();

                var testPlayers = new[]
                {
                    new TestClient(TestPlayer1UserName, gameSessionManager),
                    new TestClient(TestPlayer2UserName, gameSessionManager),
                    new TestClient(TestPlayer3UserName, gameSessionManager),
                    new TestClient(TestPlayer4UserName, gameSessionManager)
                };

                var testPlayer1 = testPlayers[0];
                var testPlayer2 = testPlayers[1];
                var testPlayer3 = testPlayers[2];
                var testPlayer4 = testPlayers[3];

                var firstTestPlayer  = testPlayers[firstSetupPassOrder[0]];
                var secondTestPlayer = testPlayers[firstSetupPassOrder[1]];
                var thirdTestPlayer  = testPlayers[firstSetupPassOrder[2]];
                var fourthTestPlayer = testPlayers[firstSetupPassOrder[3]];

                var testScript = new TestScript(testPlayer1, testPlayer2, testPlayer3, testPlayer4);
                testScript.RunUntil(TestScript.RunPoints.RunUntilEnd);
                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), firstTestPlayer);
                testScript.SendTownPlacementFromClient(firstTestPlayer, 0u);
                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), secondTestPlayer);
                testScript.SendTownPlacementFromClient(secondTestPlayer, 10u);
                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), thirdTestPlayer);
                testScript.SendTownPlacementFromClient(thirdTestPlayer, 20u);
                testScript.WaitUntilClientsReceiveMessageOfType(typeof(PlaceTownMessage), fourthTestPlayer);
            }
            finally
            {
                gameSessionManager.WaitUntilGameSessionManagerHasStopped();
            }
        }
        public void ShootBaloons_CoordinatesZeroZero()
        {
            GameBoardManager gameBoardManager = new GameBoardManager();

            gameBoardManager.GenerateNewGameBoard();
            string      input       = "0 0";
            Coordinates coordinates = new Coordinates();

            Coordinates.TryParse(input, ref coordinates);
            gameBoardManager.ShootBaloons(coordinates);
            char arr    = gameBoardManager.GameBoard[4, 2];
            char result = '.';

            Assert.AreEqual(result, arr);
        }
Example #18
0
        public static GameInitializationData Build(GameBoardManager board)
        {
            // Standard board only
            var boardData      = new byte[GameBoard.StandardBoardHexCount];
            var hexInformation = board.Data.GetHexData();

            for (var index = 0; index < GameBoard.StandardBoardHexCount; index++)
            {
                boardData[index] = CreateDataForProvider(hexInformation[index]);
            }

            return(new GameInitializationData()
            {
                BoardData = boardData
            });
        }
Example #19
0
        public async void CanCreateGameBoard()
        {
            Microsoft.EntityFrameworkCore.DbContextOptions <SudokuDbContext> options = new
                                                                                       DbContextOptionsBuilder <SudokuDbContext>().UseInMemoryDatabase
                                                                                           ("CreateGameBoard").Options;

            using (SudokuDbContext context = new SudokuDbContext(options))
            {
                //Arrange
                GameBoard gameboard = new GameBoard();
                gameboard.ID     = 1;
                gameboard.Placed = 2;

                //Act
                GameBoardManager GBM = new GameBoardManager(context);
                await GBM.CreateGameBoard(gameboard);

                var result = context.GameBoards.FirstOrDefault(g => g.ID == g.ID);

                Assert.Equal(gameboard, result);
            }
        }
Example #20
0
        static void Main(string[] args)
        {
            GameBoardManager gameBoardManager = new GameBoardManager();

            gameBoardManager.PlaceTileByCoordinatesAndTileType(new Coordinates(1, 1), TileType.Placed);

            gameBoardManager.PrintBoard();

            gameBoardManager.PlaceTileByCoordinatesAndTileType(new Coordinates(4, 5), TileType.American);

            gameBoardManager.PrintBoard();

            gameBoardManager.PlaceTileByCoordinatesAndTileType(new Coordinates(5, 5), TileType.American);

            gameBoardManager.PrintBoard();

            Console.WriteLine(gameBoardManager.GetTileTypeCount(TileType.Placed));

            Console.WriteLine(gameBoardManager.GetTileTypeCount(TileType.American));

            Console.ReadLine();
            Console.WriteLine("Hello World!");
        }
Example #21
0
        //#####################################################################################

        public void ExcuteNext(GameBoardManager boardDirector, UserManager userDirector, Tile hereTile, Point herePos)
        {
            if (this.Pointer < 0)
            {
                this.Pointer = 0;
            }

            if (this.Pointer < this.Program.Count)
            {
                int deltaJump = 1;


                Command cmd = this.Program[this.Pointer];

                if (cmd != null)
                {
                    deltaJump = m_cmdOperator.Run(boardDirector, userDirector, this, cmd.Name, cmd.Parameters, hereTile, herePos);
                }


                this.Pointer += deltaJump;
            }
        }
Example #22
0
 protected override void Awake()
 {
     manager = FindObjectOfType <GameBoardManager>();
     fade    = FindObjectOfType <OverlayFade>();
 }
 public ResolveEventStateHandler(GameBoardManager manager) : base(manager)
 {
 }
Example #24
0
 public OutOfMyTurnStateHandler(GameBoardManager manager) : base(manager)
 {
 }
Example #25
0
 public ActionPhaseChooseTargetStateHandler(GameBoardManager manager) : base(manager)
 {
 }
Example #26
0
 public ActionPhaseIdleStateHandler(GameBoardManager manager) : base(manager)
 {
 }
 public PoliticalPhaseIdleStateHandler(GameBoardManager manager) : base(manager)
 {
 }
	protected override void Awake()
	{
		manager = FindObjectOfType<GameBoardManager>();
		fade = FindObjectOfType<OverlayFade>();
	}
Example #29
0
 public void GameInitialization(GameInitializationData gameData)
 {
     this.Board = new GameBoardManager(BoardSizes.Standard);
     this.GameInitializationEvent?.Invoke(gameData);
 }
Example #30
0
 private void Awake()
 {
     BoardFullyLoaded = false;
     Instance         = this;
     GenerateGameBoard(50, 50);
 }
Example #31
0
 public ActionPhaseInternalQueryHandler(GameBoardManager manager) : base(manager)
 {
 }