コード例 #1
0
    /// <summary>
    /// Add the current score to the leaderboard
    /// </summary>
    private void AddCurrentScoreToLeaderboard()
    {
        float  currentScore = ScoreKeeper.CurrentScore;
        string playerName   = GameOptionsManager.GetCurrentGameOptions().playerName;

        ScoreLocalLeaderboards.AddScore(playerName, currentScore, SceneManager.GetActiveScene().name);
    }
コード例 #2
0
 /// <summary>
 /// Update the volume of this audio source to the user selected
 /// SFX volume
 /// </summary>
 private void UpdateAudioSourceVolume()
 {
     //Set the audio soruce volume to the set SFX volume
     if (playSource)
     {
         playSource.volume = GameOptionsManager.GetCurrentGameOptions().sfxVolume;
     }
 }
コード例 #3
0
    /// <summary>
    /// Load the existing game options in to options fields
    /// </summary>
    private void LoadOptionsInToUI()
    {
        //Load Options from Manager
        GameOptionsInfo loadedOptions = GameOptionsManager.GetCurrentGameOptions();

        //Load values in to ui elements
        musicVolumeSlider.value = loadedOptions.musicVolume;
        sfxVolumeSlider.value   = loadedOptions.sfxVolume;
    }
コード例 #4
0
    /// <summary>
    /// Apply the game options currently held by ui elements
    /// </summary>
    public void ApplyGameOptions()
    {
        //Convert UI Values in to GameOptions class and pass to save to file
        GameOptionsInfo pendingOptions = new GameOptionsInfo();

        pendingOptions.musicVolume = musicVolumeSlider.value;
        pendingOptions.sfxVolume   = sfxVolumeSlider.value;

        GameOptionsManager.SaveGameOptions(pendingOptions);
    }
