Ejemplo n.º 1
0
    public void SaveReset()
    {
        //HP
        CharactorStatistics playerStatisticsData = new CharactorStatistics();

        playerStatisticsData.hpMax  = 100;
        playerStatisticsData.HP     = playerStatisticsData.hpMax;
        playerStatisticsData.Damage = 30;
        playerStatisticsData.Def    = 10;

        var b = new BinaryFormatter();
        var m = new MemoryStream();

        b.Serialize(m, playerStatisticsData);
        PlayerPrefs.SetString("PlayerSatat", Convert.ToBase64String(m.GetBuffer()));

        //inventory
        Item[] ChractorInventory = new Item[4];

        for (int i = 0; i < ChractorInventory.Length; i++)
        {
            ChractorInventory[i].ItemNum         = itemNumber.Empty;
            ChractorInventory[i].ItemName        = null;
            ChractorInventory[i].ItemPrice       = 0;
            ChractorInventory[i].ItemImage       = null;
            ChractorInventory[i].ItemInvenNum    = 0;
            ChractorInventory[i].ItemCount       = 0;
            ChractorInventory[i].ItemInformation = null;
            ChractorInventory[i].oneItem         = false;
        }

        Save(ChractorInventory, 500);
    }
Ejemplo n.º 2
0
    public void PlayerSaveData(CharactorStatistics playerStatistics)
    {
        var b = new BinaryFormatter();
        var m = new MemoryStream();

        b.Serialize(m, playerStatistics);
        PlayerPrefs.SetString("PlayerSatat", Convert.ToBase64String(m.GetBuffer()));
    }
Ejemplo n.º 3
0
 public void Load()
 {
     if (saveLoad.PlayerLoadData() != null)
     {
         playerStatistics = saveLoad.PlayerLoadData();
     }
     healthBar.UpdateBar(playerStatistics.HP, playerStatistics.hpMax);
     healthBar.transform.GetChild(0).GetComponent <Text>().text = playerStatistics.HP.ToString() + "/" + playerStatistics.hpMax.ToString();
 }