void ApplyPictureData(Sprite[] _sprite, CardType _type, CE_CardsDB _db) { if (_sprite == null) { return; } List <CE_Card> _cards = _db.AllCards.ToList().Where(c => c.Type == _type).ToList(); _cards.ForEach(c => c.SetSprite(_sprite)); }
void LoadDB() { TextAsset _data = Resources.Load <TextAsset>("Data/Cards"); if (!_data) { return; } gameCardsDB = JsonUtility.FromJson <CE_CardsDB>(_data.text); if (!gameCardsDB.IsValid) { return; } Sprite[] _rooms = Resources.LoadAll <Sprite>("UI/room_cards"); Sprite[] _characters = Resources.LoadAll <Sprite>("UI/suspect_cards"); Sprite[] _weapons = Resources.LoadAll <Sprite>("UI/weapons_cards"); ApplyPictureData(_rooms, CardType.Room, gameCardsDB); ApplyPictureData(_characters, CardType.Character, gameCardsDB); ApplyPictureData(_weapons, CardType.Weapon, gameCardsDB); availableCards = new List <CE_Card>(gameCardsDB.AllCards); IsReady = true; }