示例#1
0
        /****************************************************************************************
         * Public helper functions
         ***************************************************************************************/
        bool                            FilterEntity(CBaseEntity pEnt)
        {
            bool bResult = false;

            if (pEnt != null)
            {
                switch (m_eFilterMode)
                {
                case EFilterMode.Normal:
                    bResult = FilterEntityNorm(pEnt);
                    break;

                case EFilterMode.Inverted:
                    bResult = !FilterEntityNorm(pEnt);
                    break;

                case EFilterMode.Random:
                    bResult = NRand.randBool(m_flRandomChance);
                    break;

                case EFilterMode.AllowAll:
                    bResult = true;
                    break;

                case EFilterMode.BlockAll:
                    bResult = false;
                    break;
                }
            }
            return(bResult);
        }
示例#2
0
        /**
         * Returns a list of Tetromino templates. The list will be of length 7,
         * and it will contain one of each Tetronimo, but with 2 L
         * and 2 S because each of those represent two blocks.
         * In random order.
         */
        Queue <CBaseBlock> NextTetrisPieceSequence()
        {
            //Just build the list first and then we'll randomly swap around
            List <CBaseBlock> s = new List <CBaseBlock>();

            s.Add(I);
            s.Add(O);
            s.Add(T);
            s.Add(L);
            s.Add(L);
            s.Add(S);
            s.Add(S);

            //what kind of list interface doesn't have a swap functionality?
            for (int i = 0; i < 20; i++)
            {
                int j = NRand.randInt(0, 6);
                int k = NRand.randInt(0, 6);
                Swap(s, j, k);
            }

            //we don't actually need the enum
            Queue <CBaseBlock> q = new Queue <CBaseBlock>(s);

            return(q);
        }
示例#3
0
 /**
  * Returns the current max height as measured by the current sequence.
  */
 public float SequenceMeasure()
 {
     if (g.curtime > m_flSequenceNextMeasureTime)
     {
         m_flSequenceNextMeasureTime += s_flSequenceNextMeasureInterval;
         m_flSequenceLastMeasure      = MeasureMaxWorldUnits();
     }
     //result has a little randomness. The randomness decreases as the final measurement approaches.
     return(m_flSequenceLastMeasure + NRand.randFloat(-1, 1) * s_flSequenceRandomAmplitude * SequenceRemainingTimeProportion());
 }
示例#4
0
        public static void init()
        {
            g_bReinitialize = false;

            curtime   = 0.03f;
            prevtime  = 0.0f;
            frametime = 0.03f;

            timer = new Stopwatch();
            timer.Start();

            NRand.seedFromTime();
        }
示例#5
0
 /****************************************************************************************
  * Private helper functions
  ***************************************************************************************/
 bool    PassRandom()
 {
     return(NRand.randBool(m_flRandomChance));
 }