Esempio n. 1
0
 public static void LoadPreferences()
 {
     PlayerPrefs.Save();
 }
    /*//顯示存檔================================================================================================================
     * public void Save_Show(){
     *      //顯示存檔畫面
     *      Save_Show_Draw.SetActive(true);
     *      //關閉存檔按鈕
     *      Save_Show_Button.interactable = false;
     * }
     *
     * //取消存檔===============================================================================================================
     * public void Save_Show_cancel(){
     *      //隱藏存檔畫面
     *      Save_Show_Draw.SetActive(false);
     *      //開啟存檔按鈕
     *      Save_Show_Button.interactable = true;
     * }*/

    //確定存檔================================================================================================================
    public static void Save_ALL()
    {
        //開啟存檔按鈕
        //Save_Show_Button.interactable = true;

        //有存過檔
        Saved = 1;
        PlayerPrefs.SetInt("Saved", Saved);
        PlayerPrefs.Save();

        //持有金錢========================================================================
        Save_OwnMoney();

        //員工========================================================================
        //存檔(經理)==================================================
        for (int i = 0; i < ManageNumber; i++)
        {
            Manage [i].Save_Hire();
            Manage [i].Save_Work();
            Manage [i].Save_WorkPlace();
        }
        //存檔(警衛)==================================================
        for (int i = 0; i < SecurityNumber; i++)
        {
            Security [i].Save_Hire();
            Security [i].Save_Work();
            Security [i].Save_WorkPlace();
        }
        //存檔(顧問)==================================================
        for (int i = 0; i < ConsultantNumber; i++)
        {
            Consultant [i].Save_Hire();
        }

        //店鋪存檔===========================================================================
        //存檔(麵包師傅)==============================================
        for (int i = 0; i < BreadStoreNumber; i++)
        {
            BreadStore [i].Save_InvestBool(Save_Bread_InvestBool);
            BreadStore [i].Save_Level(Save_Bread_Level);
            BreadStore [i].Save_LevelEx(Save_Bread_LevelEx);
            BreadStore [i].Save_OwnBool(Save_Bread_OwnBool);
        }
        //存檔(音樂人)==============================================
        for (int i = 0; i < MusicStoreNumber; i++)
        {
            MusicStore [i].Save_InvestBool(Save_Music_InvestBool);
            MusicStore [i].Save_Level(Save_Music_Level);
            MusicStore [i].Save_LevelEx(Save_Music_LevelEx);
            MusicStore [i].Save_OwnBool(Save_Music_OwnBool);
        }
        //存檔(科技新貴)==============================================
        for (int i = 0; i < TehcnologyStoreNumber; i++)
        {
            TehcnologyStore [i].Save_InvestBool(Save_Tehcnology_InvestBool);
            TehcnologyStore [i].Save_Level(Save_Tehcnology_Level);
            TehcnologyStore [i].Save_LevelEx(Save_Tehcnology_LevelEx);
            TehcnologyStore [i].Save_OwnBool(Save_Tehcnology_OwnBool);
        }
        //存檔(機工)==============================================
        for (int i = 0; i < FactoryStoreNumber; i++)
        {
            FactoryStore [i].Save_InvestBool(Save_Factory_InvestBool);
            FactoryStore [i].Save_Level(Save_Factory_Level);
            FactoryStore [i].Save_LevelEx(Save_Factory_LevelEx);
            FactoryStore [i].Save_OwnBool(Save_Factory_OwnBool);
        }
        //存檔(銀行家)==============================================
        for (int i = 0; i < EconomicStoreNumber; i++)
        {
            EconomicStore [i].Save_InvestBool(Save_Economic_InvestBool);
            EconomicStore [i].Save_Level(Save_Economic_Level);
            EconomicStore [i].Save_LevelEx(Save_Economic_LevelEx);
            EconomicStore [i].Save_OwnBool(Save_Economic_OwnBool);
        }

        //區域存檔==========================================================================
        //存檔(麵包師傅)==============================================
        BreadArea.Save_Manage(Save_Area_Manage);
        BreadArea.Save_ManageTime(Save_Area_ManageTime);
        //存檔(音樂人)==============================================
        MusicArea.Save_Manage(Save_Area_Manage);
        MusicArea.Save_ManageTime(Save_Area_ManageTime);
        //存檔(科技新貴)==============================================
        TehcnologyArea.Save_Manage(Save_Area_Manage);
        TehcnologyArea.Save_ManageTime(Save_Area_ManageTime);
        //存檔(機工)==============================================
        FactoryArea.Save_Manage(Save_Area_Manage);
        FactoryArea.Save_ManageTime(Save_Area_ManageTime);
        //存檔(銀行家)==============================================
        EconomicArea.Save_Manage(Save_Area_Manage);
        EconomicArea.Save_ManageTime(Save_Area_ManageTime);
    }    //整體存檔================================================================================================================
 public void setSfxVolume(float value)
 {
     sfx.volume = value;
     PlayerPrefs.SetFloat("sfx volume", value);
     PlayerPrefs.Save();
 }
Esempio n. 4
0
 private void DoExit()
 {
     PlayerPrefs.Save();
     OnAdExit?.Invoke();
 }
 public void Clean()
 {
     PlayerPrefs.DeleteAll();
     PlayerPrefs.Save();
 }
Esempio n. 6
0
 public void GameEnd()
 {
     PlayerPrefs.SetInt("BestScore", bScore);
     PlayerPrefs.Save();
     restartMenu.SetActive(true);
 }
