public class GameManage : MonoBehaviour {
public int lifeTime = 0;//我方生命值
public int score=0;//分数
需要定义个公共的静态变量
public static GameManage instance;
public Player player;
void Start ()
{
instance = this;//调用本身
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();//通过标签过得player组件上的脚本
}
void OnGUI()
{
lifeTime = player.i;
GUI.Label(new Rect(20,30,100,20),"生命值为:"+lifeTime);
GUI.Label(new Rect(20, 70, 100, 20), "分数:"+score);
}
}
yield return new WaitForSeconds(1f);//开始等待5秒
Vector3 pos = new Vector3(Random.Range(-4, 4), -10.98809f, -14.5748f); //敌机位置的随机出现
GameObject.Instantiate(go, pos, transform.rotation);//随机位置克隆敌机
yield return new WaitForSeconds(2f);//每隔两秒克隆1个
}
6464

被折叠的 条评论
为什么被折叠?



