using UnityEngine;
using System.Collections;
public class beam : MonoBehaviour {
public int base_x=0;
public int base_y=0;
private float tim=0;
void Start () {}
void Update () {
tim+=Time.deltaTime;
if(tim>2){
self_des();
}
}
void init(int Eforce,int Ecost,string Etype){
gameObject.name="w";
GameObject scripto = GameObject.Find("script");
My_GUI goScript;
goScript=(My_GUI)scripto.GetComponent(typeof(My_GUI));
bool allow=false;
switch(Etype){
case "m":
if(goScript.ENG_L>=0&&goScript.ENG_R>=0){
goScript.ENG_L-=Ecost/2;
goScript.ENG_R-=Ecost/2;
allow=true;
}
break;
case "l":
if(goScript.ENG_L>=0){
goScript.ENG_L-=Ecost;
allow=true;
}
break;
case "r":
if(goScript.ENG_R>=0){
goScript.ENG_R-=Ecost;
allow=true;
}
break;
}
if(allow){
gameObject.rigidbody.velocity = transform.TransformDirection (Vector3.forward*Eforce);
}else{
self_des();
}
}
void self_des(){
Destroy (gameObject);
}
void OnCollisionEnter(Collision collision) {
Debug.Log("hit!"+collision.gameObject.name);
if(collision.gameObject.name!="w"){
self_des();
}
}
}
2011年3月19日 星期六
子彈試作
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言