这个游戏呢,基本是完成了,不过有点单调,所以我加了个主场景,用来控制游戏的难度,说白了就是给不同的速度给小鸟啦,废话不多说,上代码:
不,先上图片
NGUI创建不多说,先创建一个脚本
MainSceneManager.cs
using UnityEngine;
using System.Collections;
public class MainSeceneManager {
public static int gameLevel;//传递游戏难度
}
恩,写了它就别管了
然后每个按钮各有一个脚本:
using UnityEngine;
using System.Collections;
public class ChooseEasyLevel : MonoBehaviour {
public void SendLevel()
{
MainSeceneManager.gameLevel = 2;
Application.LoadLevel("StartGame");
}
}
using UnityEngine;
using System.Collections;
public class ChooseSimpelLevel : MonoBehaviour {
public void SendLevel()
{
MainSeceneManager.gameLevel = 5;
Application.LoadLevel("StartGame");
}
}
using UnityEngine;
using System.Collections;
public class ChooseHardlLevel : MonoBehaviour {
public void SendLevel()
{
MainSeceneManager.gameLevel = 8;
Application.LoadLevel("StartGame");
}
}
恩恩,说白了就是记录一个值,游戏难度的值,然后我们把这个值要变成小鸟的速度,这就需要修改下Bird.cs了
public void GetTheGameBegin()
{
currentBirdSpeed = MainSeceneManager.gameLevel;
this.rigidbody.velocity = new Vector3(currentBirdSpeed, 0, 0);
this.rigidbody.useGravity = true;
}
把Bird.cs脚本中的这个函数改一下,哦了,基本上游戏完毕了,创建声源就那几个步骤我也不写了,然后就是细节上的调试和UI了,我的发布的APK在第一遍总结中给了地址了,好了,全篇总结完毕!呼啦啦~~