//############################################################# Si le joueur est sur une case specifique
 void OnTriggerEnter(Collider contact)
 {
     Debug.Log(contact.name);
     if (contact.name == "Clef")
     {
         Evenements.color = new Color(255, 220, 0, 255);
         Evenements.GetComponent <Text>().text = "Une Clef! Où est le trésor?";
         Tpevent         = (int)time;
         clef            = true;
         ImageClef.color = new Color(0, 255, 0, 255);
         Destroy(Clef);
     }
     if (contact.name == "FausseClef")
     {
         Evenements.color = new Color(255, 220, 0, 255);
         Evenements.GetComponent <Text>().text = "Oups! Fausse Clef";
         Tpevent = (int)time;
         Destroy(FausseClef);
     }
     if (contact.name == "Tresor")
     {
         if (clef == true)
         {
             //A la victoire on charge le scene win, on recup le pseudo qu'on detruit et crée un résultat av une clef qui s'incremente
             Evenements.color = new Color(255, 220, 0, 255);
             Evenements.GetComponent <Text>().text = "Victoire";
             Tpevent = (int)time;
             Debug.Log("Victoire!!");
             string Pseudo = PlayerPrefs.GetString("Pseudo");
             int    i      = 0;
             while (PlayerPrefs.HasKey(i.ToString()))
             {
                 i++;
             }
             Handheld.Vibrate();
             PlayerPrefs.SetString(i.ToString(), Pseudo + "/" + time);
             PlayerPrefs.SetString("TempsVictoire", time.ToString());
             SceneManager.LoadScene("Victoire");
             Destroy(Tresor);
         }
     }
     if (contact.name == "Trou")
     {
         //Affichage fond rouge
         Fond.color = new Color32(255, 0, 0, 60);
         Handheld.Vibrate();
         Trou.GetComponent <Renderer>().enabled = true;
         Debug.Log("Tombé, Défaite!");
         PlayerPrefs.SetString("mort", "trou");
         SceneManager.LoadScene("Defaite");
     }
     if (contact.name == "Torche")
     {
         Evenements.color = new Color(255, 220, 0, 255);
         Evenements.GetComponent <Text>().text = "Cool! Une torche";
         Tpevent           = (int)time;
         Lumière.spotAngle = 35;
         Destroy(Torche);
     }
     if (contact.name == "Pic1")
     {
         Evenements.color = new Color(255, 220, 0, 255);
         Evenements.GetComponent <Text>().text = "Aie! des Pics";
         Tpevent = (int)time;
         vie--;
         Debug.Log("Vie=" + vie);
         Pic1.GetComponent <Renderer>().enabled = true;
         Pic1.transform.localScale = new Vector3(0.5f, 0.5f, 1f);
         //Affichage fond rouge
         Fond.color = new Color32(255, 0, 0, 60);
     }
     if (contact.name == "Pic2")
     {
         Evenements.color = new Color(255, 220, 0, 255);
         Evenements.GetComponent <Text>().text = "Aie! des Pics";
         Tpevent = (int)time;
         vie--;
         Debug.Log("Vie=" + vie);
         Pic2.GetComponent <Renderer>().enabled = true;
         Pic2.transform.localScale = new Vector3(0.5f, 0.5f, 1f);
         //Affichage fond rouge
         Fond.color = new Color32(255, 0, 0, 60);
     }
     if (contact.name == "Pic3")
     {
         //Affichage events texte
         Evenements.color = new Color(255, 220, 0, 255);
         Evenements.GetComponent <Text>().text = "Aie! des Pics";
         Tpevent = (int)time;
         vie--;
         Debug.Log("Vie=" + vie);
         //Affichage pic
         Pic3.GetComponent <Renderer>().enabled = true;
         Pic3.transform.localScale = new Vector3(0.5f, 0.5f, 1f);
         //Affichage fond rouge
         Fond.color = new Color32(255, 0, 0, 60);
     }
     if (contact.name == "Serpent")
     {
         //Affichage event empoisonné
         Evenements.GetComponent <Text>().text = "Empoisonné! Vite des Soins";
         Evenements.color = Color.green;
         Tpoison          = (int)time;
         Tpevent          = (int)time;
         Player.GetComponent <Renderer>().material.color = Color.green;
         poison = true;
         //Ecran vert poison
         Fond.color = new Color32(0, 255, 0, 60);
     }
     if (contact.name == "Soin")
     {
         Evenements.color = new Color(255, 220, 0, 255);
         Evenements.GetComponent <Text>().text = "Super! Je me sens mieux";
         Tpevent = (int)time;
         Player.GetComponent <Renderer>().material.color = new Color(255, 150, 0, 255);
         if (vie < 3)
         {
             vie++;
         }
         poison = false;
         Debug.Log("Vie=" + vie);
         Destroy(Soin);
     }
 }
 public static void SaveJson <T>(string key, T data)
 {
     PlayerPrefs.SetString(key, JsonUtility.ToJson(data));
 }
Esempio n. 3
0
 void LoadGame(string loatFile)
 {
     PlayerPrefs.SetString("MainLoad", loatFile);
     SceneManager.LoadScene("Level_1");
 }
