Exemple #1
0
    /// <summary>
    /// 获取某个房间
    /// </summary>
    /// <returns></returns>
    public RoomData GetRoom()
    {
        if (RoomData != null)
        {
            return(RoomData);
        }

        if (LeftChild == null && RightChild == null)
        {
            return(null);
        }

        RoomData lRoom = null;

        RoomData rRoom = null;

        if (LeftChild != null)
        {
            lRoom = LeftChild.GetRoom();
        }

        if (RightChild != null)
        {
            rRoom = RightChild.GetRoom();
        }

        if (lRoom == null && rRoom == null)
        {
            return(null);
        }

        if (lRoom != null)
        {
            return(lRoom);
        }

        if (rRoom != null)
        {
            return(rRoom);
        }

        if (Const.Random.Next(0, 10) > 4)
        {
            return(lRoom);
        }

        return(rRoom);
    }