1、,Button2Button3;foreach(stringnameinbtnnames)GameObjectobjGameObject.Find(name);Buttonbtnobj.GetComponent();btn.onClick.AddListener(delegate()this.OnClick(obj););OnClick(GameObjectobj)switch(obj.name)caseGameManager.Instance.Difficulty1;/SceneManager.LoadScene(GameScene);break;2;3;default:2. TextDif
2、ficulityScript TextDifficulityScriptstringdifficultyIDGameManager.Instance.DifficultyID;TextDifficulty).GetComponent().text=difficultyID;Updateiscalledonceperframe3. GameManager GameManagerprivatestaticinstance=null;GameManager()Instancegetif(instance=null)instancenewreturninstance;/*intscore=0;Scor
3、egetscore;setscorevalue;ScroeUp()+score;/-不同难度-floatpipeMoveSpeed=0.0f;restartInterval=0.0f;radomForY=0.0f;Difficulty(value)1:pipeMoveSpeed0.2f;restartInterval4.0f;radomForY0.0f;菜鸟级2:0.4f;2.0f;普通级3:=1f;1.0f;0.5f;专家级SceneManager.LoadSceneDifficultyIDdifficultyID;RestartIntervalrestartInterval;RadomFo
4、rYradomForY;PipeMoveSpeedpipeMoveSpeed;UpdateScore()recordPlayerPrefs.GetIntrecord(this.scorerecord)PlayerPrefs.SetInt,this.score);GetRecord()record;4. PipeScript PipeScriptboolisUpdatingfalse;this.GoBackWait(!this.isUpdating)return;speedGameManager.Instance.PipeMoveSpeed;x-speed*Time.deltaTime;game
5、Object.transform.position+=Vector3(x,0.0f,0.0f);(gameObject.transform.position.x-4.5f)GoBackWait()rangeGameManager.Instance.RadomForY;yRandom.Range(-range,range);Vector3(4.5f,y,0.0f);restart()true;IsUpdating/访问器,在GameSceneManager.cs中会获取isUpdating的值getisUpdating;5. FloorScript FloorScript-speed*Time.
6、deltaTime;-10)(10.0f,6. BirdScript BirdScriptRigidbody2Drigid2D=null;AudioSourceflysoundnull;hitsoundthis.rigid2DgameObject.GetComponent/this.flysoundAudioSource(Input.GetMouseButtonDown(0)this.rigid2D.velocity=newVector2(0.0f,5.0f);this.flysound.PlayOnCollisionEnter2D(Collision2Dother)tagother.coll
7、ider.tag;if(tag=pipecollider|tag=floor)this.hitsound.Playthis.diedie()GameOverScene 7. GameSceneScript GameSceneScriptGameObjectpipes=null;this.pipesGameObject.FindGameObjectsWithTagpipeStartCoroutineIntervalCalleeStartOnePipe()(inti0;pipes.Length;i+)pipe=this.pipesi.GetComponentpipe.IsUpdating)pipe
8、.restartIEnumeratorIntervalCallee()/counterintervalGameManager.Instance.RestartInterval;yieldWaitForSeconds(interval);this.StartOnePipe8. ScroeTriggerScript ScroeTriggerScriptTextTextScore=null;scoresoundthis.TextScoreTextScore).GetComponentthis.scoresoundOnTriggerExit2D(Collider2D(other.namebird)GameManager.Instance.ScroeUp().ToStringthis.TextScore.textScore:+this.scoresound.Play();9. GameOverScene GameOverScenetimeTextThisTimetime.text本次成绩:+GameManager.Instance.Score.ToString();TextRecordrecord.text记录:GameManager.Instance.GetRecord().ToString();GameManager.Instance.UpdateScore
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1