public void ChangeWeapon(WeaponName newWeapon, int amountOfAmmo) { //find weaopn foreach (WeaponComponent weapon in weapons) { if (weapon.name == newWeapon) { if (weapon.grade == WeaponGrade.Primary) { if (primaryWeapon) { primaryWeapon.gameObject.SetActive(false); } primaryWeapon = weapon; primaryWeapon.gameObject.SetActive(true); } if (weapon.grade == WeaponGrade.Secondary) { if (secondaryWeapon) { secondaryWeapon.gameObject.SetActive(false); } secondaryWeapon = weapon; secondaryWeapon.gameObject.SetActive(true); weaponsBar.SetShots(amountOfAmmo); } return; } } }
// Use this for initialization void Start () { // PowerUpSpawner.PowerUpCollected += powerUpCollected; weapons = GetComponentsInChildren<WeaponComponent>(); DisableAllWeapons(); player = transform.parent.gameObject.GetComponent<FirstPersonController>(); weaponsBar = player.GetComponentInChildren<SpecialWeaponsBar>(); weaponsBar.SetShots (0); ChangeWeapon(startPrimaryWeapon); ChangeWeapon(startSecondaryWeapon, 5); }
// Use this for initialization void Start() { // PowerUpSpawner.PowerUpCollected += powerUpCollected; weapons = GetComponentsInChildren <WeaponComponent>(); DisableAllWeapons(); player = transform.parent.gameObject.GetComponent <FirstPersonController>(); weaponsBar = player.GetComponentInChildren <SpecialWeaponsBar>(); weaponsBar.SetShots(0); ChangeWeapon(startPrimaryWeapon); ChangeWeapon(startSecondaryWeapon, 5); }