Example #1
0
    void FixedUpdate()
    {
        mMainPlayerRigidbody.gravityScale = float.Parse(mzhongli.text);
        float volume = mRecordSound.GetVolume();

        mVolumeSilder.value = volume;
        if (volume > 0.5f && !mbStartGame)
        {
            this.StartGame();
        }
        else if (mbStartGame)
        {
            mStartGameTimes++;
            if (mStartGameTimes < 20)
            {
                return;
            }
            if (mListDiMian.Count == 2)
            {
                if (mPlayerOnDimian)// 小于0.5且在地面
                {
                    if (volume < float.Parse(mQitiaoVolum.text))
                    {
                        // Debug.Log(volume);
                        mDimainVecl = volume * float.Parse(myidongspeed.text);
                        float xoffset = mDimainVecl * Time.fixedDeltaTime;
                        mDimainVecl += -(float.Parse(mdimianmocha.text) * Time.fixedDeltaTime);
                        if (mDimainVecl < 0)
                        {
                            mDimainVecl = 0;
                        }
                        this.MoveDimain(xoffset);
                    }
                    else
                    {
                        Debug.Log(volume);
                        mDimainVecl = volume * float.Parse(tiaoyuechangdu.text);

                        mMainPlayerRigidbody.velocity = new Vector2(0, (volume * float.Parse(mtiaoyuegaodu.text)));

                        //      mMainPlayerRigidbody.AddRelativeForce(new Vector2(0, (volume    * float.Parse(mtiaoyuegaodu.text))), ForceMode2D.Impulse);
                        mPlayerOnDimian = false;
                    }
                }
                else
                {
                    float xoffset = mDimainVecl * Time.fixedDeltaTime;
                    this.MoveDimain(xoffset);

                    // donothing
                }
            }
        }
        deleteDeadMonster();
    }
Example #2
0
    void FixedUpdate()
    {
        float volume = mRecordSound.GetVolume();

        if (volume > 0.5f && !mbStartGame)
        {
            this.StartGame();
        }
        else if (mbStartGame)
        {
            mStartGameTime += Time.fixedDeltaTime;

            mVolumeSilder.value = volume;

            float wallgroupspeed = float.Parse(mBirdXSpeed.text);
            float walldistance   = Time.fixedDeltaTime * wallgroupspeed;
            //Debug.Log(volume);
            // if (volume > 0.4)
            float yforce = float.Parse(mBirdYForce.text);
            mMainPlayerRigidbody.AddForce(new Vector2(0, volume * yforce));

            for (int n = 0; n < mListWall.Count; n++)
            {
                GroupWall curWall = (GroupWall)mListWall[n];

                curWall.Update(walldistance);
            }
            // 检查最后一个来确定是否需要添加新的wall
            if (mListWall.Count > 0)
            {
                GroupWall backWall = (GroupWall)mListWall [mListWall.Count - 1];
                float     localx   = backWall.GetXPos();
                if (localx < 400)
                {
                    NewGroupWall();
                }
            }
            // 删除过线的wall
            deleteDeadWall();

            //
            if (mMainPlayer.anchoredPosition3D.y < -680 || mMainPlayer.anchoredPosition3D.y > 620)
            {
                StopGame();
            }
        }
    }