Esempio n. 1
0
 public void SaveCheckpointLocation()
 {
     //if (transform.parent.tag == "MovingPlatform")
     if (transform.parent)
     {
         string name = transform.parent.name;
         PlayerPrefs.SetString("mpName", name);
         //var platformPos = transform.parent.gameObject.GetComponent<PlatformMover>().GetPlatformPosition();
         //PlayerPrefsX.SetVector3("mpPosition", platformPos);
         var platformsArray    = Resources.FindObjectsOfTypeAll <PlatformMover>();
         var platformsPosArray = new Vector3[platformsArray.Length];
         for (int i = 0; i < platformsArray.Length; i++)
         {
             var pm  = platformsArray[i];
             var pos = pm.GetPlatformPosition();
             platformsPosArray[i] = pos;
         }
         PlayerPrefsX.SetVector3Array("platformsPosArray", platformsPosArray);
     }
     else
     {
         PlayerPrefs.DeleteKey("mpName");
         PlayerPrefs.DeleteKey("platformsPosArray");
         SavePositionToPrefs();
     }
 }
    //Save the players race if the time is faster than before.
    IEnumerator SavePosition()
    {
        endTime = (endTime - currentTime);

        if (endTime < bestTime && !TimeSet)
        {
            TimeSet = true;
            PlayerPrefs.SetFloat("Ghost-Time-" + trackId, endTime);

            Debug.Log("Convert to array");
            Vector3[] SavePositions = Positions.ToArray();
            Vector3[] SaveRotations = Rotations.ToArray();

            Debug.Log("Save to array");
            PlayerPrefsX.SetVector3Array("Positions-" + trackId, SavePositions);
            PlayerPrefsX.SetVector3Array("Rotations-" + trackId, SaveRotations);
            Debug.Log("Save car ID");
            PlayerPrefs.SetInt("ghost-carID-" + trackId, PlayerPrefs.GetInt("CURRENTCARID"));
            PlayerPrefs.SetInt("ghost-charID-" + trackId, PlayerPrefs.GetInt("CURRENTCHARID"));
        }
        GameObject.Find("Player Cam Pivot").GetComponent <CameraFollow>().enabled = false;
        yield return(new WaitForSeconds(2f));

        GameObject.Find("FinishManager").GetComponent <FinishManager>().Endgame();
    }
Esempio n. 3
0
    private void SaveCoinFromArr(List <GameObject> coin_lst, string prefix)
    {
        List <Quaternion> coin_rotation = new List <Quaternion>();
        List <Vector3>    coin_position = new List <Vector3>();
        List <string>     coin_names    = new List <string>();

        for (int i = 0; i < coin_lst.Count; i++)
        {
            if (coin_lst[i] != null)
            {
                if (coin_lst[i].activeInHierarchy == true)
                {/////////////////////////// change from != false
                    if (coin_lst[i].activeInHierarchy)
                    {
                        coin_rotation.Add(coin_lst[i].transform.rotation);
                        coin_position.Add(coin_lst[i].transform.position);
                        coin_names.Add(coin_lst[i].name);
                    }
                }
            }
        }
        PlayerPrefsX.SetQuaternionArray(prefix + "Quaternion", coin_rotation.ToArray());
        PlayerPrefsX.SetVector3Array(prefix + "Position", coin_position.ToArray());
        PlayerPrefsX.SetStringArray(prefix + "Name", coin_names.ToArray());

        if (coin_names.Count > 0)
        {
            PlayerPrefs.SetInt(prefix + "Count", coin_names.Count);
        }
        else
        {
            PlayerPrefs.SetInt(prefix + "Count", 0);
        }
    }
