public BChessboard(Mobile black, Mobile white, int z, Rectangle2D bounds, ChessGame game, ChessSet chessSet, int whiteHue, int blackHue, int whiteMinorHue, int blackMinorHue, bool overrideMinorHue)
        {
            m_Game  = game;
            m_Black = black;
            m_White = white;

            m_ChessSet         = chessSet;
            m_WhiteHue         = whiteHue;
            m_BlackHue         = blackHue;
            m_WhiteMinorHue    = whiteMinorHue;
            m_BlackMinorHue    = blackMinorHue;
            m_Orientation      = m_Game.Orientation;
            m_OverrideMinorHue = overrideMinorHue;

            m_Map = m_Black.Map;
            m_Z   = z;

            m_Table          = new Hashtable();
            m_CapturedPieces = new ArrayList();

            m_Bounds = bounds;
            m_Step   = bounds.Width / 8;
            m_Offset = m_Step / 2;

            PlacePieces();
        }
Exemple #2
0
 /// <summary>
 /// Sets the orientation of the board
 /// </summary>
 /// <param name="orientation"></param>
 public void SetOrientation(BoardOrientation orientation)
 {
     if (m_Board != null)
     {
         m_Board.Orientation = orientation;
     }
 }
Exemple #3
0
        private static IEnumerable <Coordinate> GetCoordinates(
            BoardOrientation orientation,
            Point startingLocation,
            int length)
        {
            var endRow    = startingLocation.X;
            var endColumn = startingLocation.Y;

            if (orientation == BoardOrientation.Vertical)
            {
                endRow += length;
                endColumn++;
            }
            else
            {
                endRow++;
                endColumn += length;
            }

            var coordinates = new List <Coordinate>();

            for (var i = startingLocation.X; i < endRow; i++)
            {
                for (var j = startingLocation.Y; j < endColumn; j++)
                {
                    coordinates.Add(new Coordinate(i, j));
                }
            }

            return(coordinates);
        }
Exemple #4
0
        public bool AddShip(
            IBoard board,
            BoardOrientation orientation,
            Point startingLocation,
            int length)
        {
            var coordinates = GetCoordinates(orientation,
                                             startingLocation,
                                             length)
                              .ToList();

            var maxRow    = coordinates.Max(c => c.Location.X);
            var maxColumn = coordinates.Max(c => c.Location.Y);

            if (maxRow >= board.TotalRows || maxColumn >= board.TotalColumns)
            {
                return(false);
            }

            if (!board.IsVacant(coordinates.Select(c => c.Location)))
            {
                return(false);
            }

            var ship = new Ship(coordinates);

            return(board.AddShip(ship));
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 5:

                SafeZone = reader.ReadBool();
                goto case 4;

            case 4:

                m_BoardWhiteHue    = reader.ReadInt();
                m_BoardBlackHue    = reader.ReadInt();
                m_BoardStairsHue   = reader.ReadInt();
                m_BoardWhiteTiles  = reader.ReadStrongItemList();
                m_BoardBlackTiles  = reader.ReadStrongItemList();
                m_BoardStairsTiles = reader.ReadStrongItemList();
                goto case 3;

            case 3:

                m_OverrideMinorHue = reader.ReadBool();
                m_AllowSpectators  = reader.ReadBool();
                goto case 2;

            case 2:

                m_Orientation   = (BoardOrientation)reader.ReadByte();
                m_BlackMinorHue = reader.ReadInt();
                m_WhiteMinorHue = reader.ReadInt();
                goto case 1;

            case 1:

                m_ChessSet      = ( ChessSet )reader.ReadInt();
                m_WhiteHue      = reader.ReadInt();
                m_BlackHue      = reader.ReadInt();
                m_AttackEffect  = reader.ReadInt();
                m_CaptureEffect = reader.ReadInt();
                m_BoltOnDeath   = reader.ReadBool();
                goto case 0;

            case 0:

                m_Bounds      = reader.ReadRect2D();
                m_SquareWidth = reader.ReadInt();
                m_BoardHeight = reader.ReadInt();
                break;
            }
        }
Exemple #6
0
		/// <summary>
		/// Sets the orientation of the board
		/// </summary>
		/// <param name="orientation"></param>
		public void SetOrientation( BoardOrientation orientation )
		{
			if ( m_Board != null )
				m_Board.Orientation = orientation;
		}
		public BChessboard( Mobile black, Mobile white, int z, Rectangle2D bounds, ChessGame game, ChessSet chessSet, int whiteHue, int blackHue, int whiteMinorHue, int blackMinorHue, bool overrideMinorHue )
		{
			m_Game = game;
			m_Black = black;
			m_White = white;

			m_ChessSet = chessSet;
			m_WhiteHue = whiteHue;
			m_BlackHue = blackHue;
			m_WhiteMinorHue = whiteMinorHue;
			m_BlackMinorHue = blackMinorHue;
			m_Orientation = m_Game.Orientation;
			m_OverrideMinorHue = overrideMinorHue;

			m_Map = m_Black.Map;
			m_Z = z;

			m_Table = new Hashtable();
			m_CapturedPieces = new ArrayList();

			m_Bounds = bounds;
			m_Step = bounds.Width / 8;
			m_Offset = m_Step / 2;

			PlacePieces();
		}
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize (reader);

			int version = reader.ReadInt();

			switch ( version )
			{
                case 5:

			        SafeZone = reader.ReadBool();
			        goto case 4;

                case 4:

			        m_BoardWhiteHue = reader.ReadInt();
                    m_BoardBlackHue = reader.ReadInt();
                    m_BoardStairsHue = reader.ReadInt();
			        m_BoardWhiteTiles = reader.ReadStrongItemList();
                    m_BoardBlackTiles = reader.ReadStrongItemList();
                    m_BoardStairsTiles = reader.ReadStrongItemList();
			        goto case 3;

				case 3:

					m_OverrideMinorHue = reader.ReadBool();
					m_AllowSpectators = reader.ReadBool();
					goto case 2;

				case 2 :

					m_Orientation = (BoardOrientation) reader.ReadByte();
					m_BlackMinorHue = reader.ReadInt();
					m_WhiteMinorHue = reader.ReadInt();
					goto case 1;

				case 1:

					m_ChessSet = ( ChessSet ) reader.ReadInt();
					m_WhiteHue = reader.ReadInt();
					m_BlackHue = reader.ReadInt();
					m_AttackEffect = reader.ReadInt();
					m_CaptureEffect = reader.ReadInt();
					m_BoltOnDeath = reader.ReadBool();
					goto case 0;

				case 0:
					
					m_Bounds = reader.ReadRect2D();
					m_SquareWidth = reader.ReadInt();
					m_BoardHeight = reader.ReadInt();
					break;
			}
		}