//destroys any currently equipped weapon and equips a new weapon public void EquipWeapon(GameObject a_weaponToEquip) { if (EquippedGun != null) { Destroy(EquippedGun.gameObject); } else if (EquippedMelee != null) { Destroy(EquippedMelee.gameObject); } if (a_weaponToEquip.GetComponent <Melee>() != null) { EquippedMelee = Instantiate(a_weaponToEquip.GetComponent <Melee>(), WeaponHold) as Melee; EquippedMelee.transform.parent = WeaponHold; EquippedMelee.SetEntityCollisionLayer(EntityCollisionMask); EquippedMelee.SetDestroyableCollisionLayer(m_destroyableCollisionMask); } else if (a_weaponToEquip.GetComponent <Gun>() != null) { EquippedGun = Instantiate(a_weaponToEquip.GetComponent <Gun>(), WeaponHold) as Gun; EquippedGun.transform.parent = WeaponHold; EquippedGun.SetEntityCollisionLayer(EntityCollisionMask); EquippedGun.SetEnvironmentCollisionLayer(m_terrainCollisionMask); } }
//---------------------------- #region Equippers //destroys any currently equipped weapon and equips a new gun public void EquipGun(Gun a_gunToEquip) { if (EquippedGun != null) { Destroy(EquippedGun.gameObject); } else if (EquippedMelee != null) { Destroy(EquippedMelee.gameObject); } EquippedGun = Instantiate(a_gunToEquip, WeaponHold) as Gun; EquippedGun.transform.parent = WeaponHold; EquippedGun.SetEntityCollisionLayer(EntityCollisionMask); EquippedGun.SetEnvironmentCollisionLayer(m_terrainCollisionMask); EquippedGun.SetRicochetCollisionLayer(m_ricochetCollisionMask); }
//Equips a starting weapon public void Awake() { if (m_startingGun != null) { EquipGun(m_startingGun); EquippedGun.SetEntityCollisionLayer(EntityCollisionMask); EquippedGun.SetEnvironmentCollisionLayer(m_terrainCollisionMask); EquippedGun.SetRicochetCollisionLayer(m_ricochetCollisionMask); EquippedGun.SetCurrentClip(m_startingAmmo); } else if (m_startingMelee != null) { EquipMelee(m_startingMelee); EquippedMelee.SetEntityCollisionLayer(EntityCollisionMask); EquippedMelee.SetDestroyableCollisionLayer(m_destroyableCollisionMask); } }