Esempio n. 4
0
    public void SaveGifts()
    {
        GameObject[] gifts_array = GameObject.FindGameObjectsWithTag("Gift");
        if (gifts_array.Length > 0)
        {
            Quaternion[] gift_rotation = new Quaternion[gifts_array.Length];
            Vector3[]    gift_position = new Vector3[gifts_array.Length];
            string[]     gift_names    = new string[gifts_array.Length];

            for (int i = 0; i < gifts_array.Length; i++)
            {
                gift_rotation[i] = gifts_array[i].transform.rotation;
                gift_position[i] = gifts_array[i].transform.position;
                gift_names[i]    = gifts_array[i].name;
            }

            PlayerPrefsX.SetQuaternionArray("GiftQuaternion", gift_rotation);
            PlayerPrefsX.SetVector3Array("GiftPosition", gift_position);
            PlayerPrefsX.SetStringArray("GiftName", gift_names);
            PlayerPrefs.SetInt("GiftCount", gifts_array.Length);
        }
        else
        {
            PlayerPrefs.SetInt("GiftCount", 0);
        }
    }
Esempio n. 5
0
    public void SaveGiftsRev2(List <GameObject> objects, string prefix)
    {
        List <Vector3>    positions = new List <Vector3>();
        List <Quaternion> rotations = new List <Quaternion>();
        List <string>     names     = new List <string>();

        for (int i = 0; i < objects.Count; i++)
        {
            if (objects[i].activeInHierarchy)
            {
                positions.Add(objects[i].transform.position);
                rotations.Add(objects[i].transform.rotation);
                names.Add(objects[i].name);
            }
        }
        if (names.Count > 0)
        {
            PlayerPrefsX.SetQuaternionArray(prefix + "Quaternion", rotations.ToArray());
            PlayerPrefsX.SetVector3Array(prefix + "Position", positions.ToArray());
            PlayerPrefsX.SetStringArray(prefix + "Name", names.ToArray());
            PlayerPrefs.SetInt(prefix + "Count", names.Count);
        }
        else
        {
            PlayerPrefs.SetInt(prefix + "Count", 0);
        }
    }
    /// <summary>
    /// Remove postion data index in ArrayPrefs.
    /// </summary>
    /// <param name="playerPrefsKey"></param>
    /// <param name="vec"></param>
    /// <param name="index"></param>
    private void Del(string playerPrefsKey, Vector3[] vec, int index)
    {
        List <Vector3> list = new List <Vector3> ( );

        list.AddRange(vec);
        list.RemoveAt(index);

        PlayerPrefsX.SetVector3Array(playerPrefsKey, list.ToArray( ));
    }
Esempio n. 7
0
    void Save()
    {
        List <Vector3> savingPosList = new List <Vector3>()
        {
        };

        foreach (Transform transform in this.mappedPoints.transform)
        {
            savingPosList.Add(transform.position);
        }
        PlayerPrefsX.SetVector3Array("mappedPosList", savingPosList.ToArray());
        Debug.Log("Saved mappedPosList");
    }
Esempio n. 8
0
    public static void SaveUnitokens(List <Unitoken> unitokens)
    {
        transientPositions = new Vector3[unitokens.Count - 1];
        unitokenLabels     = new string[unitokens.Count - 1];

        for (int i = 0; i < unitokens.Count - 1; i++)
        {
            Unitoken token = unitokens[i];
            transientPositions[i] = token.TransientPosition;
            unitokenLabels[i]     = token.MyLabel.text;
        }
        PlayerPrefsX.SetVector3Array(keys[0], transientPositions);
        PlayerPrefsX.SetStringArray(keys[1], unitokenLabels);
    }
Esempio n. 9
0
    public void Save()
    {
        Vector3[] monsterLocations = new Vector3[transform.childCount];
        int[]     monsterTypes     = new int[transform.childCount];

        for (int i = 0; i < transform.childCount; i++)
        {
            MonsterMover mover = transform.GetChild(i).GetComponent <MonsterMover>();
            monsterLocations[i] = mover.transform.position;
            monsterTypes[i]     = mover.monsterType;
        }

        PlayerPrefsX.SetVector3Array("monsterLocations", monsterLocations);
        PlayerPrefsX.SetIntArray("monsterTypes", monsterTypes);
    }