Esempio n. 7
0
 public void UpdateScores()
 {
     PlayerPrefs.SetInt(this.highscorekey, this.high_score);
     PlayerPrefs.SetInt(this.highcombokey, this.high_noc);
     PlayerPrefs.Save();
 }
 private void Save()
 {
     PlayerPrefs.SetString(SELECTED_LANGUAGE_KEY, _currentlySelectedLanguage);
     PlayerPrefs.Save();
 }
Esempio n. 9
0
 // Token: 0x06001483 RID: 5251 RVA: 0x000B5DBB File Offset: 0x000B3FBB
 public static void Save()
 {
     PlayerPrefs.Save();
 }
Esempio n. 10
0
 public void SetSoundOn(bool val)
 {
     this.is_sound_on = val;
     PlayerPrefs.SetInt("sound", this.is_sound_on ? 1 : 0);
     PlayerPrefs.Save();
 }
Esempio n. 11
0
 public void SetMusicOn(bool val)
 {
     this.is_music_on = val;
     PlayerPrefs.SetInt("sound", this.is_music_on ? 1 : 0);
     PlayerPrefs.Save();
 }
Esempio n. 12
0
 // Adds an entry to the dictionary for the key-value pair.
 internal static void Add(string key, float value)
 {
     // Set the value an do an immediate save
     PlayerPrefs.SetFloat(key, value);
     PlayerPrefs.Save();
 }
Esempio n. 13
0
 internal static void Add(string key, string value)
 {
     PlayerPrefs.SetString(key, value);
     PlayerPrefs.Save();
 }
Esempio n. 14
0
 internal static void Add(string key, int value)
 {
     PlayerPrefs.SetInt(key, value);
     PlayerPrefs.Save();
 }
Esempio n. 15
0
    //检查游戏和资源版本号
    private IEnumerator CheckResourceVersion(DelegateCheckResVersion checkVersionDelFun, bool updateGate)
    {
        UpdateStatus = GetDictionaryText(3300000);
        string versionConfig;
        var    gameVersionPath = Path.Combine(Application.streamingAssetsPath, "Game.ver");

        if (!GameUtils.GetStringFromPackage(gameVersionPath, out versionConfig))
        {
            Logger.Error("cant find Game.ver at{0}", gameVersionPath);
            if (null != checkVersionDelFun)
            {
                checkVersionDelFun(CheckVersionResult.ERROR, GetDictionaryText(3300008));
            }
            yield break;
        }

        var config          = versionConfig.Split(',');
        var langue          = config[0];
        var platform        = config[1];
        var channel         = config[2];
        var bigVersion      = config[3];
        var resourceVersion = config[4];

        if (string.IsNullOrEmpty(langue) || string.IsNullOrEmpty(platform) || string.IsNullOrEmpty(channel) ||
            string.IsNullOrEmpty(bigVersion) || string.IsNullOrEmpty(bigVersion))
        {
            Logger.Error("Game.ver error {0}", versionConfig);
        }

        LocalGameVersion = bigVersion;

        if (!Int32.TryParse(resourceVersion, out LocalVersion))
        {
            Logger.Error("Game.ver error {0}", LocalVersion);
            if (null != checkVersionDelFun)
            {
                checkVersionDelFun(CheckVersionResult.ERROR, GetDictionaryText(3300009));
            }
            yield break;
        }

        UpdateStatus = GetDictionaryText(3300001);
        //获取远端游戏版本信息
        var UpdateHelper = new GameObject("UpdateHelper");
        var network      = UpdateHelper.AddComponent <DirectoryNetwork>();
        CheckVersionOutMessage msg;

        var index = 0;

        while (true)
        {
            if (index == GameSetting.Instance.DirectoryAddress.Count)
            {
                network.Stop();
                Object.Destroy(UpdateHelper);
                if (null != checkVersionDelFun)
                {
                    checkVersionDelFun(CheckVersionResult.ERROR, GetDictionaryText(3300010));
                }
                yield break;
            }

            network.ServerAddress = GameSetting.Instance.DirectoryAddress[index];
            yield return(network.StartAndWaitConnect(TimeSpan.FromSeconds(3)));

            if (network.Connected)
            {
                Logger.Debug("Connect to Directory [" + network.ServerAddress + "] succeed!");

                msg = network.CheckVersion(langue, platform, channel, bigVersion);
                yield return(msg.SendAndWaitUntilDone());

                if (msg.State == MessageState.Reply)
                {
                    break;
                }
            }
            network.Stop();
            index++;
        }

        UpdateStatus = GetDictionaryText(3300002);

        if (msg.ErrorCode == (int)ErrorCodes.OK)
        {
            if (msg.Response.HasNewVersion == 1)
            {
                var url = CheckUrl(msg.Response.NewVersionURL);
                if (null != checkVersionDelFun)
                {
                    checkVersionDelFun(CheckVersionResult.GAMENEEDUPDATE, url);
                }
                network.Stop();
                Object.DestroyImmediate(UpdateHelper);
                yield break;
            }
            LocalGameVersion = bigVersion;
            RemoteVersion    = msg.Response.SmallVersion;
            RemoteUrlRoot    = msg.Response.ResourceURL;
            AnnoucementURL   = CheckUrl(msg.Response.AnnoucementURL);
            if (updateGate && GateAddress != msg.Response.GateAddress)
            {
                GateAddress = msg.Response.GateAddress;
            }
            GameSetting.Instance.ReviewState = msg.Response.ReviewState;


            //数据收集,设备id,只发送一次
            const string key  = "deviceid";
            var          udid = PlayerPrefs.GetString(key);
            if (string.IsNullOrEmpty(udid))
            {
                udid = Guid.NewGuid().ToString();
                NetManager.Instance.ServerAddress = GateAddress;
                yield return(NetManager.Instance.StartAndWaitConnect(TimeSpan.FromSeconds(3)));

                if (NetManager.Instance.Connected)
                {
                    var msgUdid = NetManager.Instance.SendDeviceUdid(udid);
                    yield return(msgUdid.SendAndWaitUntilDone());

                    PlayerPrefs.SetString(key, udid);
                    PlayerPrefs.Save();
                    NetManager.Instance.Stop();
                }
            }
        }
        else
        {
            network.Stop();
            Object.Destroy(UpdateHelper);
            if (null != checkVersionDelFun)
            {
                checkVersionDelFun(CheckVersionResult.ERROR, GetDictionaryText(3300011) + msg.ErrorCode);
            }
            yield break;
        }


        network.Stop();
        Object.DestroyImmediate(UpdateHelper);

        ClearLastGameVersionResource();

        //读取之前更新过的版本号
        if (File.Exists(DownLoadVersionPath))
        {
            if (!GameUtils.GetIntFromFile(DownLoadVersionPath, out LocalVersion))
            {
                Logger.Error("parse version error");
                if (null != checkVersionDelFun)
                {
                    checkVersionDelFun(CheckVersionResult.ERROR, GetDictionaryText(3300013));
                }
            }
            Logger.Debug("Last Update ResourceVersion from local =" + LocalVersion);
        }

        if (RemoteVersion > LocalVersion)
        {
            UpdateStatus = GetDictionaryText(3300003);
            Caching.CleanCache();
            PlayerPrefs.SetInt(GameSetting.ShowWaitingTipKey, 0);
            checkVersionDelFun(CheckVersionResult.NEEDUPDATE);
            Logger.Debug("-----CheckUpDate needupdate = true--");
        }
        else
        {
            UpdateStatus = "";
            checkVersionDelFun(CheckVersionResult.NONEEDUPDATE);
            Logger.Debug("-----CheckUpdate needupdate = false---");
        }
    }
