internal void refreshArrays() { SquareState[,] squareStateArray = new SquareState[this.MapSizeX, this.MapSizeY]; short[,] numArray1 = new short[this.MapSizeX, this.MapSizeY]; byte[,] numArray2 = new byte[this.MapSizeX, this.MapSizeY]; for (int index1 = 0; index1 < this.MapSizeY; ++index1) { for (int index2 = 0; index2 < this.MapSizeX; ++index2) { if (index2 > this.staticModel.MapSizeX - 1 || index1 > this.staticModel.MapSizeY - 1) { squareStateArray[index2, index1] = SquareState.BLOCKED; } else { squareStateArray[index2, index1] = this.SqState[index2, index1]; numArray1[index2, index1] = this.SqFloorHeight[index2, index1]; } } } this.SqState = squareStateArray; this.SqFloorHeight = numArray1; this.RelativeSerialized = false; this.HeightmapSerialized = false; }
internal void refreshArrays() { SquareState[,] newSqState = new SquareState[MapSizeX + 1, MapSizeY + 1]; short[,] newSqFloorHeight = new short[MapSizeX + 1, MapSizeY + 1]; byte[,] newSqSeatRot = new byte[MapSizeX + 1, MapSizeY + 1]; for (int y = 0; y < MapSizeY; y++) { for (int x = 0; x < MapSizeX; x++) { if (x > (staticModel.MapSizeX - 1) || y > (staticModel.MapSizeY - 1)) { newSqState[x, y] = SquareState.BLOCKED; } else { newSqState[x, y] = SqState[x, y]; newSqFloorHeight[x, y] = SqFloorHeight[x, y]; newSqSeatRot[x, y] = SqSeatRot[x, y]; } } } SqState = newSqState; SqFloorHeight = newSqFloorHeight; SqSeatRot = newSqSeatRot; RelativeSerialized = false; HeightmapSerialized = false; }
internal void refreshArrays() { checked { SquareState[,] array = new SquareState[this.MapSizeX + 1, this.MapSizeY + 1]; int[,] array2 = new int[this.MapSizeX + 1, this.MapSizeY + 1]; byte[,] array3 = new byte[this.MapSizeX + 1, this.MapSizeY + 1]; for (int i = 0; i < this.MapSizeY; i++) { for (int j = 0; j < this.MapSizeX; j++) { if (j > this.staticModel.MapSizeX - 1 || i > this.staticModel.MapSizeY - 1) { array[j, i] = SquareState.BLOCKED; } else { array[j, i] = this.SqState[j, i]; array2[j, i] = this.SqFloorHeight[j, i]; array3[j, i] = this.SqSeatRot[j, i]; } } } this.SqState = array; this.SqFloorHeight = array2; this.SqSeatRot = array3; this.HeightmapSerialized = false; } }
public void refreshArrays() { var newSqState = new SquareState[MapSizeX + 1, MapSizeY + 1]; var newSqFloorHeight = new short[MapSizeX + 1, MapSizeY + 1]; var newSqSeatRot = new byte[MapSizeX + 1, MapSizeY + 1]; for (int y = 0; y < MapSizeY; y++) { for (int x = 0; x < MapSizeX; x++) { if (x > (staticModel.MapSizeX - 1) || y > (staticModel.MapSizeY - 1)) { newSqState[x, y] = SquareState.BLOCKED; } else { newSqState[x, y] = SqState[x, y]; newSqFloorHeight[x, y] = SqFloorHeight[x, y]; newSqSeatRot[x, y] = SqSeatRot[x, y]; } } } SqState = newSqState; SqFloorHeight = newSqFloorHeight; SqSeatRot = newSqSeatRot; }
public static bool CheckForWin(Square[,] board, SquareState player) { for (int i = 0; i <= 2; i++) { if (board[0, i].State.Equals(player) && board[1, i].State.Equals(player) && board[2, i].State.Equals(player)) { return(true); } } for (int j = 0; j <= 2; j++) { if (board[j, 0].State.Equals(player) && board[j, 1].State.Equals(player) && board[j, 2].State.Equals(player)) { return(true); } } if (board[0, 0].State.Equals(player) && board[1, 1].State.Equals(player) && board[2, 2].State.Equals(player)) { return(true); } if (board[0, 2].State.Equals(player) && board[1, 1].State.Equals(player) && board[2, 0].State.Equals(player)) { return(true); } return(false); }
public void UpdateState() { SquareSprite[,] squareMap = Player.SquareMap; switch (State) { case SquareState.Static: if (Row < squareMap.GetLength(0) - 1) { SquareSprite down = squareMap[Row + 1, Column]; if (down == null) { State = SquareState.Hung; Fall(); } else { State = down.State; } } else { State = SquareState.Static; } break; } }
public void ResetDurability() { durability = ArenaSquareSettings.maxDurability; squareState = SquareState.offSquare; spriteRenderer.color = Color.green; hasBroken = false; }
private bool HasWon(SquareState targetState) { foreach (var row in Grid) { if (row.All(s => s == targetState)) { return(true); } } for (int i = 0; i < 3; i++) { if (Grid.All(row => row[i] == targetState)) { return(true); } } if (Grid[0][0] == targetState && Grid[1][1] == targetState && Grid[2][2] == targetState) { return(true); } else if (Grid[0][2] == targetState && Grid[1][1] == targetState && Grid[2][0] == targetState) { return(true); } return(false); }
public void ArrangeShips(string playerId, IEnumerable <int[]> shipSquares) { /*todo battleship check correctness*/ var currentPlayer = GetCurrentGamePlayer(playerId); if (currentPlayer == null) { throw new ArgumentException( $"Player with ID {playerId} not found."); } /*todo battleship check correctness*/ if (AreShipsArranged) { throw new InvalidOperationException( "Ships rearrangement is not allowed."); } var grid = new SquareState[GridSize, GridSize]; foreach (var shipSquare in shipSquares) { grid[shipSquare[0], shipSquare[1]] = SquareState.IntactShipPart; } currentPlayer.Grid = grid; if (AreShipsArranged) { _currentPlayerIndex = new Random().Next(0, RequiredPlayersCount); } }
private void render() { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { IPiece piece = _gameState.At(x, y); Rectangle square = _imageSquares[x, y]; SquareState currentState = (SquareState)square.Tag; if (currentState.Piece != piece) { if (piece != null) { string path = "images/" + piece.ImageFile(); Uri imageUri = new Uri(BaseUriHelper.GetBaseUri(this), path); BitmapImage image = new BitmapImage(imageUri); currentState.Piece = piece; square.Tag = currentState; square.Fill = new ImageBrush(image); } else { currentState.Piece = null; square.Tag = currentState; square.Fill = new ImageBrush(); } } } } lblPlayerTurn.Content = _gameState.PlayerTurn.ToString(); //lblWhiteHeuristic.Content = Agent.Heuristic.GetHeuristic(_gameState, Team.White); lblWhiteHeuristic.Content = _totalEvals; }
public Square(Canvas canvas, Tuple <int, int> position, IClickListener listener) { Position = position; this.listener = listener; squareState = SquareState.Unset; rect = new Rectangle() { Width = Constants.SQ_SIZE, Height = Constants.SQ_SIZE, Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = Constants.SQ_THICKNESS, Fill = new SolidColorBrush(Constants.ColorRed), }; rect.MouseRightButtonDown += new MouseButtonEventHandler(Rect_MouseRightButtonDown); rect.MouseLeftButtonDown += new MouseButtonEventHandler(Rect_MouseLeftButtonDown); Canvas.SetBottom(rect, Constants.SQ_MARGIN + (4 - Position.Item2) * Constants.SQ_SIZE); Canvas.SetLeft(rect, Constants.SQ_MARGIN + position.Item1 * Constants.SQ_SIZE); canvas.Children.Add(rect); txt = new TextBlock() { FontSize = Constants.SQ_FONT, HorizontalAlignment = HorizontalAlignment.Left }; canvas.Children.Add(txt); txt.MouseRightButtonDown += new MouseButtonEventHandler(Rect_MouseRightButtonDown); txt.MouseLeftButtonDown += new MouseButtonEventHandler(Rect_MouseLeftButtonDown); Percent = 0; }
public int TakeTurn(SquareState[] squareStates) { for (int i = 0; i < Positions1.Length; i++) { int pos1 = Positions1[i]; int pos2 = Positions2[i]; int pos3 = Positions3[i]; if ((squareStates[pos1] == SquareState.Nought && squareStates[pos2] == SquareState.Nought) || (squareStates[pos1] == SquareState.Cross && squareStates[pos2] == SquareState.Cross)) { if (squareStates[pos3] == SquareState.Empty) { return pos3; } } } for (int i = 0; i < Priorities.Length; i++) { int priority = Priorities[i]; if (squareStates[priority] == SquareState.Empty) { return priority; } } return -1; }
/// <summary> /// Sets this squares state to <paramref name="state"/> and updates the color and boolean status /// </summary> /// /// <param name="state">The state to set this square to</param> public void SetState(SquareState state) { State = state; switch (state) { case SquareState.Dead: BackColor = Color.White; CanBePlaced = false; IsPlaced = true; IsCompany = false; break; case SquareState.Open: BackColor = Color.DarkGray; IsPlaced = false; IsCompany = false; CanBePlaced = true; break; case SquareState.Placeable: BackColor = Color.Gray; IsCompany = false; IsPlaced = false; CanBePlaced = true; break; case SquareState.Placed: BackColor = Color.Black; IsCompany = false; IsPlaced = true; break; } }
protected void setCrossOfSquares( SquareState stateValue, Vector2 pieceCoords ) { // Checar casillas hostiles int coord_x = (int)pieceCoords.x; int coord_y = (int)pieceCoords.y; for ( int x = coord_x + 1; x < 11; x++ ) if (!Game.board[coord_y, x].piece) Game.board[coord_y, x].changeState(stateValue); else break; for ( int x = coord_x - 1; x >= 0; x-- ) if ( !Game.board [coord_y, x].piece ) Game.board[coord_y, x].changeState(stateValue); else break; for ( int y = coord_y + 1; y < 11; y++ ) if ( !Game.board [y, coord_x].piece ) Game.board[y, coord_x].changeState(stateValue); else break; for ( int y = coord_y - 1; y >= 0; y-- ) if ( !Game.board [y, coord_x].piece ) Game.board[y, coord_x].changeState(stateValue); else break; }
private void LoseDurability() { durability -= Time.deltaTime; if (durability >= ArenaSquareSettings.maxDurability / 2) { spriteRenderer.color = Color.Lerp(ArenaSquareSettings.startingColor, ArenaSquareSettings.middleColor, middleLerp); if (middleLerp < 1) { Debug.Log("Durability: " + durability); Debug.Log("Max Durability: " + ArenaSquareSettings.maxDurability); Debug.Log("Middle Lerp: " + middleLerp); //middleLerp += Time.deltaTime / (maxDurability/2); middleLerp = ((ArenaSquareSettings.maxDurability - durability) / ArenaSquareSettings.maxDurability) * 2; } } else if (durability <= 0) { squareState = SquareState.breaking; } else { Debug.Log("Durability: " + durability); Debug.Log("Max Durability: " + ArenaSquareSettings.maxDurability); Debug.Log("Middle Lerp: " + middleLerp); Debug.Log("End Lerp: " + endLerp); spriteRenderer.color = Color.Lerp(ArenaSquareSettings.middleColor, ArenaSquareSettings.endColor, endLerp); if (endLerp < 1) { //endLerp += Time.deltaTime / (maxDurability/2); endLerp = ((ArenaSquareSettings.maxDurability / 2 - durability) / (ArenaSquareSettings.maxDurability / 2)); } } }
public void changeState(SquareState squareState) { switch (squareState) { case SquareState.VALID: if ( state == SquareState.TRACED ) { state = SquareState.VALID_TRACED; }else { state = SquareState.VALID; } GetComponent<Renderer>().material.color = Color.yellow; break; case SquareState.DEFAULT: if ( state == SquareState.VALID_TRACED ) { state = SquareState.TRACED; GetComponent<Renderer>().material.color = traceColor; } else { GetComponent<Renderer>().material.color = Color.white; state = SquareState.DEFAULT; } break; case SquareState.POINTED: state = squareState; break; case SquareState.TRACED: state = squareState; GetComponent<Renderer>().material.color = traceColor; break; } }
internal static void DrawBoard(Board gameBoard) { for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { SquareState currentState = gameBoard.GetSquare(x, y); switch (currentState) { case SquareState.Unmarked: Console.Write(" "); break; case SquareState.O: Console.Write("O"); break; case SquareState.X: Console.Write("X"); break; } Console.Write("|"); } Console.WriteLine(); Console.WriteLine("------"); } }
/// <summary> /// Creates a new square. /// </summary> /// <param name="location">The location or coordinates of the square.</param> /// <param name="hasMine">Determines if this square has a mine or not.</param> public Square(Point location, bool hasMine = false) { this.Location = location; this.HasMine = hasMine; this.IsVisible = false; this.MarkState = SquareState.Unmarked; }
/// <summary> /// Changes the color of a block on the GUI. /// </summary> /// <param name="s">The state of the block to change color based on</param> /// <param name="l">The block's location in the grid</param> public void SetBlockColor(SquareState s, Location l) { Color light = Color.Red; Color dark = Color.RosyBrown; Color block = Color.Gray; Color player = Color.Crimson; //Find the picturebox to be changed based on it's name. i.e.: Location 1/20 would show up as "box0120" PictureBox pb = (PictureBox)gameboard.Controls.Find( "box" + (l.x < 10 ? l.x.ToString() : "0" + l.x) + (l.y < 10 ? l.y.ToString() : "0" + l.y), false)[0]; switch (s) { case SquareState.Dark: pb.BackColor = dark; break; case SquareState.Light: pb.BackColor = light; break; case SquareState.Block: pb.BackColor = block; break; case SquareState.Player: pb.BackColor = player; break; } }
public GameResult CheckResult(SquareState[] squareStates) { for (int i = 0; i < Positions1.Length; i += 3) { int pos1 = Positions1[i]; int pos2 = Positions2[i]; int pos3 = Positions3[i]; if (squareStates[pos1] == SquareState.Nought && squareStates[pos2] == SquareState.Nought && squareStates[pos3] == SquareState.Nought) { return GameResult.ComputerWins; } if (squareStates[pos1] == SquareState.Cross && squareStates[pos2] == SquareState.Cross && squareStates[pos3] == SquareState.Cross) { return GameResult.UserWins; } } bool emptySquareFound = squareStates.Any(s => s == SquareState.Empty); if (emptySquareFound) { return GameResult.NotFinished; } return GameResult.Draw; }
public void RefreshArrays() { var newSqState = new SquareState[MapSizeX + 1, MapSizeY + 1]; var newSqFloorHeight = new short[MapSizeX + 1, MapSizeY + 1]; var newSqSeatRot = new byte[MapSizeX + 1, MapSizeY + 1]; for (var y = 0; y < MapSizeY; y++) { for (var x = 0; x < MapSizeX; x++) { if (x > staticModel.MapSizeX - 1 || y > staticModel.MapSizeY - 1) { newSqState[x, y] = SquareState.Blocked; } else { newSqState[x, y] = SqState[x, y]; newSqFloorHeight[x, y] = SqFloorHeight[x, y]; newSqSeatRot[x, y] = SqSeatRot[x, y]; } } } SqState = newSqState; SqFloorHeight = newSqFloorHeight; SqSeatRot = newSqSeatRot; }
private static SquareState SwitchPlayer(SquareState player) { return(player switch { SquareState.O => SquareState.X, SquareState.X => SquareState.O, _ => throw new InvalidOperationException($"Player cannot be switched - input Squarestate is {player}"), });
private FieldState SquareStateToFieldState(SquareState playersTurn) { if (playersTurn == SquareState.O) { return(FieldState.O); } return(FieldState.X); }
private void SetSquareState(Position pos, SquareState state) { if (pos == null) { return; } Squares.Single(s => s.Position == pos).SquareState = state; }
public Square(Point position, Point size, ContentManager content, SquareState state) { _position = position; _size = size; _currentState = state; _squareTexture = content.Load <Texture2D>("checkerBoard"); }
/*private void OnTriggerEnter2D(Collider2D collision) * { * if(collision.gameObject.GetComponent<Player>()!=null&&squareState!=SquareState.breaking) * { * squareState=SquareState.onSquare; * StopAllCoroutines(); * } * }*/ private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.GetComponent <Player>() != null && squareState != SquareState.breaking && squareState != SquareState.broken) { squareState = SquareState.onSquare; StopAllCoroutines(); } }
private IEnumerator BreakSquare() { spriteRenderer.color = Color.gray; yield return(new WaitForSeconds(ArenaSquareSettings.breakPeriod)); spriteRenderer.color = Color.black; squareState = SquareState.broken; }
public SquareViewModel(SquareState squareState, Coords coords, int numSurroundingMines, bool isMine) { _squareState = squareState; _numSurroundingMines = numSurroundingMines; _coords = coords; _displayText = SquareDataMapper.MapSquareStateToString(_squareState, _numSurroundingMines); _color = new SolidColorBrush((isMine) ? Colors.Red : Colors.Beige); }
private void LoadLastEditorState() { m_IsInEditSquareMode = EditorPrefs.GetBool(nameof(m_IsInEditSquareMode)); m_CurrentEditSquareState = (SquareState)EditorPrefs.GetInt(nameof(m_CurrentEditSquareState)); m_CurrentSquareBrush = (SquareBrush)EditorPrefs.GetInt(nameof(m_CurrentSquareBrush)); m_IsInEditEdgeMode = EditorPrefs.GetBool(nameof(m_IsInEditEdgeMode)); m_IsAddOrRemoveEdge = EditorPrefs.GetBool(nameof(m_IsAddOrRemoveEdge)); }
public TicTacToeGame(Dictionary <T, SquareState> translationDict) { Screen = new SquareState[, ] { { Empty, Empty, Empty }, { Empty, Empty, Empty }, { Empty, Empty, Empty } }; TranslationDict = translationDict; }
public void removePlayer() { if (state == SquareState.Player) { state = SquareState.Empty; } currentPlayer = null; plannedToBeMovedTo = false; }
private void setLineOfSquares( SquareState stateValue ) { if ( Game.moveTrace.vertical ) for ( int x = Game.moveTrace.start; x <= Game.moveTrace.end; x++ ) Game.board [ Game.moveTrace.index, x ].changeState ( stateValue ); else for ( int y = Game.moveTrace.start; y <= Game.moveTrace.end; y++ ) Game.board [ y, Game.moveTrace.index ].changeState ( stateValue ); }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.GetComponent <Player>() != null && squareState != SquareState.breaking && squareState != SquareState.broken) { squareState = SquareState.offSquare; StopAllCoroutines(); StartCoroutine("BeginRegen"); } }
public Square(SquareType Type, int id, Color clr, SquareState State, bool FinishSquare) { this.SqState = State; this.SqType = Type; this.SqId = id; this.SqClr = clr; this.FinishSquare = FinishSquare; this.occupiedBy = new List <Token>(); }
public bool TestIsStateSquare(Vector3 pos, SquareState state) { int index = GetIndexSquareFromPos(pos); if (index != -1) { return(mapData.grid[index].state == state); } return(false); }
void Awake() { mat = GetComponent<Renderer>().material; idleState = new IdleState(this); moveState = new MoveState(this); talkState = new TalkState(this); loveState = new LoveState(this); currentState = moveState; }
public Square( Vector2 location, Texture2D texture, Rectangle initialframe, Vector2 velocity) : base(location, texture, initialframe, velocity) { newlocation = this.location; this.State = SquareState.LIVING; }
void Awake() { mat = GetComponent <Renderer>().material; idleState = new IdleState(this); moveState = new MoveState(this); talkState = new TalkState(this); loveState = new LoveState(this); currentState = moveState; }
public Square(MineField owner, int row, int column, bool isMine) { if (owner == null) { throw new ArgumentNullException("owner"); } if (row < 0 || row >= owner.Rows) { throw new ArgumentOutOfRangeException("row"); } if (column < 0 || column >= owner.Columns) { throw new ArgumentOutOfRangeException("column"); } _owner = owner; _row = row; _column = column; _isMine = isMine; _state = SquareState.Unknown; _numberCache = -1; }
/// <summary> /// Initializes a new instance of the <see cref="RoomModel"/> class. /// </summary> /// <param name="doorX">The door x.</param> /// <param name="doorY">The door y.</param> /// <param name="doorZ">The door z.</param> /// <param name="doorOrientation">The door orientation.</param> /// <param name="heightmap">The heightmap.</param> /// <param name="staticFurniMap">The static furni map.</param> /// <param name="clubOnly">if set to <c>true</c> [club only].</param> /// <param name="poolmap">The poolmap.</param> internal RoomModel(int doorX, int doorY, double doorZ, int doorOrientation, string heightmap, string staticFurniMap, bool clubOnly, string poolmap) { try { DoorX = doorX; DoorY = doorY; DoorZ = doorZ; DoorOrientation = doorOrientation; Heightmap = heightmap.ToLower(); StaticFurniMap = staticFurniMap; GotPublicPool = !string.IsNullOrEmpty(poolmap); heightmap = heightmap.Replace(string.Format("{0}", Convert.ToChar(10)), ""); var array = heightmap.Split(Convert.ToChar(13)); MapSizeX = array[0].Length; MapSizeY = array.Length; ClubOnly = clubOnly; SqState = new SquareState[MapSizeX][]; for (var i = 0; i < MapSizeX; i++) SqState[i] = new SquareState[MapSizeY]; SqFloorHeight = new short[MapSizeX][]; for (var i = 0; i < MapSizeX; i++) SqFloorHeight[i] = new short[MapSizeY]; SqSeatRot = new byte[MapSizeX][]; for (var i = 0; i < MapSizeX; i++) SqSeatRot[i] = new byte[MapSizeY]; SqChar = new char[MapSizeX][]; for (var i = 0; i < MapSizeX; i++) SqChar[i] = new char[MapSizeY]; if (GotPublicPool) { MRoomModelfx = new byte[MapSizeX][]; for (var i = 0; i < MapSizeX; i++) MRoomModelfx[i] = new byte[MapSizeY]; } for (var y = 0; y < MapSizeY; y++) { var text2 = array[y].Replace(string.Format("{0}", Convert.ToChar(13)), "") .Replace(string.Format("{0}", Convert.ToChar(10)), ""); for (var x = 0; x < MapSizeX; x++) { var c = 'x'; try { c = text2[x]; } catch (Exception) { } if (x == doorX && y == doorY) { SqFloorHeight[x][y] = (short)DoorZ; SqState[x][y] = SquareState.Open; if (SqFloorHeight[x][y] > 9) SqChar[x][y] = Letters[(SqFloorHeight[x][y] - 10)]; else SqChar[x][y] = char.Parse(DoorZ.ToString()); } else { if (c.Equals('x')) { SqFloorHeight[x][y] = -1; SqState[x][y] = SquareState.Blocked; SqChar[x][y] = c; } else if (char.IsLetterOrDigit(c)) { SqFloorHeight[x][y] = char.IsDigit(c) ? short.Parse(c.ToString()) : Convert.ToInt16(Letters.IndexOf(char.ToLower(c)) + 10); SqState[x][y] = SquareState.Open; SqChar[x][y] = c; } } } } } catch (Exception e) { Writer.Writer.LogCriticalException(e.ToString()); } }
public override void Update(GameTime gameTime) { switch (State) { case SquareState.LIVING: KeyboardState kb = Keyboard.GetState(); DetectKeyPress(kb, Keys.Right); DetectKeyPress(kb, Keys.Left); DetectKeyPress(kb, Keys.Up); if (KeyDown) { if (kb.IsKeyUp(Key)) { switch (Key) { case Keys.Right: { this.location.X += 50; break; } case Keys.Left: { this.location.X += -50; break; } case Keys.Up: { this.location.Y += -50; playerscore += 100; break; } } KeyDown = false; Key = Keys.None; } } //To check if it is in the window. if (this.location.X >= 800) { this.location.X = 750; } if (this.location.X <= 0) { this.location.X = 0; } if (this.location.Y < 0) { this.location.X = 400; this.location.Y = 600; if (OnWin != null) OnWin(this, null); } if (this.location.Y >= 600) { this.location.Y = 550; } break; case SquareState.DYING: deathTimer += gameTime.ElapsedGameTime.TotalMilliseconds; if (deathTimer > deathTime) { deathTimer = 0; Location = new Vector2(390, 550); State = SquareState.LIVING; } break; } base.Update(gameTime); }
/// <summary> /// Changes the state of a block, including a call to update GUI. /// </summary> /// <param name="l">Location of block to be changed</param> /// <param name="s">State to change to</param> public void ChangeState(Location l, SquareState s) { board[l.x, l.y].currentState = s; LightBlockEngine.gui.UpdateBlockColor(board[l.x, l.y]); }
/// <summary> /// Generates this instance. /// </summary> internal void Generate() { SqState = new SquareState[MapSizeX][]; for (Int32 i = 0; i < MapSizeX; i++) SqState[i] = new SquareState[MapSizeY]; SqFloorHeight = new short[MapSizeX][]; for (Int32 i = 0; i < MapSizeX; i++) SqFloorHeight[i] = new short[MapSizeY]; SqSeatRot = new byte[MapSizeX][]; for (Int32 i = 0; i < MapSizeX; i++) SqSeatRot[i] = new byte[MapSizeY]; SqChar = new char[MapSizeX][]; for (Int32 i = 0; i < MapSizeX; i++) SqChar[i] = new char[MapSizeY]; for (Int32 i = 0; i < MapSizeY; i++) { for (Int32 j = 0; j < MapSizeX; j++) { if (j > _staticModel.MapSizeX - 1 || i > _staticModel.MapSizeY - 1) SqState[j][i] = SquareState.Blocked; else { SqState[j][i] = _staticModel.SqState[j][i]; SqFloorHeight[j][i] = _staticModel.SqFloorHeight[j][i]; SqSeatRot[j][i] = _staticModel.SqSeatRot[j][i]; SqChar[j][i] = _staticModel.SqChar[j][i]; } } } HeightmapSerialized = false; }
//************************************************************ //* Prints the state of a square on the screen * //* Gets the square state and form where to start writing * //* All coordinates are in the console coordinate system * //* Returns nothing * //************************************************************ static void PrintSquareState(SquareState state, int consoleRow, int consoleCol) { switch (state) { case SquareState.Busy: { for (int i = 0; i < 3; i++) { Console.SetCursorPosition(consoleCol, consoleRow); Console.BackgroundColor = ConsoleColor.DarkRed; Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write(wall[i]); consoleRow++; Console.BackgroundColor = ConsoleColor.Black; } break; } case SquareState.Player: { for (int i = 0; i < 3; i++) { Console.SetCursorPosition(consoleCol, consoleRow); Console.ForegroundColor = ConsoleColor.Green; Console.Write(player[i]); consoleRow++; } break; } case SquareState.Rock: { for (int i = 0; i < 3; i++) { Console.SetCursorPosition(consoleCol, consoleRow); Console.ForegroundColor = ConsoleColor.Blue; Console.Write(rock[i]); consoleRow++; } break; } } }
protected override void Awake() { state = SquareState.DEFAULT; traceColor = new Color (0.44314f, 0.52157f, 0.89804f); //gameObject.SetActive(false); }
/// <summary> /// Initializes a new instance of the <see cref="Square"/> class. /// </summary> /// <param name="ship">The ship occupying the square.</param> /// <param name="state">The square state.</param> public Square(Ship ship, SquareState state) { this.Ship = ship; this.State = state; }
public Square(int x, int y, int size) { this.currentState = SquareState.Dark; this.location = new Location(x, y); }
public void SetWinner(SquareState toWin) { winner = toWin; gameState = GameState.GameOver; }
/// <summary> /// Initialise our rich matrix from a simple 2-dimensional int array containing the /// start/finish and obstacles. /// </summary> /// <param name="grid">The simple int array that says where the start/finish and /// obstacles are located.</param> /// <returns>The array of squares that make up the maze which identifies the state /// of each square in the maze.</returns> private static SquareState[,] SetupMatrixTest(int[,] grid) { SquareSize = grid.GetUpperBound(0) + 1; SquareState[,] matrix = new SquareState[SquareSize, SquareSize]; for (int y = 0; y < SquareSize; y++) { for (int x = 0; x < SquareSize; x++) { matrix[x, y] = (SquareState)grid[x, y]; if (grid[x, y] == 0) targetLength++; } } // Include the start and finish square as being along the path targetLength += 2; ; return matrix; }