private GameBoard getResultOfNPlay(GameBoard board, int ply) { if (ply == 0) return baseResult(board); int bestScore = int.MinValue; GameBoard output = board; for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (!board.canPlayAtPosition(x, y)) continue; GameBoard playBoard = board.makeMove(x, y); GameBoard result = getResultOfNPlay(playBoard, ply - 1); int score = evaluateBoard(board.currentTurn, result); if (score > bestScore) { bestScore = score; output = result; } } } return output; }
public void ChecksApplyMultipleMoves() { GameBoard gameBoard = new GameBoard(3, 3); GameBlockPlayer player1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer; GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal; GameBlockMultipleMoves gameBlockMultiple = gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 2, numberOfMultipleMoves: 2) as GameBlockMultipleMoves; GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as GameBlockNormal; GameBlockPlayer player2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 2) as GameBlockPlayer; gameBlockNormal1.SetAvailability(true); gameBlockNormal2.SetAvailability(true); gameBlockMultiple.NumberOfMovesApplied = 0; player1.AvailableMoves = 2; player2.AvailableMoves = 2; BlockMovement move1 = new BlockMovement(player1, MovementDirection.Right); BlockMovement move2 = new BlockMovement(player2, MovementDirection.Up); bool applyMove1 = player1.ApplyMove(null, MovementDirection.Right, move1); bool applyMove2 = player2.ApplyMove(null, MovementDirection.Up, move2); Assert.IsTrue(applyMove1); Assert.IsTrue(applyMove2); }
private GameBoard baseResult(GameBoard board) { int bestScore = int.MinValue; GameBoard output = board; for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (!board.canPlayAtPosition(x, y)) continue; GameBoard playBoard = board.makeMove(x, y); int score = evaluateBoard(board.currentTurn, playBoard); if (score > bestScore) { bestScore = score; output = playBoard; } } } return output; }
public static IEnumerable<IMove> GetAllMovesFromField(GameBoard board, BoardPosition fromFieldPosition, out bool forcedOnly) { PlayerColor player = board[fromFieldPosition].Occupation; List<IMove> moves = new List<IMove>(); var firstTargets = GetPossibleTargetFields(board, fromFieldPosition, out forcedOnly); if (!forcedOnly) { moves.AddRange(firstTargets.Select(pos => new SimpleMove(player, fromFieldPosition, pos, board[fromFieldPosition].Piece == PieceType.King, false))); return moves; } JumpTree tree = new JumpTree(fromFieldPosition, firstTargets, board); ConstructJumpTree(ref tree); var paths = tree.Linearize(); tree = null; foreach (var path in paths) { if (path.Count == 2) { moves.Add(new SimpleMove(player, path[0], path[1], board[fromFieldPosition].Piece == PieceType.King, true)); } else { CompoundMove move = CompoundMove.FromPositions(player, path.First(), path.Last(), board[fromFieldPosition].Piece == PieceType.King, path.GetRange(1, path.Count - 2).ToArray()); moves.Add(move); } } return moves; }
/// <summary> /// Generates a grid specified by user /// </summary> /// <param name="sender">Button Click, not used.</param> /// <param name="e">Button Click, not used.</param> protected void Generate(object sender, EventArgs e) { int r, c; //Try to convert the text in text boxes to ints try { r = Convert.ToInt32(entryRows.Text); c = Convert.ToInt32(entryCols.Text); } //if it fails, log it, but dont close. Maybe user just mistyped. catch (FormatException ex) { Console.WriteLine(ex.ToString()); return; } if (CheckBounds(r, c)) { board = new GameBoard(r, c); GridConstructor gc = new GridConstructor(r, c, this); gc.Show(); gc.SetGrid(); } else { //if bounds check is not met, then display a specific dialog. ErrorDialog error = new ErrorDialog(2); error.Show(); } }
public static bool CheckForGameEnd(GameBoard board, out PlayerColor winner) { int whitePieces = board.GetPieceCountByOccupation(PlayerColor.White); int blackPieces = board.GetPieceCountByOccupation(PlayerColor.Black); if (whitePieces == 0) { winner = PlayerColor.Black; return true; } else if (blackPieces == 0) { winner = PlayerColor.White; return true; } else if (board.IdleMoves >= MAX_IDLE_MOVES) { if (whitePieces == blackPieces) { winner = PlayerColor.None; return true; } winner = whitePieces > blackPieces ? PlayerColor.White : PlayerColor.Black; return true; } winner = PlayerColor.None; return false; }
public static IEnumerable<IMove> GetAllMovesForPlayer(GameBoard board, PlayerColor player) { IEnumerable<GameField> fields = board.GetFieldsByPlayer(player); List<IMove> forcedMoves = new List<IMove>(); List<IMove> idleMoves = new List<IMove>(); bool forcedOnly; foreach (GameField f in fields) { var moves = GetAllMovesFromField(board, f.Position, out forcedOnly); if (forcedOnly) forcedMoves.AddRange(moves); else idleMoves.AddRange(moves); } if (forcedMoves.Count > 0) { int longest = 0; forcedMoves.ForEach(mv => { if (mv.Length > longest) longest = mv.Length; }); return forcedMoves.Where(mv => mv.Length == longest).ForEach<IMove, GameBoard>(SetMoveCaptures, board); } return idleMoves; }
public void Initialize() { gameOverPosition.X = 320; gameOverPosition.Y = 130; device = graphics.GraphicsDevice; gameState = new GameState(); gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight); board = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight)); darwin = new Darwin(board); zTime = new ZombieTime(board); nurseryOne = new Nursery(board, darwin); nurseryTwo = new Nursery(board, darwin); fatBossZombie = new FatBossZombie(15, 4, 19, 14, 4, 3, darwin, board); fatBossZombie.resetGapeMode(); stairs = new Stairs(board); walls = setWallsInLevelSix(); setLevelState(); gameState.setState(GameState.state.Start); }
//private LinkedList<BabyZombie> babies; public FatBossZombie(int x, int y, int maxX, int minX, int maxY, int minY, Darwin dar, GameBoard gb) : base(x, y, maxX, minX, maxY, minY, gb) { darwin = dar; destination.Height = board.getSquareLength() * 3; destination.Width = board.getSquareWidth() * 3; source = new Rectangle(0, 0, 128, 128); setEventLag(10); explodeSource = new Rectangle[4]; explodeSource[0] = new Rectangle(0, 0, 75, 90); explodeSource[1] = new Rectangle(0, 0, 75, 90); explodeSource[2] = new Rectangle(76, 0, 87, 90); explodeSource[3] = new Rectangle(169, 0, 101, 90); ran = new Random(); ran1 = new Random(); deathExplodeCount = new int[9]; deathExplodeBool = new bool[9]; for (int i = 0; i < 9; i++) { deathExplodeBool[i] = new bool(); deathExplodeCount[i] = new int(); } reset(); ZOMBIE_MOVE_RATE = 50; }
public void TestThatAllBobsDiesAtEndOfTurnTeam02() { Character[] tf2Blue = new Character[6]; for (int i = 0; i < 6; i++) { tf2Blue[i] = new Character("Bob", null, 10, 10, 10, new Item(), "Warrior"); } Character[] tf2Red = new Character[6]; for (int i = 0; i < 6; i++) { tf2Red[i] = new Character("Bob", null, 10, 10, 10, new Item(), "Warrior"); } var target = new GameBoard(null, tf2Blue, tf2Red, null, null); for (int i = 0; i < 6; i++) { Effect effThat = new Effect("health", 1, 100.0, true, target.getSecondTeamCharacters()[i]); target.addEffect(effThat); } target.turn(); Assert.AreEqual(target.getSecondTeamCharacters()[0].GetDead(), true); Assert.AreEqual(target.getSecondTeamCharacters()[1].GetDead(), true); Assert.AreEqual(target.getSecondTeamCharacters()[2].GetDead(), true); Assert.AreEqual(target.getSecondTeamCharacters()[3].GetDead(), true); Assert.AreEqual(target.getSecondTeamCharacters()[4].GetDead(), true); Assert.AreEqual(target.getSecondTeamCharacters()[5].GetDead(), true); }
public void TestThatGameBoardChangesToOriginalTurnPerson() { var target = new GameBoard(null, null, null, null, null); target.turn(); target.turn(); Assert.True(target.getTurn()); }
public void GameBoard_TestShowBoard() { GameBoard gameBoard = new GameBoard(); StringWriter stringWriter = new StringWriter(); using (stringWriter) { Console.SetOut(stringWriter); gameBoard.ShowBoard(); string expectedString = @" UL 0 1 2 3 4 5 6 7 UR _________________ 0 | A B C D | 0 1 | | 1 2 | | 2 3 | | 3 4 | | 4 5 | | 5 6 | | 6 7 | K | 7 |_________________| DL 0 1 2 3 4 5 6 7 DR "; Assert.AreEqual(expectedString, stringWriter.ToString()); } }
protected GameBlockBase(GameBoard gameBoard, int indexRow, int indexColumn) { this.gameBoard = gameBoard; this.gameBoard.GameBlocks[indexRow, indexColumn] = this; this.indexRow = indexRow; this.indexColumn = indexColumn; }
protected override IMove GetNextMove_Impl(IGameBoard board) { m_GameBoard = board as GameBoard; InkCollectorStrokeEventHandler handler = new InkCollectorStrokeEventHandler(m_InkPicture_Stroke); IMove move = null; m_Waiter = new EventWaitHandle(false, EventResetMode.ManualReset); m_InkPicture.Stroke += handler; try { while (move == null) { m_Waiter.Reset(); if (m_Waiter.WaitOne()) { move = m_Move; } } } finally { m_InkPicture.Stroke -= handler; } return move; }
public Vortex(GameBoard gameBoard, int startX, int startY) : base(gameBoard) { this.X = startX; this.Y = startY; destination = board.getPosition(startX, startY); }
// refer to Zombie constructor for details public BabyZombie(int x, int y, int maxX, int minX, int maxY, int minY, Darwin dar, GameBoard gb) : base(x, y, maxX, minX, maxY, minY, gb) { darwin = dar; babyCount = 0; babyCountTwo = 0; babySource = new Rectangle[6]; babySource[0] = new Rectangle(0, 0, 64, 64); babySource[1] = new Rectangle(65, 0, 64, 64); babySource[2] = new Rectangle(128, 0, 64, 64); babySource[3] = new Rectangle(192, 0, 64, 64); babySource[4] = new Rectangle(256, 0, 64, 64); babySource[5] = new Rectangle(320, 0, 64, 64); goingToExplode = false; exploding = false; explodeCount = 0; explodeSource = new Rectangle[3]; explodeSource[0] = new Rectangle(0, 0, 75, 90); explodeSource[1] = new Rectangle(76, 0, 87, 90); explodeSource[2] = new Rectangle(169, 0, 101, 90); this.setEventLag(40); }
/// <summary> /// Converts a string to a valid command in the context of a game board /// </summary> /// <param name="input">A string to parse the command from</param> /// <param name="gameBoard">The context of validation</param> /// <returns></returns> public Command ExtractCommand(string input, GameBoard gameBoard) { Command command; CommandType cmdType; Position coordinates = new Position(0, 0); string[] inputCommands = input.Split(' '); cmdType = this.GetCommandType(inputCommands); if (cmdType == CommandType.Flag || cmdType == CommandType.ValidMove) { try { coordinates = this.GetCoordinates(inputCommands, cmdType); } catch (Exception) { cmdType = CommandType.InvalidMove; } } if (!gameBoard.IsInsideBoard(coordinates)) { return new Command(CommandType.InvalidMove); } command = new Command(cmdType, coordinates); return command; }
public void IndexToCoords_IsCorrect() { var board = new GameBoard(); int x; int y; board.IndexToCoords(0,out x,out y); Assert.AreEqual(0, x); Assert.AreEqual(0, y); board.IndexToCoords(1,out x,out y); Assert.AreEqual(1, x); Assert.AreEqual(0, y); board.IndexToCoords(2,out x,out y); Assert.AreEqual(2, x); Assert.AreEqual(0, y); board.IndexToCoords(3,out x,out y); Assert.AreEqual(0, x); Assert.AreEqual(1, y); board.IndexToCoords(4,out x,out y); Assert.AreEqual(1, x); Assert.AreEqual(1, y); board.IndexToCoords(5,out x,out y); Assert.AreEqual(2, x); Assert.AreEqual(1, y); board.IndexToCoords(6,out x,out y); Assert.AreEqual(0, x); Assert.AreEqual(2, y); board.IndexToCoords(7,out x,out y); Assert.AreEqual(1, x); Assert.AreEqual(2, y); board.IndexToCoords(8,out x,out y); Assert.AreEqual(2, x); Assert.AreEqual(2, y); }
public Game(GameBoard gameBoard, Dice dice) { this.gameBoard = gameBoard; this.dice = dice; this.players = new List<Player>(); this.shuffler = new Shuffler<Player>(); }
protected override int evaluateBoard(int currentTurn, GameBoard board) { int whiteEdges = 0; int blackEdges = 0; for (int index = 0; index < 8; ++index) { if (board.cells[index, 0] == GameBoard.WHITE) whiteEdges += 1; else if (board.cells[index, 0] == GameBoard.BLACK) blackEdges += 1; if (board.cells[index, 7] == GameBoard.WHITE) whiteEdges += 1; else if (board.cells[index, 7] == GameBoard.BLACK) blackEdges += 1; if (board.cells[0, index] == GameBoard.WHITE) whiteEdges += 1; else if (board.cells[0, index] == GameBoard.BLACK) blackEdges += 1; if (board.cells[7, index] == GameBoard.WHITE) whiteEdges += 1; else if (board.cells[7, index] == GameBoard.BLACK) blackEdges += 1; } if (currentTurn == GameBoard.WHITE) return whiteEdges - blackEdges; else return blackEdges - whiteEdges; }
public void Initialize() { this.fakeDice = new FakeDice(); this.player = new Player("Horse"); this.board = new ClassicBoard(); this.turn = new Turn(this.fakeDice, this.player, this.board); }
/* constructor * sets an initial area for the zombie to take up * mymaxX, myminX are the max/min allowed horizontal range for the zombie * mymaxY, myminY are the max/min allowed vertical range for the zombie * Gameboard myboard -- the board which the zombie is moving on **/ public Zombie(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY, GameBoard myboard) : base(myboard) { maxX = mymaxX; maxY = mymaxY; minX = myminX; minY = myminY; // start with no zombie vision allowVision = false; visionMaxX = 3; visionMaxY = 3; isAlive = true; allowRangeDetection = true; board = myboard; this.X = startX; this.Y = startY; if (board.isGridPositionOpen(this)) { board.setGridPositionOccupied(this.X, this.Y); this.destination = board.getPosition(X, Y); } source = new Rectangle(0, 0, ZOMBIE_WIDTH, ZOMBIE_HEIGHT); enemyAlert = false; }
/// <summary> /// Sets up the player chooser combo boxes with list of players /// </summary> private void SetupPlayerChoosers() { // Construct and set the game board GameBoard game = new GameBoard(10, 10, 4); this.ButtonBoard.TheGame = game; Assembly assembly = Assembly.GetAssembly(this.GetType()); Type[] ctorParameterTypes = new Type[] { typeof(PlayerToken), typeof(GameBoard) }; foreach (Type type in assembly.GetTypes()) { if (type.IsSubclassOf(typeof(PlayerBase))) { ConstructorInfo ctorInfo = type.GetConstructor(ctorParameterTypes); if (ctorInfo != null) { comboPlayerX.Items.Add(ctorInfo.Invoke(new object[] { PlayerToken.X, this.buttonBoard.TheGame })); comboPlayerO.Items.Add(ctorInfo.Invoke(new object[] { PlayerToken.O, this.buttonBoard.TheGame })); } } } comboPlayerX.SelectedIndex = 0; comboPlayerO.SelectedIndex = 0; }
static void Main(string[] args) { GameBoard newGameBoard = new GameBoard(); WordsForGame words = new WordsForGame(); _answer = words.wordGenerator(); _blankAnswer = words.blankWord(_answer); //debug //Console.WriteLine(_answer); while(_blankCount > 0 && _playerLives >= 0) { newGameBoard.drawGallows(_playerLives); Console.WriteLine(_blankAnswer); Console.WriteLine("\nEnter a letter to guess"); guess = Console.ReadKey().KeyChar; words.checkGuessAgainstWord(_answer, _blankAnswer, guess); Console.Clear(); } if (_blankCount == 0) { Console.WriteLine("Hooray, you win"); } else { Console.WriteLine("Something has gone horribly wrong"); } Console.ReadLine(); }
// refer to ZOmbie constructor public Snake(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY, GameBoard myboard) : base(startX, startY, mymaxX, myminX, mymaxY, myminY, myboard) { ZOMBIE_MOVE_RATE = 20; source.X = 0; isAlive = true; }
public void TestThatAllPlayersStartWithTheSameAmountOfMoney() { GameBoard gameBoard = new GameBoard(); gameBoard.Players = new List<Player> { new Player { Token = PlayerTokens.Tokens.Dog }, new Player { Token = PlayerTokens.Tokens.Hat } }; gameBoard.SetInitialMonies(1234); Assert.That(gameBoard.Players[0].Money, Is.EqualTo(1234)); Assert.That(gameBoard.Players[1].Money, Is.EqualTo(1234)); }
public void ThenTheResultShouldBe(Table table) { IEnumerable<IGameMove> steps = table.ParseMoves(); var board = new GameBoard(); board.Restore(steps); TicTacToeScenarioContext.Board.Should().Match(board); }
/// <summary> /// /// </summary> /// <param name="game"></param> /// <param name="board">The board</param> public Player(Game game, GameBoard.GameBoard board) : base(game) { Angle = 2.142f; this.Score = 0; this.Texture = game.Content.Load<Texture2D>("Game/Player"); this.Board = board; }
public void EmptyBoard() { var board = new GameBoard(); TicTacToeScenarioContext.Board = board; var game = new Game(board); TicTacToeScenarioContext.Game = game; }
public void Are_Ships_Set_Up_On_Board_Correctly_OK() { var gameBoard = new GameBoard("Tom"); gameBoard.SetUpShips(); var cells = gameBoard.Board.Cells; Assert.AreEqual(100, cells.Count); Assert.AreEqual(13, cells.Count(x => x.Value.HasShip)); }
//Method that calls the action method on the player sent to the method private void PlayerAction(Player currentPlayer, GameBoard board) { currentPlayer.Action(currentPlayer.GetSpaceOccupied(), board, players); }
private void Start() { rb = GetComponent <Rigidbody2D>(); board = FindObjectOfType <GameBoard>(); }
public static ClientGameBoard Client(this GameBoard obj) { return((ClientGameBoard)obj); }
public void Initialize(CursorHandler h) { gameboard = h.gameboard; baseTile = h.baseTile; tile = baseTile; }
public SingleGameSolver(GameBoard board, Random rand) { Board = board; Random = rand; }
/// <summary> /// This function saves just the part of the game file without any use edits applied. /// </summary> public bool SaveFileUnsolved(GameBoard gameBoard, String fileName) { return(true); }
public void Setup() { _sut = new GameBoard(); _fixture = new Fixture(); }
public Bishop(GameBoard gameBoard, string c) { MyBoard = gameBoard; Color = c; }
void Awake() { Instance = this; }
public CommunityChestFactory(IBanker banker, IJailRoster jailRoster, GameBoard board) { this.banker = banker; this.jailRoster = jailRoster; this.board = board; }
public void ConnectFour_ViewBoard_Test() { var board = new GameBoard(rowCount, columnCount); Assert.IsTrue(connect4.ViewBoard() == board.DrawBoard()); }
public Knight(GameBoard gameBoard, string c) { MyBoard = gameBoard; Color = c; }
//Creates a new board and adds it and its spaces to the gameobjects list. private void SetupBoard(SizeEnum size) { board = new GameBoard(0, 0, Color.Blue, new Size(2048, 2048)); gameObjects.Add(board); gameObjects.AddRange(board.GetBoardSpaces()); }
public GameBoardGenerator(GameBoard gameBoard) { this.gameBoard = gameBoard; cachedGraphRoot = new IntVector2(); }
public WeaponDisplay(String fireText, String availableText, String unavailableText, Texture2D buttonSprite, int availableAtPower, Vector2 position, SpriteFont font, GameBoard gameBoard) : base(position, font, gameBoard) { this.fireText = fireText; this.availableText = availableText; this.unavailableText = unavailableText; this.buttonSprite = buttonSprite; this.available = false; this.availableAtPower = availableAtPower; }
public bool canPlay(int x, int y) { return(!GameBoard.ContainsKey(keyString(x, y))); }
void CreateBoard() { if (boardchanged) { if (mainboard != null) { mainview.Destroy(); } string gamechoice = gameChoiceButton.GetSelectionString(); switch (gamechoice) { case "Tic Tac Toe": mainboard = new GomokuBoard(3, 3, 3, 3); mainview = new GomokuView((GomokuBoard)mainboard); break; case "Tic Tac 5": mainboard = new GomokuBoard(5, 5, 3, 5); mainview = new GomokuView((GomokuBoard)mainboard); break; case "Gomoku 9x9": mainboard = new GomokuBoard(9, 9, 5, 5); mainview = new GomokuView((GomokuBoard)mainboard); break; case "Gomoku 15x15": // omitted from the options for now mainboard = new GomokuBoard(15, 15, 5, 5); mainview = new GomokuView((GomokuBoard)mainboard); break; case "Connect Four": mainboard = new ConnectFourBoard(7, 6); mainview = new ConnectFourView((ConnectFourBoard)mainboard); break; case "Othello": mainboard = new OthelloBoard(8, 8); mainview = new OthelloView((OthelloBoard)mainboard); break; case "Domineering 7x7": mainboard = new DomineeringBoard(7, 7); mainview = new DomineeringView((DomineeringBoard)mainboard); break; case "Domineering 9x9": mainboard = new DomineeringBoard(9, 9); mainview = new DomineeringView((DomineeringBoard)mainboard); break; case "Pentago": mainboard = new PentagoBoard(); mainview = new PentagoView((PentagoBoard)mainboard); break; case "Hex 7x7": mainboard = new HexBoard(7, 7); mainview = new HexView((HexBoard)mainboard); break; case "Hex 10x10": mainboard = new HexBoard(10, 10); mainview = new HexView((HexBoard)mainboard); break; default: Console.WriteLine("Unknown game name"); return; } AddChild(mainview); mainview.RegisterCellClickHandler(RegisterHumanMove); boardchanged = false; } else { mainboard.Reset(); } mainboard.SetActivePlayer(1); }
private void DrawChunkBorder(GameBoard board, Tile[,] chunk, int chunkX, int chunkY, int beginX, int beginY, Graphics g) { int width = chunk.GetLength(0); int height = chunk.GetLength(1); int tileSize = this.TileSize; int halfTileSize = tileSize / 2; for (int x = 0; x < width; ++x) { int tileX = x * tileSize + beginX + halfTileSize; for (int y = 0; y < height; ++y) { var tile = chunk[x, y]; // 영토(타일)가 존재하면 if (tile != null) { int tileY = y * tileSize + beginY + halfTileSize; int[] nearX = new int[] { x, x + 1 }; int[] nearY = new int[] { y - 1, y }; for (int i = 0; i < 2; ++i) { Tile nearTile = null; if (nearX[i] < 0 || nearX[i] >= width || nearY[i] < 0 || nearY[i] >= height) { int globalX = chunkX * board.Board.ChunkSize + nearX[i]; int globalY = chunkY * board.Board.ChunkSize + nearY[i]; if (board.Board.ContainsItemAt(globalX, globalY)) { nearTile = board.Board.GetItemAt(globalX, globalY); } } else { nearTile = chunk[nearX[i], nearY[i]]; } if (nearTile != null && nearTile.Owner != tile.Owner) { switch (i) { case 0: g.DrawLine(Pens.Black, beginX + x * TileSize, beginY + y * TileSize, beginX + x * TileSize + TileSize, beginY + y * TileSize); break; case 1: g.DrawLine(Pens.Black, beginX + x * TileSize + TileSize, beginY + y * TileSize, beginX + x * TileSize + TileSize, beginY + y * TileSize + TileSize); break; } } } } } } }
public ServerCheckersGame() { gameBoard = new GameBoard(); SetCurrentPlayer(1); }
// Use this for initialization void Start() { m_gameBoard = (GameBoard)GameObject.FindObjectOfType <Canvas>().GetComponentInChildren <GameBoard>(); }
public ActionResult Index() { var gb = new GameBoard(10, 10, 5); return(View()); }
public IActionResult Index() { GameBoard boardGame = new GameBoard(); return(View(boardGame)); }
//##################################################################################### // 그리기 public void DrawBoard(GameBoard board, Rectangle screenRect, bool showInvisibleTile, Graphics g) { int chunkSize = board.Board.ChunkSize; int chunkXBegin = -this.BoardLocation.X / (chunkSize * this.TileSize) - 1; int chunkYBegin = -this.BoardLocation.Y / (chunkSize * this.TileSize) - 1; int chunkXEndInScreen = screenRect.Width / (chunkSize * this.TileSize) + 2 + chunkXBegin; int chunkYEndInScreen = screenRect.Height / (chunkSize * this.TileSize) + 2 + chunkYBegin; for (int chunkX = chunkXBegin; chunkX <= chunkXEndInScreen; ++chunkX) { int x = chunkX * (chunkSize * this.TileSize) + this.BoardLocation.X; for (int chunkY = chunkYBegin; chunkY <= chunkYEndInScreen; ++chunkY) { var chunk = board.Board.GetChunkAt(chunkX, chunkY); if (chunk != null) { this.DrawChunkBack(chunk, x, chunkY * (chunkSize * this.TileSize) + this.BoardLocation.Y, showInvisibleTile, g); } } } // 타일 크기가 충분히 크면 if (this.TileSize >= MinTileSizeToShowDetail) { const int minLength = 8; Point[] rectVtx = new Point[] { new Point(this.TileCursor.X, this.TileCursor.Y), new Point(this.TileCursor.X - minLength, this.TileCursor.Y), new Point(this.TileCursor.X + minLength, this.TileCursor.Y), new Point(this.TileCursor.X, this.TileCursor.Y - minLength), new Point(this.TileCursor.X, this.TileCursor.Y + minLength), new Point(this.TileCursor.X - minLength, this.TileCursor.Y - minLength), new Point(this.TileCursor.X + minLength, this.TileCursor.Y - minLength), new Point(this.TileCursor.X + minLength, this.TileCursor.Y + minLength), new Point(this.TileCursor.X - minLength, this.TileCursor.Y + minLength), }; foreach (Point vtx in rectVtx) { int chunkX, chunkY; board.Board.GetChunkPosContainsItemAt(vtx.X, vtx.Y, out chunkX, out chunkY); var focusChunk = board.Board.GetChunkAt(chunkX, chunkY); if (focusChunk != null) { this.DrawChunkTileDetail(focusChunk, chunkX * (chunkSize * this.TileSize) + this.BoardLocation.X, chunkY * (chunkSize * this.TileSize) + this.BoardLocation.Y, showInvisibleTile, g); } } } for (int chunkX = chunkXBegin; chunkX <= chunkXEndInScreen; ++chunkX) { int x = chunkX * (chunkSize * this.TileSize) + this.BoardLocation.X; for (int chunkY = chunkYBegin; chunkY <= chunkYEndInScreen; ++chunkY) { var chunk = board.Board.GetChunkAt(chunkX, chunkY); if (chunk != null) { this.DrawChunkBorder(board, chunk, chunkX, chunkY, x, chunkY * (chunkSize * this.TileSize) + this.BoardLocation.Y, g); } } } for (int chunkX = chunkXBegin; chunkX <= chunkXEndInScreen; ++chunkX) { int x = chunkX * (chunkSize * this.TileSize) + this.BoardLocation.X; for (int chunkY = chunkYBegin; chunkY <= chunkYEndInScreen; ++chunkY) { var chunk = board.Board.GetChunkAt(chunkX, chunkY); if (chunk != null) { this.DrawChunkSign(chunk, x, chunkY * (chunkSize * this.TileSize) + this.BoardLocation.Y, showInvisibleTile, g); } } } Tile focusTile = null; if (board.Board.ContainsItemAt(this.TileCursor.X, this.TileCursor.Y)) { focusTile = board.Board.GetItemAt(this.TileCursor.X, this.TileCursor.Y); } DrawFocusTile(g, focusTile); }
public NewGameCommand(GameBoard gameBoard) { this.gameBoard = gameBoard ?? throw new ArgumentNullException(nameof(gameBoard)); }
public Queen(GameBoard tab, Cor cor) : base(tab, cor) { }
public void CreateGame() { game = new GameBoard(); }
public void InitializeWithLevel(string levelToLoad) { this.gameBoard = new GameBoard(levelToLoad); this.SetUpBoardSquares(); }
private void OnMouseDown() { if (!ButtonEnabled) { return; } _board = GameObject.FindObjectOfType <GameBoard>(); if (isSendButton) { _board.OnSend(); } else if (isDigButton) { _board.OnDig(); } else if (isPlayButton) { if (NamePromptGUI.PlayerName.Length > 0) { NamePromptGUI.NameSet = true; PlayerPrefs.SetString("PlayerName", NamePromptGUI.PlayerName); Application.LoadLevel("MainGame"); } } else if (isResetButton) { Application.LoadLevel("MainGame"); } else if (isSuperButton) { switch (Power) { case SuperPower.AllColor: _board.ApplyAllColorPower(); break; case SuperPower.AllExplode: _board.ApplyExplodePower(); break; case SuperPower.IgnoreColor: _board.ApplyIgnoreColorPower(); break; case SuperPower.ScoreMultiplier: _board.ApplyScoreMultiplierPower(); break; case SuperPower.Shuffle: _board.ApplyShufflePower(); break; case SuperPower.StopTimer: _board.ApplyStopTimePower(); break; default: Debug.LogError("Oops don't know how to handle power " + Power); break; } // single use! ButtonEnabled = false; } else if (isEndButton) { SceneDataPasser.LastScore = _board.Score; Application.LoadLevel("ScoreBoard"); } }
public Cannon(GameBoard gameBoard, CannonPlane cannonPlane) { GameBoard = gameBoard; CannonPlane = cannonPlane; MovingCannon = false; }
} //end CheckValidMoveLeft public void CheckValidRotate(Transform in_block1, Transform in_block2, Transform in_block3, Transform in_block4, GameBoard in_gameBoardRotate) { in_block1.parent = pivot.transform; in_block2.parent = pivot.transform; in_block3.parent = pivot.transform; in_block4.parent = pivot.transform; currentRotation += 90; if (currentRotation == 360) { currentRotation = 0; } //rotate block pivot.transform.localEulerAngles = new Vector3(0, 0, currentRotation); //check if rotation results in valid position. if ((in_gameBoardRotate.requestStatusOfPosition(Mathf.RoundToInt(in_block1.position.x), Mathf.RoundToInt(in_block1.position.y)) == 1) || (in_gameBoardRotate.requestStatusOfPosition(Mathf.RoundToInt(in_block2.position.x), Mathf.RoundToInt(in_block2.position.y)) == 1) || (in_gameBoardRotate.requestStatusOfPosition(Mathf.RoundToInt(in_block3.position.x), Mathf.RoundToInt(in_block3.position.y)) == 1) || (in_gameBoardRotate.requestStatusOfPosition(Mathf.RoundToInt(in_block4.position.x), Mathf.RoundToInt(in_block4.position.y)) == 1) ) { //not valid, undo rotation currentRotation -= 90; pivot.transform.localEulerAngles = new Vector3(0, 0, currentRotation); } in_block1.parent = null; in_block2.parent = null; in_block3.parent = null; in_block4.parent = null; }