예제 #1
0
		public static MahjongPieceDim GetDimensions( Point2D position, MahjongPieceDirection direction )
		{
			if ( direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down )
				return new MahjongPieceDim( position, 40, 20 );
			else
				return new MahjongPieceDim( position, 20, 40 );
		}
예제 #2
0
 public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind)
 {
     _game      = game;
     _position  = position;
     _direction = direction;
     _wind      = wind;
 }
예제 #3
0
        public static void MoveTile(MahjongGame game, NetState state, PacketReader pvSrc)
        {
            if (game == null || !game.Players.IsInGamePlayer(state.Mobile))
            {
                return;
            }

            int number = pvSrc.ReadByte();

            if (number < 0 || number >= game.Tiles.Length)
            {
                return;
            }

            pvSrc.ReadByte(); // Current direction

            MahjongPieceDirection direction = GetDirection(pvSrc.ReadByte());

            pvSrc.ReadByte();

            bool flip = pvSrc.ReadBoolean();

            pvSrc.ReadInt16(); // Current Y
            pvSrc.ReadInt16(); // Current X

            pvSrc.ReadByte();

            int y = pvSrc.ReadInt16();
            int x = pvSrc.ReadInt16();

            pvSrc.ReadByte();

            game.Tiles[number].Move(new Point2D(x, y), direction, flip, game.Players.GetPlayerIndex(state.Mobile));
        }
예제 #4
0
		public MahjongDealerIndicator( MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind )
		{
			m_Game = game;
			m_Position = position;
			m_Direction = direction;
			m_Wind = wind;
		}
예제 #5
0
 public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind)
 {
     m_Game      = game;
     m_Position  = position;
     m_Direction = direction;
     m_Wind      = wind;
 }
예제 #6
0
 public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction)
 {
     if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down)
     {
         return(new MahjongPieceDim(position, 20, 30));
     }
     return(new MahjongPieceDim(position, 30, 20));
 }
예제 #7
0
        public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction)
        {
            if (direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down)
            {
                return(new MahjongPieceDim(position, 40, 20));
            }

            return(new MahjongPieceDim(position, 20, 40));
        }
예제 #8
0
 public MahjongTile(MahjongGame game, int number, MahjongTileType value, Point2D position, int stackLevel, MahjongPieceDirection direction, bool flipped)
 {
     m_Game       = game;
     m_Number     = number;
     m_Value      = value;
     m_Position   = position;
     m_StackLevel = stackLevel;
     m_Direction  = direction;
     m_Flipped    = flipped;
 }
예제 #9
0
        private void BuildVerticalWall(ref int index, int x, int y, int stackLevel, MahjongPieceDirection direction, MahjongTileTypeGenerator typeGenerator)
        {
            for (int i = 0; i < 17; i++)
            {
                Point2D position = new Point2D(x, y + i * 20);
                m_Tiles[index + i] = new MahjongTile(this, index + i, typeGenerator.Next(), position, stackLevel, direction, false);
            }

            index += 17;
        }
예제 #10
0
		public MahjongDealerIndicator( MahjongGame game, GenericReader reader )
		{
			m_Game = game;

			int version = reader.ReadInt();

			m_Position = reader.ReadPoint2D();
			m_Direction = (MahjongPieceDirection) reader.ReadInt();
			m_Wind = (MahjongWind) reader.ReadInt();
		}
예제 #11
0
		public MahjongTile( MahjongGame game, int number, MahjongTileType value, Point2D position, int stackLevel, MahjongPieceDirection direction, bool flipped )
		{
			m_Game = game;
			m_Number = number;
			m_Value = value;
			m_Position = position;
			m_StackLevel = stackLevel;
			m_Direction = direction;
			m_Flipped = flipped;
		}
예제 #12
0
        public MahjongDealerIndicator(MahjongGame game, GenericReader reader)
        {
            m_Game = game;

            int version = reader.ReadInt();

            m_Position  = reader.ReadPoint2D();
            m_Direction = (MahjongPieceDirection)reader.ReadInt();
            m_Wind      = (MahjongWind)reader.ReadInt();
        }
예제 #13
0
		public void Move( Point2D position, MahjongPieceDirection direction, MahjongWind wind )
		{
			MahjongPieceDim dim = GetDimensions( position, direction );

			if ( !dim.IsValid() )
				return;

			m_Position = position;
			m_Direction = direction;
			m_Wind = wind;

			m_Game.Players.SendGeneralPacket( true, true );
		}