Esempio n. 4
0
    void Update()
    {
        //print("emergency sub stat: " + curSub.EmergencyStatus);

        prevSub = Get_sub_stats();

        if (!Get_innerairlock_pos() || !Get_innerairlock_lock() || !Get_outerairlock_pos() || !Get_outerairlock_lock())
        {
            isReady = false;
        }
        else
        {
            isReady = true;
        }
        animator.SetBool("isReady", isReady);
        animator.SetBool("isAlive", isAlive);

        //check for emergency surface
        if (isEmergency)
        //if (Check_emergency())
        {
            if (curSub.Temp < 100 && curSub.Oxygen > 0)
            {
                //TODO dud noise?
                StartCoroutine(ShowWarning("The emergency surface procedure has been triggered unnecessarily"));
            }

            if (transform.position.y != subPos.y)
            {
                print("pos is: " + transform.position.y + ", should be: " + subPos.y);
                isSurfacing        = true;
                transform.position = Vector2.MoveTowards(transform.position, new Vector2(transform.position.x, subPos.y), 1.0f * Time.deltaTime);
            }
            else
            {
                Stop_emergency_surface();
                isSurfacing = false;
            }
        }
        else
        {
            if (curSub.Temp >= 100)
            {
                PlayerPrefs.SetString("PlayerDeath", "The sub didn't emergency surface and overheated.");
                StartCoroutine(TriggerExplosion());
            }
            else if (curSub.Oxygen <= 0)
            {
                PlayerPrefs.SetString("PlayerDeath", "The sub didn't emergency surface and ran out of oxygen.");
                StartCoroutine(TriggerExplosion()); //TODO update to correct death animation
            }
        }

        //Do some sub stuff
        if (!isPaused && isAlive && !isSurfacing)
        {
            //move the sub
            if (Input.GetKeyUp(KeyCode.LeftArrow)) //move sub left
            {
                //TESTING
                //Test 1: too far left:

                /*prevSub.FrontSpace = 100;
                 *              curSub.FrontSpace = 100;
                 * curSub.FrontSpace++;*/

                //Test 2: Everything working

                /*prevSub.FrontSpace = 10;
                 *              curSub.FrontSpace = 10;
                 * curSub.FrontSpace++;*/

                //ACTUAL FUNCTION
                Sub_go_back();
                curSub = Get_sub_stats();

                if (curSub.FrontSpace > 100)
                {
                    PlayerPrefs.SetString("PlayerDeath", "The sub went beyond the boundaries.");
                    StartCoroutine(TriggerExplosion());
                }
                else if (prevSub.FrontSpace < curSub.FrontSpace)
                {
                    transform.Translate(-horizontalMovement, 0, 0);
                }
            }
            else if (Input.GetKeyUp(KeyCode.RightArrow)) //move right
            {
                //TESTING
                //Test 1: too far right:

                /*prevSub.FrontSpace = 0;
                 * curSub.FrontSpace = 0;
                 * curSub.FrontSpace--;
                 * print(curSub.FrontSpace);*/

                //Test 2: Everything working

                /*prevSub.FrontSpace = 10;
                 * curSub.FrontSpace = 10;
                 * curSub.FrontSpace--;
                 * print(curSub.FrontSpace);*/

                //ACTUAL FUNCTION
                Sub_go_forward();
                curSub = Get_sub_stats();

                //FrontSpace has changed from 0 but not decreased - this should indicate it has incorrectly moved further right
                //which should result in a value of 255 since it's stored in a byte
                //But want to account for any possible incorrect value
                if (prevSub.FrontSpace == 0 && curSub.FrontSpace != prevSub.FrontSpace && curSub.FrontSpace != 1)
                {
                    PlayerPrefs.SetString("PlayerDeath", "The sub went beyond the boundaries.");
                    StartCoroutine(TriggerExplosion());
                }
                else if (prevSub.FrontSpace > curSub.FrontSpace)
                {
                    transform.Translate(horizontalMovement, 0, 0);
                }
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow)) //dive
            {
                //TESTING
                //Test 1: too deep:

                /*curSub.Depth = 100;
                 * curSub.Depth++;*/

                //Test 2: Everything working

                /*prevSub.Depth = 10;
                 *              curSub.Depth = 10;
                 * curSub.Depth++;*/

                //ACTUAL FUNCTION
                Sub_dive();
                curSub = Get_sub_stats();

                if (curSub.Depth > 100)
                {
                    transform.Translate(0, -verticalMovement, 0);
                    PlayerPrefs.SetString("PlayerDeath", "The sub went too deep.");
                    StartCoroutine(TriggerImplosion());
                }
                else if (prevSub.Depth < curSub.Depth)
                {
                    transform.Translate(0, -verticalMovement, 0);
                }
            }
            else if (Input.GetKeyUp(KeyCode.UpArrow)) //surface
            {
                //TESTING
                //Test 1: too high:

                /*prevSub.Depth = 0;
                 * curSub.Depth = 0;
                 * curSub.Depth--;
                 * print(curSub.Depth);*/

                //Test 2: Everything working

                /*prevSub.Depth = 1;
                 * curSub.Depth = 1;
                 * curSub.Depth--;
                 * print(curSub.Depth);*/

                //ACTUAL FUNCTION
                Sub_surface();
                curSub = Get_sub_stats();

                //Depth has changed from 0 but not decreased - this should indicate it has incorrectly surfaced further
                //which should result in a value of 255 since it's stored in a byte
                //But want to account for any possible incorrect value
                if (prevSub.Depth == 0 && curSub.Depth != prevSub.Depth && curSub.Depth != 1)
                {
                    PlayerPrefs.SetString("PlayerDeath", "The sub left the water.");
                    StartCoroutine(TriggerExplosion()); //TODO need something different - like the sub flying away
                }
                else if (prevSub.Depth > curSub.Depth)
                {
                    transform.Translate(0, verticalMovement, 0);
                }
            }

            //Reset the sub
            if (Input.GetKeyUp(KeyCode.Keypad0))
            {
                //print("Resetting...\n");
                ResetSub();
            }

            //Use the doors
            if (Input.GetKeyUp(KeyCode.I))
            {
                //TESTING
                //Test 1: opening a second door

                /*curSub.InnerAirlockPos = false;
                *  curSub.OuterAirlockPos = false;*/

                //Test 2: not toggling inner door when unlocked

                /*curSub.InnerAirlockLock = false;
                 * prevSub.InnerAirlockPos = true;
                 * curSub.InnerAirlockPos = true;*/

                //Test 3: Toggling inner door when locked

                /*curSub.InnerAirlockLock = true;
                 * curSub.InnerAirlockPos = true;
                 * prevSub.InnerAirlockPos = false;*/

                //ACTUAL FUNCTION
                //print("toggle inner door pos\n");
                Close_inner_door();
                curSub = Get_sub_stats();
                UpdateDoors();

                //if new door pos = open AND other door pos = open -> death
                if (curSub.InnerAirlockPos == false && curSub.OuterAirlockPos == false)
                {
                    audioSource.PlayOneShot(doorSFX);
                    PlayerPrefs.SetString("PlayerDeath", "Both doors have been opened, flooding the sub.");
                    StartCoroutine(TriggerImplosion());
                }
                //if prev door pos == new door pos AND the door is unlocked, toggle didn't work
                else if (curSub.InnerAirlockPos == prevSub.InnerAirlockPos && curSub.InnerAirlockLock == false)
                {
                    //TODO dud noise
                    StartCoroutine(ShowWarning("The inner door failed to open/close."));
                }
                //if prev door pos != new door pos BUT door = locked
                else if (curSub.InnerAirlockPos != prevSub.InnerAirlockPos && curSub.InnerAirlockLock == true)
                {
                    StartCoroutine(ShowWarning("The inner door lock appears to be broken."));
                }
                //Everything is fine
                else if (curSub.InnerAirlockPos != prevSub.InnerAirlockPos && curSub.InnerAirlockLock == false)
                {
                    audioSource.PlayOneShot(doorSFX);
                }
                //something other than the expected scenarios has happened - will need to be investigated
                else
                {
                    StartCoroutine(ShowWarning("Something unexpected has happened..."));
                }
            }
            if (Input.GetKeyUp(KeyCode.K))
            {
                //TESTING
                //Test 1: lock doesn't change

                /*curSub.InnerAirlockLock = false;
                 * prevSub.InnerAirlockLock = false;*/

                //ACTUAL FUNCTION
                //print("toggle inner door lock\n");
                Lock_inner_door();
                curSub = Get_sub_stats();
                UpdateDoors();

                //The lock hasn't changed.
                //Can't differentiate between deliberate or erroneous so using a generic warning
                if (curSub.InnerAirlockLock == prevSub.InnerAirlockLock)
                {
                    StartCoroutine(ShowWarning("The inner lock hasn't changed"));
                    //TODO play dud sound
                }
                //everything is fine
                else if (curSub.InnerAirlockLock != prevSub.InnerAirlockLock)
                {
                    audioSource.PlayOneShot(doorSFX);
                }
                //something other than the expected scenarios has happened - will need to be investigated
                else
                {
                    StartCoroutine(ShowWarning("Something unexpected has happened..."));
                }
            }
            if (Input.GetKeyUp(KeyCode.O))
            {
                //TESTING
                //Test 1: opening a second door

                /*curSub.InnerAirlockPos = false;
                *  curSub.OuterAirlockPos = false;*/

                //Test 2: not toggling outer door when unlocked

                /*curSub.OuterAirlockLock = false;
                 * prevSub.OuterAirlockPos = true;
                 * curSub.OuterAirlockPos = true;*/

                //Test 3: Toggling outer door when locked

                /*curSub.OuterAirlockLock = true;
                 * curSub.OuterAirlockPos = true;
                 * prevSub.OuterAirlockPos = false;*/

                //ACTUAL FUNCTION
                //print("toggle outer door pos\n");
                Close_outer_door();
                curSub = Get_sub_stats();
                UpdateDoors();

                //if new door pos = open AND other door pos = open - death
                if (curSub.OuterAirlockPos == false && curSub.OuterAirlockPos == false)
                {
                    audioSource.PlayOneShot(doorSFX);
                    PlayerPrefs.SetString("PlayerDeath", "Both doors have been opened, flooding the sub.");
                    StartCoroutine(TriggerImplosion());
                }
                //if prev door pos == new door pos AND the door is unlocked, toggle didn't work - warning  && dud noise
                else if (curSub.OuterAirlockPos == prevSub.OuterAirlockPos && curSub.OuterAirlockLock == false)
                {
                    StartCoroutine(ShowWarning("The outer door position hasn't changed"));
                }
                //if prev door pos != new door pos BUT door = locked - warning and dud noise
                else if (curSub.OuterAirlockPos != prevSub.OuterAirlockPos && curSub.OuterAirlockLock == true)
                {
                    StartCoroutine(ShowWarning("The outer door hasn't changed"));
                }
                //Everything is fine
                else if (curSub.OuterAirlockPos != prevSub.OuterAirlockPos && curSub.OuterAirlockLock == false)
                {
                    audioSource.PlayOneShot(doorSFX);
                }
                //something other than the expected scenarios has happened - will need to be investigated
                else
                {
                    StartCoroutine(ShowWarning("Something unexpected has happened..."));
                }
            }
            if (Input.GetKeyUp(KeyCode.L))
            {
                //TESTING
                //Test 1: lock doesn't change

                /*curSub.OuterAirlockLock = false;
                 * prevSub.OuterAirlockLock = false;*/

                //ACTUAL FUNCTION
                //print("toggle outer door lock\n");
                Lock_outer_door();
                curSub = Get_sub_stats();
                UpdateDoors();

                //The lock hasn't changed.
                //Can't differentiate between deliberate or erroneous so using a generic warning
                if (curSub.OuterAirlockLock == prevSub.OuterAirlockLock)
                {
                    StartCoroutine(ShowWarning("The outer lock hasn't changed"));
                    //TODO play dud sound
                    //audioSource.PlayOneShot(DudSFX);
                }
                //everything is fine
                else if (curSub.OuterAirlockLock != prevSub.OuterAirlockLock)
                {
                    audioSource.PlayOneShot(doorSFX);
                }
                //something other than the expected scenarios has happened - will need to be investigated
                else
                {
                    StartCoroutine(ShowWarning("Something unexpected has happened..."));
                }
            }

            //Fire torpedos (tube num)
            if (Input.GetKeyUp(KeyCode.Alpha1))
            {
                FireTorpedo(1);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha2))
            {
                FireTorpedo(2);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha3))
            {
                FireTorpedo(3);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha4))
            {
                FireTorpedo(4);
            }

            //load torpedos (tube num)
            if (Input.GetKeyUp(KeyCode.Q))
            {
                LoadTorpedo(1);
            }
            else if (Input.GetKeyUp(KeyCode.W))
            {
                LoadTorpedo(2);
            }
            else if (Input.GetKeyUp(KeyCode.E))
            {
                LoadTorpedo(3);
            }
            else if (Input.GetKeyUp(KeyCode.R))
            {
                LoadTorpedo(4);
            }
        }

        // FOR TESTING PURPOSES
        if (Input.GetKeyUp(KeyCode.T))
        {
            //Vector3 targetPos = transform.position - new Vector3(0.0f, 2.5f, 0.0f);
            //StartCoroutine(TriggerImplosion(targetPos));
            //StartCoroutine(TriggerImplosion());

            //StartCoroutine(TriggerExplosion());

            //isSurfacing = true;



            //Test: min oxy, no emergency
            //Just needed to keep the oxy counter running and ensure emergency check remained false

            //Test: max temp, no emergency
            curSub.Temp = 100;
            //And comment out the curSub update in UpdateUI

            /*// Test: unneeded emergency
             * curSub.Temp = 50;
             * curSub.Oxygen = 50;
             * isEmergency = true;*/
        }

        //pause/unpause
        if (Input.GetKeyUp(KeyCode.P) && !isSurfacing)
        {
            if (isPaused)
            {
                //if already paused then unpause
                isPaused = false;
                //PauseScreen.SetActive(false);
                PauseScreen.GetComponent <Canvas>().sortingOrder = -1;
            }
            else
            {
                //pause the screen
                isPaused = true;
                //PauseScreen.SetActive(true);
                PauseScreen.GetComponent <Canvas>().sortingOrder = 15;
            }
        }



        UpdateUI();
    }
