UNITY3D初学笔记



#pragma strict

function Start () 
{
	Destroy(gameObject,3.0);
}
 



#pragma strict

function Start () {

}
var speed : int = 5;
var newobject : Transform;
var sdshu:int=0;
var xmshu:int=0;

function Update () 
{
	var x :float = Input.GetAxis("Horizontal")*Time.deltaTime*speed;
	var z :float = Input.GetAxis("Vertical")*Time.deltaTime*speed;
	
	transform.Translate(x,0,z);
	//print(x);
	
	if(Input.GetButton("Fire1"))
	{
		var n:Transform = Instantiate(newobject,transform.position,transform.rotation);
		
		var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
		
		n.rigidbody.AddForce(fwd*2800);
		sdshu++;
		
		gameObject.Find("zt").GetComponent(GUIText).text="射弹数:"+sdshu+"  XiaoMianShu:"+xmshu;
		
		
	}
	
	if(Input.GetKey(KeyCode.Q))
	{
		transform.Rotate(0,-25*Time.deltaTime,0,Space.Self);
	}
	
	if(Input.GetKey(KeyCode.E))
	{
		transform.Rotate(0,25*Time.deltaTime,0,Space.Self);
	}
	
	if(Input.GetKey(KeyCode.Z))
	{
		transform.Rotate(-25*Time.deltaTime,0,0,Space.Self);
	}
	
	if(Input.GetKey(KeyCode.C))
	{
		transform.Rotate(25*Time.deltaTime,0,0,Space.Self);
	}
	
	if(Input.GetKey(KeyCode.H))
	{
		transform.Translate(0,5*Time.deltaTime,0);
	}
	
	if(Input.GetKey(KeyCode.N))
	{
		transform.Translate(0,-5*Time.deltaTime,0);
	}
	
}



#pragma strict

function Start () {

}

function Update () {

}

function OnGUI()
{
	if(GUI.Button(Rect(180,100,60,30),"tui chu"))
	{
		Application.Quit();
	}
	
	if(GUI.Button(Rect(280,100,60,30),"chong xin kai shi"))
	{
		Application.Quit();
		Application.LoadLevel("Untitled");
	}
	
	if(GUI.Button(Rect(10,160,100,50),"Play"))
	{
		audio.Play();
	}
	if(GUI.Button(Rect(10,220,100,50),"Pause"))
	{
		audio.Pause();
	}
	if(GUI.Button(Rect(10,280,100,50),"Stop"))
	{
		audio.Stop();
	}	
		
}



#pragma strict

function Start () {

}
var sd:int;
var xm:int;
function Update () 
{
	if(gameObject.transform.position.y<0){
		//Transform.Find("Main Camera").GetComponent("sheji").xmshu++;
		xm = gameObject.Find("Main Camera").GetComponent(sheji).xmshu++;
		sd = gameObject.Find("Main Camera").GetComponent(sheji).sdshu;
		gameObject.Find("zt").GetComponent(GUIText).text="射弹数:"+sd+"  消灭数:"+xm;
		
		if(xm>16)
		{
			gameObject.Find("zt").GetComponent(GUIText).text="恭喜成功了";
			gameObject.Find("Main Camera").GetComponent(sheji).enabled=false;
			gameObject.Find("dimian").GetComponent(restart).enabled = true;
			print("win");
		}
		
		
		Destroy(gameObject);
	}
}




#pragma strict

function Start () {

}

function Update () {

}

function OnCollisionEnter()
{
	gameObject.Find("zt").GetComponent(GUIText).text="aabbccddeeff";
	gameObject.Find("Directional light").GetComponent(Light).enabled = false;
	
	Destroy(gameObject);
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值