Esempio n. 16
0
 /// <summary>
 /// Removes all high score for given level
 /// </summary>
 /// <param name="levelName">Level Name</param>
 public static void ResetHighScores(string levelName)
 {
     PlayerPrefs.DeleteKey(GetIdentifier(levelName));
     PlayerPrefs.Save();
 }
    private static void ExportGradle()
    {
        EditorUserBuildSettings.androidBuildSystem           = AndroidBuildSystem.Gradle;
        EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

        string path = PlayerPrefs.GetString("gradlePath", "");

        path = string.IsNullOrEmpty(path)
            ? System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)
            : path;
        path = EditorUtility.SaveFolderPanel("选择Gradle目录", path, "");
        if (string.IsNullOrEmpty(path))
        {
            return;
        }
        PlayerPrefs.SetString("gradlePath", path);
        PlayerPrefs.Save();

        string assetsPath = path + "/src/main/assets".Replace("/", Path.AltDirectorySeparatorChar.ToString());
        string newPath    = path;
        bool   hasProject = Directory.Exists(assetsPath);

        if (hasProject)
        {
            path.TrimEnd(Path.AltDirectorySeparatorChar);
            newPath = path.Substring(0, path.LastIndexOf(Path.AltDirectorySeparatorChar) + 1);
            newPath = newPath + Application.productName + "gradle";
            if (Directory.Exists(newPath))
            {
                Directory.Delete(newPath, true);
            }
        }

        Caching.ClearCache();
        var error = BuildPipeline.BuildPlayer(GetBuildScenes(), newPath, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer);

        //if (!string.IsNullOrEmpty(error))
        //{
        //    Clear();
        //}

        if (hasProject)
        {
            if (Directory.Exists(assetsPath))
            {
                Directory.Delete(assetsPath, true);
            }
            Directory.Move(newPath + Path.AltDirectorySeparatorChar + Application.productName + "/src/main/assets".Replace("/", Path.AltDirectorySeparatorChar.ToString()), assetsPath);

            string           cmd  = path + Path.AltDirectorySeparatorChar + "gradlew";
            ProcessStartInfo info = new ProcessStartInfo(cmd);
            info.WorkingDirectory = path;
            info.Arguments        = "assembleRelease";
            info.CreateNoWindow   = false;
            info.ErrorDialog      = true;
            info.UseShellExecute  = true;

            if (info.UseShellExecute)
            {
                info.RedirectStandardOutput = false;
                info.RedirectStandardOutput = false;
                info.RedirectStandardError  = false;
                info.RedirectStandardInput  = false;
            }
            else
            {
                info.RedirectStandardOutput = true;
                info.RedirectStandardError  = true;
                info.RedirectStandardInput  = true;
                info.StandardOutputEncoding = UTF8Encoding.UTF8;
                info.StandardErrorEncoding  = UTF8Encoding.UTF8;
            }

            Process process = Process.Start(info);

            if (!info.UseShellExecute)
            {
                //Debug.Log(process.StandardOutput);
                //Debug.Log(process.StandardError);
            }
            process.WaitForExit();
            process.Close();
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                string openPath =
                    Path.GetFullPath(path + "/build/outputs/apk/release/".Replace("/", Path.AltDirectorySeparatorChar.ToString()));
                Process.Start("explorer.exe", openPath);



                if (!string.IsNullOrEmpty(gitCommitID))
                {
                    Process pro = new Process();
                    pro.StartInfo.FileName               = "cmd";
                    pro.StartInfo.CreateNoWindow         = true;  // 不创建新窗口
                    pro.StartInfo.UseShellExecute        = false; //不启用shell启动进程
                    pro.StartInfo.RedirectStandardInput  = true;  // 重定向输入
                    pro.StartInfo.RedirectStandardOutput = true;  // 重定向标准输出
                    pro.StartInfo.RedirectStandardError  = false; //重定向标准错误
                    // 重定向错误输出
                    //            pro.StartInfo.WorkingDirectory = Application.dataPath;  //定义执行的路径
                    Console.OutputEncoding = Encoding.GetEncoding(936);
                    pro.Start();
                    pro.StandardInput.AutoFlush = true;
                    string gitlog = "git log --pretty=format:\"%s%n        ========> %an , %ai%n\" {0}^..HEAD --grep \"·新增·\\|·修改·\\|·删除·\\|·其他·\" > {1}.log";
                    gitlog = string.Format(gitlog, gitCommitID.Trim(), openPath + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
                    pro.StandardInput.WriteLine(gitlog);             //向cmd中输入命令
                    pro.StandardInput.WriteLine("exit");             //退出
                    string outRead = pro.StandardOutput.ReadToEnd(); //获得所有标准输出流
                    //Debug.Log(outRead);
                    pro.WaitForExit();                               //等待命令执行完成后退出
                    pro.Close();                                     //关闭窗口
                }
            }
        }
    }
