Exemple #1
0
 public void UpdateSpawner(float passedtime)
 {
     if (m_CacheSpawner.Count > 0)
     {
         TileSpawner pSpawner = m_CacheSpawner.Peek();
         if (pSpawner.getStartTime <= passedtime)
         {
             float passedprocess =
                 ((float)pSpawner.getStartTime + m_DelayTime)
                 / (m_MusicTime + m_DelayTime);
             AttachBlock(pSpawner, passedprocess);
             m_CacheSpawner.Dequeue();
         }
     }
 }
Exemple #2
0
        void AttachBlock(TileSpawner bs, float passedprocess)
        {
            //test for curve
            TouchTileBase pTile = null;

            List <int> usefultracknum = new List <int>();

            if (m_LastTrackProcesses.Count > 0)
            {
                for (int i = 0; i < TrackManager.instance.trackNum; ++i)
                {
                    if (i == lasttrack)
                    {
                        continue;
                    }
                    if (m_LastTrackProcesses.ContainsKey(i))
                    {
                        //证明这个轨道的音此刻已经播完了
                        if (m_LastTrackProcesses[i] <= passedprocess)
                        {
                            usefultracknum.Add(i);
                        }
                    }
                    else
                    {
                        usefultracknum.Add(i);
                    }
                }
            }

            //求轨道
            //for(int i=0;i< usefultracknum.Count;++i)
            int usetrack = -1;

            if (usefultracknum.Count > 0)
            {
                int index = UnityEngine.Random.Range(0, usefultracknum.Count);

                usetrack = usefultracknum[index];

                //Debug.Log("lasttrack: " + lasttrack);
                //Debug.Log("usefultracknum: " + usetrack);
            }
            else
            {
                //Debug.LogError("no find usetrack ");
                usetrack = UnityEngine.Random.Range(0, TrackManager.instance.trackNum);
            }

            //Debug.Log("track index: " + usetrack + "lasttrack: " + lasttrack);
            if (usetrack == lasttrack)
            {
                Debug.LogError("error " + usetrack);
            }
            if (bs.getLength > 1)
            //if (true)
            {
                int       numpoints   = 16;
                Vector3[] curvepoints = new Vector3[numpoints];
                float     endtime     = (float)bs.getEndTime;
                float     everytime   = (endtime - (float)bs.getStartTime) / numpoints;
                Vector3[] normals     = new Vector3[numpoints];

                for (int i = 0; i < curvepoints.Length; ++i)
                {
                    //选取点计算的问题 每个采样点为延迟进度+花费时间/歌曲时间
                    //float process = m_DelayProcess +
                    //    ((float)bs.getStartTime + everytime * i)
                    //    / (m_MusicTime + m_DelayTime);
                    float process = m_DelayProcess +
                                    ((float)bs.getStartTime + everytime * i)
                                    / (m_MusicTime);
                    curvepoints[i] = TrackManager.instance.GetPosition(process, 0);

                    normals[i] = TrackManager.instance.GetRotation(process, 0) * new Vector3(0, 1, 0);
                }

                float endprocess = m_DelayProcess +
                                   ((float)bs.getEndTime) / (m_MusicTime + m_DelayTime);
                pTile = bs.CreateTile(m_MusicTime, m_DelayTime, m_StartPressTime
                                      , CurverTouchTile.m_TileName);

                TrackManager.instance.PushValue(pTile, usetrack);

                m_LastTrackProcesses[usetrack] = endprocess;

                bs.CreateTileMesh(pTile, curvepoints, normals);

                lasttrack = usetrack;
            }
            else
            {
                float endprocess = m_DelayProcess + ((float)bs.getEndTime) / (m_MusicTime + m_DelayTime);

                pTile = bs.CreateTile(
                    m_MusicTime, m_DelayTime, m_StartPressTime, NormalTouchTile.m_TileName);

                TrackManager.instance.PushValue(pTile, usetrack);

                m_LastTrackProcesses[usetrack] = endprocess;

                bs.CreateTileMesh(pTile);

                //test
                //if(pTile.transform.childCount==0)
                //{
                //    GameObject testobj = new GameObject();
                //    testobj.transform.parent = pTile.transform;
                //    testobj.name = "track:" + usetrack;
                //}
                //else
                //{
                //    pTile.transform.GetChild(0).name = "track:" + usetrack;
                //}


                lasttrack = usetrack;
            }



            //m_RunningTiles.Add(pTile);
        }