Problem with my weapons switch statement C#

Found the answer. Just have to make the gun stop shooting when I press the button.

	void OnGUI()
	{

		if(GUI.Button(new Rect(250, 10, 50, 30), "SemiAuto22"))
		{
			gunType = GunType.SemiAuto22;
			Guns ();
		}
	}

My enum GunType determines the stats of the gun. Some of the stats have no meaning at the moment. Right now the only stats that affect anything are

rpm(rounds per minute),

maxMagSize(the maximum rounds the gun can have),

magSize(the current rounds of the gun),

and secondsBetweenShots.

The problem im having is exactly where to put my method Guns(). The only issue im noticing at the moment is that if I put Guns() in the start method, the GunTypes variables wont change if I try to change my weapon in runtime. If I try to put it in my Update method, the GunTypes ammo will constantly refill. And if I put it in my Shoot() method everytime I pull the trigger the ammo refills.

Im sure there is a way to get this to work I just cant figure it out.

This is where I declare my enum and its variables before the start method

public enum GunType 
	{
		Revolver22 = 0,
		SemiAuto22 = 1,
		SemiAuto9mil = 2
	};

	public GunType gunType = GunType.Revolver22;
	public float rpm;
	public float maxMagSize;
	public float magSize;
	public float damage;
	public float cost;

My guns method

void Guns()
	{
		switch(gunType)
		{
		case GunType.Revolver22:
			rpm = 90;
			maxMagSize = 8;
			magSize = 8;
			damage = 3;
			cost = 0;
			secondsBetweenShots = 60/rpm;
			break;
		case GunType.SemiAuto22:
			rpm = 120;
			maxMagSize = 12;
			magSize = 12;
			damage = 3;
			cost = 25;
			secondsBetweenShots = 60/rpm;
			break;
		case GunType.SemiAuto9mil:
			rpm = 120;
			maxMagSize = 12;
			magSize = 10;
			damage = 5;
			cost = 75;
			secondsBetweenShots = 60/rpm;
			break;
		}
	}

How my shooting works

public void Shoot()
	{

		if(CanShoot())
		{
			Ray ray = new Ray(spawn.position,spawn.forward);
			RaycastHit hit;

			float shotDistance = 200;

			if (Physics.Raycast(ray,out hit,shotDistance))
			{
				shotDistance = hit.distance;
				if(hit.collider.gameObject.tag == "Enemy")
				{
					///Something Needs to happen here.
					hit.collider.gameObject.SendMessage("DamageEnemy", 2);
					Debug.Log("You Hit an Enemy");
				}
				
			}

			nextPossibleShootTime = Time.time + secondsBetweenShots;

			audio.Play();

			if (tracer)
			{
			StartCoroutine("RenderTracer", ray.direction * shotDistance);
			}

			Rigidbody newShell = Instantiate(shell,chamber.position,Quaternion.identity) as Rigidbody;
			newShell.AddForce(chamber.forward * Random.Range (150f,200f) + spawn.forward * Random.Range(-10f,10f));

			magSize -=1;
		}
	}

	private bool CanShoot()
	{
		bool canShoot = false;
		if (magSize > 0)
		{
			 canShoot = true;
			if(Time.time < nextPossibleShootTime)
			{
				canShoot = false;
			}
		}
		else 
		{
			Reload();
		}
		return canShoot;
	}

	private void Reload()
	{
		magSize = maxMagSize;
	}

Guns should be inside the update method, inside an if statement that checks if the user has pressed the change gun key.

Guns should also be called ChangeGun. Make your method names specific, you will regret not doing so later.

According to the logic you are trying to accomplish, I don’t think the magSize should be placed in the cases of the switch-case.

The magSize variable I gather will change when the player shoots and your switch case is meant to be only for the purpose of switching between weapon types.
So it is better that you remove that from the switch-case part. Your logic construction is not accurate.
When the switch-case initiates your weapons will also take in the magSize value that you have determined in the cases.
I think you should either considering a struct for weapon types or object classes so as to selectively call on variables dynamically.
Then you can make the magSize variable either static according to your needs or simply use the switch case for switching between weapons.
Hope this helps…

Doing this worked perfectly. Just have to make the gun not shoot when pressing the button.

	void OnGUI()
	{

		if(GUI.Button(new Rect(250, 10, 50, 30), "SemiAuto22"))
		{
			gunType = GunType.SemiAuto22;
			Guns ();
		}
	}