コード例 #5
0
 void Awake()
 {
     if (!instance)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #6
0
    /// <summary>
    /// Update the music volume of future and currently
    /// playing tracks.
    /// Called by event when options are updated
    /// </summary>
    private void UpdateMusicVolume()
    {
        float newVolume = GameOptionsManager.GetCurrentGameOptions().musicVolume;

        //Set active player volume
        if (musicPlayers[activeMusicPlayerIndex])
        {
            musicPlayers[activeMusicPlayerIndex].volume = newVolume;
        }

        //Set target volume for when we are fading in songs
        targetMusicVolume = newVolume;
    }
コード例 #7
0
    /// <summary>
    /// Apply the game options currently held by ui elements
    /// Called by button press in inspector
    /// </summary>
    public void ApplyGameOptions()
    {
        //Convert UI Values in to GameOptions class and pass to save to file
        GameOptionsInfo pendingOptions = new GameOptionsInfo
        {
            musicVolume    = musicVolumeSlider.value,
            sfxVolume      = sfxVolumeSlider.value,
            playerName     = nameInput.text,
            phoneRotOffset = calibrationValues.lastCalibrationValues.eulerAngles
        };


        GameOptionsManager.SaveGameOptions(pendingOptions);
    }
コード例 #8
0
    public static void DeleteLeaderboardFile()
    {
        string optionsFile = GameOptionsManager.GetOptionsSaveLocation();

        if (File.Exists(optionsFile))
        {
            //Delete existing options file
            File.Delete(optionsFile);
            Debug.Log("[Success] Reset all options from file: " + optionsFile);

            //Save a new set of default options
            GameOptionsManager.SaveGameOptions(new GameOptionsInfo());
        }
        else
        {
            Debug.LogWarning("[Failed] Could not delete options file. Does not exist or is in use: " + optionsFile);
        }
    }
コード例 #9
0
        private void OnStartButtonClick(object sender, RoutedEventArgs e)
        {
            if (!AppContext.IsGameHost)
            {
                return;
            }

            GameLog.Client.General.DebugFormat("EmpireID-Selected={0} ", AppContext.LocalPlayer.EmpireID);

            //Federation
            if ((AppContext.LocalPlayer.Empire.Key == "FEDERATION") && (OptionsPanel.Options.FederationPlayable == EmpirePlayable.No))
            {
                MessageDialog.Show(Environment.NewLine + _resourceManager.GetString("CIV_1_NOT_IN GAME"), MessageDialogButtons.Ok);
                return;
            }

            //"Terran Empire":
            if ((AppContext.LocalPlayer.Empire.Key == "TERRANEMPIRE") && (OptionsPanel.Options.TerranEmpirePlayable == EmpirePlayable.No))
            {
                MessageDialog.Show(Environment.NewLine + _resourceManager.GetString("CIV_2_NOT_IN GAME"), MessageDialogButtons.Ok);
                return;
            }

            //"Romulans":
            if ((AppContext.LocalPlayer.Empire.Key == "ROMULANS") && (OptionsPanel.Options.RomulanPlayable == EmpirePlayable.No))
            {
                MessageDialog.Show(Environment.NewLine + _resourceManager.GetString("CIV_3_NOT_IN GAME"), MessageDialogButtons.Ok);
                return;
            }

            //"Klingons":
            if ((AppContext.LocalPlayer.Empire.Key == "KLINGONS") && (OptionsPanel.Options.KlingonPlayable == EmpirePlayable.No))
            {
                MessageDialog.Show(Environment.NewLine + _resourceManager.GetString("CIV_4_NOT_IN GAME"), MessageDialogButtons.Ok);
                return;
            }

            //"Cardassians":
            if ((AppContext.LocalPlayer.Empire.Key == "CARDASSIANS") && (OptionsPanel.Options.CardassianPlayable == EmpirePlayable.No))
            {
                MessageDialog.Show(Environment.NewLine + _resourceManager.GetString("CIV_5_NOT_IN GAME"), MessageDialogButtons.Ok);
                return;
            }

            //"Dominion":
            if ((AppContext.LocalPlayer.Empire.Key == "DOMINION") && (OptionsPanel.Options.DominionPlayable == EmpirePlayable.No))
            {
                MessageDialog.Show(Environment.NewLine + _resourceManager.GetString("CIV_6_NOT_IN GAME"), MessageDialogButtons.Ok);
                return;
            }

            //"Borg":
            if ((AppContext.LocalPlayer.Empire.Key == "BORG") && (OptionsPanel.Options.BorgPlayable == EmpirePlayable.No))
            {
                MessageDialog.Show(Environment.NewLine + _resourceManager.GetString("CIV_7_NOT_IN GAME"), MessageDialogButtons.Ok);
                return;
            }

            GameLog.Client.General.DebugFormat("EmpireID STARTING Game={0}", AppContext.LocalPlayer.EmpireID);


            if (AppContext.LobbyData.UnassignedPlayers.Any())
            {
                var result = MessageDialog.Show(
                    _resourceManager.GetString("MP_LOBBY_WARN_UNASSIGNED_PLAYERS_HEADER"),
                    _resourceManager.GetString("MP_LOBBY_WARN_UNASSIGNED_PLAYERS_MESSAGE"),
                    MessageDialogButtons.YesNo);
                if (result == MessageDialogResult.No)
                {
                    return;
                }
            }
            if (OptionsPanel.Options.GalaxySize > GalaxySize.Small)
            {
                var result = MessageDialog.Show(
                    "Warning",
                    "For performance reasons, it is highly recommended that the galaxy size"
                    + " be restricted to 'Tiny' or 'Small' for multiplayer games."
                    + "  Are you sure you want to continue?",
                    MessageDialogButtons.YesNo);
                if ((result != MessageDialogResult.None) && (result != MessageDialogResult.Yes))
                {
                    return;
                }
            }

            GameOptionsManager.SaveDefaults(OptionsPanel.Options);
            ClientCommands.StartMultiplayerGame.Execute(null);
        }
コード例 #10
0
 void OkButton_Click(object sender, RoutedEventArgs e)
 {
     GameOptionsManager.SaveDefaults(Options);
     DialogResult = true;
 }
コード例 #11
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            // first check for races available

            // aim is to have this variable, also for translation:
            // Just usage of civ and stuff in en.txt must fit manually, in en.txt Terran Empire can be translated into french "Empire"
            // only INSIDE CODE we use names like "RomulanPlayable" instead of "Civ_3_Playable"

            if (CivSelector.SelectedIndex >= 0)
            {
                switch (CivSelector.SelectedValue.ToString())
                {
                case "Federation":
                    if (Options.FederationPlayable == EmpirePlayable.No)
                    {
                        MessageDialog.Show(
                            ResourceManager.GetString("CIV_1_NOT_IN GAME"),
                            MessageDialogButtons.Ok);
                        return;
                    }
                    break;

                case "Terran Empire":
                    if (Options.TerranEmpirePlayable == EmpirePlayable.No)
                    {
                        MessageDialog.Show(
                            ResourceManager.GetString("CIV_2_NOT_IN GAME"),
                            MessageDialogButtons.Ok);
                        return;
                    }
                    break;

                case "Romulans":
                    if (Options.RomulanPlayable == EmpirePlayable.No)
                    {
                        MessageDialog.Show(
                            ResourceManager.GetString("CIV_3_NOT_IN GAME"),
                            MessageDialogButtons.Ok);
                        return;
                    }
                    break;

                case "Klingons":
                    if (Options.KlingonPlayable == EmpirePlayable.No)
                    {
                        MessageDialog.Show(
                            ResourceManager.GetString("CIV_4_NOT_IN GAME"),
                            MessageDialogButtons.Ok);
                        return;
                    }
                    break;

                case "Cardassians":
                    if (Options.CardassianPlayable == EmpirePlayable.No)
                    {
                        MessageDialog.Show(
                            ResourceManager.GetString("CIV_5_NOT_IN GAME"),
                            MessageDialogButtons.Ok);
                        return;
                    }
                    break;

                case "Dominion":
                    if (Options.DominionPlayable == EmpirePlayable.No)
                    {
                        MessageDialog.Show(
                            ResourceManager.GetString("CIV_6_NOT_IN GAME"),
                            MessageDialogButtons.Ok);
                        return;
                    }
                    break;

                case "Borg":
                    if (Options.BorgPlayable == EmpirePlayable.No)
                    {
                        MessageDialog.Show(
                            ResourceManager.GetString("CIV_7_NOT_IN GAME"),
                            MessageDialogButtons.Ok);
                        return;
                    }
                    break;
                }
            }

            _soundPlayer.Play("Menu", "LoadingGame");
            GameOptionsManager.SaveDefaults(OptionsPanel.Options);
            DialogResult = true;
        }
