コード例 #1
0
    public static void SaveAmmo(PizzaBoyController player)
    {
        //makes file binary
        BinaryFormatter formatter = new BinaryFormatter();
        //stores file to a consistent location
        string     path   = Application.persistentDataPath + "/ammo.txt";
        FileStream stream = new FileStream(path, FileMode.Create);
        //collects data
        PlayerData data = new PlayerData(player);

        //writes data to file
        formatter.Serialize(stream, data);
        stream.Close();
        Debug.LogError("Saved ammo");
    }
コード例 #2
0
 public PlayerData(PizzaBoyController player)
 {
     lives = player.lives;
     ammo  = player.ammo;
 }