Esempio n. 10
0
    public static void SaveTheGame(int saveSlot) //should be 1-4
    {
        loadedSlot = saveSlot;
        //KEEP PLANTS IN THE SAME ORDER FOR INSTANTIATION IN PLAYERGRIDOBJECT?
        PlayerPrefsX.SetVector3("respawn" + saveSlot, new Vector3(player.transform.position.x, player.transform.position.y, player.transform.position.z));
        PlayerPrefs.SetString("activeScene" + saveSlot, SceneManager.GetActiveScene().name);
        PlayerPrefs.SetInt("playerHealth" + saveSlot, player.health);

        PlayerPrefsX.SetBool("lavaBossBeaten" + saveSlot, lavaBossBeaten);
        PlayerPrefsX.SetBool("windBossBeaten" + saveSlot, windBossBeaten);
        PlayerPrefsX.SetBool("caveBossBeaten" + saveSlot, caveBossBeaten);

        //Debug.Log("SAVING HEALTH AS " + player.health);
        PlayerPrefsX.SetIntArray("playerInventory" + saveSlot, inventory);

        Vector3[] tempPlantPositions  = new Vector3[plants.Count];
        int[]     tempPlantTypes      = new int[plants.Count]; //need plant type
        String[]  tempPlantScenes     = new String[plants.Count];
        int[]     tempPlantDirections = new int[plants.Count]; //need plant object or direction

        int i = 0;

        foreach (KeyValuePair <PlantData, int> plantInfo in plants)
        {
            tempPlantPositions[i]  = plantInfo.Key.PlantLocation;
            tempPlantScenes[i]     = plantInfo.Key.PlantScene;
            tempPlantTypes[i]      = plantInfo.Value;
            tempPlantDirections[i] = (int)plantInfo.Key.PlantDirection;
            i++;
        }

        PlayerPrefsX.SetVector3Array("PlantPositions" + saveSlot, tempPlantPositions);
        PlayerPrefsX.SetIntArray("PlantTypes" + saveSlot, tempPlantTypes);
        PlayerPrefsX.SetStringArray("PlantScenes" + saveSlot, tempPlantScenes);
        PlayerPrefsX.SetIntArray("PlantDirections" + saveSlot, tempPlantDirections);

        foreach (DialogueNPCTrigger n in npcs)
        {
            n.saveRead();
        }
    }
Esempio n. 11
0
    /*
     * データをPlayerPrefsXに保存する
     */
    public void Save()
    {
        this.MapSelectedObjects(); //選択したオブジェクトをマッピングする
        List <Vector3> savingPosList = new List <Vector3>()
        {
        };
        List <Quaternion> savingRotList = new List <Quaternion>()
        {
        };
        List <Vector3> savingScaleList = new List <Vector3>()
        {
        };

        foreach (Transform transform in this.mapped.transform)
        {
            savingPosList.Add(transform.position);
            savingRotList.Add(transform.rotation);
            savingScaleList.Add(transform.localScale);
        }
        PlayerPrefsX.SetVector3Array("mappedPosList", savingPosList.ToArray());
        PlayerPrefsX.SetQuaternionArray("mappedRotList", savingRotList.ToArray());
        PlayerPrefsX.SetVector3Array("mappedScaleList", savingScaleList.ToArray());
    }
Esempio n. 12
0
 void OnApplicationQuit()
 {
     //When we quit the application we want to save our position and rotation
     PlayerPrefsX.SetVector3Array(this.gameObject.name + "PaintPos", newPos);
 }
 /// <summary>
 /// Set list position to ArrayPrefs.
 /// </summary>
 /// <param name="list"></param>
 public void SetVec3Arr(List <Vector3> list)
 {
     PlayerPrefsX.SetVector3Array(PlayerPrefsKeys.POSITION.ToString( ), list.ToArray( ));
 }