Esempio n. 5
0
 /// <summary>
 /// Sets the value of the preference identified by key.
 /// </summary>
 /// <param name="Key">Key name</param>
 /// <param name="Value">New value</param>
 public static void SetString(string Key, string Value)
 {
     PlayerPrefs.SetString(GetKeyName(Key), Value);
     PlayerPrefs.Save();
 }
 public void ChooseCharacter(string character)
 {
     PlayerPrefs.SetString("chosenCharacter", character);
     SceneManager.LoadScene("Scenes/BattleScene");
 }
Esempio n. 7
0
 public void Restart()
 {
     PlayerPrefs.SetInt("restartCount", PlayerPrefs.GetInt("restartCount") + 1);
     PlayerPrefs.SetString("seenTutorial", "true");
     SceneManager.LoadScene("MainScene");
 }
 public void setAddress(string address)
 {
     IP = address; PlayerPrefs.SetString("UDPAddress", address);
 }
Esempio n. 9
0
 public static void setString(string key, string value)
 {
     PlayerPrefs.SetString(key, value);
     PlayerPrefs.Save();
 }
Esempio n. 10
0
 public void SetPlayer(string name)
 {
     CurrentCharacter = name;
     PlayerPrefs.SetString("Character", CurrentCharacter);
 }
Esempio n. 11
0
        public void SetPlayerName(string value)
        {
            PhotonNetwork.playerName = value + " ";

            PlayerPrefs.SetString(playerNamePrefKey, value);
        }
