public Location GetLocation(BattleFieldCoordinate coordinate) { var x = coordinate.X; var y = coordinate.Y; return(_locations[x, y]); }
public MoveInfo(BattleFieldCoordinate fromCoor, BattleFieldCoordinate toCoor) { FromX = fromCoor.X; FromY = fromCoor.Y; ToX = toCoor.X; ToY = toCoor.Y; }
public bool IsLocationOccupied(BattleFieldCoordinate coordinate) { if (GetLocation(coordinate).Token != null) { return(true); } return(false); }
public override void MoveToken(BattleFieldCoordinate from, BattleFieldCoordinate to) { var fromLocation = GetLocation(from); var destLocation = GetLocation(to); var fromChessboard = _chessboardDisplayer.GetChessboard(from); var toChessboard = _chessboardDisplayer.GetChessboard(to); var token = fromLocation.Token; var btn = fromChessboard.Button; var availables = token.Role.GetAvailableMove(); if (!availables.Contains(to)) { return; } _chessboardDisplayer.EraseHighlight(availables); fromLocation.RemoveToken(); destLocation.PlaceToken(token); fromChessboard.RemoveButton(); toChessboard.RemoveButtonFromGame(); toChessboard.PlaceButton(btn); //destLocation.RemoveTokenFromGame(); token.Deactivate(); GamePhase.SwitchTurn(); //if (!shouldNotify) // return; //var message = new Message(new MoveInfo(from, to)); //MessageSender.Send(Message.Serialize(message), IsClient); _chessboardDisplayer.DrawChessboard(); }
public Token(BattleFieldCoordinate coordinate, Role role) { //var indexX = coordinate.X; //var indexY = coordinate.Y; //Color color; //if (role.Faction == Factions.Black) // color = Color.Black; //else // color = Color.Red; Coordinate = coordinate; Role = role; Role.CurrentCoordinate = coordinate; //Button = new Button //{ // Text = Role.DisplayName, // Location = ServerBattleField._locations[indexX, indexY].CoordinateToPlaceBtn, // ForeColor = color, // FlatStyle = FlatStyle.Flat, // Font = new Font(new FontFamily("標楷體"), 16), // Size = new Size(40, 40), //}; //Button.Click += new EventHandler(Button_OnClick); }
public Chessboard GetChessboard(BattleFieldCoordinate coordinate) { return(_chessboard[coordinate.X, coordinate.Y]); }
public abstract void MoveToken(BattleFieldCoordinate from, BattleFieldCoordinate to);