/// <summary> /// Get the maximum values for all of the missile module metrics so that missile module performance can be displayed /// as a relative value in a bar. /// </summary> /// <param name="modulePrefabs">A list of all the module prefabs available in the game.</param> /// <param name="maxSpeed">Return the max speed of any of the missiles. /// <param name="maxArmorDamage">Return the maximum armor damage that is available from a missile.</param> /// <param name="maxShieldDamage">Return the maximum shield damage that is available from a missile.</param> /// <param name="maxAgility">Return the maximum agility found for any of the missiles.</param> /// <param name="maxRange">Return the maximum range found for any of the missiles.</param> public static void GetMissileMetricsReferenceValues(List <Module> modulePrefabs, out float maxSpeed, out float maxArmorDamage, out float maxShieldDamage, out float maxAgility, out float maxRange) { maxSpeed = 0; maxArmorDamage = 0; maxShieldDamage = 0; maxAgility = 0; maxRange = 0; for (int i = 0; i < modulePrefabs.Count; ++i) { MissileWeapon missileWeapon = modulePrefabs[i].GetComponent <MissileWeapon>(); if (missileWeapon == null) { continue; } maxSpeed = Mathf.Max(missileWeapon.GetMissileSpeed(), maxSpeed); maxArmorDamage = Mathf.Max(missileWeapon.GetMissileDamage(HealthType.Armor), maxArmorDamage); maxShieldDamage = Mathf.Max(missileWeapon.GetMissileDamage(HealthType.Shield), maxShieldDamage); maxAgility = Mathf.Max(missileWeapon.GetMissileAgility(), maxAgility); maxRange = Mathf.Max(missileWeapon.GetMissileRange(), maxRange); } }
public override void ShowModuleStats(Module module) { base.ShowModuleStats(module); // If it's a missile, show missile stats MissileWeapon missileWeapon = module.GetComponent <MissileWeapon>(); if (missileWeapon != null) { for (int i = 0; i < damageStatsBars.Count; ++i) { damageStatsBars[i].gameObject.SetActive(true); damageStatsBars[i].SetFillAmount(missileWeapon.GetMissileDamage(damageStatsBars[i].HealthType) / maxDamageByHealthType[i]); } speedBar.gameObject.SetActive(true); speedBar.SetFillAmount(missileWeapon.GetMissileSpeed() / maxSpeed); agilityBar.gameObject.SetActive(true); agilityBar.SetFillAmount(missileWeapon.GetMissileAgility() / maxAgility); rangeBar.gameObject.SetActive(true); rangeBar.SetFillAmount(missileWeapon.GetMissileRange() / maxRange); } }
public override void UpdateMaxStats(List <Module> modulePrefabs) { // Reset missile max stats maxSpeed = 0; for (int i = 0; i < maxDamageByHealthType.Length; ++i) { maxDamageByHealthType[i] = 0; } // Update gun max stats for (int i = 0; i < modulePrefabs.Count; ++i) { MissileWeapon missileWeapon = modulePrefabs[i].GetComponent <MissileWeapon>(); if (missileWeapon != null) { // Update the missile speed maxSpeed = Mathf.Max(missileWeapon.GetMissileSpeed(), maxSpeed); // Update the missile agility maxAgility = Mathf.Max(missileWeapon.GetMissileAgility(), maxAgility); // Update the max missile range maxRange = Mathf.Max(missileWeapon.GetMissileRange(), maxRange); // Update max damage values for each health type for (int j = 0; j < damageStatsBars.Count; ++j) { maxDamageByHealthType[j] = Mathf.Max(maxDamageByHealthType[j], missileWeapon.GetMissileDamage(damageStatsBars[j].HealthType)); } } } }
/// <summary> /// Called when the player clicks on a module item in the loadout menu. /// </summary> /// <param name="newModuleIndex">The index of the newly selected module in the menu</param> /// <param name="playAudio">Whether to play the sound effect for module selection.</param> public void SelectModule(int newModuleIndex, bool playAudio = true) { if (newModuleIndex == -1) { displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountModule(-1); } else { // Update the module being displayed at the mount for (int i = 0; i < displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountableModules.Count; ++i) { if (displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountableModules[i].modulePrefab == itemManager.modulePrefabs[newModuleIndex]) { displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountModule(i); } } } int mountedIndex = displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountedModuleIndex; if (mountedIndex != -1) { Module modulePrefab = displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountableModules[mountedIndex].modulePrefab; focusedModuleItemIndex = itemManager.modulePrefabs.IndexOf(modulePrefab); } else { focusedModuleItemIndex = -1; } // Update the module menu moduleMenuController.OnSelectModule(focusedModuleItemIndex); weaponInfoParent.SetActive(focusedModuleItemIndex != -1); weaponArmorDamageBar.DisableBar(); weaponShieldDamageBar.DisableBar(); weaponSpeedBar.DisableBar(); weaponAgilityBar.DisableBar(); weaponRangeBar.DisableBar(); // Update the module metrics if (focusedModuleItemIndex != -1) { Module module = itemManager.modulePrefabs[focusedModuleItemIndex].GetComponent <Module>(); if (module == null) { return; } moduleName.text = module.Label; moduleDescription.text = module.Description; GunWeapon gunWeapon = module.GetComponent <GunWeapon>(); if (gunWeapon != null) { weaponArmorDamageBar.SetValue(gunWeapon.GetDamage(HealthType.Armor) / maxGunArmorDamage); weaponArmorDamageBar.EnableBar(); weaponShieldDamageBar.SetValue(gunWeapon.GetDamage(HealthType.Shield) / maxGunShieldDamage); weaponShieldDamageBar.EnableBar(); weaponSpeedBar.SetValue(gunWeapon.GetSpeed() / maxGunSpeed); weaponSpeedBar.EnableBar(); } MissileWeapon missileWeapon = module.GetComponent <MissileWeapon>(); if (missileWeapon != null) { weaponArmorDamageBar.SetValue(missileWeapon.GetMissileDamage(HealthType.Armor) / maxMissileArmorDamage); weaponArmorDamageBar.EnableBar(); weaponShieldDamageBar.SetValue(missileWeapon.GetMissileDamage(HealthType.Shield) / maxMissileShieldDamage); weaponShieldDamageBar.EnableBar(); weaponSpeedBar.SetValue(missileWeapon.GetMissileSpeed() / maxMissileSpeed); weaponSpeedBar.EnableBar(); weaponAgilityBar.SetValue(missileWeapon.GetMissileAgility() / maxMissileAgility); weaponAgilityBar.EnableBar(); weaponRangeBar.SetValue(missileWeapon.GetMissileRange() / maxMissileLockingRange); weaponRangeBar.EnableBar(); } } if (playAudio) { PlayMenuAudio(); } }