Beispiel #1
0
	private bool CanShoot() {
		int numberOfAmmunition = ammunition;
		if (ammunitionLeft != GunsConstants.InfinityAmmunition()) {
			numberOfAmmunition += ammunitionLeft;
		}
		return Time.time - lastShootTime > shootTimeInterval && numberOfAmmunition != GunsConstants.EmptyMagazine();
	}
Beispiel #2
0
	public bool HasAmmoLeft() {
		int numberOfAmmunition = ammunition;
		if (ammunitionLeft != GunsConstants.InfinityAmmunition()) {
			numberOfAmmunition += ammunitionLeft;
		}
		return numberOfAmmunition == GunsConstants.EmptyMagazine() ? false : true;
	}
Beispiel #3
0
    public void AddMachinegunAmmo()
    {
        if (guns[GunsConstants.MachinegunGunType()].AmmunitionLeft == GunsConstants.EmptyMagazine() && guns[GunsConstants.MachinegunGunType()].Ammunition == GunsConstants.EmptyMagazine())
        {
            guns[GunsConstants.MachinegunGunType()].Ammunition     = GunsConstants.MachinegunMagazineCapacity();
            guns[GunsConstants.MachinegunGunType()].AmmunitionLeft = GunsConstants.MachineStartAmmunitionLeftQuantity();
        }
        else if (guns[GunsConstants.MachinegunGunType()].Ammunition == GunsConstants.EmptyMagazine())
        {
            guns[GunsConstants.MachinegunGunType()].Ammunition     += GunsConstants.MachinegunMagazineCapacity();
            guns[GunsConstants.MachinegunGunType()].AmmunitionLeft += GunsConstants.MachinegunMagazineCapacity();
        }
        else
        {
            guns[GunsConstants.MachinegunGunType()].AmmunitionLeft += GunsConstants.MachineStartAmmunitionLeftQuantity();
        }

        if (guns[GunsConstants.MachinegunGunType()].Ammunition > GunsConstants.MachinegunMagazineCapacity())
        {
            guns[GunsConstants.MachinegunGunType()].Ammunition = GunsConstants.MachinegunMagazineCapacity();
        }

        if (guns[GunsConstants.MachinegunGunType()].AmmunitionLeft > GunsConstants.MachinegunTotalAmmunitionCapacity())
        {
            guns[GunsConstants.MachinegunGunType()].AmmunitionLeft = GunsConstants.MachinegunTotalAmmunitionCapacity();
        }
    }
Beispiel #4
0
    private void CreateGuns()
    {
        Gun Pistol = new Gun();

        Pistol.Type           = GunType.Pistol;
        Pistol.AmmunitionLeft = GunsConstants.InfinityAmmunition();;
        Pistol.Ammunition     = 7;

        Gun Submachinegun = new Gun();

        Submachinegun.Type           = GunType.SubMachinegun;
        Submachinegun.AmmunitionLeft = GunsConstants.EmptyMagazine();
        Submachinegun.Ammunition     = GunsConstants.EmptyMagazine();

        Gun Machinegun = new Gun();

        Machinegun.Type           = GunType.Machinegun;
        Machinegun.AmmunitionLeft = GunsConstants.EmptyMagazine();
        Machinegun.Ammunition     = GunsConstants.EmptyMagazine();

        guns = new Gun[3];
        guns[GunsConstants.PistolGunType()]        = Pistol;
        guns[GunsConstants.SubmachinegunGunType()] = Submachinegun;
        guns[GunsConstants.MachinegunGunType()]    = Machinegun;
    }
Beispiel #5
0
	void Start () {
		isReloading = false;
		if (owner == GunOwner.Player) {
			GameHUDManager.instance.HideReloadingText();
		}

		if (Ammunition == GunsConstants.EmptyMagazine()) {
			isReloading = true;
			startReloadingTime = Time.time;
			Reload();
		}

		audio.clip = audioClip;
	}
Beispiel #6
0
    public void Restart()
    {
        if (guns == null || guns.Length == 0)
        {
            CreateGuns();
        }
        guns[GunsConstants.PistolGunType()].Ammunition            = 7;
        guns[GunsConstants.SubmachinegunGunType()].AmmunitionLeft = GunsConstants.EmptyMagazine();
        guns[GunsConstants.SubmachinegunGunType()].Ammunition     = GunsConstants.EmptyMagazine();
        guns[GunsConstants.MachinegunGunType()].AmmunitionLeft    = GunsConstants.EmptyMagazine();
        guns[GunsConstants.MachinegunGunType()].Ammunition        = GunsConstants.EmptyMagazine();

        playerLives = 1;
    }
Beispiel #7
0
	public void Shoot(int direction, string tag) {
		if (!isReloading) {
			if (CanShoot()) {
				Vector3 spawnPosition = spawnPoint.transform.position;
				Bullet firedBullet;
				firedBullet = (Instantiate(bullet, spawnPosition, Quaternion.identity) as Bullet);
				firedBullet.Shoot(direction);
				firedBullet.tag = tag;
				ammunition--;
				lastShootTime = Time.time;
				audio.Play();
				if (ammunition == GunsConstants.EmptyMagazine()) {
					isReloading = true;
					startReloadingTime = Time.time;
					if (owner == GunOwner.Player) {
						GameHUDManager.instance.ShowReloadingText();
					}
					Reload();
				} 
			}
		}
	}
Beispiel #8
0
 public Gun CurrentGun()
 {
     if (guns[GunsConstants.MachinegunGunType()].AmmunitionLeft + guns[GunsConstants.MachinegunGunType()].Ammunition > GunsConstants.EmptyMagazine())
     {
         return(guns[GunsConstants.MachinegunGunType()]);
     }
     else if (guns[GunsConstants.SubmachinegunGunType()].AmmunitionLeft + guns[GunsConstants.SubmachinegunGunType()].Ammunition > GunsConstants.EmptyMagazine())
     {
         return(guns[GunsConstants.SubmachinegunGunType()]);
     }
     else
     {
         return(guns[GunsConstants.PistolGunType()]);
     }
 }