Ejemplo n.º 1
0
    //this method uses a BinaryFormatter object to create a binary file that will store the players stats by serializing data
    public static void savePlayer(HealthPL player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/player.LOL";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(player);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Ejemplo n.º 2
0
    public PlayerData(HealthPL player)
    {
        health = HealthPL.currentHealth;
        //level = HealthPL.currentSceneIndex;
        level = HealthPL.lvl;

        //using a float array is a way to stroe vector positions
        position = new float[3];

        position[0] = player.transform.position.x;
        position[1] = player.transform.position.y;
        position[2] = player.transform.position.z;
    }
Ejemplo n.º 3
0
 public void Save(HealthPL player)
 {
     SaveSystem.savePlayer(player);
     Debug.Log("save runs");
 }