using UnityEngine;
|
using UnityEngine.UI;
|
|
using System;
|
|
namespace vnxbqy.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<ComposeWinModel>(); } }
|
|
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.SetActive(thirdType != 0);
|
UpdateBtnImg(selectSecondType);
|
|
var index = composeModel.composeRedpointCategories.FindIndex((x) =>
|
{
|
return x.x == firstType && x.y == secondType;
|
});
|
|
if (index != -1)
|
{
|
redpoint.SetActive(true);
|
redpoint.redpointId = composeModel.secondTypeRedDict[firstType * 100 + secondType].id;
|
}
|
else
|
{
|
redpoint.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);
|
}
|
}
|
}
|