Esempio n. 18
0
        /// <summary>
        /// Saves data using the identifier.
        /// </summary>
        /// <param name="identifier">Identifier.</param>
        /// <param name="obj">Object to save.</param>
        /// <param name="encode">Encrypt the data?</param>
        /// <param name="password">Encryption Password.</param>
        /// <param name="serializer">Serializer.</param>
        /// <param name="encoder">Encoder.</param>
        /// <param name="encoding">Encoding.</param>
        /// <param name="path">Path.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public static void Save <T>(string identifier, T obj, bool encode, string password, ISaveGameSerializer serializer, ISaveGameEncoder encoder, Encoding encoding, SaveGamePath path)
        {
            if (string.IsNullOrEmpty(identifier))
            {
                throw new System.ArgumentNullException("identifier");
            }
            if (serializer == null)
            {
                serializer = SaveGame.Serializer;
            }
            if (encoding == null)
            {
                encoding = SaveGame.DefaultEncoding;
            }
            string filePath = "";

            if (!IsFilePath(identifier))
            {
                switch (path)
                {
                case SaveGamePath.PersistentDataPath:
                    filePath = string.Format("{0}/{1}", Application.persistentDataPath, identifier);
                    break;

                case SaveGamePath.DataPath:
                    filePath = string.Format("{0}/{1}", $"E:\\MaoXianYuJingYing\\Unity\\Assets\\Data\\LevelData", identifier);
                    break;
                }
            }
            else
            {
                filePath = identifier;
            }
            if (obj == null)
            {
                obj = default(T);
            }
            Stream stream = null;

#if !UNITY_SAMSUNGTV && !UNITY_TVOS && !UNITY_WEBGL
#if UNITY_WSA || UNITY_WINRT
            UnityEngine.Windows.Directory.CreateDirectory(filePath);
#else
            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
#endif
#endif
            if (encode)
            {
                stream = new MemoryStream();
            }
            else
            {
#if !UNITY_SAMSUNGTV && !UNITY_TVOS && !UNITY_WEBGL
                if (IOSupported())
                {
#if UNITY_WSA || UNITY_WINRT
                    stream = new MemoryStream();
#else
                    stream = File.Create(filePath);
#endif
                }
                else
                {
                    stream = new MemoryStream();
                }
#else
                stream = new MemoryStream();
#endif
            }
            serializer.Serialize(obj, stream, encoding);
            if (encode)
            {
                string data    = System.Convert.ToBase64String(((MemoryStream)stream).ToArray());
                string encoded = encoder.Encode(data, password);
#if !UNITY_SAMSUNGTV && !UNITY_TVOS && !UNITY_WEBGL
                if (IOSupported())
                {
#if UNITY_WSA || UNITY_WINRT
                    UnityEngine.Windows.File.WriteAllBytes(filePath, encoding.GetBytes(encoded));
#else
                    File.WriteAllText(filePath, encoded, encoding);
#endif
                }
                else
                {
                    PlayerPrefs.SetString(filePath, encoded);
                    PlayerPrefs.Save();
                }
#else
                PlayerPrefs.SetString(filePath, encoded);
                PlayerPrefs.Save();
#endif
            }
            else if (!IOSupported())
            {
                string data = encoding.GetString(((MemoryStream)stream).ToArray());
                PlayerPrefs.SetString(filePath, data);
                PlayerPrefs.Save();
            }
            stream.Dispose();
            if (SaveCallback != null)
            {
                SaveCallback.Invoke(
                    obj,
                    identifier,
                    encode,
                    password,
                    serializer,
                    encoder,
                    encoding,
                    path);
            }
            if (OnSaved != null)
            {
                OnSaved(
                    obj,
                    identifier,
                    encode,
                    password,
                    serializer,
                    encoder,
                    encoding,
                    path);
            }
        }
Esempio n. 19
0
 public void Motion(bool on)
 {
     PlayerPrefs.SetInt("motion", on ? 0 : 1);
     PlayerPrefs.Save();
     GetComponent <DressManager>().fm.doMotion(on);
 }
