public void EnqueueToPipeQueue(PipeController pipe)
 {
     pipe.transform.position = new Vector3(startPosX, UnityEngine.Random.Range(generatePosMin, generatePosMax));
     pipe.gameObject.SetActive(false);
     // Enqueue
     pipeQueue.Enqueue(pipe);
 }
        private void Initialize()
        {
            pipeQueue = new Queue <PipeController>();
            // Initialize event
            GameManager._instance.SetStateEvent(SystemDefine.EGameState.Start, StartEvent);
            GameManager._instance.SetStateEvent(SystemDefine.EGameState.Playing, PlayingEvent);
            GameManager._instance.SetStateEvent(SystemDefine.EGameState.Fall, FallEvent);
            // Init pipe speed
            currentPipeSpeed = pipeSpeed;
            // Init Pipe prefab

            pipePrefab = Instantiate((Resources.Load <GameObject>("Prefab/Pipe")));
            PipeController initPipe = pipePrefab.GetComponent <PipeController>();

            initPipe.transform.parent = this.gameObject.transform;
        }
        private void DequeuePipeRandomly()
        {
            PipeController newPipe;

            // If queue is empty, than create more pipe
            if (pipeQueue.Count < 1)
            {
                newPipe = Instantiate(pipePrefab).GetComponent <PipeController>();
                newPipe.transform.parent = this.gameObject.transform;
                EnqueueToPipeQueue(newPipe);
            }
            PipeController pipe = pipeQueue.Dequeue();

            // Set pipe Active true
            pipe.gameObject.SetActive(true);
            // Set pipe state to PlayingState
            pipe.SetState(PipeDefine.EPipeState.Playing);
            // Random position
            pipe.transform.position = new Vector3(startPosX, UnityEngine.Random.Range(generatePosMin, generatePosMax));
        }