using UnityEngine; using UnityEngine.UI; using System; namespace Snxxz.UI { public class ComposeFirstTypeCell : MonoBehaviour { [SerializeField] Image btnImg; [SerializeField] Transform arrowImg; [SerializeField] Text unlockTypeName; [SerializeField] Button typeBtn; [SerializeField] RedpointBehaviour redpoint; ComposeWinModel composeModel { get { return ModelCenter.Instance.GetModel(); } } int secondType = 0; public void SetDisplay(int firstType,int secondType,int thirdType,int selectSecondType) { this.secondType = secondType; ComposeWinModel.ComposeThirdTypeData thirdTypeData = null; bool isThird = composeModel.TryGetThirdTypeData(firstType,secondType,thirdType,out thirdTypeData); if (!isThird) return; var itemCompound = thirdTypeData.itemCompound; unlockTypeName.text = itemCompound.secondTypeName; arrowImg.gameObject.SetActive(thirdType != 0); UpdateBtnImg(selectSecondType); if (firstType == (int)ComposeFuncType.Item && composeModel.secondTypeRedDict.ContainsKey(secondType)) { redpoint.gameObject.SetActive(true); redpoint.redpointId = composeModel.secondTypeRedDict[secondType].id; } else { redpoint.gameObject.SetActive(false); } typeBtn.RemoveAllListeners(); typeBtn.AddListener(ClickTypeBtn); } public void UpdateBtnImg(int selectSecondType) { string iconKey = secondType == selectSecondType ? "ComposeFirstClassChoosebtn" : "ComposeFirstClassNormalbtn"; btnImg.SetSprite(iconKey); arrowImg.localRotation = secondType == selectSecondType ? Quaternion.Euler(0, 0, -90) : Quaternion.Euler(0, 0, 0); } private void ClickTypeBtn() { composeModel.UpdateSecondType(secondType); } } }