void SetAmmo()
 {
     ammo = GetComponentInChildren <WeaponAmmo>();
     // ammoString = player.ammo.ToString() + " / " + player.maxAmmo.ToString();
     ammoCount.text = ammo.currentMag.ToString() + " / " + ammo.currentReserveAmmo.ToString();
     // ammoCount.text = ammoString;
 }
    // Start is called before the first frame update
    void Start()
    {
        ammo              = GetComponentInChildren <WeaponAmmo>();
        health            = GetComponentInParent <Health>();
        hitmarker.enabled = false;

        weaponHolder  = GameObject.Find("WeaponHolder");
        managerObject = GameObject.FindGameObjectWithTag("GameManager");
        managerScript = managerObject.GetComponent <GameManager>();
        waveText      = GetComponentInChildren <TextMeshProUGUI>();
        waveScript    = managerObject.GetComponent <waveScript>();

        dmgOverlay.enabled = false;

        completionText1.enabled = false;
        completionText2.enabled = false;
        completionText3.enabled = false;
        completionText4.enabled = false;

        if (managerScript.isArena)
        {
            waveScript.waveText = waveText;
            waveText.enabled    = true;
        }
        else
        {
            waveText.enabled = false;
        }
    }
Example #3
0
 void Awake()
 {
     _weaponAmmo = transform.GetComponent <WeaponAmmo>();
     _controller = GetComponentInParent <SteamVR_TrackedController>();
     _controller.TriggerClicked += (sender, eventArgs) => TryFire();
     _controller.Gripped        += (sender, eventArgs) => _weaponAmmo.Reload();
     _weaponAmmo.Reload();
 }
Example #4
0
 public void Reload()
 {
     if (WeaponAmmo != null)
     {
         if (useMagasine)
         {
             WeaponAmmo.RefillAmmo();
         }
     }
 }
Example #5
0
    void OnTriggerEnter(Collider PlayerCollision)
    {
        if (PlayerCollision.gameObject.tag.Equals("Player"))
        {
            ChangingGun playerGun = PlayerCollision.gameObject.GetComponent <ChangingGun> ();


            foreach (ChangingGun.BlockAnimation nGun in playerGun.EntAnimList)
            {
                if (nGun.animationName.Equals("HandsGun"))
                {
                    WeaponAmmo AmmoGun = nGun.gameObjForAnimator.GetComponent <WeaponAmmo> ();
                    AmmoGun.Magazine += 5;
                }

                if (nGun.animationName.Equals("HandsShootgun"))
                {
                    WeaponAmmo AmmoShootgun = nGun.gameObjForAnimator.GetComponent <WeaponAmmo> ();
                    AmmoShootgun.Magazine += 36;
                }

                if (nGun.animationName.Equals("HandsTommyGun"))
                {
                    WeaponAmmo AmmoTommyGun = nGun.gameObjForAnimator.GetComponent <WeaponAmmo> ();
                    AmmoTommyGun.Magazine += 5;
                }

                if (nGun.animationName.Equals("HandsFNScar"))
                {
                    WeaponAmmo AmmoFNScar = nGun.gameObjForAnimator.GetComponent <WeaponAmmo> ();
                    AmmoFNScar.Magazine += 5;
                }

                if (nGun.animationName.Equals("HandsGrenadeGun"))
                {
                    WeaponAmmo AmmoGrenadeGun = nGun.gameObjForAnimator.GetComponent <WeaponAmmo> ();
                    AmmoGrenadeGun.Magazine += 3;
                }

                if (nGun.animationName.Equals("HandsGrenade"))
                {
                    WeaponAmmo AmmoGrenade = nGun.gameObjForAnimator.GetComponent <WeaponAmmo> ();
                    AmmoGrenade.bulletCount += 5;
                }

                if (nGun.animationName.Equals("HandsSniperRifle"))
                {
                    WeaponAmmo AmmoSniperRifle = nGun.gameObjForAnimator.GetComponent <WeaponAmmo> ();
                    AmmoSniperRifle.Magazine += 5;
                }
            }

            Destroy(this.gameObject);
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            // get the weapons of the player, even if they are inactive

            Pistol       pistol  = player.GetComponentInChildren(typeof(Pistol), true) as Pistol;
            AssaultRifle rifle   = player.GetComponentInChildren(typeof(AssaultRifle), true) as AssaultRifle;
            Shotgun      shotgun = player.GetComponentInChildren(typeof(Shotgun), true) as Shotgun;

            if (ammoSprite == sprites[0])
            {
                WeaponAmmo ammo = pistol.GetComponent <WeaponAmmo>();
                if (ammo.currentReserveAmmo != ammo.maxReserveAmmo)
                {
                    pickUpSound.Play();
                    ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag);
                    if (ammo.currentReserveAmmo > ammo.maxReserveAmmo)
                    {
                        ammo.currentReserveAmmo = ammo.maxReserveAmmo;
                    }
                    StartCoroutine(DeleteObject());
                }
            }
            else if (ammoSprite == sprites[1])
            {
                WeaponAmmo ammo = rifle.GetComponent <WeaponAmmo>();
                if (ammo.currentReserveAmmo != ammo.maxReserveAmmo)
                {
                    pickUpSound.Play();
                    ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag);
                    if (ammo.currentReserveAmmo > ammo.maxReserveAmmo)
                    {
                        ammo.currentReserveAmmo = ammo.maxReserveAmmo;
                    }
                    StartCoroutine(DeleteObject());
                }
            }
            else if (ammoSprite == sprites[2])
            {
                WeaponAmmo ammo = shotgun.GetComponent <WeaponAmmo>();
                if (ammo.currentReserveAmmo != ammo.maxReserveAmmo)
                {
                    pickUpSound.Play();
                    ammo.currentReserveAmmo = ammo.currentReserveAmmo + (ammoMultiplier * ammo.maxMag);
                    if (ammo.currentReserveAmmo > ammo.maxReserveAmmo)
                    {
                        ammo.currentReserveAmmo = ammo.maxReserveAmmo;
                    }
                    StartCoroutine(DeleteObject());
                }
            }
        }
    }
