Пример #1
0
    //节拍观察者,颤抖圆环;评价观察者,累计分数
    public void ObserverUpdate(ISubject subject, System.Object arg)
    {
        //节拍观察者
        if (subject == SingletonBeatManager.GetInstance())
        {
            if (mIsFirstBeat)
            {
                mIsFirstBeat = false;
                return;
            }
            //以防有的歌曲抖动过快,所以在每次抖动前清空数据
            mCurrentRadius = RadiusLowerBound;
            if (WaveSpeedInPixel < 0)
            {
                WaveSpeedInPixel *= -1.0f;
            }
            //开始颤抖圆环
            StartCoroutine(WaveCircle());
        }
        //评价观察者
        if (subject == SingletonActionMatchManager.GetInstance())
        {
            mScore += (arg as MatchResult).Score;
            DataBetweenScene.Score = mScore;
            //DataBetweenScene.AverageScore = mScore / SingletonActionMatchManager.GetInstance().ActionMatchCount;

            StartCoroutine(UpdateScore());
        }
    }
Пример #2
0
 //订阅主题数据
 void IObserver.ObserverUpdate(ISubject subject, System.Object arg)
 {
     if ((EnumBeatType)arg == EnumBeatType.DOWNBEAT)
     {
         mCount = 0;
     }
     else
     {
         mCount++;
     }
     print("mCount" + mCount);
     mCurrentBarIndex = SingletonBeatManager.GetInstance().BarIndex;
     while (j < mEffectsIterator.Count &&
            mArrayEffectAttribute[j].BarNum == (mCurrentBarIndex - 1) &&
            (mCount == mArrayEffectAttribute[j].Beat))
     {
         //if(mCount == mArrayEffectAttribute[j].Beat){
         if (mArrayEffectAttribute[j].FlagPos)
         {
             //print ("dddddd");
             Instantiate(SingletonLoadGamePlayResources.GetInstance().ArrayEffects[mArrayEffectAttribute[j].EffectId], new Vector3(mArrayEffectAttribute[j].PosX, mArrayEffectAttribute[j].PosY, mArrayEffectAttribute[j].PosZ), Quaternion.identity);
             //Effect.SetActive (true);
         }
         else
         {
             //print ("ccccc"+mCurrentBarIndex+"   "+mArrayEffectAttribute[j].EffectId);
             Instantiate(SingletonLoadGamePlayResources.GetInstance().ArrayEffects[mArrayEffectAttribute[j].EffectId]);
             //Effect.SetActive (true);
         }
         j++;
     }
 }
 // Use this for initialization
 void Start()
 {
     mInstance           = this;
     mBeatCount          = 0;
     mBarCount           = 0;
     mEvaluationTimes    = 0;
     mIsEvaluationAllEnd = false;
     mIsEvaluationEnd    = true;
     mIsFirstEvaluation  = false;
     mBeatManager        = SingletonBeatManager.GetInstance();
     mBeatManager.AddObserver(this);
     mListObservers           = new List <IObserver>();
     mListEvaluationAttribute = new List <EvaluationAttribute> ();
     //通过迭代器读入数据
     ReadEvaluationAttribute();
     //记录哪个小节进行评价
     mListEvaluationBar = new List <int> ();
     CalEvaluationBar();
     //初始化标准动画队列
     mQueueStdMotion = new Queue <MotionJointQuaternionVector>();
     //初始化四元组
     InitTransform();
     InitQuaternionVector();
     //算法
     mActionMatchAlogrithm = new StaticMatch(mStdJointQuaternionVector, mUserJointQuaternionVector);
 }
