//This method handles setting up the initial weapon as well as setting up everything when the Player needs to change weapons based on input protected virtual void ChangeWeapon() { //This bool makes sure that the current weapon doesn't create a pool of objects if that pool of objects already exists bool matched = new bool(); //Counts all the different weapon types in the list for (int i = 0; i < weaponTypes.Count; i++) { //If there isn't a current weapon, sets up the first weapon type in the list as the current weapon, and creates the pool for that weapon type if (currentWeapon == null) { currentWeapon = weaponTypes[0]; currentTimeBetweenShots = currentWeapon.timeBetweenShots; NewPool(); return; } //This else statement handles the logic for changing weapons after the initial weapon is loaded else { //If the current iteration value is the current weapon if (weaponTypes[i] == currentWeapon) { //Add one to the iteration value for the comment above i++; //If the iteration value is the last one in the list, we reset it back to the begining of the list if (i == weaponTypes.Count) { i = 0; } //Whatever the iteration value is, the current weapon is this iteration value in the weaponTypes list currentWeapon = weaponTypes[i]; //Restes the currentTimeBetweenShots value to the currentWeapon timeBetweenShots value currentTimeBetweenShots = currentWeapon.timeBetweenShots; } } } for (int i = 0; i < totalPools.Count; i++) { if (currentWeapon.projectile.tag == totalPools[i].tag) { projectileParentFolder = totalPools[i].gameObject; currentProjectile = currentWeapon.projectile; matched = true; } } if (currentWeapon.projectile.tag == "GrapplingHook") { grapplingHook.enabled = true; } else { grapplingHook.removed = true; grapplingHook.RemoveGrapple(); grapplingHook.enabled = false; } if (!matched) { NewPool(); } if (currentWeapon.canResetPool) { bulletsToReset.Clear(); } }