public PlayerData(Stats.BaseStats player)
    {
        savedLevel      = player.level;
        savedHealth     = player.characterStatus[0].currentValue;
        savedName       = player.name;
        savedExp        = player.currentExp;
        savedNeededExp  = player.neededExp;
        savedMaxExp     = player.maxExp;
        savedCheckpoint = player.currentCheckpoint.name;


        savedPlayerPos    = new float[3];
        savedPlayerPos[0] = player.transform.position.x;
        savedPlayerPos[1] = player.transform.position.y;
        savedPlayerPos[2] = player.transform.position.z;

        savedPlayerRot    = new float[4];
        savedPlayerRot[0] = player.transform.rotation.x;
        savedPlayerRot[1] = player.transform.rotation.y;
        savedPlayerRot[2] = player.transform.rotation.z;
        savedPlayerRot[3] = player.transform.rotation.w;

        for (int i = 0; i < currentStatus.Length; i++)
        {
            currentStatus[i] = player.characterStatus[i].currentValue;
            maxStatus[i]     = player.characterStatus[i].maxValue;
        }
        for (int i = 0; i < stats.Length; i++)
        {
            stats[i] = player.characterstats[i].value + player.characterstats[i].value;
        }
    }
Пример #2
0
    // Start is called before the first frame update

    void Start()
    {
        player            = this.gameObject.GetComponent <Stats.BaseStats>();
        enumTypesForItems = new string[] { "All", "Food", "Weapon", "Apparel", "Crafting", "Ingredients", "Potions", "Scrolls", "Quest" };
        AddItem(ItemData.CreateItem(0));
        AddItem(ItemData.CreateItem(1));
        AddItem(ItemData.CreateItem(300));
        objectInfo.SetActive(false);
        inventoryScreen.SetActive(false);
        showInv = false;
        // Display();
    }
Пример #3
0
    public static void SavePlayer(Stats.BaseStats player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.save";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(player);

        formatter.Serialize(stream, data);

        stream.Close();
    }
    public static void SavePlayer(Stats.BaseStats player)
    {
        //Reference a Binary Formatter
        BinaryFormatter formatter = new BinaryFormatter();
        //Location to Save
        string path = Application.dataPath + "/" + "playersave" + ".sav";
        //Create File at file path
        FileStream stream = new FileStream(path, FileMode.Create);
        //What Data to write to the file
        PlayerData data = new PlayerData(player);

        //write it and convert to bytes for writing to binary
        formatter.Serialize(stream, data);
        //and we are done
        stream.Close();
        Debug.Log("Saved");
    }
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <Stats.BaseStats>();
     if (!PlayerPrefs.HasKey("Loaded"))
     {
         PlayerPrefs.DeleteAll();
         //FirstLoad Function...sets up Player Data
         FirstLoad();
         //Save Data Creates first save file in binary
         Save();
         //We now have our first save file
         PlayerPrefs.SetInt("Loaded", 0);
     }
     else
     {
         Load();
     }
 }
Пример #6
0
 private void Awake()
 {
     playerStats = GameObject.FindWithTag("Player").GetComponent <BaseStats>();
 }
Пример #7
0
 private void Awake()
 {
     _levelToDisplay = GameObject.FindWithTag("Player").GetComponent <BaseStats>();
 }