//赢得游戏后显示画面 public void WinGame() { WinPanel.SetActive(true); string filepath = Application.dataPath + "/Doc" + "/cardlist_all.json"; if (File.Exists(filepath)) { Debug.Log("card load"); StreamReader sr = new StreamReader(filepath); //读取JSON文件 string str = sr.ReadToEnd(); rewordcard = JsonConvert.DeserializeObject <List <Card> >(str); //反序列化为List } for (int i = 0; i < 3; i++) { GameObject go = Instantiate(reword.gameObject, cardchoose.content); go.transform.Find("ui").gameObject.name = (++count).ToString(); Settest setcard = go.GetComponent <Settest>(); setcard.Textset(rewordcard[i]); } System.Random random = new System.Random(); int gold = random.Next(13, 37); getmoney.text = "+" + gold.ToString(); playermoney += gold; }
//抽卡 private void DrawCard(int num) { if (licards.Count < num) { for (int j = 0; j < usedcard.Count; j++) { licards.Add(usedcard[j]); licards = RandomCard.RandomCards(licards); usedcard.Remove(usedcard[j]); } } for (int i = 0; i < num; i++) { GameObject go = Instantiate(newcard.gameObject, rect.content); go.transform.Find("ui").gameObject.name = (++count).ToString(); Settest setcard = go.GetComponent <Settest>(); CardListener cardlistener = go.GetComponentInChildren <CardListener>(); cardlistener.GetCardData(licards[i]); setcard.Textset(licards[i]); } }