Exemplo n.º 1
0
        /// <summary>
        /// Called when the player clicks on a button to focus on a different module mount in the loadout menu.
        /// </summary>
        /// <param name="newMountIndex">The index of the new module mount.</param>
        public void SelectModuleMount(int moduleMountIndex)
        {
            selectedModuleMountIndex = moduleMountIndex;

            // Update the module mount
            mountMenuController.SetButtonSelected(selectedModuleMountIndex);

            // Update the module options menu
            selectableModuleIndexes = new List <int>();
            int mountedIndex = -1;

            for (int i = 0; i < displayVehicles[selectedVehicleIndex].ModuleMounts[selectedModuleMountIndex].MountableModules.Count; ++i)
            {
                int index = itemManager.modulePrefabs.IndexOf(displayVehicles[selectedVehicleIndex].ModuleMounts[selectedModuleMountIndex].MountableModules[i].modulePrefab);

                selectableModuleIndexes.Add(index);

                if (displayVehicles[selectedVehicleIndex].ModuleMounts[selectedModuleMountIndex].MountedModuleIndex == i)
                {
                    mountedIndex = index;

                    SelectModule(mountedIndex);
                }
            }

            moduleMenuController.SetVisibleButtons(selectableModuleIndexes);
            moduleMenuController.SetButtonSelected(mountedIndex);

            if (menuState == LoadoutMenuState.ModuleSelection)
            {
                ModuleMount focusedMount = selectedModuleMountIndex == -1 ? null : displayVehicles[selectedVehicleIndex].ModuleMounts[selectedModuleMountIndex];
                displayManager.FocusModuleMount(focusedMount);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when a module mount is removed from the vehicle.
        /// </summary>
        /// <param name="moduleMount">The new module mount.</param>
        public virtual void OnModuleMountRemoved(ModuleMount moduleMount)
        {
            if (moduleMount.Module() != null)
            {
                OnModuleUnmounted(moduleMount.Module());
            }

            moduleMount.onModuleMounted.RemoveListener(OnModuleMounted);
            moduleMount.onModuleUnmounted.RemoveListener(OnModuleUnmounted);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Event called when a different module mount is focused on in the loadout menu.
 /// </summary>
 /// <param name="moduleMount">The new module mount to focus on.</param>
 public void FocusModuleMount(ModuleMount moduleMount)
 {
     if (moduleMount != null)
     {
         focusedMount = moduleMount.transform;
     }
     else
     {
         focusedMount = null;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Remove a module mount from the vehicle.
        /// </summary>
        /// <param name="moduleMount">The module mount to be removed.</param>
        public virtual void RemoveModuleMount(ModuleMount moduleMount)
        {
            int index = moduleMounts.IndexOf(moduleMount);

            if (index == -1)
            {
                return;
            }

            moduleMounts.Remove(moduleMount);

            for (int i = 0; i < moduleManagers.Count; ++i)
            {
                moduleManagers[i].OnModuleMountRemoved(moduleMount);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called when the player clicks on a button to focus on a different module mount in the loadout menu.
        /// </summary>
        /// <param name="newMountIndex">The index of the new module mount.</param>
        /// <param name="playAudio">Whether to play the module mount selection sound effect.</param>
        public void SelectModuleMount(int newMountIndex, bool playAudio = true)
        {
            // If index out of range, return
            if (newMountIndex < 0 || newMountIndex >= displayVehicles[selectedVehicleIndex].ModuleMounts.Count)
            {
                return;
            }

            // Update the module mount
            focusedModuleMountIndex = newMountIndex;
            mountMenuController.OnSelectMount(focusedModuleMountIndex);

            // Update the module options menu
            selectableModuleIndexes = new List <int>();
            int mountedIndex = -1;

            for (int i = 0; i < displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountableModules.Count; ++i)
            {
                int index = itemManager.modulePrefabs.IndexOf(displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountableModules[i].modulePrefab);

                selectableModuleIndexes.Add(index);

                if (displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex].MountedModuleIndex == i)
                {
                    mountedIndex = index;

                    SelectModule(mountedIndex, false);
                }
            }

            moduleMenuController.UpdateModuleSelectionMenu(selectableModuleIndexes, mountedIndex);

            if (loadoutMenuState == LoadoutMenuState.ModuleSelection)
            {
                ModuleMount focusedMount = focusedModuleMountIndex == -1 ? null : displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex];
                displayManager.FocusModuleMount(focusedMount);
            }

            // Play menu audio
            if (playAudio)
            {
                PlayMenuAudio();
            }
        }
Exemplo n.º 6
0
        public void SetMenuState(LoadoutMenuState newState)
        {
            menuState = newState;

            if (menuState == LoadoutMenuState.VehicleSelection)
            {
                shipSelectionUI.SetActive(true);
                moduleSelectionUI.SetActive(false);
                displayManager.FocusModuleMount(null);
            }
            else
            {
                shipSelectionUI.SetActive(false);
                moduleSelectionUI.SetActive(true);

                ModuleMount focusedMount = selectedModuleMountIndex == -1 ? null : displayVehicles[selectedVehicleIndex].ModuleMounts[selectedModuleMountIndex];
                displayManager.FocusModuleMount(focusedMount);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Toggle between the vehicle and module selection modes in the loadout menu.
        /// </summary>
        /// <param name="newStateIndex">The new menu state.</param>
        public void ChangeMenuState(int newStateIndex)
        {
            loadoutMenuState = (LoadoutMenuState)newStateIndex;

            if (loadoutMenuState == LoadoutMenuState.VehicleSelection)
            {
                shipSelectionUI.SetActive(true);
                moduleSelectionUI.SetActive(false);
                displayManager.FocusModuleMount(null);
            }
            else
            {
                shipSelectionUI.SetActive(false);
                moduleSelectionUI.SetActive(true);

                ModuleMount focusedMount = focusedModuleMountIndex == -1 ? null : displayVehicles[selectedVehicleIndex].ModuleMounts[focusedModuleMountIndex];
                displayManager.FocusModuleMount(focusedMount);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Add a module mount to the vehicle.
        /// </summary>
        /// <param name="moduleMount">The module mount to be added.</param>
        public virtual void AddModuleMount(ModuleMount moduleMount)
        {
            // Find the right index to insert the module mount according to its sorting index
            int insertIndex = 0;

            for (int i = 0; i < moduleMounts.Count; ++i)
            {
                if (moduleMounts[i].SortingIndex < moduleMount.SortingIndex)
                {
                    insertIndex = i + 1;
                }
            }

            // Insert the camera view target into the list
            moduleMounts.Insert(insertIndex, moduleMount);

            for (int i = 0; i < moduleManagers.Count; ++i)
            {
                moduleManagers[i].OnModuleMountAdded(moduleMount);
            }
        }
 protected virtual void Reset()
 {
     moduleMount = GetComponent <ModuleMount>();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Called when this module is mounted at a module mount.
 /// </summary>
 /// <param name="moduleMount">The module mount this module is to be mounted at.</param>
 public virtual void Mount(ModuleMount moduleMount)
 {
     onModuleMounted.Invoke(moduleMount);
 }