Exemplo n.º 1
0
        public List <Box> CreateBox()
        {
            int total = m_players.Count + 2;

            int itemCount            = 0;
            List <MapGoodsInfo> list = new List <MapGoodsInfo>();

            if (CurrentTurnTotalDamage > 0)
            {
                itemCount = m_random.Next(1, 3);
                if (m_tempBox.Count + itemCount > total)
                {
                    itemCount = total - m_tempBox.Count;
                }
                if (itemCount > 0)
                {
                    list.AddRange(MapMgr.GetRandomGoodsByNumber(m_map.Info.ID, itemCount, (int)m_mapType));
                }
            }

            int ghostCount = GetGhostCount();
            int propCount  = 0;

            if (ghostCount > 0)
            {
                propCount = m_random.Next(ghostCount);
            }
            if (m_tempBox.Count + itemCount + propCount > total)
            {
                propCount = total - m_tempBox.Count - itemCount;
            }
            if (propCount > 0)
            {
                MapMgr.GetRandomFightPropByCount(m_map.Info.ID, propCount, list);
            }

            List <Box> box = new List <Box>();

            if (list.Count > 0)
            {
                for (int i = 0; i < m_tempPoints.Count; i++)
                {
                    int   index = m_random.Next(m_tempPoints.Count);
                    Point p     = m_tempPoints[index];
                    m_tempPoints[index] = m_tempPoints[i];
                    m_tempPoints[i]     = p;
                }
                int count = Math.Max(list.Count, m_tempPoints.Count);
                for (int i = 0; i < count; i++)
                {
                    box.Add(AddBox(list[i], m_tempPoints[i]));
                }
            }

            m_tempPoints.Clear();
            return(box);
        }