Example #7
0
 public void RemoveAmmoFromInventory(WeaponAmmo weaponType)
 {
     if (weaponType == WeaponAmmo.Pistol)
     {
         pistolAmmo--;
     }
     else
     {
         rifleAmmo--;
     }
 }
Example #8
0
    void Awake()
    {
        int i;

        a = this;
        for (i = 0; i < 16; i++)
        {
            a.wepAmmo[i]                  = 0;
            a.wepAmmoSecondary[i]         = 0;
            a.currentEnergyWeaponState[i] = energyWeaponStates.Ready;
        }
    }
Example #9
0
 public void AddAmmoToInventory(WeaponAmmo weaponType, int ammo)
 {
     currentUsedWeapon = weaponType;
     if (weaponType == WeaponAmmo.Pistol)
     {
         pistolAmmo += ammo;
     }
     else
     {
         rifleAmmo += ammo;
     }
 }
Example #10
0
    protected virtual void RequestShot()
    {
        if (!CanShoot)
        {
            return;
        }

        if (useRecoil)
        {
            Recoil();
        }

        WeaponAmmo.ConsumeAmmo();
    }
Example #11
0
    /// <summary>
    /// Throw the grenade
    /// </summary>
    /// <param name="elapsedTime">Elapsed time between the pression and the release of the button</param>
    public override void Shoot(int elapsedTime)
    {
        Vector2 direction = GetMouseDirection();

        this.Load();

        grenadeHolder.RemoveChild(WeaponAmmo);
        GetTree().GetRoot().AddChild(WeaponAmmo);
        WeaponAmmo.SetGlobalPosition(grenadeHolder.GlobalPosition);

        Grenade grenade = WeaponAmmo as Grenade;

        grenade.Launch(direction, elapsedTime * STRENGTH_FACTOR);
    }
Example #12
0
    /// <summary>
    /// Shoot the ammo
    /// </summary>
    /// <param name="elapsedTime">Time elasped between the pression and the release of the button</param>
    public override void Shoot(int elapsedTime)
    {
        Vector2 direction = GetMouseDirection();

        this.Load();

        rifleHolder.RemoveChild(WeaponAmmo);
        GetTree().GetRoot().AddChild(WeaponAmmo);
        WeaponAmmo.SetGlobalPosition(rifleHolder.GlobalPosition);

        RifleAmmo rifleAmmo = WeaponAmmo as RifleAmmo;

        rifleAmmo.Launch(direction, STRENGTH_FACTOR);
    }
