123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using LitJson;
- using System.IO;
- using UnityEngine.UI;
- using static UnityEditor.Progress;
- public class TenExtract : MonoBehaviour
- {
- private List<TalentsItem> talentsItemList = new List<TalentsItem>();
- private List<TalentsItem> currentItemList = new List<TalentsItem>();
- public List<Toggle> toggleList = new List<Toggle>();
- public List<Text> labelList = new List<Text>();
- public Button selectBtn;
- public GameObject Adjust_Panel;
- void Start()
- {
- string filePath = "Assets/Data/myTalent.json";
- if (File.Exists(filePath))
- {
- string dataAsJson = File.ReadAllText(filePath);
- TalentsData talentsData = JsonMapper.ToObject<TalentsData>(dataAsJson);
- foreach (var item in talentsData.talents)
- {
- talentsItemList.Add(item);
- }
- }
- for (int i = 0; i < 10; i++)
- {
- int index = Random.Range(0, talentsItemList.Count);
- currentItemList.Add(talentsItemList[index]);
- talentsItemList.Remove(talentsItemList[index]);
- }
- foreach (var item in toggleList)
- {
- labelList.Add(item.transform.GetChild(1).GetComponent<Text>());
- }
- for (int i = 0; i < labelList.Count; i++)
- {
- labelList[i].text = currentItemList[i].name + "(" + currentItemList[i].description + ")";
- }
- selectBtn.onClick.AddListener(() =>
- {
- PlayerData.intance.currentItemTalentList.Clear();
- int m = 0;
- for (int i = 0; i < toggleList.Count; i++)
- {
- if (toggleList[i].isOn == true) m++;
-
- }
- if (m != 3)
- {
- Debug.Log("ÇëÑ¡ÔñÈý¸öÌ츳£¡");
- return;
- }
- for (int i = 0;i<toggleList.Count;i++)
- {
- if (toggleList[i].isOn == true)
- {
- PlayerData.intance.currentItemTalentList.Add(currentItemList[i]);
- }
- }
- Adjust_Panel.SetActive(true);
- });
- }
- void Update()
- {
- }
- }
|