private void Start()
    {
        if (PlayerPrefs.HasKey("OfflineGamePropertyAssemble"))
        {
            JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString("OfflineGamePropertyAssemble"), offlineGamePropertyAssemble);
        }
        else
        {
            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW2Middle,
                presetName   = "Default-WW2Middle-1V1",
                TeamANumber  = 1,
                TeamBNumber  = 1
            }
                );

            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW1,
                presetName   = "Default-WW1-1V1",
                TeamANumber  = 1,
                TeamBNumber  = 1
            }
                );

            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW2Late,
                presetName   = "Default-WW2Late-1V1",
                TeamANumber  = 1,
                TeamBNumber  = 1
            }
                );

            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW2Late,
                presetName   = "Default-WW2Late-2V2",
                TeamANumber  = 2,
                TeamBNumber  = 2
            }
                );
        }


        //设置界面
        ShowGamePropertySetUIPanel_Button.onClick.AddListener(() => {
            GamePropertySetUIPanel.SetActive(true);
        });

        CloseGamePropertySetUIPanel_Button.onClick.AddListener(() => {
            GamePropertySetUIPanel.SetActive(false);
        });

        CreateGamePropertyPreset_Button.onClick.AddListener(() => {
            string presetName = GamePropertyPresetName_InputField.text;

            OfflineGameProperty currentGameProperty = new OfflineGameProperty();

            currentGameProperty.presetName = presetName;

            currentGameProperty.gameMapEnum = availableGameMapList[currentGameMap];

            currentGameProperty.gameYearEnum = availableGameYearList[currentGameYear];

            currentGameProperty.TeamANumber = int.Parse(BattleTeamANumber_DropDown.buttonTextContent.text);

            currentGameProperty.TeamBNumber = int.Parse(BattleTeamBNumber_DropDown.buttonTextContent.text);

            offlineGamePropertyAssemble.Assemble.Add(currentGameProperty);

            PlayerPrefs.SetString("OfflineGamePropertyAssemble", JsonUtility.ToJson(offlineGamePropertyAssemble));

            Debug.Log(JsonUtility.ToJson(offlineGamePropertyAssemble));

            foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble)
            {
                CreateTemplateInstance(gameProperty);
            }

            GamePropertySetUIPanel.SetActive(false);
        });

        for (int i = 0; i < availableGameMapList.Length; i++)
        {
            BattleMap_Dropdown.AddData(new MaterialUI.OptionData()
            {
                text = uGUI_Localsize.GetContent(availableGameMapList[i].ToString())
            });
        }

        BattleMap_Dropdown.onItemSelected.AddListener((changedValue) => {
            currentGameMap = changedValue;
        });

        for (int i = 0; i < availableGameYearList.Length; i++)
        {
            BattleYear_Dropdown.AddData(new MaterialUI.OptionData()
            {
                text = uGUI_Localsize.GetContent(availableGameYearList[i].ToString())
            });
        }

        BattleYear_Dropdown.onItemSelected.AddListener((valueChanged) => {
            currentGameYear = valueChanged;
        });

        //设置预设显示
        roomLabelTemplate.SetActive(false);

        foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble)
        {
            CreateTemplateInstance(gameProperty);
        }


        OpenRaceMode_Button.onClick.AddListener(() => {
            OfflineGameManager._Instance.onRaceGamerequested();
        });
    }
