using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TableConfig; using System.Linq; namespace Snxxz.UI { public class PracticeTypeCell : CellView { [SerializeField] public GameObject unSelectImg; [SerializeField] public GameObject selectImg; [SerializeField] public Text nameText; [SerializeField] public Slider progressSlider; [SerializeField] public Text progressText; [SerializeField] public Button cellBtn; [SerializeField] public Transform arrowIcon; [SerializeField] public RedpointBehaviour redpoint; RealmPracticeModel practiceModel { get { return ModelCenter.Instance.GetModel(); } } public void Init(int firstType,int selectFirstType,bool isDoubleClick) { redpoint.redpointId = practiceModel.realmFirstTypeDict[firstType].id; nameText.text = practiceModel.GetPracticePointStr(firstType); List secondTypelist = practiceModel.GetAllOpenRealmPra()[firstType].Keys.ToList(); if(secondTypelist[0] != 0) { arrowIcon.gameObject.SetActive(true); } else { arrowIcon.gameObject.SetActive(false); } if(selectFirstType == firstType) { selectImg.SetActive(true); unSelectImg.SetActive(false); if(secondTypelist[0] != 0) { if(isDoubleClick) { arrowIcon.localRotation = Quaternion.Euler(0, 0, 0); } else { arrowIcon.localRotation = Quaternion.Euler(0, 0, -90); } } } else { arrowIcon.localRotation = Quaternion.Euler(0, 0,0); unSelectImg.SetActive(true); selectImg.SetActive(false); } RefreshProgress(firstType); } public void RefreshProgress(int practiceType) { progressSlider.minValue = 0; progressSlider.maxValue = practiceModel.GetRealmPraPointByType(practiceType); progressSlider.value = practiceModel.GetRealmPraPointByType(practiceType,0,false); string precent = ""; float precentValue = (float)(progressSlider.value / progressSlider.maxValue)*100; if(precentValue > 0 && precentValue < 1) { precentValue = 1; } precent = StringUtility.Contact((float)Math.Round(precentValue,1),"%"); progressText.text = precent; } } }