Example #13
0
    // Makes our weapon start shooting
    protected virtual void RequestShot()
    {
        if (!CanShoot)
        {
            return;
        }

        if (useRecoil)
        {
            Recoil();
        }

        animator.SetTrigger(weaponUseParameter);
        WeaponAmmo.ConsumeAmmo();
        //muzzlePS.Play();
    }
    /// <summary>
    /// Shoot the rocket
    /// </summary>
    /// <param name="elapsedTime">Elapsed time between the pression and the release of the button</param>
    public override void Shoot(int elapsedTime)
    {
        Vector2 direction = GetMouseDirection();

        this.Load();

        // Remove the rocket from the launcher and set it in the scene as a child of root
        rocketHolder.RemoveChild(WeaponAmmo);
        GetTree().GetRoot().AddChild(WeaponAmmo);
        WeaponAmmo.SetGlobalPosition(rocketHolder.GlobalPosition);

        // Launch the rocket (apply force)
        Rocket rocket = WeaponAmmo as Rocket;

        rocket.Launch(direction, elapsedTime * STRENGTH_FACTOR);
    }
Example #15
0
    // Start is called before the first frame update
    void Start()
    {
        playerCam = GetComponentInParent <Camera>();
        ammo      = GetComponent <WeaponAmmo>();
        stats     = GetComponent <WeaponStats>();
        hud       = GetComponentInParent <PlayerHUD>();

        AudioSource[] sources = GetComponentsInChildren <AudioSource>();

        gunAudio  = sources[0];
        gunShoot  = sources[0].clip;
        gunReload = sources[1].clip;
        gunEmpty  = sources[2].clip;

        muzzle = GetComponentInChildren <ParticleSystem>();

        isReloading = false;
    }
Example #16
0
    void Start()
    {
        healthController.onHeal     += Flee;
        healthController.onStopHeal += StopFlee;
        leftBorder  = transform.GetChild(0).position.x;
        rightBorder = transform.GetChild(1).position.x;
        up          = transform.GetChild(0).position.y;
        down        = transform.GetChild(1).position.y;
        if (MainMenu.difficulty == 2)
        {
            enemiesThisRoundPistol = 2;
        }
        if (MainMenu.difficulty == 3)
        {
            enemiesThisRoundPistol     = 2;
            enemiesThisRoundMachineGun = 3;
        }

        WeaponAmmo pistolAmmoDrop     = enemyPistol.GetComponent <Enemy_Controller>().ammoDrop;
        WeaponAmmo machineGunAmmoDrop = enemyMachineGun.GetComponent <Enemy_Controller>().ammoDrop;

        switch (MainMenu.difficulty)
        {
        case 1:
            pistolAmmoDrop.ammo     = 5;
            machineGunAmmoDrop.ammo = 5;
            break;

        case 2:
            pistolAmmoDrop.ammo     = 4;
            machineGunAmmoDrop.ammo = 4;
            break;

        case 3:
            pistolAmmoDrop.ammo     = 3;
            machineGunAmmoDrop.ammo = 3;
            break;
        }

        StartNextRound();
    }
Example #17
0
    protected virtual void RequestShot()
    {
        /*GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
         * Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();
         * rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);*/

        if (!CanShoot)
        {
            return;
        }

        if (useRecoil)
        {
            Recoil();
        }

        Debug.Log("Shooting");
        WeaponAmmo.ConsumeAmmo();
        Recoil();

        CanShoot = false;
    }
Example #18
0
 private void StartShooting()
 {
     if (useMagasine)
     {
         if (WeaponAmmo != null)
         {
             if (WeaponAmmo.CanUseWeapon())
             {
                 RequestShot();
             }
             else
             {
                 if (autoReload)
                 {
                     Reload();
                 }
             }
         }
     }
     else
     {
         RequestShot();
     }
 }
Example #19
0
 // Makes our weapon start shooting
 // If using magazine, check for ammo. If no ammo, don't shoot.
 // If weapon doesn't use ammo at all, go nuts. Shoot.
 private void StartShooting()
 {
     if (useMagazine)
     {
         if (WeaponAmmo != null)
         {
             if (WeaponAmmo.CanUseWeapon()) // If ammo > 0.
             {
                 RequestShot();
             }
             else // If no ammo
             {
                 if (autoReload)
                 {
                     Reload();
                 }
             }
         }
     }
     else
     {
         RequestShot();
     }
 }