コード例 #12
0
 /// <summary>
 /// Sets the phones gyro offset. Used for calibration
 /// of the device so we detect up as the same
 /// as the players phone
 /// </summary>
 public static void SetDeviceGyroOffset()
 {
     phoneRotationOffset = GyroToUnity(Quaternion.Euler(GameOptionsManager.GetCurrentGameOptions().phoneRotOffset));
     Debug.Log("Set Phone Rotation:" + phoneRotationOffset.eulerAngles);
 }
コード例 #13
0
        private void RegisterViewsAndServices()
        {
            _container.RegisterInstance(GameOptionsManager.LoadDefaults());

            _container.RegisterType <IScheduler, EventLoopScheduler>(new ContainerControlledLifetimeManager());
            _container.RegisterType <INavigationService, NavigationService>(new ContainerControlledLifetimeManager());

            _container.Resolve <INavigationService>();

            _container.RegisterType <IGameObjectIDService, GameObjectIDService>(new ContainerControlledLifetimeManager());
            _container.RegisterType <ISupremacyCallback, GameClientCallback>(new TransientLifetimeManager());
            _container.RegisterType <IGameClient, GameClient>(new TransientLifetimeManager());
            _container.RegisterType <IGameServer, GameServer>(new TransientLifetimeManager());
            _container.RegisterType <IPlayerOrderService, PlayerOrderService>(new ExternallyControlledLifetimeManager());
            //_container.RegisterType<IPlayerTarget1Service, PlayerTarget1Service>(new ExternallyControlledLifetimeManager());
            //_container.RegisterType<IPlayerTarget2Service, PlayerTarget2Service>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <IGameController, GameController>(new TransientLifetimeManager());
            //_container.RegisterInstance<IScriptService>(new ScriptService());*/

            _container.RegisterType <StatusWindow>(new ContainerControlledLifetimeManager());
            _container.RegisterInstance(new CombatWindow());

            _container.RegisterType <GalaxyScreenPresentationModel>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <ColonyScreenPresentationModel>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <DiplomacyScreenViewModel>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <ScienceScreenPresentationModel>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <AssetsScreenPresentationModel>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <SystemAssaultScreenViewModel>(new ContainerControlledLifetimeManager());

            _container.RegisterType <IGalaxyScreenView, GalaxyScreenView>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <IColonyScreenView, ColonyScreenView>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <INewDiplomacyScreenView, NewDiplomacyScreen>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <IScienceScreenView, ResearchScreen>(new ExternallyControlledLifetimeManager());
            //_container.RegisterType<IIntelScreenView, IntelScreen>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <IAssetsScreenView, AssetsScreen>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <ILobbyScreenView, MultiplayerLobby>(new ContainerControlledLifetimeManager());
            _container.RegisterType <ISystemAssaultScreenView, SystemAssaultScreen>(new ContainerControlledLifetimeManager());

            _container.RegisterType <IGalaxyScreenPresenter, GalaxyScreenPresenter>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <IColonyScreenPresenter, ColonyScreenPresenter>(new ExternallyControlledLifetimeManager());
            //_container.RegisterType<IDiplomacyScreenPresenter, DiplomacyScreenPresenter>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <IScienceScreenPresenter, ScienceScreenPresenter>(new ExternallyControlledLifetimeManager());
            _container.RegisterType <IAssetsScreenPresenter, AssetsScreenPresenter>(new ExternallyControlledLifetimeManager());

            _regionViewRegistry.RegisterViewWithRegion(ClientRegions.GameScreens, StandardGameScreens.MenuScreen, typeof(MenuScreen));
            _regionViewRegistry.RegisterViewWithRegion(ClientRegions.GameScreens, StandardGameScreens.MultiplayerLobby, typeof(ILobbyScreenView));

            // first is first shown in Options
            _regionViewRegistry.RegisterViewWithRegion(ClientRegions.OptionsPages, typeof(AllOptionsPage));
            //_regionViewRegistry.RegisterViewWithRegion(ClientRegions.OptionsPages, typeof(SecondOptionsPage));
            _regionViewRegistry.RegisterViewWithRegion(ClientRegions.OptionsPages, typeof(TracesOptionsPage));
            //_regionViewRegistry.RegisterViewWithRegion(ClientRegions.OptionsPages, typeof(AudioOptionsPage));   // remove outcomment to be shown again
            //_regionViewRegistry.RegisterViewWithRegion(ClientRegions.OptionsPages, typeof(GraphicsOptionsPage));  // remove outcomment to be shown again
            //_regionViewRegistry.RegisterViewWithRegion(ClientRegions.OptionsPages, typeof(GeneralOptionsPage));
            //_regionViewRegistry.RegisterViewWithRegion(ClientRegions.OptionsPages, typeof(AllOptionsPage));

            _regionViewRegistry.RegisterViewWithRegion(CommonGameScreenRegions.PlanetsView, typeof(StarSystemPanel));

            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.EmpireOverview, typeof(EmpireInfoView));
            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.EmpireResources, typeof(EmpireResourcesView));
            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.GalaxyGrid, typeof(GalaxyGridView));
            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.TradeRouteList, typeof(TradeRouteListView));
            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.TaskForceList, typeof(TaskForceListView));
            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.AssignedShipList, typeof(AssignedShipListView));
            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.AvailableShipList, typeof(AvailableShipListView));
            _regionViewRegistry.RegisterViewWithRegion(GalaxyScreenRegions.ShipStats, typeof(ShipInfoPanel));

            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.ColonyInfo, ColonyScreenRegions.ColonyInfo, typeof(ColonyInfoView));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.ProductionManagement, ColonyScreenRegions.ProductionManagement, typeof(SystemProductionPanel));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.PlanetaryBuildQueue, ColonyScreenRegions.PlanetaryBuildQueue, typeof(ColonyPlanetaryBuildQueueView));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.PlanetaryBuildList, ColonyScreenRegions.PlanetaryBuildList, typeof(ColonyPlanetaryBuildListView));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.SelectedPlanetaryBuildProjectInfo, ColonyScreenRegions.SelectedPlanetaryBuildProjectInfo, typeof(ColonyBuildProjectInfoView));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.ShipyardBuildQueue, ColonyScreenRegions.ShipyardBuildQueue, typeof(ColonyShipyardBuildQueueView));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.ShipyardBuildList, ColonyScreenRegions.ShipyardBuildList, typeof(ColonyShipyardBuildListView));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.SelectedShipyardBuildProjectInfo, ColonyScreenRegions.SelectedShipyardBuildProjectInfo, typeof(ColonyBuildProjectInfoView));
            _regionViewRegistry.RegisterViewWithRegion(ColonyScreenRegions.StructureList, ColonyScreenRegions.StructureList, typeof(ColonyStructureListView));
        }
コード例 #14
0
        private void ExecuteHostMultiplayerGameCommand(string playerName)
        {
            var initData = GameInitData.CreateMultiplayerGame(GameOptionsManager.LoadDefaults(), playerName);

            RunGameController(gameController => gameController.RunLocal(initData), true);
        }