Example #1
0
        public void Move(Point2D position)
        {
            MahjongPieceDim dim = GetDimensions(position);

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

            m_Position = position;

            m_Game.Players.SendGeneralPacket(true, true);
        }
        public int GetStackLevel(MahjongPieceDim dim)
        {
            int level = -1;

            foreach (MahjongTile tile in m_Tiles)
            {
                if (tile.StackLevel > level && dim.IsOverlapping(tile.Dimensions))
                {
                    level = tile.StackLevel;
                }
            }
            return(level);
        }
        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);
        }
 public bool IsOverlapping(MahjongPieceDim dim)
 {
     return(m_Position.X < dim.m_Position.X + dim.m_Width && m_Position.Y < dim.m_Position.Y + dim.m_Height && m_Position.X + m_Width > dim.m_Position.X && m_Position.Y + m_Height > dim.m_Position.Y);
 }