Example #20
0
 /// <summary>
 /// Sets the "backpack" ammo ammount, the ammo the players carries around.
 /// </summary>
 /// <param name="player">
 /// the player <see cref="Player"/>
 /// </param>
 /// <param name="ammoType">
 /// The weaponammo type <see cref="WeaponAmmo"/>
 /// </param>
 /// <param name="amount">
 /// amount of ammo <see cref="System.Int32"/>
 /// </param>
 public static void SetAmmo(this Player player, WeaponAmmo ammoType, int ammount)
 {
     player.SetPrivateData(CounterStrikeOffset.Ammo.awm + (int)ammoType, ammount);
 }
Example #21
0
 /// <summary>
 /// Gets the ammount of ammo the player carries around.
 /// </summary>
 /// <param name="player">
 /// The player <see cref="Player"/>
 /// </param>
 /// <param name="ammoType">
 /// The ammo type <see cref="WeaponAmmo"/>
 /// </param>
 /// <returns>
 /// The amount of ammo <see cref="System.Int32"/>
 /// </returns>
 public static int GetAmmo(this Player player, WeaponAmmo ammoType)
 {
     return player.GetPrivateData(CounterStrikeOffset.Ammo.awm + (int)ammoType);
 }
Example #22
0
 private void Start()
 {
     time = secondsBetweenShoot;
     ammo = GetComponent <WeaponAmmo>();
 }
Example #23
0
 void Start()
 {
     animator = GetComponent <Animator> ();
     Ammo     = GetComponent <WeaponAmmo> ();
 }
Example #24
0
 //Set ammo from select weapon
 public void SetAmmo(WeaponAmmo newAmmo)
 {
     Ammo = newAmmo;
 }
Example #25
0
 public static void SendAmmo(this Player player, WeaponAmmo ammoType, int ammount)
 {
     player.SendAmmo(ammoType, (byte)ammount);
 }
Example #26
0
 /// <summary>
 /// Gets the ammount of ammo the player carries around.
 /// </summary>
 /// <param name="player">
 /// The player <see cref="Player"/>
 /// </param>
 /// <param name="ammoType">
 /// The ammo type <see cref="WeaponAmmo"/>
 /// </param>
 /// <returns>
 /// The amount of ammo <see cref="System.Int32"/>
 /// </returns>
 public static int GetAmmo(this Player player, WeaponAmmo ammoType)
 {
     return(player.GetPrivateData(CounterStrikeOffset.Ammo.awm + (int)ammoType));
 }
Example #27
0
    public int GetCurrentAmmo(WeaponAmmo weaponType)
    {
        int ammo = weaponType == WeaponAmmo.Pistol ? pistolAmmo : rifleAmmo;

        return(ammo);
    }
Example #28
0
 void Awake()
 {
     Instance = this;
     PV       = GetComponentInParent <PhotonView>();
     wp       = GetComponentInChildren <weapon>();
 }
Example #29
0
 void Start()
 {
     Ammo = GetComponent <WeaponAmmo> ();
     plrBehavior.SetAmmo(Ammo);
     CurAnimator = GetComponent <Animator> ();
 }
Example #30
0
 public static void SendAmmo(this Player player, WeaponAmmo ammoType, byte ammount)
 {
     player.SetAmmo(ammoType, ammount);
     player.SendAmmoXMessage((byte)ammoType, ammount);
 }
Example #31
0
 void Awake()
 {
     animator = plBehaviorContr.CurAnimator;
     Ammo     = plBehaviorContr.Ammo;
 }
Example #32
0
 /// <summary>
 /// Sets the "backpack" ammo ammount, the ammo the players carries around.
 /// </summary>
 /// <param name="player">
 /// the player <see cref="Player"/>
 /// </param>
 /// <param name="ammoType">
 /// The weaponammo type <see cref="WeaponAmmo"/>
 /// </param>
 /// <param name="amount">
 /// amount of ammo <see cref="System.Int32"/>
 /// </param>
 public static void SetAmmo(this Player player, WeaponAmmo ammoType, int ammount)
 {
     player.SetPrivateData(CounterStrikeOffset.Ammo.awm + (int)ammoType, ammount);
 }
Example #33
0
 public static void SendAmmo(this Player player, WeaponAmmo ammoType, byte ammount)
 {
     player.SetAmmo(ammoType, ammount);
     player.SendAmmoXMessage((byte)ammoType, ammount);
 }
Example #34
0
 public static void SendAmmo(this Player player, WeaponAmmo ammoType, int ammount)
 {
     player.SendAmmo(ammoType, (byte)ammount);
 }