Ejemplo n.º 1
0
        public Location GetLocation(BattleFieldCoordinate coordinate)
        {
            var x = coordinate.X;
            var y = coordinate.Y;

            return(_locations[x, y]);
        }
Ejemplo n.º 2
0
 public MoveInfo(BattleFieldCoordinate fromCoor, BattleFieldCoordinate toCoor)
 {
     FromX = fromCoor.X;
     FromY = fromCoor.Y;
     ToX   = toCoor.X;
     ToY   = toCoor.Y;
 }
Ejemplo n.º 3
0
 public bool IsLocationOccupied(BattleFieldCoordinate coordinate)
 {
     if (GetLocation(coordinate).Token != null)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 public Chessboard GetChessboard(BattleFieldCoordinate coordinate)
 {
     return(_chessboard[coordinate.X, coordinate.Y]);
 }
Ejemplo n.º 7
0
 public abstract void MoveToken(BattleFieldCoordinate from, BattleFieldCoordinate to);