Пример #4
0
 // Update is called once per frame
 void Update()
 {
     //判断游戏结束,计算平均分,跳转场景
     if (SingletonBeatManager.GetInstance().IsGameOver)
     {
         DataBetweenScene.AverageScore = DataBetweenScene.Score / SingletonActionMatchManager.GetInstance().ActionMatchCount;
         Application.LoadLevel("GameOver");
     }
 }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        mCurrentRadius = RadiusLowerBound;
        SingletonBeatManager.GetInstance().AddObserver(this);
        SingletonActionMatchManager.GetInstance().AddObserver(this);

        mFullScore = SingletonActionMatchManager.GetInstance().ActionMatchCount * 100.0f;
        mCenter    = new Vector2();
        mCubeRect  = new Rect();
    }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        //TODO: 根据配置文件,选择场景和角色的prefab,目前只有一个角色,一个场景(除了角色在那边Instantiate以外,其余的都在需要时相应模块Instantiate)


        //TODO: 开启节拍控制模块,播放音乐,开始动画
        SingletonBeatManager.GetInstance().Begin();
        SingletonLoadGamePlayResources.GetInstance().ArrayCharacters[0].animation.Play(DataBetweenScene.SongName);
        audio.clip = SingletonLoadGamePlayResources.GetInstance().CurrentSong;
        audio.Play();
    }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        mInstance    = this;
        mObservers   = new ArrayList();
        mBarIterator = SingletonGameData.GetInstance().CreateBarIterator();
        //mSongIterator = SingletonGameData.GetInstance ().CreateSongIterator ();
        mListSameBarsAttribute = new List <BarAttribute> ();
        while (mBarIterator.HasNext())
        {
            mListSameBarsAttribute.Add(mBarIterator.Next() as BarAttribute);
        }
        mCurrentBarType = mListSameBarsAttribute[mCurrentBar].BarType;
        mSameBarNumber  = mListSameBarsAttribute [mCurrentBar].SameBarsNumber;
        mListCount      = mListSameBarsAttribute.Count;

        mSongAttribute = SingletonGameData.GetInstance().GetCurrentSongAttribute();
        mBeatSeconds   = (float)60 / mSongAttribute.BPM;
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        //订阅主题SingletonBeatManager
        mEffectsManager = SingletonBeatManager.GetInstance();
        mEffectsManager.AddObserver(this);
        mEffectsIterator = SingletonGameData.GetInstance().CreateEffectIterator();
        //加载特效属性,并排序
        mArrayEffectAttribute = new EffectAttribute[mEffectsIterator.Count];

        while (mEffectsIterator.HasNext())
        {
            mArrayEffectAttribute[i] = (mEffectsIterator.Next()) as EffectAttribute;
            i++;
        }
        MySortClass mySortClass = new MySortClass();

        Array.Sort(mArrayEffectAttribute, mySortClass);

        /*foreach (EffectAttribute effects in mArrayEffectAttribute){
         *      print (effects.BarNum+"dd" );
         *      print (effects .Beat+"cc");
         * }*/
    }
Пример #9
0
 void Start()
 {
     mBeatManager = SingletonBeatManager.GetInstance();
     mBeatManager.AddObserver(this);
 }
