public void Load() { resourceList = JsonConvert.DeserializeObject <PlayerCharacterSaveLoad>(PlayerPrefs.GetString(KeyUtils.CHARACTER_DATA)); //JsonUtility.FromJson<PlayerCharacterSaveLoad>(PlayerPrefs.GetString(KeyUtils.CHARACTER_DATA)); if (resourceList == null) { resourceList = new PlayerCharacterSaveLoad { currentCharacter = 0 }; for (int i = 0; i < 6; i++) { int id = UnityEngine.Random.Range(0, 4); resourceList.AddData(CharacterResource.CreateInstance((int)ResourceType.CharacterType, id, 1, i)); } Save(); } for (int i = 0; i < resourceList.dataList.Count; i++) { inventoryDic.Add(resourceList.dataList[i].characterId, resourceList.dataList[i]); } }
public void RecieveReward() { if (resType == (int)ResourceType.ItemType) { DataPlayer.GetModule <PlayerInventory>().AddNewItem(ItemResource.CreateInstance(resType, resId, resNumber, 0, 0)); } else if (resType == (int)ResourceType.MoneyType) { DataPlayer.GetModule <PlayerMoney>().AddOne((MoneyType)resId, resNumber); } else if (resType == (int)ResourceType.CharacterType) { DataPlayer.GetModule <PlayerCharacter>().AddCharacter(CharacterResource.CreateInstance(resType, resId, resNumber)); } else { } }