コード例 #1
0
        public override void UpdateMaxStats(List <Module> modulePrefabs)
        {
            // Reset gun max stats
            maxBulletSpeed = 0;
            for (int i = 0; i < maxDamageByHealthType.Length; ++i)
            {
                maxDamageByHealthType[i] = 0;
            }

            // Update gun max stats
            for (int i = 0; i < modulePrefabs.Count; ++i)
            {
                GunWeapon gunWeapon = modulePrefabs[i].GetComponent <GunWeapon>();

                if (gunWeapon != null)
                {
                    // Update the gun bullet speed
                    maxBulletSpeed = Mathf.Max(gunWeapon.GetSpeed(), maxBulletSpeed);

                    // Updeate max damage values for each health type
                    for (int j = 0; j < damageStatsBars.Count; ++j)
                    {
                        maxDamageByHealthType[j] = Mathf.Max(maxDamageByHealthType[j], gunWeapon.GetDamage(damageStatsBars[j].HealthType));
                    }
                }
            }
        }
コード例 #2
0
        public override void ShowModuleStats(Module module)
        {
            base.ShowModuleStats(module);

            GunWeapon gunWeapon = module.GetComponent <GunWeapon>();

            if (gunWeapon != null)
            {
                speedBar.gameObject.SetActive(true);
                speedBar.SetFillAmount(gunWeapon.GetSpeed() / maxBulletSpeed);

                // Update gun stats
                for (int i = 0; i < damageStatsBars.Count; ++i)
                {
                    damageStatsBars[i].gameObject.SetActive(true);
                    damageStatsBars[i].SetFillAmount(gunWeapon.GetDamage(damageStatsBars[i].HealthType) / maxDamageByHealthType[i]);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Get the maximum values for all of the gun module metrics so that gun 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 the gun (relevant only for projectile weapons).</param>
        /// <param name="maxArmorDamage">Return the maximum armor damage that is available from a gun weapon.</param>
        /// <param name="maxShieldDamage">Return the maximum shield damage that is available from a gun weapon.</param>
        public static void GetGunMetricsReferenceValues(List <Module> modulePrefabs, out float maxSpeed, out float maxArmorDamage, out float maxShieldDamage)
        {
            maxSpeed        = 0;
            maxArmorDamage  = 0;
            maxShieldDamage = 0;

            for (int i = 0; i < modulePrefabs.Count; ++i)
            {
                GunWeapon gunWeapon = modulePrefabs[i].GetComponent <GunWeapon>();
                if (gunWeapon == null)
                {
                    continue;
                }

                maxArmorDamage  = Mathf.Max(gunWeapon.GetDamage(HealthType.Armor), maxArmorDamage);
                maxShieldDamage = Mathf.Max(gunWeapon.GetDamage(HealthType.Shield), maxShieldDamage);

                maxSpeed = Mathf.Max(gunWeapon.GetSpeed(), maxSpeed);
            }
        }
コード例 #4
0
        /// <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();
            }
        }