Esempio n. 1
0
    void OnDestroy()
    {
        foreach (BoxWithTimer bwt in produceList)
        {
            Destroy(bwt.box);
        }
        produceList.Clear();

        while (collectQueue.Count > 0)
        {
            BoxWithTimer bwt = (BoxWithTimer)collectQueue.Dequeue();
            Destroy(bwt.box);
        }
    }
Esempio n. 2
0
    //消去一个盒子
    public static void DestroyOneBox()
    {
        if (produceList.Count > 0)
        {
            BoxWithTimer bwt = produceList.First.Value;
            MoveToBeyondScreen(bwt.box);                                     //移出屏幕

            //bwt.box.SetActive(false);
            bwt.box.transform.localRotation = Quaternion.Euler(0, 0, 0);

            produceList.RemoveFirst();                                     //移除链表第一个节点
            collectQueue.Enqueue(bwt);                                     //放入回收队列
        }
        //控制声音
        musicInstant_icedelete.audio.Play();
    }
Esempio n. 3
0
    //生产一个盒子
    void ProduceOneBox()
    {
        if (collectQueue.Count > 0)
        {
            BoxWithTimer bwt = collectQueue.Dequeue() as BoxWithTimer;
            bwt.box.SetActive(false);
            SetPosition(bwt.box);                                     //设盒子坐标
            bwt.box.SetActive(true);

            produceList.AddLast(bwt);            //放入链表尾部
            bwt.aliveTime = ALIVE_TIME;          //重置存活时间
        }
        else if (produceList.Count > 0)          //回收队列为空
        {
            DestroyOneBox();                     //则先消去一个盒子,再生产出来
        }
        //控制声音
        musicInstant_iceadd.audio.Play();
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        if (isBig)
        {
            transform.localScale = new Vector3(2, 2, 2);
            Thread delay = new Thread(Wait);
            delay.Start();
        }

        foreach (BoxWithTimer bwt in produceList)
        {
            bwt.aliveTime -= Time.deltaTime;
        }
        while (produceList.Count > 0)
        {
            BoxWithTimer bwt = produceList.First.Value;
            if (bwt.aliveTime > 0)
            {
                break;
            }
            DestroyOneBox();                                           //时间到,消去
        }
    }