public static void Initialize () { gameCanvas = GameObject.Find("Level Canvas"); popUpTextZombie = Resources.Load<FloatingText>("Prefabs/PopupTextZombie"); popUpTextPlayer = Resources.Load<FloatingText>("Prefabs/PopupTextPlayer"); popUpCritText = Resources.Load<FloatingText>("Prefabs/PopupCritText"); gunBlast = Resources.Load<WeaponGFX>("Prefabs/GunBlast"); clubSwing = Resources.Load<WeaponGFX>("Prefabs/ClubSwing"); knifeStab = Resources.Load<WeaponGFX>("Prefabs/KnifeStab"); }
public void EquipWeapon(GameObject weapon) { //if (currentWeapon != null) //{ // Debug.Log("Destroying the previous weapon"); // affD // Destroy(currentWeapon.transform); //} GameObject weaponIns = (GameObject)Instantiate(weapon, weaponHolder.position, weaponHolder.rotation); currentWeapon = weaponIns.GetComponent <PlayerWeapon>(); weaponIns.transform.SetParent(weaponHolder); currentGFX = weaponIns.GetComponent <WeaponGFX>(); if (currentGFX == null) { Debug.LogError("No weaponGFX component on the weapon object " + weaponIns.name); } }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponIns = (GameObject)Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponIns.transform.SetParent(weaponHolder); currentGFX = _weaponIns.GetComponent <WeaponGFX> (); if (currentGFX == null) { Debug.LogError("No WeaponGFX component on the weapon object:" + _weaponIns.name); } if (isLocalPlayer) { Util.SetLayerRecursively(_weaponIns, LayerMask.NameToLayer(weaponLayerName)); } }