Пример #10
0
    // Update is called once per frame
    void Update()
    {
        switch (mIndex)
        {
        case 1:
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum - 2)
            {
                gameObject.transform.position = mVector[2];
                guiTexture.texture            = mTexture3;
                guiTexture.pixelInset         = mRect[1];
            }
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum - 1)
            {
                if (gameObject.transform.position.x > mVector[1].x)
                {
                    transform.Translate((mVector[1] - mVector[2]) * Time.deltaTime * mSpeed);
                }
                else
                {
                    gameObject.transform.position = mVector[1];
                    guiTexture.pixelInset         = mRect[0];
                }
            }
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum)
            {
                if (gameObject.transform.position.x < mVector[0].x)
                {
                    transform.Translate((mVector [0] - mVector [1]) * Time.deltaTime * mSpeed);
                }
                else
                {
                    gameObject.transform.position = mVector[0];
                    guiTexture.pixelInset         = mRect[1];
                }
            }
            break;

        case 2:
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum - 2)
            {
                if (gameObject.transform.position.x < mVector[0].x)
                {
                    transform.Translate((mVector [0] - mVector [1]) * Time.deltaTime * mSpeed);
                }
                else
                {
                    gameObject.transform.position = mVector[0];
                    guiTexture.pixelInset         = mRect[1];
                }
            }
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum - 1)
            {
                gameObject.transform.position = mVector[2];
                guiTexture.texture            = mTexture4;
                guiTexture.pixelInset         = mRect[1];
            }
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum)
            {
                if (gameObject.transform.position.x > mVector[1].x)
                {
                    transform.Translate((mVector[1] - mVector[2]) * Time.deltaTime * mSpeed);
                }
                else
                {
                    gameObject.transform.position = mVector[1];
                    guiTexture.pixelInset         = mRect[0];
                }
            }

            break;

        case 3:
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum - 2)
            {
                if (gameObject.transform.position.x > mVector[1].x)
                {
                    transform.Translate((mVector[1] - mVector[2]) * Time.deltaTime * mSpeed);
                }
                else
                {
                    gameObject.transform.position = mVector[1];
                    guiTexture.pixelInset         = mRect[0];
                }
            }
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum - 1)
            {
                if (gameObject.transform.position.x < mVector[0].x)
                {
                    transform.Translate((mVector [0] - mVector [1]) * Time.deltaTime * mSpeed);
                }
                else
                {
                    gameObject.transform.position = mVector[0];
                    guiTexture.pixelInset         = mRect[1];
                }
            }
            if (SingletonBeatManager.GetInstance().BarIndex == mFirstBarNum)
            {
                gameObject.transform.position = mVector[2];
                guiTexture.texture            = SingletonLoadGamePlayResources.GetInstance().ArrayTextureUserPromptImages[mIndex % 3];
                guiTexture.pixelInset         = mRect[1];
            }

            break;
        }
        if (SingletonBeatManager.GetInstance().BarIndex > mBarNum)
        {
            mBarNumber = mBarNum;
            if ((gameObject.transform.position.y == mVector [0].y) && mIsMoved2)
            {
                gameObject.transform.position = mVector[2];
                guiTexture.texture            = SingletonLoadGamePlayResources.GetInstance().ArrayTextureUserPromptImages[mIndex % 3 + 3 * mImageIndex];
                guiTexture.pixelInset         = mRect[1];
                if (mUserPromptImageIterator.HasNext())
                {
                    mUserPromptsAttribute = (UserPromptsAttribute)mUserPromptImageIterator.Next();
                }
                mBarNum   = mUserPromptsAttribute.BarNumber;
                mText     = mUserPromptsAttribute.Text;
                mBarNum   = mBarNum + mBarNumber;
                mIsMoved2 = false;
                mImageIndex++;
            }
            else if ((gameObject.transform.position.x == mVector[2].x || mIsMoved))
            {
                if (gameObject.transform.position.x > mVector[1].x)
                {
                    mIsMoved = true;
                    transform.Translate((mVector[1] - mVector[2]) * Time.deltaTime * mSpeed);
                    guiTexture.pixelInset = mRect[1];
                }
                else
                {
                    gameObject.transform.position = mVector[1];
                    guiTexture.pixelInset         = mRect[0];
                    if (mUserPromptImageIterator.HasNext())
                    {
                        mUserPromptsAttribute = (UserPromptsAttribute)mUserPromptImageIterator.Next();
                    }
                    mBarNum  = mUserPromptsAttribute.BarNumber;
                    mText    = mUserPromptsAttribute.Text;
                    mBarNum  = mBarNum + mBarNumber;
                    mIsMoved = false;
                }
            }
            else if ((gameObject.transform.position.x == mVector [1].x || mIsMoved1))
            {
                if (gameObject.transform.position.y < mVector[0].y)
                {
                    mIsMoved1 = true;
                    transform.Translate((mVector [0] - mVector [1]) * Time.deltaTime * mSpeed);
                    guiTexture.pixelInset = mRect[0];
                    mIsMoved2             = false;
                }
                else
                {
                    gameObject.transform.position = mVector[0];
                    guiTexture.pixelInset         = mRect[1];
                    if (mUserPromptImageIterator.HasNext())
                    {
                        mUserPromptsAttribute = (UserPromptsAttribute)mUserPromptImageIterator.Next();
                    }
                    mBarNum   = mUserPromptsAttribute.BarNumber;
                    mText     = mUserPromptsAttribute.Text;
                    mBarNum   = mBarNum + mBarNumber;
                    mIsMoved1 = false;
                    mIsMoved2 = true;
                }
            }
        }
    }