public void TestRemovalMatches_ShouldAlterSomeCells() { var simpleBoardContentsAfterRemoval = new BlockColor[, ] { { BlockColor.Red, BlockColor.Empty, BlockColor.Green, BlockColor.Red }, { BlockColor.Green, BlockColor.Empty, BlockColor.Blue, BlockColor.Green }, { BlockColor.Blue, BlockColor.Empty, BlockColor.Green, BlockColor.Red }, { BlockColor.Empty, BlockColor.Empty, BlockColor.Empty, BlockColor.Red } }; var match3Game = new Match3Game(Simple, AllowedTypes); List <SpecialBlockActivation> blockActivation = new List <SpecialBlockActivation>(); List <BlockRemoval> removedBlocks2 = new List <BlockRemoval>(); List <BlockAndPosition> createdBlocks = new List <BlockAndPosition>(); match3Game.RemoveMatches(blockActivation, removedBlocks2, createdBlocks); for (int row = 0; row < match3Game.RowCount; row++) { for (int column = 0; column < match3Game.ColumnCount; column++) { Assert.That(match3Game[row, column].color == simpleBoardContentsAfterRemoval[row, column]); } } }
void Start() { var boardSettings = GetComponent <BoardSettings>(); rowCount = boardSettings.rows; columnCount = boardSettings.columns; cellWidth = boardSettings.cellWidth; cellHeight = boardSettings.cellHeight; boardWidth = columnCount * cellWidth; boardHeight = rowCount * cellHeight; #if (UNITY_ANDROID || UNITY_IO || UNITY_WP8) input = new MobileInput(); #endif #if (UNITY_STANDALONE || UNITY_EDITOR || UNITY_WEBPLAYER) input = new StandaloneInput(); #endif if (camera == null) { camera = Camera.main; } match3Game = new Match3Game(rowCount, columnCount, new HashSet <BlockColor> { BlockColor.Yellow, BlockColor.Blue, BlockColor.Orange, BlockColor.Green, BlockColor.Red, BlockColor.Purple }); boardRenderer = GetComponent <BoardRenderer>(); boardRenderer.SetGame(match3Game); boardRenderer.Render(); StartCoroutine(MainLoop()); }
public void TestGetMatches2() { var board = new Match3Game(NoPossibleActions, AllowedTypes); var matches = board.GetMatches(); Assert.IsTrue(matches.Count == 0); }
/// <summary> /// Creating a new Match3-game. /// </summary> private void InitNewGame() { _game?.Dispose(); _game = new Match3Game(Rows, Columns, ColorsCount, this); SetGameState(Match3GameStates.Wait); ScoreText.text = "0"; EarnedScoreText.UpdateText("", withMoving: false); }
public void TestGetMatches1() { var board = new Match3Game(Simple, AllowedTypes); var matches = board.GetMatches(); Assert.IsTrue(matches.Count == 2); Assert.IsTrue(matches.Contains(new MatchSet(0, 1, 3, MatchSet.Alignment.Vertical, BlockColor.Green))); Assert.IsTrue(matches.Contains(new MatchSet(3, 0, 3, MatchSet.Alignment.Horizontal, BlockColor.Blue))); }
public GameState(Match3Game game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content) { GameField = GetPlayingField(); _elements = new List <Element>(); _elements.Add(new Background(TextureController.GetTexture(BackgroundType.Full.SpritePath()), Vector2.Zero)); gameFont = TextureController.GetFont("Fonts/galleryFont"); _gameOverWindow = new EndWindow(_game, EndButton_Click); }
private static void GetBlockCountByType(Match3Game match3Game, Dictionary <BlockColor, int> blockTypeCount) { for (int row = 0; row < match3Game.RowCount; row++) { for (int column = 0; column < match3Game.ColumnCount; column++) { var block = match3Game[row, column]; int count; blockTypeCount.TryGetValue(block.color, out count); blockTypeCount[block.color] = ++count; } } }
public void TestRemovalMatches_ShouldNotAlterBoard() { var match3Game = new Match3Game(NoPossibleActions, AllowedTypes); List <SpecialBlockActivation> blockActivation = new List <SpecialBlockActivation>(); List <BlockRemoval> removedBlocks2 = new List <BlockRemoval>(); List <BlockAndPosition> createdBlocks = new List <BlockAndPosition>(); match3Game.RemoveMatches(blockActivation, removedBlocks2, createdBlocks); for (int row = 0; row < match3Game.RowCount; row++) { for (int column = 0; column < match3Game.ColumnCount; column++) { Assert.That(match3Game[row, column].color != BlockColor.Empty); } } }
public MenuState(Match3Game game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content) { var background = new Background(TextureController.GetTexture(BackgroundType.Sky.SpritePath()), Vector2.Zero); var btnType = ButtonType.Yellow; var startBtn = new ButtonBuilder() .AddType(btnType) .AddTextureByType() .AddFontByType() .AddText("Play") .AddPenColor(Color.Black) .OnClick(StartButton_Click) .AddPosition(new Vector2( game.Window.ClientBounds.Width / 2f - btnType.ButtonWidth() / 2f, game.Window.ClientBounds.Height / 2f - btnType.ButtonHeight() / 2f)) .Build(); _elements = new List <Element>() { background, startBtn }; }
public void TestShuffle() { Match3Game match3Game = new Match3Game(12, 12, AllowedTypes); var blocksByTypeOriginal = new Dictionary <BlockColor, int>(); GetBlockCountByType(match3Game, blocksByTypeOriginal); for (int i = 0; i < 10; i++) { match3Game.Shuffle(); var blocksByType = new Dictionary <BlockColor, int>(); GetBlockCountByType(match3Game, blocksByType); foreach (var allowedType in AllowedTypes) { int originalCount; blocksByTypeOriginal.TryGetValue(allowedType, out originalCount); int shuffledCount; blocksByType.TryGetValue(allowedType, out shuffledCount); Assert.True(originalCount == shuffledCount); } } }
public void SetGame(Match3Game game) { match3Game = game; rowCount = game.RowCount; columnCount = game.ColumnCount; }
protected GuiScreen(Match3Game game) { this.game = game; childElements = new Dictionary<int, GuiElement>(); }
public State(Match3Game game, GraphicsDevice graphicsDevice, ContentManager content) { _content = content; _graphicsDevice = graphicsDevice; _game = game; }
public EndScreen(Match3Game game) : base(game) { }
public StartScreen(Match3Game game) : base(game) { }
public void TestHasActions1() { Match3Game match3Game = new Match3Game(Simple, AllowedTypes); Assert.IsTrue(match3Game.HasAvailableActions()); }
public void TestHasActions2() { var board = new Match3Game(ManyMatches, AllowedTypes); Assert.IsTrue(board.HasAvailableActions()); }
public void TestHasMatches3() { var board = new Match3Game(ManyMatches, AllowedTypes); Assert.IsTrue(board.HasMatches()); }
public void TestHasMatches2() { var board = new Match3Game(NoPossibleActions, AllowedTypes); Assert.IsFalse(board.HasMatches()); }
public void TestHasMatches1() { var board = new Match3Game(Simple, AllowedTypes); Assert.IsTrue(board.HasMatches()); }