Esempio n. 14
0
 private void OnApplicationQuit()
 { //save date
     PlayerPrefsX.SetVector3("position", transform.position);
     Vector3[] anArray = target.ToArray();
     PlayerPrefsX.SetVector3Array("VectorsArray", anArray);
 }
Esempio n. 15
0
 public void SaveBalls(string saveName)
 {
     PlayerPrefsX.SetVector3Array(saveName + "balls", ballPos.ToArray());
 }
Esempio n. 16
0
    public static void save()
    {
        // save all lumberjacks, lumbermills, and trees

        // start with the lumberjacks
        List <string> jackNames = new List <string>();
        List <string> jackPass  = new List <string>();

        List <int> jackLumber = new List <int>();
        List <int> jackMoney  = new List <int>();

        List <int> jackWalkLevel     = new List <int>();
        List <int> jackBackpackLevel = new List <int>();
        List <int> jackAxeSpeedLevel = new List <int>();
        List <int> jackAxePowerLevel = new List <int>();

        List <Vector3> jackPos    = new List <Vector3>();
        List <Vector3> jackRotate = new List <Vector3>();

        foreach (GameObject jack in GameObject.FindGameObjectsWithTag("LumberJack"))
        {
            jackNames.Add(jack.GetComponent <Character> ().charName);
            jackPass.Add(jack.GetComponent <Character> ().password);

            jackLumber.Add(jack.GetComponent <Character> ().lumberCount);
            jackMoney.Add(jack.GetComponent <Character> ().money);


            jackWalkLevel.Add(jack.GetComponent <Character> ().lumberCount);
            jackBackpackLevel.Add(jack.GetComponent <Character> ().backpackLv);
            jackAxeSpeedLevel.Add(jack.GetComponent <Character> ().axeSpeedLv);
            jackAxePowerLevel.Add(jack.GetComponent <Character> ().axePowerLv);

            jackPos.Add(jack.transform.position);
            jackRotate.Add(Quaternion.ToEulerAngles(jack.transform.rotation));
        }

        PlayerPrefsX.SetStringArray("JackNames", jackNames.ToArray());
        PlayerPrefsX.SetStringArray("JackPass", jackPass.ToArray());

        PlayerPrefsX.SetIntArray("JackLumber", jackLumber.ToArray());
        PlayerPrefsX.SetIntArray("JackMoney", jackMoney.ToArray());


        PlayerPrefsX.SetIntArray("JackWalkLevel", jackWalkLevel.ToArray());
        PlayerPrefsX.SetIntArray("JackBackpackLevel", jackBackpackLevel.ToArray());
        PlayerPrefsX.SetIntArray("JackAxeSpeedLevel", jackAxeSpeedLevel.ToArray());
        PlayerPrefsX.SetIntArray("JackAxePowerLevel", jackAxePowerLevel.ToArray());

        // next we do the lumberMills

        List <string>  millNames = new List <string>();
        List <Vector3> millPos   = new List <Vector3>();

        foreach (GameObject mill in GameObject.FindGameObjectsWithTag("LumberMill"))
        {
            millNames.Add(mill.GetComponent <LumberMillBehaviour> ().millName);
            millPos.Add(mill.transform.position);
        }

        PlayerPrefsX.SetStringArray("MillNames", millNames.ToArray());
        PlayerPrefsX.SetVector3Array("MillPos", millPos.ToArray());

        // save the trees!

        List <Vector3> treePos  = new List <Vector3>();
        List <int>     treeType = new List <int>();

        foreach (GameObject tree in GameObject.FindGameObjectsWithTag("Tree"))
        {
            treePos.Add(tree.transform.position);
            treeType.Add(tree.GetComponent <TreeBehaviour> ().type);
        }

        PlayerPrefsX.SetVector3Array("TreePos", treePos.ToArray());
        PlayerPrefsX.SetIntArray("TreeType", treeType.ToArray());
    }