//attacks with the equipped melee public void Swing() { if (EquippedMelee != null) { EquippedMelee.Swing(); } }
//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); } }
//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); } }