Esempio n. 20
0
    // Update is called once per frame
    void Update()
    {
        if (PlayerPrefs.GetString("Last Checkpoint") == "End")
        {
            fadeAll = true;
            PlayerPrefs.SetString("Cutscene", "true");
        }

        //This is just us slowly fading the black screen away from the player to reveal the opening animations.
        if (fadeAllIn == true)
        {
            fadeAlpha      -= Time.deltaTime / 2f;
            fadeGroup.alpha = fadeAlpha;
            audio.volume    = masterLevel * .8f * Mathf.Abs(1f - fadeAlpha);

            if (fadeAlpha <= 0f)
            {
                fadeAllIn       = false;
                fadeGroup.alpha = 0;
                audio.volume    = masterLevel * .8f;
                fadeObject.SetActive(false);
            }
        }

        //We are transitioning out of the game.
        if (fadeAll == true)
        {
            fadeObject.SetActive(true);

            fadeAlpha      += Time.deltaTime / 2f;
            fadeGroup.alpha = fadeAlpha;
            audio.volume    = masterLevel * .8f * Mathf.Abs(1f - fadeAlpha);

            if (fadeAlpha > 1f)
            {
                fadeGroup.alpha = 1f;
                fadeAll         = false;
                audio.volume    = masterLevel * 0f;
                PlayerPrefs.Save();

                if (backingOut == true)
                {
                    StartCoroutine(LoadScene("Main Menu"));
                }
                else if (scene.name == "NewTutorial")
                {
                    StartCoroutine(LoadScene("1st Level"));
                }
                else if (scene.name == "1st Level")
                {
                    StartCoroutine(LoadScene("2nd Level"));
                }
                else if (scene.name == "2nd Level")
                {
                    StartCoroutine(LoadScene("3rd Level"));
                }
                else if (scene.name == "3rd Level")
                {
                    StartCoroutine(LoadScene("Main Menu"));
                }
            }
        }

        //We are closing the in game pause menu.
        if (fadeUI == true)
        {
            UIAlpha      -= Time.deltaTime * 2f;
            UIGroup.alpha = UIAlpha;

            hover.volume  = UIAlpha * masterLevel * .5f;
            select.volume = UIAlpha * masterLevel * .5f;

            if (UIAlpha <= 0f)
            {
                UIAlpha       = 0f;
                hover.volume  = UIAlpha * masterLevel * .5f;
                select.volume = UIAlpha * masterLevel * .5f;
                fadeUI        = false;
            }
        }

        //We are opening the in game pause menu.
        if (fadeUIIn == true)
        {
            UIAlpha      += Time.deltaTime * 2f;
            UIGroup.alpha = UIAlpha;
            hover.volume  = UIAlpha * masterLevel * .5f;
            select.volume = UIAlpha * masterLevel * .5f;

            if (UIAlpha >= 1f)
            {
                UIAlpha       = 1f;
                hover.volume  = UIAlpha * masterLevel * .5f;
                select.volume = UIAlpha * masterLevel * .5f;
                fadeUIIn      = false;
            }
        }

        if (tradeWindows == true && PlayerPrefs.GetString("Paused") == "true" && PlayerPrefs.GetString("Cutscene") == "false")
        {
            UIAlpha      -= Time.deltaTime * 2f;
            UIGroup.alpha = UIAlpha;
            hover.volume  = UIAlpha * masterLevel * .5f;
            select.volume = UIAlpha * masterLevel * .5f;

            if (UIAlpha <= 0f)
            {
                mainWindow.SetActive(false);
                UIGroup.alpha = 0f;
                UIAlpha       = 0f;
                hover.volume  = UIAlpha * masterLevel * .5f;
                select.volume = UIAlpha * masterLevel * .5f;

                settingsWindow.SetActive(true);

                settingsAlpha       += Time.deltaTime * 2f;
                SettingsWindow.alpha = settingsAlpha;

                if (settingsAlpha >= 1f)
                {
                    settingsAlpha        = 1f;
                    SettingsWindow.alpha = 1f;
                    resolutionB.enabled  = true;
                    fullscreenB.enabled  = true;
                    qualityB.enabled     = true;
                    applyB.enabled       = true;
                    masterS.enabled      = true;
                }
            }
        }
        else if (tradeWindows == false && PlayerPrefs.GetString("Paused") == "true" && PlayerPrefs.GetString("Cutscene") == "false")
        {
            settingsAlpha       -= Time.deltaTime * 2f;
            SettingsWindow.alpha = settingsAlpha;

            if (settingsAlpha <= 0f)
            {
                settingsWindow.SetActive(false);
                settingsAlpha        = 0f;
                SettingsWindow.alpha = 0f;

                UIAlpha      += Time.deltaTime * 2f;
                UIGroup.alpha = UIAlpha;
                hover.volume  = UIAlpha * masterLevel * .5f;
                select.volume = UIAlpha * masterLevel * .5f;

                mainWindow.SetActive(true);

                if (UIAlpha >= 1f)
                {
                    UIAlpha              = 1f;
                    hover.volume         = UIAlpha * masterLevel * .5f;
                    select.volume        = UIAlpha * masterLevel * .5f;
                    UIGroup.alpha        = 1f;
                    continueGame.enabled = true;
                    settingsB.enabled    = true;
                    exitB.enabled        = true;
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape) && PlayerPrefs.GetString("Cutscene") == "false" && PlayerPrefs.GetString("Paused") == "false")
        {
            PlayerPrefs.SetString("Paused", "true");
            PlayerPrefs.Save();
        }
        else if (Input.GetKeyDown(KeyCode.Escape) && PlayerPrefs.GetString("Cutscene") == "false" && PlayerPrefs.GetString("Paused") == "true" && tradeWindows == false)
        {
            PlayerPrefs.SetString("Paused", "false");
            PlayerPrefs.Save();
            continueGame.enabled = false;
            settingsB.enabled    = false;
            exitB.enabled        = false;
            fadeUI = true;
        }
        else if (Input.GetKeyDown(KeyCode.Escape) && PlayerPrefs.GetString("Cutscene") == "false" && PlayerPrefs.GetString("Paused") == "true" && tradeWindows == true)
        {
            PlayerPrefs.Save();
            fadeSettingsIn      = false;
            resolutionB.enabled = false;
            fullscreenB.enabled = false;
            qualityB.enabled    = false;
            applyB.enabled      = false;
            masterS.enabled     = false;

            tradeWindows = false;
        }

        if (PlayerPrefs.GetString("Section Display") == "true")
        {
            if (titleAlpha < 1f)
            {
                if (PlayerPrefs.GetString("Last Section") == "NewTutorial")
                {
                    sectionName = "Medical Ward";
                }
                else if (PlayerPrefs.GetString("Last Section") == "1st Level")
                {
                    sectionName = "Feeding Grounds";
                }
                else if (PlayerPrefs.GetString("Last Section") == "2nd Level")
                {
                    sectionName = "Heart of the Hive";
                }
                else if (PlayerPrefs.GetString("Last Section") == "3rd Level")
                {
                    sectionName = "Breeding Grounds";
                }

                if (PlayerPrefs.GetString("Last Checkpoint") == "new" && PlayerPrefs.GetString("Last Section") == "NewTutorial")
                {
                    checkpointName = "Cryo Pod";
                }
                else if (PlayerPrefs.GetString("Last Checkpoint") == "new")
                {
                    checkpointName = "Entrance";
                }
                else
                {
                    checkpointName = PlayerPrefs.GetString("Last Checkpoint");
                }

                areaTitle.text     = (sectionName + " - " + checkpointName);
                titleAlpha        += Time.deltaTime / 3f;
                sectionTitle.alpha = titleAlpha;
            }
            else if (titleAlpha > 1f)
            {
                titleAlpha         = 1f;
                sectionTitle.alpha = titleAlpha;
            }
        }
        else
        {
            if (titleAlpha > 0f)
            {
                titleAlpha        -= Time.deltaTime / 3f;
                sectionTitle.alpha = titleAlpha;
            }
            else if (titleAlpha < 0f)
            {
                titleAlpha         = 0f;
                sectionTitle.alpha = titleAlpha;
            }
        }
    }
Esempio n. 21
0
    void First()
    {
        #region
        int    c   = 0;
        string str = "";
        if (c == PlayerPrefs.GetInt("first", 0))
        {
            for (int i = 0; i < 16; i++)
            {
                int a = Random.Range(0, 16);//0~15
                switch (a)
                {
                case 0:
                    str = str + "0";
                    break;

                case 1:
                    str = str + "1";
                    break;

                case 2:
                    str = str + "2";
                    break;

                case 3:
                    str = str + "3";
                    break;

                case 4:
                    str = str + "4";
                    break;

                case 5:
                    str = str + "5";
                    break;

                case 6:
                    str = str + "6";
                    break;

                case 7:
                    str = str + "7";
                    break;

                case 8:
                    str = str + "8";
                    break;

                case 9:
                    str = str + "9";
                    break;

                case 10:
                    str = str + "a";
                    break;

                case 11:
                    str = str + "b";
                    break;

                case 12:
                    str = str + "c";
                    break;

                case 13:
                    str = str + "d";
                    break;

                case 14:
                    str = str + "e";
                    break;

                case 15:
                    str = str + "f";
                    break;

                default:
                    break;
                }
            }
            PlayerPrefs.SetString("code", str);
            PlayerPrefs.SetInt("first", 1);
            PlayerPrefs.Save();

            PlayerPrefs.SetString("adtimes", System.DateTime.Now.ToString());
        }//endOfIf

        #endregion
    }
 void Start()
 {
     PlayerPrefs.SetString("PreviousScene", SceneList.MenuScene);
     PlayerPrefs.Save();
 }
Esempio n. 23
0
    public void InputButtonRegister()
    {
        if (flag_register == 0)
        {
            flag_register = 1;
            object_register.SetActive(true);

            if (Cameracollider.capture > _top_score)
            {
                PlayerPrefs.SetFloat("3rd_SCORE", _second_score);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_DURATION", _second_duration);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_DV", _second_dv);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_REL_V", _second_relative_v);
                PlayerPrefs.Save();
                PlayerPrefs.SetString("3rd_NAME", _second_name);
                PlayerPrefs.Save();

                PlayerPrefs.SetFloat("2nd_SCORE", _top_score);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("2nd_DURATION", _top_duration);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("2nd_DV", _top_dv);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("2nd_REL_V", _top_relative_v);
                PlayerPrefs.Save();
                PlayerPrefs.SetString("2nd_NAME", _top_name);
                PlayerPrefs.Save();

                PlayerPrefs.SetFloat("1st_SCORE", Cameracollider.capture);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("1st_DURATION", Cameracollider.battery);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("1st_DV", Cameracollider.iss);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("1st_REL_V", Cameracollider.technical);
                PlayerPrefs.Save();
                if (inputField.text == "")
                {
                    PlayerPrefs.SetString("1st_NAME", "KOUNOTORI");
                    PlayerPrefs.Save();
                }
                else
                {
                    PlayerPrefs.SetString("1st_NAME", inputField.text);
                    PlayerPrefs.Save();
                }
            }
            else if (Cameracollider.capture > _second_score)
            {
                PlayerPrefs.SetFloat("3rd_SCORE", _second_score);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_DURATION", _second_duration);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_DV", _second_dv);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_REL_V", _second_relative_v);
                PlayerPrefs.Save();
                PlayerPrefs.SetString("3rd_NAME", _second_name);
                PlayerPrefs.Save();

                PlayerPrefs.SetFloat("2nd_SCORE", Cameracollider.capture);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("2nd_DURATION", Cameracollider.battery);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("2nd_DV", Cameracollider.iss);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("2nd_REL_V", Cameracollider.technical);
                if (inputField.text == "")
                {
                    PlayerPrefs.SetString("2nd_NAME", "KOUNOTORI");
                    PlayerPrefs.Save();
                }
                else
                {
                    PlayerPrefs.SetString("2nd_NAME", inputField.text);
                    PlayerPrefs.Save();
                }
            }
            else if (Cameracollider.capture > _third_score)
            {
                PlayerPrefs.SetFloat("3rd_SCORE", Cameracollider.capture);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_DURATION", Cameracollider.battery);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_DV", Cameracollider.iss);
                PlayerPrefs.Save();
                PlayerPrefs.SetFloat("3rd_REL_V", Cameracollider.technical);
                PlayerPrefs.Save();
                if (inputField.text == "")
                {
                    PlayerPrefs.SetString("3rd_NAME", "KOUNOTORI");
                    PlayerPrefs.Save();
                }
                else
                {
                    PlayerPrefs.SetString("3rd_NAME", inputField.text);
                    PlayerPrefs.Save();
                }
            }

            _top_score      = PlayerPrefs.GetFloat("1st_SCORE", 0f);
            _top_duration   = PlayerPrefs.GetFloat("1st_DURATION", 0f);
            _top_dv         = PlayerPrefs.GetFloat("1st_DV", 0f);
            _top_relative_v = PlayerPrefs.GetFloat("1st_REL_V", 0f);
            _top_name       = PlayerPrefs.GetString("1st_NAME", "NO NAME");

            _second_score      = PlayerPrefs.GetFloat("2nd_SCORE", 0f);
            _second_duration   = PlayerPrefs.GetFloat("2nd_DURATION", 0f);
            _second_dv         = PlayerPrefs.GetFloat("2nd_DV", 0f);
            _second_relative_v = PlayerPrefs.GetFloat("2nd_REL_V", 0f);
            _second_name       = PlayerPrefs.GetString("2nd_NAME", "NO NAME");

            _third_score      = PlayerPrefs.GetFloat("3rd_SCORE", 0f);
            _third_duration   = PlayerPrefs.GetFloat("3rd_DURATION", 0f);
            _third_dv         = PlayerPrefs.GetFloat("3rd_DV", 0f);
            _third_relative_v = PlayerPrefs.GetFloat("3rd_REL_V", 0f);
            _third_name       = PlayerPrefs.GetString("3rd_NAME", "NO NAME");

            GameObject.Find("1st_name").GetComponent <Text>().text          = _top_name;
            GameObject.Find("2nd_name").GetComponent <Text>().text          = _second_name;
            GameObject.Find("3rd_name").GetComponent <Text>().text          = _third_name;
            GameObject.Find("1st_point").GetComponent <Text>().text         = string.Format("{0:0.0}", _top_score);
            GameObject.Find("2nd_point").GetComponent <Text>().text         = string.Format("{0:0.0}", _second_score);
            GameObject.Find("3rd_point").GetComponent <Text>().text         = string.Format("{0:0.0}", _third_score);
            GameObject.Find("1st_sub_relativeV").GetComponent <Text>().text = string.Format("{0:0.000}", _top_relative_v);
            GameObject.Find("2nd_sub_relativeV").GetComponent <Text>().text = string.Format("{0:0.000}", _second_relative_v);
            GameObject.Find("3rd_sub_relativeV").GetComponent <Text>().text = string.Format("{0:0.000}", _third_relative_v);
            GameObject.Find("1st_sub_duration").GetComponent <Text>().text  = string.Format("{0:0.0}", _top_duration);
            GameObject.Find("2nd_sub_duration").GetComponent <Text>().text  = string.Format("{0:0.0}", _second_duration);
            GameObject.Find("3rd_sub_duration").GetComponent <Text>().text  = string.Format("{0:0.0}", _third_duration);
            GameObject.Find("1st_sub_dv").GetComponent <Text>().text        = string.Format("{0:0.0}", _top_dv);
            GameObject.Find("2nd_sub_dv").GetComponent <Text>().text        = string.Format("{0:0.0}", _second_dv);
            GameObject.Find("3rd_sub_dv").GetComponent <Text>().text        = string.Format("{0:0.0}", _third_dv);
        }
    }
 /// <summary>
 /// 保存游戏配置。
 /// </summary>
 /// <returns>是否保存游戏配置成功。</returns>
 public override bool Save()
 {
     PlayerPrefs.Save();
     return(true);
 }
