示例#1
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        gameUnit victim = coll.gameObject.GetComponent <gameUnit>();

        if (victim)
        {
            victim.GetComponent <Rigidbody2D> ().drag = 2;
            victim.Death.Invoke();
            GameObject.Destroy(this.gameObject);
        }
        else
        {
            if (linger)
            {
                GetComponent <Rigidbody2D> ().mass = 0.1f;
                GetComponent <Rigidbody2D> ().drag = 2;
                Destroy(this.gameObject, timeOut);
                Destroy(this);
            }
            else
            {
                GameObject.Destroy(this.gameObject);
            }
        }
    }
示例#2
0
 void Awake()
 {
     ammoCount = ammo_count;
     lastFired = fireRate;
     sounds    = GetComponent <unitSounds> ();
     held      = null;
 }
示例#3
0
 public Weapon equip(gameUnit unit)
 {
     if (!held)
     {
         GetComponent <BoxCollider2D> ().enabled = false;
         transform.parent        = unit.transform;
         transform.localPosition = held_position;
         transform.localRotation = held_rotation;
         held = unit;
         return(this);
     }
     Debug.Log("Weapon " + this + " already held!");
     return(null);
 }
示例#4
0
 public void drop()
 {
     if (held)
     {
         GetComponent <BoxCollider2D> ().enabled = true;
         transform.position = transform.parent.transform.position;
         transform.rotation = transform.parent.transform.rotation;
         transform.parent   = null;
         held = null;
     }
     else
     {
         Debug.Log("Weapon " + this + " already dropped!");
     }
 }