コード例 #1
0
    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;
            }
        }
    }
コード例 #2
0
	// 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);

	}
コード例 #3
0
    // 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);
    }