private int weaponIndex; //the current index of the weapon array #endregion Fields #region Constructors public WeaponManager() { weaponsAvailable = new Weapon[WeaponManager.WEAPONS_AVAILABLE]; weaponsAvailable[0] = new BasicSword(1); weaponsAvailable[1] = new SwordOfTruth(0); weaponsAvailable[2] = new KnightSword(0); weaponsAvailable[3] = new WhirlwindAxe(0); weaponIndex = 0; currentWeapon = weaponsAvailable[weaponIndex]; }
// Constructor to load from save file with levels on weapons public WeaponManager(int[] weaponsLevels, int equippedWeapon) { weaponsAvailable = new Weapon[WeaponManager.WEAPONS_AVAILABLE]; weaponsAvailable[0] = new BasicSword(weaponsLevels[0]); weaponsAvailable[1] = new SwordOfTruth(weaponsLevels[1]); weaponsAvailable[2] = new KnightSword(weaponsLevels[2]); weaponsAvailable[2] = new WhirlwindAxe(weaponsLevels[3]); weaponIndex = equippedWeapon; currentWeapon = weaponsAvailable[weaponIndex]; }
//method for the drop at the end of the level //return the droping weapon or null if the player don't got a weapon public static Weapon getWeaponDrop(int level) { Weapon returnValue = null; int randomType = Random.Range(0, 100); int randomWeapon = Random.Range(0, 100); if (randomType < 5) { returnValue = new SwordOfTruth(level); } else if (randomType < 25) { if (randomWeapon < 50) returnValue = new KnightSword(level); else returnValue = new WhirlwindAxe(level); } else { returnValue = new BasicSword(level); } return returnValue; }