예제 #14
0
        public MahjongTile(MahjongGame game, GenericReader reader)
        {
            this.m_Game = game;

            int version = reader.ReadInt();

            this.m_Number = reader.ReadInt();
            this.m_Value = (MahjongTileType)reader.ReadInt();
            this.m_Position = reader.ReadPoint2D();
            this.m_StackLevel = reader.ReadInt();
            this.m_Direction = (MahjongPieceDirection)reader.ReadInt();
            this.m_Flipped = reader.ReadBool();
        }
예제 #15
0
        public MahjongTile(MahjongGame game, GenericReader reader)
        {
            m_Game = game;

            int version = reader.ReadInt();

            m_Number     = reader.ReadInt();
            m_Value      = (MahjongTileType)reader.ReadInt();
            m_Position   = reader.ReadPoint2D();
            m_StackLevel = reader.ReadInt();
            m_Direction  = (MahjongPieceDirection)reader.ReadInt();
            m_Flipped    = reader.ReadBool();
        }
예제 #16
0
        public void Move(Point2D position, MahjongPieceDirection direction, MahjongWind wind)
        {
            MahjongPieceDim dim = GetDimensions(position, direction);

            if (!dim.IsValid())
            {
                return;
            }

            m_Position  = position;
            m_Direction = direction;
            m_Wind      = wind;

            m_Game.Players.SendGeneralPacket(true, true);
        }
예제 #17
0
        public static void MoveDealerIndicator(MahjongGame game, NetState state, PacketReader pvSrc)
        {
            if (game == null || !game.Players.IsInGameDealer(state.Mobile))
            {
                return;
            }

            MahjongPieceDirection direction = GetDirection(pvSrc.ReadByte());

            MahjongWind wind = GetWind(pvSrc.ReadByte());

            int y = pvSrc.ReadInt16();
            int x = pvSrc.ReadInt16();

            game.DealerIndicator.Move(new Point2D(x, y), direction, wind);
        }
예제 #18
0
		public void Move( Point2D position, MahjongPieceDirection direction, bool flip, int validHandArea )
		{
			MahjongPieceDim dim = GetDimensions( position, direction );
			int curHandArea = Dimensions.GetHandArea();
			int newHandArea = dim.GetHandArea();

			if ( !IsMovable || !dim.IsValid() || ( validHandArea >= 0 && ((curHandArea >= 0 && curHandArea != validHandArea) || (newHandArea >= 0 && newHandArea != validHandArea)) ) )
				return;

			m_Position = position;
			m_Direction = direction;
			m_StackLevel = -1; // Avoid self interference
			m_StackLevel = m_Game.GetStackLevel( dim ) + 1;
			m_Flipped = flip;

			m_Game.Players.SendTilePacket( this, true, true );
		}
예제 #19
0
        public void Move(Point2D position, MahjongPieceDirection direction, bool flip, int validHandArea)
        {
            MahjongPieceDim dim         = GetDimensions(position, direction);
            int             curHandArea = Dimensions.GetHandArea();
            int             newHandArea = dim.GetHandArea();

            if (!IsMovable || !dim.IsValid() || (validHandArea >= 0 && ((curHandArea >= 0 && curHandArea != validHandArea) || (newHandArea >= 0 && newHandArea != validHandArea))))
            {
                return;
            }

            m_Position   = position;
            m_Direction  = direction;
            m_StackLevel = -1;             // Avoid self interference
            m_StackLevel = m_Game.GetStackLevel(dim) + 1;
            m_Flipped    = flip;

            m_Game.Players.SendTilePacket(this, true, true);
        }
예제 #20
0
 private void Deserialize(IGenericReader reader, int version)
 {
     _position  = reader.ReadPoint2D();
     _direction = (MahjongPieceDirection)reader.ReadInt();
     _wind      = (MahjongWind)reader.ReadInt();
 }
예제 #21
0
		private void BuildHorizontalWall( ref int index, int x, int y, int stackLevel, MahjongPieceDirection direction, MahjongTileTypeGenerator typeGenerator )
		{
			for ( int i = 0; i < 17; i++ )
			{
				Point2D position = new Point2D( x + i*20, y );
				m_Tiles[index + i] = new MahjongTile( this, index + i, typeGenerator.Next(), position, stackLevel, direction, false );
			}

			index += 17;
		}
예제 #22
0
 public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) =>
 direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down