private void Start()
    {
        currentWeaponScript = GetComponent <IWeaponAction>();
        playerController    = this.transform.parent.parent.GetComponent <PlayerController>();
        gunShootScript      = GetComponent <ClassicGunShoot>();

        currentWeaponScript.OnShoot += ShootShoddyBarrels;
    }
Пример #2
0
 void UnequipCurrentWeapon()
 {
     if (weaponHolder.childCount > 0)
     {
         currentWeapon = 0;
         Destroy(weaponHolder.GetChild(0).gameObject);
         currentSpawnedWeaponPrefab   = null;
         currentSpawnedWeaponRenderer = null;
         currentWeaponAction          = null;
     }
 }
Пример #3
0
    public void EquipWeapon(int weaponId)
    {
        UnequipCurrentWeapon();
        GameManager.instance.SetPlayerEquipWeaponDisplay(GameManager.instance.GetPlayerId(this.gameObject), weaponId);
        currentWeapon = weaponId;

        WeaponInfo weaponToEquip = GameManager.instance.weaponDatabase.allWeapons[weaponId];

        if (weaponToEquip.weaponPrefab != null)
        {
            currentSpawnedWeaponPrefab = Instantiate(weaponToEquip.weaponPrefab, weaponHolder);
        }
        currentWeaponAction          = currentSpawnedWeaponPrefab.GetComponent <IWeaponAction>();
        currentSpawnedWeaponRenderer = currentSpawnedWeaponPrefab.GetComponent <SpriteRenderer>();
        GetComponent <PlayerHealth>().SetMaxHealth(weaponId);
        maxAmmo     = weaponToEquip.ammoCount;
        currentAmmo = maxAmmo;
        RefreshAmmoDisplay();
    }
Пример #4
0
 public void Fire(IWeaponAction gun)
 {
     gun.Fire();
 }