Ejemplo n.º 1
0
 public static void ClearAll(bool prompt)
 {
     if (!prompt || EditorUtility.DisplayDialog("Clear Editor Prefs", "Delete all the editor preferences?", "Yes", "No"))
     {
         PlayerPref.ClearAll();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 public void ResetGame()
 {
     playerPref = new PlayerPref();
     save();
     soundButton.GetComponent <Image>().sprite = normalSound;
     Awake();
 }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     #region PlayerPref
     if (PlayerPref.kolayDegerOku() == 1)
     {
         carpan1           = 0.7f;
         carpan2           = 1.3f;
         canEklemeZamanı   = 10;
         virüsÜretmeZamanı = 2.4f;
     }
     if (PlayerPref.ortaDegerOku() == 1)
     {
         carpan1           = 0.9f;
         carpan2           = 1.5f;
         canEklemeZamanı   = 12;
         virüsÜretmeZamanı = 2.2f;
     }
     if (PlayerPref.zorDegerOku() == 1)
     {
         carpan1           = 1.1f;
         carpan2           = 1.8f;
         canEklemeZamanı   = 14;
         virüsÜretmeZamanı = 2f;
     }
     #endregion
     Puan                      = 0;
     ekran_Hesaplama           = cadde1.GetComponent <Ekran_Hesaplama>();
     camKonum                  = Camera.main.transform.position;
     cadde1.transform.position = new Vector2(camKonum.x, camKonum.y);
     cadde2.transform.position = new Vector2(camKonum.x + ekran_Hesaplama.EkranGenislik, camKonum.y);
     oyunBalangıcı();
 }
    // Use this for initialization
    void Start()
    {
        //Set all panels to Hide until we need them
        StoryPanel.SetActive(false);
        LevelPanel.SetActive(false);
        ChallengePanel.SetActive(false);
        AccountPanel.SetActive(false);
        //Logout Button
        Logout.onClick.AddListener(LogOut);
        //Linking and unlinking device
        LinkButton.onClick.AddListener(LinkAndUnlink);
        //Opening and closing account panel
        AccountButton.onClick.AddListener(OpenAccount);
        CloseButton.onClick.AddListener(CloseAccount);
        ClearButton.onClick.AddListener(ClearData);
        //Story mode
        StoryButton.onClick.AddListener(Storymode);
        LevelButton.onClick.AddListener(Levelmode);
        ChallengeButton.onClick.AddListener(Challengemode);
        //Credit page
        CreditButton.gameObject.SetActive(true);
        CreditButton.onClick.AddListener(GoToCredit);

        //Subscribe to events that happen after we get data
        PlayFabService.DataResult += DataResult;
        pf = new PlayerPref();

        //Remove Some UI for WebGL
        if (Application.platform == RuntimePlatform.WebGLPlayer)
        {
            Logout.gameObject.SetActive(false);
            LinkButton.gameObject.SetActive(false);
            Title.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 5
0
    public static void Save(string name, object o)
    {
        Type t = o.GetType();

        FieldInfo[] fiedls = t.GetFields();
        for (int i = 0; i < fiedls.Length; i++)
        {
            string saveName = name + "." + fiedls[i].Name;
            switch (fiedls[i].FieldType.Name)
            {
            case "String":
                PlayerPref.SetString(saveName, fiedls[i].GetValue(o).ToString());
                break;

            case "Int32":
            case "Int64":
            case "Int":
            case "uInt":
                PlayerPref.SetInt(saveName, (int)fiedls[i].GetValue(o));
                break;

            case "Float":
                PlayerPref.SetFloat(saveName, (float)fiedls[i].GetValue(o));
                break;
            }
        }
    }
Ejemplo n.º 6
0
 public static void LoadCvar(Cvar data)
 {
     if (Console.Get().configFile != "")
     {
         return;
     }
     if (PlayerPref.Has(data.fullName))
     {
         object value = data.value.Get();
         Type   type  = data.value.type;
         if (type == typeof(float))
         {
             value = PlayerPref.Get <float>(data.fullName);
         }
         else if (type == typeof(string))
         {
             value = PlayerPref.Get <string>(data.fullName);
         }
         else if (type == typeof(int) || type == typeof(byte))
         {
             value = PlayerPref.Get <int>(data.fullName);
         }
         else if (type == typeof(bool))
         {
             value = PlayerPref.Get <int>(data.fullName) == 1 ? true : false;
         }
         data.value.Set(value);
     }
 }
Ejemplo n.º 7
0
 public void UpdateEffects()
 {
                 #if UNITY_EDITOR
     var updateShaders   = PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateShaders");
     var updateParticles = PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateParticles");
     if (updateShaders)
     {
         Shader.SetGlobalFloat("timeConstant", Time.Get());
     }
     foreach (var system in Locate.GetSceneComponents <ParticleSystem>())
     {
         if (system.IsNull())
         {
             continue;
         }
         var updater = system.gameObject.GetComponent <UpdateParticle>();
         if (updateParticles && updater.IsNull())
         {
             updater           = system.gameObject.AddComponent <UpdateParticle>();
             updater.hideFlags = HideFlags.DontSaveInBuild | HideFlags.NotEditable | HideFlags.HideInInspector;
         }
         if (!updateParticles && !updater.IsNull())
         {
             DestroyImmediate(updater);
         }
     }
     if (updateShaders || updateParticles)
     {
         ProxyEditor.RepaintSceneView();
     }
                 #endif
 }
Ejemplo n.º 8
0
    public static T GetValue <T>(string name) where T : new()
    {
        T newObj = new T();

        Type t = newObj.GetType();

        FieldInfo[] fiedls = t.GetFields();
        for (int i = 0; i < fiedls.Length; i++)
        {
            string saveName = name + "." + fiedls[i].Name;
            switch (fiedls[i].FieldType.Name)
            {
            case "String":
                fiedls[i].SetValue(newObj, PlayerPref.GetString(saveName));
                break;

            case "Int32":
            case "Int64":
            case "Int":
            case "uInt":
                fiedls[i].SetValue(newObj, PlayerPref.GetInt(saveName));
                break;

            case "Float":
                fiedls[i].SetValue(newObj, PlayerPref.GetFloat(saveName));
                break;
            }
        }

        return(newObj);
    }
Ejemplo n.º 9
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 10
0
 private void buttonInSelect_Click(object sender, EventArgs e)
 {
     if (IsFolder)
     {
         FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
         folderBrowserDialog1.Description         = "请选择文件夹路径";
         folderBrowserDialog1.ShowNewFolderButton = false;
         folderBrowserDialog1.SelectedPath        = InputPath;
         DialogResult result = folderBrowserDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             string folderName = folderBrowserDialog1.SelectedPath;
             if (folderName != "")
             {
                 textBoxInput.Text = folderName;
             }
         }
     }
     else
     {
         OpenFileDialog fileDialog = new OpenFileDialog();
         fileDialog.Multiselect = false;
         fileDialog.Title       = "请选择文件";
         fileDialog.FileName    = PlayerPref.GetData("Md5VersionSingle_Input");
         fileDialog.Filter      = "所有 文件(*.*)|*.*";
         if (fileDialog.ShowDialog() == DialogResult.OK)
         {
             textBoxInput.Text = fileDialog.FileName;
         }
     }
 }
Ejemplo n.º 11
0
        public static void LoadBinds()
        {
            Console.AddBind("BackQuote", "console");
            if (Console.Get().configFile != "")
            {
                return;
            }
            if (!PlayerPref.Has("binds"))
            {
                PlayerPref.Set <string>("binds", "|");
            }
            string binds = PlayerPref.Get <string>("binds");

            string[] bindList = binds.Split('|');
            foreach (string item in bindList)
            {
                string[] dataList = item.Split('-');
                if (dataList.Length < 3)
                {
                    continue;
                }
                string key         = dataList[1];
                string action      = dataList[2];
                bool   toggle      = dataList[0] == "toggle";
                bool   repeat      = dataList[0] == "repeat";
                float  repeatDelay = dataList.Length > 3 ? Convert.ToSingle(dataList[3]) : 0;
                Console.AddBind(key, action, toggle, repeat, repeatDelay);
            }
        }
Ejemplo n.º 12
0
    public static float GetFloat(string key, float defaultValue = 0f)
    {
        string @string = PlayerPref.GetString(key, defaultValue.ToString());
        float  result  = defaultValue;

        float.TryParse(@string, out result);
        return(result);
    }
Ejemplo n.º 13
0
    public static int GetInt(string key, int defaultValue = 0)
    {
        string @string = PlayerPref.GetString(key, defaultValue.ToString());
        int    result  = defaultValue;

        int.TryParse(@string, out result);
        return(result);
    }
Ejemplo n.º 14
0
        public override void Load()
        {
            string path = this.value.info.fullPath;

            this.value.x = PlayerPref.Get <float>(path + "x");
            this.value.y = PlayerPref.Get <float>(path + "y");
            this.value.z = PlayerPref.Get <float>(path + "z");
        }
Ejemplo n.º 15
0
        public override void Store()
        {
            string path = this.value.info.fullPath;

            PlayerPref.Set <float>(path + "x", this.value.x);
            PlayerPref.Set <float>(path + "y", this.value.y);
            PlayerPref.Set <float>(path + "z", this.value.z);
        }
Ejemplo n.º 16
0
 public void Zor()
 {
     PlayerPref.kolayDegerAta(0);
     PlayerPref.ortaDegerAta(0);
     PlayerPref.zorDegerAta(1);
     kolay.interactable = true;
     orta.interactable  = true;
     zor.interactable   = false;
 }
Ejemplo n.º 17
0
    // Start is called before the first frame update
    void Start()
    {
        puan1 = PlayerPref.puan1rOku();
        puan2 = PlayerPref.puan2rOku();
        puan3 = PlayerPref.puan3Oku();

        Puan1.text = "1:)   " + puan1.ToString();
        Puan2.text = "2:)   " + puan2.ToString();
        Puan3.text = "3:)   " + puan3.ToString();
    }
Ejemplo n.º 18
0
    public static string GetString(string key, string defaultValue = "")
    {
        string text    = defaultValue;
        string @string = PlayerPrefs.GetString(PlayerPref.GetHash(key), defaultValue.ToString());

        if (!text.Equals(@string))
        {
            text = PlayerPref.Decrypt(@string);
        }
        return(text);
    }
Ejemplo n.º 19
0
        private void Init()
        {
            if (IsFolder)
            {
                labelInput.Text = "资源文件夹路径:";
                InputPath       = PlayerPref.GetData(VersionFolderInput);
                OutPutPath      = PlayerPref.GetData(VersionFolderOutput);
            }
            else
            {
                labelInput.Text = "资源文件路径:";
                InputPath       = PlayerPref.GetData(VersionSingleInput);
                OutPutPath      = PlayerPref.GetData(VersionSingleOutput);
            }
            BigVersionNum              = PlayerPref.GetData(VersionBigVersionNum);
            VerType                    = PlayerPref.GetData(VersionType);
            TarType                    = PlayerPref.GetData(TargetType);
            IgnoorePostFix             = PlayerPref.GetData(VersionIgnorePostFix);
            textBoxInput.Text          = InputPath;
            textBoxOutPut.Text         = OutPutPath;
            textBoxBigVersionNum.Text  = BigVersionNum;
            textBoxIgnoreFileName.Text = IgnoorePostFix;
            switch (VerType)
            {
            case "Num":
                radioButtonNum.Checked = true;
                break;

            default:
                radioButtonMd5.Checked = true;
                break;
            }
            switch (TarType)
            {
            case "Upper":
                radioButtonUpper.Checked = true;
                break;

            default:
                radioButtonLower.Checked = true;
                break;
            }
            SizeUnit = PlayerPref.GetData(VersionFileSizeUnit, "B");
            for (int i = 0; i < cbUnit.Items.Count; i++)
            {
                if (cbUnit.Items[i].ToString() == SizeUnit)
                {
                    cbUnit.SelectedIndex = i;
                    break;
                }
            }
            buttonSave.Enabled = false;
        }
Ejemplo n.º 20
0
    private void LoadPlayerPref()
    {
        playerPref = new PlayerPref();

        //Stores and accesses player preferences between game sessions.
        // HasKey Returns true if key exists in the preferences.
        if (PlayerPrefs.HasKey("audioMode"))
        {
            // get audioMode form PlayePrefs and store in playerPref.audioMode
            playerPref.audioMode = PlayerPrefs.GetInt("audioMode");
        }
    }
Ejemplo n.º 21
0
 void Awake()
 {
     if(current != null && current != this)
     {
         Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         current = this;
     }
 }
Ejemplo n.º 22
0
        public static void ResetCvars(string[] values)
        {
            string binds = PlayerPref.Get <string>("binds");

            PlayerPref.ClearAll();
            PlayerPref.Set <string>("binds", binds);
            foreach (var item in Console.cvars)
            {
                Cvar data = item.Value;
                data.value.Set(data.defaultValue);
            }
            Console.AddLog("^10All stored ^3cvars^10 have been reset to default values.");
        }
Ejemplo n.º 23
0
 bool TryGetPlayerPref(string key, out PlayerPref playerPref)
 {
     playerPref = null;
     for (int i = 0; i < playerPrefs.Count; i++)
     {
         if (playerPrefs[i].key == key)
         {
             playerPref = playerPrefs[i];
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 24
0
 void Start()
 {
     Time.timeScale = 1;
     if (!PlayerPref.ZorlukDegerKontrol())
     {
         PlayerPref.ortaDegerAta(1);
     }
     //Debug.Log("aa"+PlayerPref.Puanlar.Count);
     if (PlayerPref.Puanlar.Count < 1)
     {
         PlayerPref.Puanlar.Add(PlayerPref.puan1rOku());
         PlayerPref.Puanlar.Add(PlayerPref.puan2rOku());
         PlayerPref.Puanlar.Add(PlayerPref.puan3Oku());
     }
 }
Ejemplo n.º 25
0
 void muteButtonClick()
 {
     if (PlayerPrefs.GetInt("playerMute"))
     {
         // If 1 (on)
         // Set sound off
         PlayerPref.SetInt("playerMute", 0);
     }
     else
     {
         // It's 0 (off)
         // Set sound on
         PlayerPrefs.SetInt("playerMute", 1);
     }
 }
Ejemplo n.º 26
0
 public void OnWillRenderObject()
 {
     if (Proxy.IsEditor() && !Proxy.IsPlaying() && Camera.current != null)
     {
         if (PlayerPref.Get <bool>("EditorSettings-AlwaysUpdateParticles"))
         {
             float   range          = PlayerPref.Get <float>("EditorSettings-ParticleUpdateRange");
             Vector3 cameraPosition = Camera.current.transform.position;
             Vector3 objectPosition = this.transform.position;
             if (Vector3.Distance(cameraPosition, objectPosition) <= range)
             {
                 this.GetComponent <ParticleSystem>().Simulate(Time.Get() % 60 + 10);
             }
         }
     }
 }
Ejemplo n.º 27
0
        private void buttonOutSelect_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();

            folderBrowserDialog1.Description         = "请选择生成的文件路径";
            folderBrowserDialog1.SelectedPath        = PlayerPref.GetData("Md5VersionSingle_Output");
            folderBrowserDialog1.ShowNewFolderButton = false;
            DialogResult result = folderBrowserDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                string folderName = folderBrowserDialog1.SelectedPath;
                if (folderName != "")
                {
                    textBoxOutPut.Text = folderName;
                }
            }
        }
Ejemplo n.º 28
0
    public void Test()
    {
        User user = new User();

        user.Name     = "哈哈哈";
        user.Age      = 122;
        user.Describe = "test ";
        user.dse      = "text";
        user.text     = "text";
        PlayerPref.Save("user", user);

        user = null;

        user = PlayerPref.GetValue <User>("user");

        Debug.Log("user name: " + user.Name);
        Debug.Log("user Age: " + user.Age);
        Debug.Log("user Describe: " + user.Describe);
    }
Ejemplo n.º 29
0
    /// <summary>
    /// Load game data (Player Pref)
    /// </summary>
    public void load()
    {
        string data = PlayerPrefs.GetString(PLAYER_KEY);

        if (data == null || data.Length == 0)
        {
            playerPref = new PlayerPref();
        }
        else
        {
            BinaryFormatter bf = new BinaryFormatter();
            byte[]          b  = Convert.FromBase64String(data);
            MemoryStream    ms = new MemoryStream(b);

            try {
                playerPref = (PlayerPref)bf.Deserialize(ms);
            } finally {
                ms.Close();
            }
        }
    }
Ejemplo n.º 30
0
 // Start is called before the first frame update
 void Start()
 {
     if (PlayerPref.kolayDegerOku() == 1)
     {
         kolay.interactable = false;
         orta.interactable  = true;
         zor.interactable   = true;
     }
     if (PlayerPref.ortaDegerOku() == 1)
     {
         kolay.interactable = true;
         orta.interactable  = false;
         zor.interactable   = true;
     }
     if (PlayerPref.zorDegerOku() == 1)
     {
         kolay.interactable = true;
         orta.interactable  = true;
         zor.interactable   = false;
     }
 }
    //  Use this for initialization
    private void Start()
    {
        is_bunny_moving_            = false;
        are_loop_commands_finished_ = false;
        executing_loop_             = false;
        hit_a_rock_ = false;
        win_        = false;

        next_command_name_ = "";
        error_message_     = "Oops! Wrong commands!";

        if (SceneManager.GetActiveScene().name.Contains("Challenge"))
        {
            is_challenge_level_ = true;
        }
        else
        {
            is_challenge_level_ = false;
        }

        execute_function_calls_ = new Stack <bool>();
        list_of_commands_       = new List <GameObject>();

        Win.text        = "";
        speed_          = 3;
        Beginning_      = GameObject.FindGameObjectWithTag("Respawn");
        PlayerCommands_ = GameObject.FindGameObjectWithTag("Player Commands");
        if (is_challenge_level_ == true)
        {
            score_ = GameObject.FindGameObjectWithTag("Score");
        }
        else
        {
            score_ = null;
        }

        anim   = GetComponent <Animator>();
        level_ = SceneManager.GetSceneAt(SceneManager.sceneCount - 1).name;
        pf_    = new PlayerPref();
    }