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); } } }
void Awake() { ammoCount = ammo_count; lastFired = fireRate; sounds = GetComponent <unitSounds> (); held = null; }
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); }
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!"); } }