Esempio n. 25
0
 public void OpenGallery()
 {
     PlayerPrefs.SetFloat(SceneManagementConstants.PerPageKey, perPageSlider.value);
     PlayerPrefs.Save();
     SceneManager.LoadScene(SceneManagementConstants.GallerySceneIndex);
 }
Esempio n. 26
0
 public void Save()
 {
     PlayerPrefs.SetInt(scoreKey, score);
     PlayerPrefs.Save();
 }
 public void setMusicVolume(float value)
 {
     music.volume = value;
     PlayerPrefs.SetFloat("music volume", value);
     PlayerPrefs.Save();
 }
Esempio n. 28
0
    // Update is called once per frame
    void Update()
    {
        if (startGame == false)
        {
            Time.timeScale = 0f;
        }

        if (Input.GetKeyDown(KeyCode.Space) && startGame == false)
        {
            gameStart          = true;
            Time.timeScale     = 1f;
            ClockShots.text    = "";
            startGameText.text = "";
            startGame          = true;
        }

        //Sets the highscore to the highest score stored in PlayerPrefs
        highScore = PlayerPrefs.GetInt(highscoreKey);

        //The clock will go down depending on how much the bullets have slowed down
        clock -= (slowDown * Time.deltaTime);

        //Finds the gun in the scene and gets the script on it
        GameObject gun       = GameObject.Find("Gun");
        Gun        gunscript = gun.GetComponent <Gun> ();

        //This switch statement gives each bullet count an amount to slow down the clock by
        switch (gunscript.bulletCount)
        {
        case 6:
            slowDown = 1f;
            break;

        case 5:
            slowDown = .875f;
            break;

        case 4:
            slowDown = .75f;
            break;

        case 3:
            slowDown = .625f;
            break;

        case 2:
            slowDown = .5f;
            break;

        case 1:
            slowDown = .375f;
            break;

        case 0:
            slowDown = .25f;
            break;
        }

        //The clock will read the lowest int of the current time
        if (startGame == true)
        {
            clockText.text = "" + Mathf.FloorToInt(clock);
        }

        //Goes into the gun script and plays the the gunshot sound effect when gun is shot. Also changes the audio clip depending on the bulletCount
        if (gunscript.shotsound && gunscript.bulletCount > 2f)
        {
            audioSource.PlayOneShot(shotSound, .4f);
            gunscript.shotsound = false;
        }
        else if (gunscript.shotsound && gunscript.bulletCount <= 2f)
        {
            audioSource.PlayOneShot(slowShotSound, .4f);
            gunscript.shotsound = false;
        }

        if (gunscript.reloadSound)
        {
            audioSource.PlayOneShot(reloadSound, 1f);
            gunscript.reloadSound = false;
        }

        //The score will show as the score earned this round
        if (startGame == true)
        {
            scoreText.text = "Score: " + score;
        }

        //If the score is greater than the highscore, than set the PlayerPrefs to the score
        if (score > highScore)
        {
            PlayerPrefs.SetInt(highscoreKey, score);
            PlayerPrefs.Save();
        }

        //If the clock reaches less than 0, Game Over
        if (clock <= 0)
        {
            clock = 0;
            GameOver();
        }

        //Finds the player on the scene and gets its script
        GameObject  player       = GameObject.FindGameObjectWithTag("Player");
        NSMMovement playerScript = player.GetComponent <NSMMovement> ();

        //If player is hit with a bullet, Game Over
        if (playerScript.playerDead)
        {
            GameOver();
        }

        //If the restart is true and Escape is pressed, load the scene again and return Time.timeScale back to 1
        if (restart)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                SceneManager.LoadScene(0);
                Time.timeScale = 1;
            }
        }
    }
