public override void Init(UnitControl _owner) { base.Init(_owner); type = WeaponType.Ranged; projectilePrefab = gameManager.GetPrefab("Projectile"); muzzle = transform.Find("Muzzle"); GameObject muzzleFlashObj = Instantiate(gameManager.GetPrefab("MuzzleFlash"), muzzle); muzzleFlash = muzzleFlashObj.GetComponent <MuzzleFlash>(); magazine = transform.Find("Magazine"); rounds = magazineSize; if (_owner.IsPlayer) { if (hasScope) { GameObject scopeCamObj = Instantiate(gameManager.GetPrefab("ScopeCam"), muzzle); scope = scopeCamObj.AddComponent <ScopeControl>(); scopeCamObj.transform.localRotation = Quaternion.identity; } if (needsUI) { GameObject weaponUIObj = Instantiate(gameManager.GetPrefab("WeaponUI")); weaponUI = weaponUIObj.GetComponent <WeaponUI>(); weaponUI.Init(this); } } }
void Awake() { Instance = this; ItemViewer.Init(); WeaponViewer.Init(); }