void DropWeapon() { Vector2 aimDirection = (cursor.position - transform.position).normalized; if (weapons [currentWeapon] != null && weapons [currentWeapon].name != "" && weapons [currentWeapon].name != "None") { GameObject newWeaponDrop = Instantiate(Resources.Load("WeaponDrops/" + weapons[currentWeapon].name) as GameObject, transform.position + (Vector3)aimDirection, Quaternion.Euler(0, 0, Random.Range(0, 360))); newWeaponDrop.GetComponent <Rigidbody2D> ().velocity = aimDirection * 5; newWeaponDrop.GetComponent <WeaponDrop> ().weapon = new Weapon(weapons [currentWeapon]); weaponsManager.AddWeapon(newWeaponDrop); weapons [currentWeapon].name = "None"; } }
void SelfDestruct(Collision2D coll) { selfDestructed = true; if (projectileType == ProjectileType.Bullet) { } else { if (coll.transform.gameObject.GetComponent <Goldfish> ()) { coll.transform.gameObject.GetComponent <Goldfish> ().Die(); } GameObject newWeaponDrop = (GameObject)Instantiate(weaponDrop, transform.position, transform.rotation); Destroy(newWeaponDrop.transform.GetComponent <Rigidbody2D>()); newWeaponDrop.transform.parent = coll.transform; weaponsManager.AddWeapon(newWeaponDrop); Destroy(gameObject); } }