Esempio n. 29
0
 static public void ppSet(string id, string val)
 {
     PlayerPrefs.SetString(id, val);
     PlayerPrefs.Save();
 }
Esempio n. 30
0
    public void SetupControls()
    {
        if (!PlayerPrefs.HasKey("mouseAim"))
        {
            PlayerPrefs.SetString("mouseAim", "False");
        }

        if (!PlayerPrefs.HasKey("weaponHotkeys"))
        {
            PlayerPrefs.SetString("weaponHotkeys", "True");
        }

        if (!PlayerPrefs.HasKey("mapKey"))
        {
            PlayerPrefs.SetString("mapKey", "M");
        }

        if (!PlayerPrefs.HasKey("down"))
        {
            PlayerPrefs.SetString("down", "DownArrow");
        }

        if (!PlayerPrefs.HasKey("forward"))
        {
            PlayerPrefs.SetString("forward", "UpArrow");
        }

        if (!PlayerPrefs.HasKey("turnLeft"))
        {
            PlayerPrefs.SetString("turnLeft", "LeftArrow");
        }

        if (!PlayerPrefs.HasKey("turnRight"))
        {
            PlayerPrefs.SetString("turnRight", "RightArrow");
        }

        if (!PlayerPrefs.HasKey("shootKey"))
        {
            PlayerPrefs.SetString("shootKey", "Space");
        }

        if (!PlayerPrefs.HasKey("shootKey1"))
        {
            PlayerPrefs.SetString("shootKey1", "Alpha1");
        }

        if (!PlayerPrefs.HasKey("shootKey2"))
        {
            PlayerPrefs.SetString("shootKey2", "Alpha2");
        }

        if (!PlayerPrefs.HasKey("shootKey3"))
        {
            PlayerPrefs.SetString("shootKey3", "Alpha3");
        }

        if (!PlayerPrefs.HasKey("shootKey4"))
        {
            PlayerPrefs.SetString("shootKey4", "Alpha4");
        }

        if (!PlayerPrefs.HasKey("shootKey5"))
        {
            PlayerPrefs.SetString("shootKey5", "Alpha5");
        }

        if (!PlayerPrefs.HasKey("cruiseKey"))
        {
            PlayerPrefs.SetString("cruiseKey", "C");
        }

        if (!PlayerPrefs.HasKey("respawnKey"))
        {
            PlayerPrefs.SetString("respawnKey", "Space");
        }

        if (!PlayerPrefs.HasKey("chatKey"))
        {
            PlayerPrefs.SetString("chatKey", "KeypadEnter");
        }

        if (!PlayerPrefs.HasKey("chatKey2"))
        {
            PlayerPrefs.SetString("chatKey2", "Return");
        }

        if (!PlayerPrefs.HasKey("settingsMenuKey"))
        {
            PlayerPrefs.SetString("settingsMenuKey", "H");
        }

        if (!PlayerPrefs.HasKey("inventoryKey"))
        {
            PlayerPrefs.SetString("inventoryKey", "I");
        }

        if (!PlayerPrefs.HasKey("playerMenuKey"))
        {
            PlayerPrefs.SetString("playerMenuKey", "P");
        }

        PlayerPrefs.Save();
    }