Beispiel #2
0
    private IEnumerator CheckSettingsOnEnable(MaterialDialog dialog, float duration)
    {
        try
        {
            Resolutions = Screen.resolutions;

            resolutionDropdown.ClearData();
            qualityDropdown.ClearData();
            antiAliasDropdown.ClearData();
            vSyncDropdown.ClearData();
            aiDropdown.ClearData();

            settings = SettingsData.Settings ?? SettingsHelper.LoadSettings();
            resolutionDropdown.ClearData();
            qualityDropdown.ClearData();
            antiAliasDropdown.ClearData();
            vSyncDropdown.ClearData();
            aiDropdown.ClearData();
            vSyncDropdown.AddData(new OptionData
            {
                text = "No sync"
            });
            vSyncDropdown.AddData(new OptionData
            {
                text = "Every V Blank (60 fps)"
            });
            vSyncDropdown.AddData(new OptionData
            {
                text = "Every Second V Blank (30 fps)"
            });
            vSyncDropdown.AddData(new OptionData
            {
                text = "Every Third V Blank (15 fps)"
            });

            foreach (var res in Resolutions)
            {
                resolutionDropdown.AddData(new OptionData
                {
                    //text = res.width + "x" + res.height + " : " + res.refreshRate
                    text = res.ToString()
                });
            }

            antiAliasDropdown.AddData(new OptionData
            {
                text = "None"
            });
            antiAliasDropdown.AddData(new OptionData
            {
                text = "Low"
            });
            antiAliasDropdown.AddData(new OptionData
            {
                text = "Normal"
            });
            antiAliasDropdown.AddData(new OptionData
            {
                text = "High"
            });

            qualityDropdown.AddData(new OptionData
            {
                text = "Very Low"
            });
            qualityDropdown.AddData(new OptionData
            {
                text = "Low"
            });
            qualityDropdown.AddData(new OptionData
            {
                text = "Medium"
            });
            qualityDropdown.AddData(new OptionData
            {
                text = "High"
            });
            qualityDropdown.AddData(new OptionData
            {
                text = "Very High"
            });
            qualityDropdown.AddData(new OptionData
            {
                text = "Ultra"
            });

            aiDropdown.AddData(new OptionData
            {
                text = "Easy"
            });
            aiDropdown.AddData(new OptionData
            {
                text = "Medium"
            });
            aiDropdown.AddData(new OptionData
            {
                text = "Hard"
            });
            aiDropdown.AddData(new OptionData
            {
                text = "Very Hard"
            });

            fullscreenToggle.onValueChanged.AddListener(delegate { FullscreenChange(); });
            resolutionDropdown.onItemSelected.AddListener(delegate { ResolutionChange(); });
            vSyncDropdown.onItemSelected.AddListener(delegate { VSyncChange(); });
            qualityDropdown.onItemSelected.AddListener(delegate { QualityChange(); });
            antiAliasDropdown.onItemSelected.AddListener(delegate { AntiAliasChange(); });
            volumeSlider.onValueChanged.AddListener(delegate { VolumeChange(); });
            applyBtn.onClick.AddListener(SaveSettings);
            fpsToggle.onValueChanged.AddListener(SwitchFpsChange);
            aiDropdown.onItemSelected.AddListener(delegate { AiChange(); });
        }
        catch (Exception e)
        {
            Debug.LogError(e);
            throw;
        }

        yield return(new WaitForSeconds(duration));

        dialog.Hide();
    }
    private void Start()
    {
        if (PlayerPrefs.HasKey("OfflineGamePropertyAssemble"))
        {
            JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString("OfflineGamePropertyAssemble"), offlineGamePropertyAssemble);
        }
        else
        {
            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW2Middle,
                presetName   = "Default-WW2Middle-1V1",
                TeamANumber  = 1,
                TeamBNumber  = 1
            }
                );

            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW1,
                presetName   = "Default-WW1-1V1",
                TeamANumber  = 1,
                TeamBNumber  = 1
            }
                );

            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW2Late,
                presetName   = "Default-WW2Late-1V1",
                TeamANumber  = 1,
                TeamBNumber  = 1
            }
                );

            offlineGamePropertyAssemble.Assemble.Add(
                new OfflineGameProperty()
            {
                gameYearEnum = GameYearEnum.WW2Late,
                presetName   = "Default-WW2Late-2V2",
                TeamANumber  = 2,
                TeamBNumber  = 2
            }
                );
        }


        //设置界面
        ShowGamePropertySetUIPanel_Button.onClick.AddListener(() => {
            GamePropertySetUIPanel.SetActive(true);
        });

        CloseGamePropertySetUIPanel_Button.onClick.AddListener(() => {
            GamePropertySetUIPanel.SetActive(false);
        });

        CreateGamePropertyPreset_Button.onClick.AddListener(() => {
            string presetName = GamePropertyPresetName_InputField.text;

            OfflineGameProperty currentGameProperty = new OfflineGameProperty();

            currentGameProperty.presetName = presetName;

            currentGameProperty.gameMapEnum = availableGameMapList[currentGameMap];

            currentGameProperty.gameYearEnum = availableGameYearList[currentGameYear];

            currentGameProperty.TeamANumber = int.Parse(BattleTeamANumber_DropDown.buttonTextContent.text);

            currentGameProperty.TeamBNumber = int.Parse(BattleTeamBNumber_DropDown.buttonTextContent.text);

            offlineGamePropertyAssemble.Assemble.Add(currentGameProperty);

            PlayerPrefs.SetString("OfflineGamePropertyAssemble", JsonUtility.ToJson(offlineGamePropertyAssemble));

            Debug.Log(JsonUtility.ToJson(offlineGamePropertyAssemble));

            foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble)
            {
                CreateTemplateInstance(gameProperty);
            }

            GamePropertySetUIPanel.SetActive(false);
        });

        for (int i = 0; i < availableGameMapList.Length; i++)
        {
            BattleMap_Dropdown.AddData(new MaterialUI.OptionData()
            {
                text = uGUI_Localsize.GetContent(availableGameMapList[i].ToString())
            });
        }

        BattleMap_Dropdown.onItemSelected.AddListener((changedValue) => {
            currentGameMap = changedValue;
        });

        for (int i = 0; i < availableGameYearList.Length; i++)
        {
            BattleYear_Dropdown.AddData(new MaterialUI.OptionData()
            {
                text = uGUI_Localsize.GetContent(availableGameYearList[i].ToString())
            });
        }

        BattleYear_Dropdown.onItemSelected.AddListener((valueChanged) => {
            currentGameYear = valueChanged;
        });

        //设置预设显示
        roomLabelTemplate.SetActive(false);

        foreach (OfflineGameProperty gameProperty in offlineGamePropertyAssemble.Assemble)
        {
            CreateTemplateInstance(gameProperty);
        }
        //Garage
        OpenGarage_Button.onClick.AddListener(() => {
            //ClientNetwork.Instance.StartCoroutine(
            //    AssetBundleManager.RequestScene(true, true, "garage", (myReturnValue) => {
            //        Hashtable vehicleList = new Hashtable();

            //        AccountDataManager.InstanceAllHastables();

            //        foreach (string Vehicle in AccountDataManager.ExcelVehicleData.Keys) {
            //            vehicleList.Add(Vehicle, new Crew.CrewInfo());
            //        }

            //        GarageTankManger.Instance.UpdataTankList(vehicleList, true);

            //        AccountManager.Instance.DataUpdata();
            //    }, null)
            //);
        });

        OpenRaceMode_Button.onClick.AddListener(() => {
            OfflineGameManager._Instance.onRaceGamerequested();
        });
    }