| | |
| | | public class FestivalActivityCheckInCell : MonoBehaviour |
| | | { |
| | | [SerializeField] ButtonEx clickButton; |
| | | [SerializeField] ImageEx bgImage; |
| | | [SerializeField] ImageEx darkImage; |
| | | [SerializeField] ImageEx lightImage; |
| | | [SerializeField] TextEx dayText; |
| | | [SerializeField] TextEx itemNameText; |
| | | [SerializeField] ItemCell itemCell; |
| | | [SerializeField] UIEffectPlayer uiEffectPlayer; |
| | | [SerializeField] ItemCell[] itemCells; |
| | | [SerializeField] UIEffectPlayer[] uiEffectPlayers; |
| | | [SerializeField] ImageEx[] haveImages; |
| | | [SerializeField] Transform imgMask; |
| | | |
| | | FestivalActivityCheckInManager manager => FestivalActivityCheckInManager.Instance; |
| | | |
| | | private int currentItemId; |
| | | private int currentState; |
| | | |
| | | public void Display(int templateID, int dayNum) |
| | | { |
| | | uiEffectPlayer.Stop(); |
| | | for (int i = 0; i < uiEffectPlayers.Length; i++) |
| | | { |
| | | uiEffectPlayers[i].Stop(); |
| | | } |
| | | for (int i = 0; i < haveImages.Length; i++) |
| | | { |
| | | haveImages[i].SetActive(false); |
| | | } |
| | | |
| | | var config = ActSignAwardConfig.GetConfig(templateID, dayNum); |
| | | if (config == null) return; |
| | | if (config.SignAwardItemList.IsNullOrEmpty()) return; |
| | | |
| | | currentItemId = config.SignAwardItemList[0][0]; |
| | | int count = config.SignAwardItemList[0][1]; |
| | | |
| | | var itemConfig = ItemConfig.Get(currentItemId); |
| | | if (itemConfig == null) return; |
| | | |
| | | currentState = manager.GetCheckInState(dayNum); |
| | | imgMask.SetActive(currentState == 2); |
| | | bgImage.SetSprite(currentState == 1 ? "HeroDebutCheckInDayBG1" : "HeroDebutCheckInDayBG2"); |
| | | darkImage.SetActive(currentState != 1); |
| | | lightImage.SetActive(currentState == 1); |
| | | |
| | | if (currentState == 1) |
| | | { |
| | | uiEffectPlayer.Play(); |
| | | for (int i = 0; i < uiEffectPlayers.Length; i++) |
| | | { |
| | | if (i < config.SignAwardItemList.Length) |
| | | { |
| | | uiEffectPlayers[i].Play(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (currentState == 2) |
| | | { |
| | | for (int i = 0; i < haveImages.Length; i++) |
| | | { |
| | | if (i < config.SignAwardItemList.Length) |
| | | { |
| | | haveImages[i].SetActive(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | dayText.text = Language.Get($"SignDay{dayNum}"); |
| | | itemNameText.text = itemConfig.ItemName; |
| | | |
| | | itemCell.Init(new ItemCellModel(currentItemId, false, count)); |
| | | itemCell.button.AddListener(OnItemClicked); |
| | | |
| | | for (int i = 0; i < itemCells.Length; i++) |
| | | { |
| | | int index = i; |
| | | if (i < config.SignAwardItemList.Length) |
| | | { |
| | | itemCells[i].SetActive(true); |
| | | itemCells[i].Init(new ItemCellModel(config.SignAwardItemList[i][0], false, config.SignAwardItemList[i][1])); |
| | | itemCells[i].button.AddListener(() => |
| | | { |
| | | if (currentState == 1) |
| | | { |
| | | manager.SendGetCheckInReward(); |
| | | } |
| | | else |
| | | { |
| | | ItemTipUtility.Show(config.SignAwardItemList[index][0]); |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | itemCells[i].SetActive(false); |
| | | } |
| | | } |
| | | clickButton.SetListener(() => manager.SendGetCheckInReward()); |
| | | } |
| | | |
| | | private void OnItemClicked() |
| | | { |
| | | if (currentState == 1) |
| | | { |
| | | manager.SendGetCheckInReward(); |
| | | } |
| | | else |
| | | { |
| | | ItemTipUtility.Show(currentItemId); |
| | | } |
| | | } |
| | | } |