Exemple #1
0
        public CardDeck()
        {
            List <ICard> cardList = InitialAllCards();

            cardList.Shuffle();
            CurrentDeck = new SpecialQueue <ICard>(cardList);
        }
    private void ThreadDequeue(SpecialQueue <ThreadInfo> dataQueue)
    {
        ThreadInfo threadInfo = dataQueue.Dequeue();

        if (threadInfo.parameter == null || threadInfo.callback == null)
        {
            return;
        }

        threadInfo.callback(threadInfo.parameter);
    }
    // Generates the new spike id that is to be instatiated.
    private int GetspikeId(SpecialQueue queue)
    {
        int x = Random.Range(1, maxObstacleId);

        while (queue.IsAlert(x))
        {
            x = Random.Range(1, maxObstacleId);
        }
        queue.Push(x);

        return(x);
    }
    private IEnumerator GenerateObstacle()
    {
        objectPoolers = new Dictionary <int, ObjectPooler> (5);
        InitObjectPools();

        //make queue for storing previous values which will help in generating next spike.
        SpecialQueue queue = new SpecialQueue();

        spikeId = GetspikeId(queue);

        //Initial wait before the objects start falling
        //yield return new WaitForSeconds (1.8f);

        float waitTime = 1.8f / SpeedController.Speed * 6.5f;

        while (!isGameOver)
        {
            Spawn(objectPoolers [spikeId].GetPooledObject());

            //Generate the next spike id and decide its generation rate.
            spikeId = GetspikeId(queue);

            if (queue.IsCenterSpike())
            {
                waitTime = 1.4f / SpeedController.Speed * 6.5f;
            }
            else if (queue.IsBigCenterSpike())
            {
                waitTime = 1.6f / SpeedController.Speed * 6.5f;
            }
            else if (queue.WasBigCenterSpike())
            {
                waitTime = 1.3f / SpeedController.Speed * 6.5f;
            }
            else
            {
                waitTime = 1.1f / SpeedController.Speed * 6.5f;
            }

            yield return(new WaitForSeconds(waitTime));

            //This increases the maxObstacleId to allow moving obstacles to fall
            if (manager.Score > threshold)
            {
                if (maxObstacleId == 6)
                {
                    maxObstacleId = 7;
                }
            }
        }
    }
    private void Setup()
    {
        if (categorizedQueues.Count <= 0)         // Make sure the queues have not yet been initalized
        {
            foreach (QueueCategory queueCategory in Enum.GetValues(typeof(QueueCategory)))
            {
                // Gives each queue category its own array of priority queues.
                categorizedQueues.Add(queueCategory, new SpecialQueue <ThreadInfo> [Enum.GetValues(typeof(QueuePriority)).Length]);

                for (var i = 0; i < categorizedQueues[queueCategory].Length; i++)
                {
                    categorizedQueues[queueCategory][i] = new SpecialQueue <ThreadInfo>();
                }

                Debug.Log("Category Added: " + queueCategory);
            }
        }
    }