Exemple #1
0
    public static void SavePlayer(LLB llb, Inventory inv)  //invoke for saving player
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/save.ebml";

        Debug.Log(path);
        FileStream stream = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(llb, inv);

        formatter.Serialize(stream, data);
        stream.Close();
    }
    //public string slotTag; // needs to be set

    public PlayerData(LLB llb, Inventory inv)
    {
        //place variables in here such as
        //level = player.level
        health     = llb.health;
        stamina    = llb.stamina;
        strength   = llb.strength;
        maxHealth  = llb.maxHealth;
        depth      = llb.DungeonDepth;
        ammo       = llb.ammo;
        weaponType = llb.weaponType;

        isFull = inv.getFullSlots();
        items  = inv.getItemStructs();
        //slotTag = "InventoryTag";
    }