public void InitGame() { Width = WindowSize; // Set width of form Height = WindowSize; // Set height of form MainPanel.Paint += OnDraw; // Add a Paint Event Handler MainPanel.MouseDown += OnMousePress; // Add a Mouse Event Handler FieldWidth = (MainPanel.Width - BordMargin * 2) / BoardSize; // Set width of the grid fields FieldHeight = (MainPanel.Height - BordMargin * 2) / BoardSize; // Set height of the grid fields XOSize = FieldWidth / 2; // Set size of Xs and Os to half the width of a field BoardState = new FieldState[BoardSize, BoardSize]; // Initialize two dimensional grid array for (int c = 0; c < BoardSize; c++) { for (int r = 0; r < BoardSize; r++) { BoardState[c, r] = FieldState.EMPTY; // Set default value to empty state } } Logic = new GameLogic(this); // Initialize game logic Logic.CreateNewPlayer(PlayerType.HUMAN); // Assign player 1 to X Logic.CreateNewPlayer(PlayerType.ROBOT); // Assign bot to O Logic.StartGame(); // Starts the game }
public GridModel(int width = 20, int height = 20) { this.Width = width; this.Height = height; this.fields = new FieldState[Height, Width]; ResetCellsToDefault(); }
static void Draw(FieldState[,] Board) { Console.Clear(); for (int row = 0; row < 3; row++) // reihe zählen von 0 solange kleiner als 3 { for (int column = 0; column < 3; column++) // spalte zählen von 0 solange kleiner als 3 { switch (Board[row, column]) { case FieldState.Empty: // wenn im spielfeld an koordinate reihe,spalte leer steht Console.Write("_"); // ausgabe leerzeichen break; case FieldState.X: // wenn im spielfeld an koordinate reihe,spalte X steht Console.Write("X"); // ausgabe eines X break; case FieldState.O: // wenn im spielfeld an koordinate reihe,spalte O steht Console.Write("O"); // ausgabe eines O break; case FieldState.Hint: // wenn im spielfeld an koordinate reihe,spalte hint steht Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Write(" "); // ausgabe eines leerzeichens mit anderer hintergrundfarbe Console.ResetColor(); break; default: // wenn etwas völlig unerwartetes in einem Spielfeld steht throw new NotImplementedException(); //abbruch der Methode }//ende switch }// ende zählen spalte Console.WriteLine(); }// ende zählen reihe }
public override void Draw(FieldState[,] board) { Console.CursorVisible = false; Text($"turn {game.turnNumber}, {game.playerNames[Convert.ToInt32(game.currentPlayerID)]} [{(game.currentPlayerID ? FieldState.X : FieldState.O)}] it's your turn!\n", 0, 2, (game.currentPlayerID ? pColor[0] : pColor[1])); Text("0 1 2", 12, 5); for (int y = 0; y < 3; y++) { Text(" -------------", 7, 6); Text("0 | | | |", 7, 7); Text(" -------------", 7, 8); Text("1 | | | |", 7, 9); Text(" -------------", 7, 10); Text("2 | | | |", 7, 11); Text(" -------------", 7, 12); } for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { if (board[y, x] == FieldState.O || board[y, x] == FieldState.X) { Text($"{board[y, x]}", 12 + x * 4, 7 + y * 2, (board[y, x] == FieldState.X ? pColor[0] : pColor[1])); } } } Console.CursorVisible = true; }
void Start() { if (debugMode) { stageInfo.mapNumber = 0001; stageInfo.mapName = "산 남부 중턱"; stageInfo.areaName = "디스메어 산"; stageInfo.gridColor = new Color(0f, 179f / 255f, 63f / 255f); stageInfo.gameRule = GameRules.DefaultRule; } else { stageInfo = GlobalData.stageInfo; } units = new List <Unit>(); skills = new List <Skill>(); gameRule = GameRule.GetGameRule(stageInfo.gameRule); fieldState = new FieldState[12, 4]; for (int x = 0; x < 12; ++x) { for (int y = 0; y < 4; ++y) { fieldState[x, y] = new FieldState(); } } UIManager.Instance.Initialize(); TouchManager.Instance.Initialize(); CameraManager.Instance.Initialize(); gameRule.Initialize(); grid.Initialize(); background.Initialize(); }
private bool IsRotateValid() { // Все матрицы элементов квадратные по дефолту currentElementMatrix = new FieldState[playingFieldManager.currentElementSize, playingFieldManager.currentElementSize]; xShift = (int)playingFieldManager.topLeftPositionOfCurrentElement.x; yShift = (int)playingFieldManager.topLeftPositionOfCurrentElement.y; // Записываем часть поля с элементом в отдельный массив for (int y = 0; y < playingFieldManager.currentElementSize; y++) { for (int x = 0; x < playingFieldManager.currentElementSize; x++) { if (playingFieldManager.matrix[y + yShift, x + xShift] == FieldState.Fallen) { return(false); } if (playingFieldManager.matrix[y + yShift, x + xShift] == FieldState.Falling) { currentElementMatrix[y, x] = playingFieldManager.matrix[y + yShift, x + xShift]; } } } return(true); }
public Field(int w, int h) { Width = w; Height = h; States = new FieldState[Width, Height]; FillField(); }
public Field() { Width = 10; Height = 10; States = new FieldState[Width, Height]; FillField(); }
private void setField(int w, int h) { Width = w < minWidth ? minWidth : w; Height = h < minHeight ? minHeight : h; field = new FieldState[Width, Height]; }
// Побудова дошки для гри: char[] BuildCharBoard(FieldState[,] board) { char[] charBoard = new char[9]; int k = 0; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if (board[i, j] == FieldState.Cross) { charBoard[k] = 'X'; } else if (board[i, j] == FieldState.Circle) { charBoard[k] = 'O'; } else { charBoard[k] = Convert.ToChar(k.ToString()); } ++k; } } return(charBoard); }
public GameStateInternal(GameStateInternal state) { Ko = FieldCoordinates.Pass; CapturedStones = state.CapturedStones; BoardSize = state.BoardSize; BoardFields = new FieldState[BoardSize, BoardSize]; Array.Copy(state.BoardFields, BoardFields, state.BoardFields.Length); }
public BoardState(FieldState[,] template, IEnumerable <HitOption> hitOptions, IEnumerable <SunkShipOption> sunkenShips, FieldState[] remainingShips, int shot) { Template = template; Shot = shot; RemainingShips = remainingShips; HitOptions = hitOptions.ToImmutableList(); SunkenShips = sunkenShips.ToImmutableList(); }
public void SpawnElement(FieldState[,] element, FieldState[,] playingFieldMatrix) { for (int y = 0; y < element.GetLength(0); y++) { for (int x = 0; x < element.GetLength(1); x++) { playingFieldMatrix[y, x + spawnPoint] = element[y, x]; } } }
public GameState() { BoardArray = new FieldState[8, 8]; PreviousBoardArray = new FieldState[8, 8]; PossibleMoves = new List<FieldState[,]>(); PossibleCapture = new List<FieldState[,]>(); CurrentPlayer = 0; CurrentPawn = FieldState.RedPawn; CurrentDame = FieldState.BluePawn; }
IEnumerator FieldInit() { Debug.Log("asdf"); _field = new FieldState[_floorWidth, _floorHeight]; yield return(DungeonGenerator.CreateMaze(_field, _floorWidth, _floorHeight)); //yield return DungeonGenerator.CreateMaze(_field,_floorWidth, _floorHeight); Debug.Log("OUT"); }
// logically this is a starting new game public GameState() { board = new FieldState[rows, columns]; for (int y = 0; y < rows; y++) { for (int x = 0; x < columns; x++) { board[y, x] = FieldState.none; } } currentPlayer = FieldState.yellow; // let the blue player make turn first }
void Start() { LevelController.Instance.InitializeLevel(); matrix = new FieldState[Height, Width]; field = new GameObject[Height, Width]; FillThePlayingField(); topLeftPositionDefault = new Vector2(SpawnManager.spawnPoint, 0); topLeftPositionOfCurrentElement = topLeftPositionDefault; spawnManager.SpawnRandomElement(matrix); }
private void NewGame(object sender = null, EventArgs e = null) { gameEnded = false; boardRows = (int)rowsInput.Value; boardColumns = (int)columnsInput.Value; board = new FieldState[boardRows, boardColumns]; CreateInitialBoard(); currentPlayer = FieldState.PlayerOne; DetermineBoardState(); Invalidate(true); }
/// <summary> /// Запись упавших элементов из оригинальной матрицы во временную /// </summary> public void FallenToTemp(FieldState[,] tempMatrix) { for (int y = Height - 1; y > 0; y--) { for (int x = Width - 1; x >= 0; x--) { if (matrix[y, x] == FieldState.Fallen) { tempMatrix[y, x] = FieldState.Fallen; } } } }
// Для пустих клітинок: int ContainNull(FieldState[,] list) { int countNull = 0; foreach (var el in list) { if (el == FieldState.Empty) { countNull++; } } return(countNull); }
private static void MarkHit(FieldState[,] result, int x, int y, int currentLength, bool vertical = false) { var state = GetPossibleShips(currentLength + 1); for (byte i = 0; i < currentLength; i++) { if (vertical) { result[x, y + i] &= state; result[x, y + i] |= FieldState.Hit; } else { result[x + i, y] &= state; result[x + i, y] |= FieldState.Hit; } } if (vertical) { if (x > 0) { result[x - 1, y] &= state; } if (x < 9) { result[x + 1, y] &= state; } } else { if (y > 0) { result[x, y - 1] &= state; } if (y < 9) { result[x, y + 1] &= state; } } }
public void SpawnRandomElement(FieldState[,] playingFieldMatrix) { Element element = elements.GetRandomElement(); playingFieldManager.currentElementArray = element.Matrix; playingFieldManager.currentElementSize = element.Matrix.GetLength(0); playingFieldManager.topLeftPositionOfCurrentElement = playingFieldManager.topLeftPositionDefault; for (int y = 0; y < element.Matrix.GetLength(0); y++) { for (int x = 0; x < element.Matrix.GetLength(1); x++) { if (playingFieldMatrix[y, x + spawnPoint] == FieldState.Fallen) { StartCoroutine(GameOver()); } playingFieldMatrix[y, x + spawnPoint] = element.Matrix[y, x]; } } playingFieldManager.UpdateThePlayingField(); }
public Board(Game game, ref Texture2D textures, Rectangle[] rectangles) : base(game) { sBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); // Load textures for blocks this.textures = textures; // Rectangles to draw figures this.rectangles = rectangles; // Create tetris board boardFields = new FieldState[width, height]; BoardColor = new int[width, height]; #region Creating figures // Figures[figure's number, figure's modification, figure's block number] = Vector2 // At all figures is 7, every has 4 modifications (for cube all modifications the same) // and every figure consists from 4 blocks Figures = new Vector2[7, 4, 4]; // O-figure for (int i = 0; i < 4; i++) { Figures[0, i, 0] = new Vector2(1, 0); Figures[0, i, 1] = new Vector2(2, 0); Figures[0, i, 2] = new Vector2(1, 1); Figures[0, i, 3] = new Vector2(2, 1); } // I-figures for (int i = 0; i < 4; i += 2) { Figures[1, i, 0] = new Vector2(0, 0); Figures[1, i, 1] = new Vector2(1, 0); Figures[1, i, 2] = new Vector2(2, 0); Figures[1, i, 3] = new Vector2(3, 0); Figures[1, i + 1, 0] = new Vector2(1, 0); Figures[1, i + 1, 1] = new Vector2(1, 1); Figures[1, i + 1, 2] = new Vector2(1, 2); Figures[1, i + 1, 3] = new Vector2(1, 3); } // J-figures Figures[2, 0, 0] = new Vector2(0, 0); Figures[2, 0, 1] = new Vector2(1, 0); Figures[2, 0, 2] = new Vector2(2, 0); Figures[2, 0, 3] = new Vector2(2, 1); Figures[2, 1, 0] = new Vector2(2, 0); Figures[2, 1, 1] = new Vector2(2, 1); Figures[2, 1, 2] = new Vector2(1, 2); Figures[2, 1, 3] = new Vector2(2, 2); Figures[2, 2, 0] = new Vector2(0, 0); Figures[2, 2, 1] = new Vector2(0, 1); Figures[2, 2, 2] = new Vector2(1, 1); Figures[2, 2, 3] = new Vector2(2, 1); Figures[2, 3, 0] = new Vector2(1, 0); Figures[2, 3, 1] = new Vector2(2, 0); Figures[2, 3, 2] = new Vector2(1, 1); Figures[2, 3, 3] = new Vector2(1, 2); // L-figures Figures[3, 0, 0] = new Vector2(0, 0); Figures[3, 0, 1] = new Vector2(1, 0); Figures[3, 0, 2] = new Vector2(2, 0); Figures[3, 0, 3] = new Vector2(0, 1); Figures[3, 1, 0] = new Vector2(2, 0); Figures[3, 1, 1] = new Vector2(2, 1); Figures[3, 1, 2] = new Vector2(1, 0); Figures[3, 1, 3] = new Vector2(2, 2); Figures[3, 2, 0] = new Vector2(0, 1); Figures[3, 2, 1] = new Vector2(1, 1); Figures[3, 2, 2] = new Vector2(2, 1); Figures[3, 2, 3] = new Vector2(2, 0); Figures[3, 3, 0] = new Vector2(1, 0); Figures[3, 3, 1] = new Vector2(2, 2); Figures[3, 3, 2] = new Vector2(1, 1); Figures[3, 3, 3] = new Vector2(1, 2); // S-figures for (int i = 0; i < 4; i += 2) { Figures[4, i, 0] = new Vector2(0, 1); Figures[4, i, 1] = new Vector2(1, 1); Figures[4, i, 2] = new Vector2(1, 0); Figures[4, i, 3] = new Vector2(2, 0); Figures[4, i + 1, 0] = new Vector2(1, 0); Figures[4, i + 1, 1] = new Vector2(1, 1); Figures[4, i + 1, 2] = new Vector2(2, 1); Figures[4, i + 1, 3] = new Vector2(2, 2); } // Z-figures for (int i = 0; i < 4; i += 2) { Figures[5, i, 0] = new Vector2(0, 0); Figures[5, i, 1] = new Vector2(1, 0); Figures[5, i, 2] = new Vector2(1, 1); Figures[5, i, 3] = new Vector2(2, 1); Figures[5, i + 1, 0] = new Vector2(2, 0); Figures[5, i + 1, 1] = new Vector2(1, 1); Figures[5, i + 1, 2] = new Vector2(2, 1); Figures[5, i + 1, 3] = new Vector2(1, 2); } // T-figures Figures[6, 0, 0] = new Vector2(0, 1); Figures[6, 0, 1] = new Vector2(1, 1); Figures[6, 0, 2] = new Vector2(2, 1); Figures[6, 0, 3] = new Vector2(1, 0); Figures[6, 1, 0] = new Vector2(1, 0); Figures[6, 1, 1] = new Vector2(1, 1); Figures[6, 1, 2] = new Vector2(1, 2); Figures[6, 1, 3] = new Vector2(2, 1); Figures[6, 2, 0] = new Vector2(0, 0); Figures[6, 2, 1] = new Vector2(1, 0); Figures[6, 2, 2] = new Vector2(2, 0); Figures[6, 2, 3] = new Vector2(1, 1); Figures[6, 3, 0] = new Vector2(2, 0); Figures[6, 3, 1] = new Vector2(2, 1); Figures[6, 3, 2] = new Vector2(2, 2); Figures[6, 3, 3] = new Vector2(1, 1); #endregion nextFigures.Enqueue(random.Next(7)); nextFigures.Enqueue(random.Next(7)); nextFigures.Enqueue(random.Next(7)); nextFigures.Enqueue(random.Next(7)); nextFiguresModification.Enqueue(random.Next(4)); nextFiguresModification.Enqueue(random.Next(4)); nextFiguresModification.Enqueue(random.Next(4)); nextFiguresModification.Enqueue(random.Next(4)); }
public Spielfeld() { board = new FieldState[3, 3]; Reset(); }
public GameRepresentation(FieldState[,] field, int score, bool isStopped) { Field = field; Score = score; IsStopped = isStopped; }
public GameStateInternal(uint boardSize) { Ko = FieldCoordinates.Pass; BoardSize = boardSize; BoardFields = new FieldState[BoardSize, BoardSize]; }
public CheckerBoard(FieldState[,] initialBoard) { board = initialBoard; }
public GameLogic() { board = new FieldState[3, 3]; lastStarter = DateTime.Now.Millisecond % 2 == 0; Reset(); }
public GameState() { this.BoardSize = 3; this.BoardFields = new FieldState[this.BoardSize, this.BoardSize]; this.CurrentPlayer = Player.Nought; }
private void _webCamService_BoardChanged(object sender, FieldState[,] board) { var tmp = new ObservableCollection<FieldState>(); foreach (var state in board) { tmp.Add(state); } this.Board = tmp; _currentBoard = board; if (isTracking && _logicService != null) { string message = _logicService.UpdateAndValidBoard(board); if (!string.IsNullOrWhiteSpace(message)) { LogMessages = message + Environment.NewLine + LogMessages; //TODO - DONE } } else { if (_logicService != null) { IsStartTrackingEnable = _logicService.InitAndValid(board); //TODO - DONE CommandManager.InvalidateRequerySuggested(); } } }
public GameState(GameState state) { this.BoardSize = state.BoardSize; this.BoardFields = new FieldState[this.BoardSize, this.BoardSize]; Array.Copy(state.BoardFields, this.BoardFields, state.BoardFields.Length); }
void InitGameField() { gameField = new FieldState[FieldWidth + 1, FieldHeight + 1]; fieldsCenters = new FieldState[FieldWidth, FieldHeight]; }
public Board (Game game, ref Texture2D textures, Rectangle[] rectangles) : base(game) { sBatch = (SpriteBatch)Game.Services.GetService (typeof(SpriteBatch)); // Load textures for blocks this.textures = textures; // Rectangles to draw figures this.rectangles = rectangles; // Create tetris board boardFields = new FieldState[width, height]; BoardColor = new int[width, height]; #region Creating figures // Figures[figure's number, figure's modification, figure's block number] = Vector2 // At all figures is 7, every has 4 modifications (for cube all modifications the same) // and every figure consists from 4 blocks Figures = new Vector2[7, 4, 4]; // O-figure for (int i = 0; i < 4; i++) { Figures [0, i, 0] = new Vector2 (1, 0); Figures [0, i, 1] = new Vector2 (2, 0); Figures [0, i, 2] = new Vector2 (1, 1); Figures [0, i, 3] = new Vector2 (2, 1); } // I-figures for (int i = 0; i < 4; i += 2) { Figures [1, i, 0] = new Vector2 (0, 0); Figures [1, i, 1] = new Vector2 (1, 0); Figures [1, i, 2] = new Vector2 (2, 0); Figures [1, i, 3] = new Vector2 (3, 0); Figures [1, i + 1, 0] = new Vector2 (1, 0); Figures [1, i + 1, 1] = new Vector2 (1, 1); Figures [1, i + 1, 2] = new Vector2 (1, 2); Figures [1, i + 1, 3] = new Vector2 (1, 3); } // J-figures Figures [2, 0, 0] = new Vector2 (0, 0); Figures [2, 0, 1] = new Vector2 (1, 0); Figures [2, 0, 2] = new Vector2 (2, 0); Figures [2, 0, 3] = new Vector2 (2, 1); Figures [2, 1, 0] = new Vector2 (2, 0); Figures [2, 1, 1] = new Vector2 (2, 1); Figures [2, 1, 2] = new Vector2 (1, 2); Figures [2, 1, 3] = new Vector2 (2, 2); Figures [2, 2, 0] = new Vector2 (0, 0); Figures [2, 2, 1] = new Vector2 (0, 1); Figures [2, 2, 2] = new Vector2 (1, 1); Figures [2, 2, 3] = new Vector2 (2, 1); Figures [2, 3, 0] = new Vector2 (1, 0); Figures [2, 3, 1] = new Vector2 (2, 0); Figures [2, 3, 2] = new Vector2 (1, 1); Figures [2, 3, 3] = new Vector2 (1, 2); // L-figures Figures [3, 0, 0] = new Vector2 (0, 0); Figures [3, 0, 1] = new Vector2 (1, 0); Figures [3, 0, 2] = new Vector2 (2, 0); Figures [3, 0, 3] = new Vector2 (0, 1); Figures [3, 1, 0] = new Vector2 (2, 0); Figures [3, 1, 1] = new Vector2 (2, 1); Figures [3, 1, 2] = new Vector2 (1, 0); Figures [3, 1, 3] = new Vector2 (2, 2); Figures [3, 2, 0] = new Vector2 (0, 1); Figures [3, 2, 1] = new Vector2 (1, 1); Figures [3, 2, 2] = new Vector2 (2, 1); Figures [3, 2, 3] = new Vector2 (2, 0); Figures [3, 3, 0] = new Vector2 (1, 0); Figures [3, 3, 1] = new Vector2 (2, 2); Figures [3, 3, 2] = new Vector2 (1, 1); Figures [3, 3, 3] = new Vector2 (1, 2); // S-figures for (int i = 0; i < 4; i += 2) { Figures [4, i, 0] = new Vector2 (0, 1); Figures [4, i, 1] = new Vector2 (1, 1); Figures [4, i, 2] = new Vector2 (1, 0); Figures [4, i, 3] = new Vector2 (2, 0); Figures [4, i + 1, 0] = new Vector2 (1, 0); Figures [4, i + 1, 1] = new Vector2 (1, 1); Figures [4, i + 1, 2] = new Vector2 (2, 1); Figures [4, i + 1, 3] = new Vector2 (2, 2); } // Z-figures for (int i = 0; i < 4; i += 2) { Figures [5, i, 0] = new Vector2 (0, 0); Figures [5, i, 1] = new Vector2 (1, 0); Figures [5, i, 2] = new Vector2 (1, 1); Figures [5, i, 3] = new Vector2 (2, 1); Figures [5, i + 1, 0] = new Vector2 (2, 0); Figures [5, i + 1, 1] = new Vector2 (1, 1); Figures [5, i + 1, 2] = new Vector2 (2, 1); Figures [5, i + 1, 3] = new Vector2 (1, 2); } // T-figures Figures [6, 0, 0] = new Vector2 (0, 1); Figures [6, 0, 1] = new Vector2 (1, 1); Figures [6, 0, 2] = new Vector2 (2, 1); Figures [6, 0, 3] = new Vector2 (1, 0); Figures [6, 1, 0] = new Vector2 (1, 0); Figures [6, 1, 1] = new Vector2 (1, 1); Figures [6, 1, 2] = new Vector2 (1, 2); Figures [6, 1, 3] = new Vector2 (2, 1); Figures [6, 2, 0] = new Vector2 (0, 0); Figures [6, 2, 1] = new Vector2 (1, 0); Figures [6, 2, 2] = new Vector2 (2, 0); Figures [6, 2, 3] = new Vector2 (1, 1); Figures [6, 3, 0] = new Vector2 (2, 0); Figures [6, 3, 1] = new Vector2 (2, 1); Figures [6, 3, 2] = new Vector2 (2, 2); Figures [6, 3, 3] = new Vector2 (1, 1); #endregion nextFigures.Enqueue (random.Next (7)); nextFigures.Enqueue (random.Next (7)); nextFigures.Enqueue (random.Next (7)); nextFigures.Enqueue (random.Next (7)); nextFiguresModification.Enqueue (random.Next (4)); nextFiguresModification.Enqueue (random.Next (4)); nextFiguresModification.Enqueue (random.Next (4)); nextFiguresModification.Enqueue (random.Next (4)); }
public void Restore() { _boardArray = PreviousBoardArray; //UpdateCurrentPlayer(); }