Esempio n. 12
0
 /// <summary>
 /// Sets the name of the player, and save it in the PlayerPrefs for future sessions.
 /// </summary>
 /// <param name="value">The name of the Player</param>
 public void SetPlayerName(string value)
 {
     // #Important
     PhotonNetwork.playerName = value;
     PlayerPrefs.SetString(playerNamePrefKey, value);
 }
Esempio n. 13
0
 private static void SaveCurrentCreaturePP(string content)
 {
     PlayerPrefs.SetString(CURRENT_SAVE_KEY, content);
 }
Esempio n. 14
0
 public static void SaveCurrentCreatureName(string name)
 {
     PlayerPrefs.SetString(CURRENT_CREATURE_NAME_KEY, name);
 }
Esempio n. 15
0
 /// <summary>
 /// 储存一个String数据
 /// </summary>
 private void SaveStringData(string key, string defaultValue = "")
 {
     PlayerPrefs.SetString(key, defaultValue);
 }
Esempio n. 16
0
    public static bool SetObject(string name, object value)
    {
        var t          = value.GetType();
        var fieldInfos = t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly);

        try
        {
            foreach (var fieldInfo in fieldInfos)
            {
                var fieldName = fieldInfo.Name;
                var fieldKey  = $"{name}-{t}-{fieldInfo.MemberType}-{fieldName}";

                if (fieldInfo.FieldType == typeof(int))
                {
                    var val = (int)fieldInfo.GetValue(value);
                    PlayerPrefs.SetInt(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(float))
                {
                    var val = (float)fieldInfo.GetValue(value);
                    PlayerPrefs.SetFloat(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(string))
                {
                    var val = (string)fieldInfo.GetValue(value);
                    PlayerPrefs.SetString(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(long))
                {
                    var val = (long)fieldInfo.GetValue(value);
                    SetLong(fieldKey, val);
                }
                // Unity val.
                else if (fieldInfo.FieldType == typeof(Vector2))
                {
                    var val = (Vector2)fieldInfo.GetValue(value);
                    SetVector2(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(Vector3))
                {
                    var val = (Vector3)fieldInfo.GetValue(value);
                    SetVector3(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(Quaternion))
                {
                    var val = (Quaternion)fieldInfo.GetValue(value);
                    SetQuaternion(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(Color))
                {
                    var val = (Color)fieldInfo.GetValue(value);
                    SetColor(fieldKey, val);
                }
                // array.
                else if (fieldInfo.FieldType == typeof(int[]))
                {
                    var val = (int[])fieldInfo.GetValue(value);
                    SetIntArray(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(float[]))
                {
                    var val = (float[])fieldInfo.GetValue(value);
                    SetFloatArray(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(string[]))
                {
                    var val = (string[])fieldInfo.GetValue(value);
                    SetStringArray(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(Quaternion[]))
                {
                    var val = (Quaternion[])fieldInfo.GetValue(value);
                    SetQuaternionArray(fieldKey, val);
                }
                else if (fieldInfo.FieldType == typeof(Color[]))
                {
                    var val = (Color[])fieldInfo.GetValue(value);
                    SetColorArray(fieldKey, val);
                }
                // list.
                else if (fieldInfo.FieldType == typeof(List <int>))
                {
                    var val = (List <int>)fieldInfo.GetValue(value);
                    SetIntArray(fieldKey, val.ToArray());
                }
                else if (fieldInfo.FieldType == typeof(List <float>))
                {
                    var val = (List <float>)fieldInfo.GetValue(value);
                    SetFloatArray(fieldKey, val.ToArray());
                }
                else if (fieldInfo.FieldType == typeof(List <string>))
                {
                    var val = (List <string>)fieldInfo.GetValue(value);
                    SetStringArray(fieldKey, val.ToArray());
                }
                else if (fieldInfo.FieldType == typeof(List <Quaternion>))
                {
                    var val = (Quaternion[])fieldInfo.GetValue(value);
                    SetQuaternionArray(fieldKey, val.ToArray());
                }
                else if (fieldInfo.FieldType == typeof(List <Color>))
                {
                    var val = (Color[])fieldInfo.GetValue(value);
                    SetColorArray(fieldKey, val.ToArray());
                }
                else
                {
                    Debug.LogError("Unknown type.");
                }
            }
        }
        catch
        {
            return(false);
        }
        return(true);
    }
Esempio n. 17
0
 public void Add(string key, string value)
 {
     PlayerPrefs.SetString(key, value);
     PlayerPrefs.Save();
 }
 public void RecordTime()
 {
     PlayerPrefs.SetString(SceneManager.GetActiveScene().name, timeSpan.ToString("mm':'ss'.'ff"));
     Debug.Log(SceneManager.GetActiveScene().name + timeSpan.ToString("mm':'ss'.'ff"));
 }
Esempio n. 19
0
 private void GoToMap()
 {
     PlayerPrefs.SetString("lastLoadedScene", SceneManager.GetActiveScene().name);
     SceneManager.LoadScene("Map- Hexagon");
 }
Esempio n. 20
0
 public void OnDestroy()
 {
     PlayerPrefs.SetString("UserProgramType", EmulatorManager.programType.ToString());
 }
Esempio n. 21
0
 void OnApplicationQuit()
 {
     PlayerPrefs.SetInt("restartCount", 0);
     PlayerPrefs.SetString("seenTutorial", "false");
 }
Esempio n. 22
0
    public void PlayerPrefsSetStringUTF8(string key, string val)
    {
        string valBase64 = System.Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(val));

        PlayerPrefs.SetString(key, valBase64);
    }
Esempio n. 23
0
 public void ClickMlog()
 {
     PlayerPrefs.SetString("facenumber", "0"); SceneManager.LoadScene("Mlog");
 }
Esempio n. 24
0
        private void Awake()
        {
            #region Saved Data
            if (PlayerPrefs.HasKey("score") == false)
            {
                // Общий счет викторины
                PlayerPrefs.SetInt("score", 0);
                // Общее количество монет
                PlayerPrefs.SetInt("coins", 1000);

                // Прогресс категорий по странам
                PlayerPrefs.SetString("sets", "{\"arraySets\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}");
                // Количество правильных ответов
                PlayerPrefs.SetInt("countries-answer", 0);
                // Количество допущенных ошибок
                PlayerPrefs.SetInt("countries-error", 0);
                // Количество использованных подсказок
                PlayerPrefs.SetInt("countries-tips", 0);
                // Количество пропусков вопросов
                PlayerPrefs.SetInt("countries-pass", 0);

                // Прогресс викторины по фактам
                PlayerPrefs.SetString("facts", "{\"status\": []}");
                // Количество завершенных подборок
                PlayerPrefs.SetInt("facts-quantity", 0);
                // Количество выигранных подборок
                PlayerPrefs.SetInt("facts-victory", 0);
                // Количество правильных ответов
                PlayerPrefs.SetInt("facts-answer", 0);
                // Количество допущенных ошибок
                PlayerPrefs.SetInt("facts-errors", 0);

                // Прогресс легендарных карточек
                PlayerPrefs.SetString("legends", "{\"status\": []}");
                // Количество открытых карточек
                PlayerPrefs.SetInt("legends-open", 0);

                // Сохранение таблицы лидеров
                PlayerPrefs.SetString("leaders", "{\"Rating\": 0, \"Names\": [\"User\", \"User\", \"User\", \"User\", \"User\", \"User\", \"User\", \"User\", \"User\", \"User\"], \"Results\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}");

                // Сохранение последней даты
                PlayerPrefs.SetInt("date", 0);
                // Ежедневный рекламный бонус
                PlayerPrefs.SetInt("bonus", 0);
            }
            #endregion

            #region Additional Saved Data
            // Прогресс по викторине с фотографиями
            if (PlayerPrefs.HasKey("photo-quiz") == false)
            {
                PlayerPrefs.SetString("photo-quiz", "{\"arraySets\": [0, 0]}");
                // Количество успешно завершенных заданий
                PlayerPrefs.SetInt("photo-quiz-successfully", 0);
                // Количество правильных ответов
                PlayerPrefs.SetInt("photo-quiz-answer", 0);
                // Количество ошибок в заданиях
                PlayerPrefs.SetInt("photo-quiz-errors", 0);
            }

            // Отображение рекламных баннеров
            if (PlayerPrefs.HasKey("show-ads") == false)
            {
                PlayerPrefs.SetString("show-ads", "yes");
            }
            #endregion

            PlayGamesPlatform.Activate();
        }
Esempio n. 25
0
 public static void SaveSettings(string key, string data)
 {
     PlayerPrefs.SetString(key, data);
 }
Esempio n. 26
0
    public void Update()
    {
        if (selectP1.transform.position.x == -1.6f && !p1)
        {
            print("Entered");
            if ((Input.GetAxisRaw("LeftJoystickX1") > .5 || Input.GetKeyDown(KeyCode.D)) && !p1)
            {
                if (Input.GetAxisRaw("LeftJoystickX1") > .5 && x1_isAxisInUse == false)
                {
                    charList1[0].enabled = false;
                    charList1[1].enabled = true;
                    selectP1.transform.Translate(new Vector3(1.6f, 0f));
                    x1_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.D))
                {
                    charList1[0].enabled = false;
                    charList1[1].enabled = true;
                    selectP1.transform.Translate(new Vector3(1.6f, 0f));
                }
            }
        }
        else if (selectP1.transform.position.x == 1.6f && !p1)
        {
            print("Entered");
            if (Input.GetAxisRaw("LeftJoystickX1") < -.5 || Input.GetKeyDown(KeyCode.A))
            {
                if (Input.GetAxisRaw("LeftJoystickX1") < -.5 && x_isAxisInUse == false)
                {
                    charList1[1].enabled = true;
                    selectP1.transform.Translate(new Vector3(-1.6f, 0f));
                    x1_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.A))
                {
                    charList1[1].enabled = true;
                    selectP1.transform.Translate(new Vector3(-1.6f, 0f));
                }
                ;
            }
        }
        else if (!p1)
        {
            if (Input.GetAxisRaw("LeftJoystickX1") > .5 || Input.GetKeyDown(KeyCode.D))
            {
                if (Input.GetAxisRaw("LeftJoystickX1") > .5 && x1_isAxisInUse == false)
                {
                    charList1[1].enabled = false;
                    selectP1.transform.Translate(new Vector3(1.6f, 0f));
                    x1_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.D))
                {
                    charList1[1].enabled = false;
                    selectP1.transform.Translate(new Vector3(1.6f, 0f));
                }
            }
            if (Input.GetAxisRaw("LeftJoystickX1") < -.5 || Input.GetKeyDown(KeyCode.A))
            {
                if (Input.GetAxisRaw("LeftJoystickX1") < -.5 && x1_isAxisInUse == false)
                {
                    charList1[1].enabled = false;
                    charList1[0].enabled = true;
                    selectP1.transform.Translate(new Vector3(-1.6f, 0f));
                    x1_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.A))
                {
                    charList1[1].enabled = false;
                    charList1[0].enabled = true;
                    selectP1.transform.Translate(new Vector3(-1.6f, 0f));
                }
            }
        }
        if (Input.GetButtonDown("X1") || Input.GetKeyDown(KeyCode.R))
        {
            if (charList1[0].enabled)
            {
                p1select = 0;
                p1       = true;
                PlayerPrefs.SetString("Player1", "Orange");
                readyText1.enabled = true;
            }
            else if (charList1[1].enabled)
            {
                p1select = 1;
                p1       = true;
                PlayerPrefs.SetString("Player1", "Blue");
                readyText1.enabled = true;
            }
        }

        //Player 2 Select
        if (selectP2.transform.position.x == -1.6f && !p2)
        {
            if (Input.GetAxisRaw("LeftJoystickX") > .5 || Input.GetKeyDown(KeyCode.RightArrow))
            {
                if (Input.GetAxisRaw("LeftJoystickX") > .5 && x_isAxisInUse == false)
                {
                    charList2[0].enabled = false;
                    charList2[1].enabled = true;
                    Debug.Log("IN HERE DUMMY");
                    selectP2.transform.Translate(new Vector3(1.6f, 0f));
                    x_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    charList2[0].enabled = false;
                    charList2[1].enabled = true;
                    selectP2.transform.Translate(new Vector3(1.6f, 0f));
                }
            }
        }

        else if (selectP2.transform.position.x == 1.6f && !p2)
        {
            if (Input.GetAxisRaw("LeftJoystickX") < -.5 || Input.GetKeyDown(KeyCode.LeftArrow))
            {
                if (Input.GetAxisRaw("LeftJoystickX") < -.5 && x_isAxisInUse == false)
                {
                    charList2[1].enabled = true;
                    selectP2.transform.Translate(new Vector3(-1.6f, 0f));
                    x_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    charList2[1].enabled = true;
                    selectP2.transform.Translate(new Vector3(-1.6f, 0f));
                }
            }
        }
        else if (!p2)
        {
            if (Input.GetAxisRaw("LeftJoystickX") > .5 || Input.GetKeyDown(KeyCode.RightArrow))
            {
                if (Input.GetAxisRaw("LeftJoystickX") > .5 && x_isAxisInUse == false)
                {
                    charList2[1].enabled = false;
                    Debug.Log("No IN HERE DUMMY");
                    selectP2.transform.Translate(new Vector3(1.6f, 0f));
                    x_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    charList2[1].enabled = false;
                    selectP2.transform.Translate(new Vector3(1.6f, 0f));
                }
            }
            if (Input.GetAxisRaw("LeftJoystickX") < -.5 || Input.GetKeyDown(KeyCode.LeftArrow))
            {
                if (Input.GetAxisRaw("LeftJoystickX") < -.5 && x_isAxisInUse == false)
                {
                    charList2[1].enabled = false;
                    charList2[0].enabled = true;
                    selectP2.transform.Translate(new Vector3(-1.6f, 0f));
                    x_isAxisInUse = true;
                }
                else if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    charList2[1].enabled = false;
                    charList2[0].enabled = true;
                    selectP2.transform.Translate(new Vector3(-1.6f, 0f));
                }
            }
        }
        if (Input.GetButtonDown("X") || Input.GetKeyDown(KeyCode.K))
        {
            if (charList2[0].enabled)
            {
                p2select = 0;
                p2       = true;
                PlayerPrefs.SetString("Player2", "Orange");
                readyText2.enabled = true;
            }
            else if (charList2[1].enabled)
            {
                p2select = 1;
                p2       = true;
                PlayerPrefs.SetString("Player2", "Blue");
                readyText2.enabled = true;
            }
        }
        if (Input.GetAxisRaw("LeftJoystickX") == 0)
        {
            x_isAxisInUse = false;
        }
        if (Input.GetAxisRaw("LeftJoystickX1") == 0)
        {
            x1_isAxisInUse = false;
        }

        // ready to start da fight!!!
        if (p1 && p2)
        {
            SceneManager.LoadScene("MahdiGameTestingScene");
        }
        //player 1 toggle characters
        //if (Input.GetKeyDown(KeyCode.D))
        //{
        //    charList1[index1].SetActive(false);
        //    index1++;
        //    if (index1 == charList1.Length)
        //    {
        //        index1 = 0;
        //    }
        //    charList1[index1].SetActive(true);

        //}
        //if (Input.GetKey(KeyCode.A))
        //{
        //    charList1[index1].SetActive(false);
        //    index1--;
        //    if (index1 < 0)
        //    {
        //        index1 = 0;
        //    }
        //    charList1[index1].SetActive(true);
        //}
        //if (Input.GetKey(KeyCode.S))
        //{

        //}
    }
Esempio n. 27
0
    // Use this for initialization
    void Start()
    {
//		Debug.LogError("Onee"+PlayerPrefs.GetInt("China/a-1"));
//		Debug.LogError("tree"+PlayerPrefs.GetInt("China/a-3"));
//		Debug.LogError("four"+PlayerPrefs.GetInt("China/a-4"));
//
//
//
//
//		Debug.Log("impp"+PlayerPrefs.GetString("GrillsUpgrade"));

        _instance = this;
                #if UNITY_IOS || UNITY_IPHONE
        Chartboost.cacheInterstitial(CBLocation.Default);
        Debug.Log("Chartboostcaching @Menumanager");
#elif UNITY_ANDROID
#endif
        Application.targetFrameRate  = 120;
        AchievementChild.check_claim = (PlayerPrefs.GetInt("claimvalue"));
        //PlayerPrefs.DeleteAll ();

        if (!PlayerPrefs.HasKey("PlateUpgrade"))
        {
            PlayerPrefs.SetString("Golds", EncryptionHandler64.Encrypt("1"));
            PlayerPrefs.SetString("TotalScore", EncryptionHandler64.Encrypt("100"));

            PlayerPrefs.SetString("Cupcake", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("Handcuff", EncryptionHandler64.Encrypt("0"));


            PlayerPrefs.SetString("GrillsUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("USCokeUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("PlateUpgrade", EncryptionHandler64.Encrypt("0"));


            PlayerPrefs.SetString("USStars", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("USLevels", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("US_TableCover", "US/base-flat-1");
            PlayerPrefs.SetString("US_TableTop", "US/top-floor-1");

            PlayerPrefs.SetInt("US/base-flat-1", 1);
            PlayerPrefs.SetInt("US/top-floor-1", 1);

            PlayerPrefs.SetString("AusLevels", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("ItalyLevels", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("ChinaLevels", EncryptionHandler64.Encrypt("0"));

            PlayerPrefs.SetString("ItalyStars", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("Italy_TableCover", "Italy/1");
            PlayerPrefs.SetString("Italy_TableTop", "Italy/top-strip-1");

            PlayerPrefs.SetString("ItalyPlateUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("ItalyCokeUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("OvenUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetInt("Italy/1", 1);
            PlayerPrefs.SetInt("Italy/top-strip-1", 1);


            PlayerPrefs.SetString("ChinaStars", EncryptionHandler64.Encrypt("0"));

            PlayerPrefs.SetString("China_TableCover", "China/1");
            PlayerPrefs.SetString("China_TableTop", "China/a-1");

            PlayerPrefs.SetString("ChinaPlateUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("ChinaBowlsUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("ChinaPansUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("ChinaSoupContainerUpgrade", EncryptionHandler64.Encrypt("0"));

            PlayerPrefs.SetInt("China/1", 1);
            PlayerPrefs.SetInt("China/a-1", 1);

            PlayerPrefs.SetString("AusStars", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("Aus_TableCover", "Aus/1");
            PlayerPrefs.SetString("Aus_TableTop", "Aus/top-shed-1");

            PlayerPrefs.SetString("AusPlateUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("FriesUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("AusCokeUpgrade", EncryptionHandler64.Encrypt("0"));
            PlayerPrefs.SetString("AusGrillsUpgrade", EncryptionHandler64.Encrypt("0"));

            PlayerPrefs.SetInt("Aus/1", 1);
            PlayerPrefs.SetInt("Aus/top-shed-1", 3);
            PlayerPrefs.SetInt("Upgrade2", 1);
        }


//		PlayerPrefs.SetInt ("ItalyOpen", 1);
//		PlayerPrefs.SetInt ("ChinaOpen", 1);

        //	PlayerPrefs.SetString("Golds",EncryptionHandler64.Encrypt ("100"));
//			PlayerPrefs.SetString ("ChinaSoupContainerUpgrade",EncryptionHandler64.Encrypt ("0"));


        golds      = (int)EncryptionHandler64.Decrypt(PlayerPrefs.GetString("Golds"));
        totalscore = (int)EncryptionHandler64.Decrypt(PlayerPrefs.GetString("TotalScore"));
        cupcakeNo  = (int)EncryptionHandler64.Decrypt(PlayerPrefs.GetString("Cupcake"));
        handcuffNo = (int)EncryptionHandler64.Decrypt(PlayerPrefs.GetString("Handcuff"));
    }
Esempio n. 28
0
 public void SetName(string name)
 {
     PlayerPrefs.SetString("PlayerName", name);
 }
Esempio n. 29
0
 public static void SetValue(string val, ref ValueKey <string> valueKey)
 {
     valueKey.value = val;
     PlayerPrefs.SetString(valueKey.key, valueKey.value);
 }
Esempio n. 30
0
    //############################################################# Est appelé toutes les secondes après le début
    void Update()
    {
        float x = Player.transform.position.x;
        float z = Player.transform.position.z;

        //############################################################# Deplace la lumière et la caméra sur le joueur
        Lumière.transform.position = new Vector3(x, 8f, z);
        Cam.transform.position     = new Vector3(x, 8f, z);

        //############################################################# Verifier si le joueur est proche du trou et le prevenir en seccouant la cam

        if (Trou.transform.position.x + 1.3 >= x && x >= Trou.transform.position.x - 1.3 && Trou.transform.position.z + 1.3 >= z && z >= Trou.transform.position.z - 1.3)
        {
            Cam.transform.localPosition           = new Vector3(Random.Range(x - 0.05f, x + 0.05f), 8f, Random.Range(z - 0.05f, z + 0.05f));
            Evenements.color                      = new Color(255, 222, 0, 255);
            Evenements.GetComponent <Text>().text = "Attention! Le sol est instable";
            Tpevent = (int)time;
        }

        //############################################################# Revenir en arrière avec la touche android
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene("Options", LoadSceneMode.Single);
        }

        //############################################################# On vérifie si on doit retirer l'event au bout de 3sec pour le message et le fond et 1sec pour l'anim des pic
        if (Evenements.GetComponent <Text>().text != "")
        {
            if (Tpevent + 3 <= (int)time)
            {
                Evenements.color = new Color(255, 222, 0, 255);
                Evenements.GetComponent <Text>().text = "";
                Fond.color = new Color32(0, 0, 0, 0);
                Pic1.transform.localScale = new Vector3(0.25f, 0.25f, 1f);
                Pic2.transform.localScale = new Vector3(0.25f, 0.25f, 1f);
                Pic3.transform.localScale = new Vector3(0.25f, 0.25f, 1f);
            }
        }

        Tour.GetComponent <Text>().text = Ntour.ToString("0");
        Debug.DrawRay(transform.position, transform.forward);

        if (joueur == "player")
        {
            //############################################################# Si il ne n'est pas en deplacement rechercher les cases accessible
            if (!deplacement)
            {
                FindSelectableTiles();
                VerifClic();
            }
            else
            {
                Mouvement();
            }
        }
        else
        {
        }

        //############################################################## Chronomètre
        time += 1 * Time.deltaTime;
        Chrono.GetComponent <Text>().text = time.ToString("0");

        //############################################################## On verifie si le poison est encore actif, et dois enlever de la vie
        if (poison == true)
        {
            if ((int)time == (int)Tpoison + 5 && vie > 1)
            {
                vie--; Debug.Log("Vie=" + vie); Tpoison = (int)time;
            }
        }

        //############################################################## On verifie si il reste de la vie
        if (vie == 3)
        {
            Coeur1.color = new Color(255, 255, 255, 255); Coeur2.color = new Color(255, 255, 255, 255); Coeur3.color = new Color(255, 255, 255, 255);
        }
        if (vie == 2)
        {
            Coeur1.color = new Color(0, 0, 0, 0); Coeur2.color = new Color(255, 255, 255, 255); Coeur3.color = new Color(255, 255, 255, 255);
        }
        else
        {
            if (vie == 1)
            {
                Coeur1.color = new Color(0, 0, 0, 0); Coeur2.color = new Color(0, 0, 0, 0); Coeur3.color = new Color(255, 255, 255, 255);
            }
            else
            {
                if (vie == 0)
                {
                    Handheld.Vibrate();
                    Coeur3.color = new Color(0, 0, 0, 0);
                    Debug.Log("Plus de vie, Défaite!");
                    PlayerPrefs.SetString("mort", "pic");
                    SceneManager.LoadScene("Defaite");
                }
            }
        }
    }