107 lines
4.3 KiB
C#
107 lines
4.3 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UniRx;
|
|
using cfg;
|
|
using UnityEngine.AddressableAssets;
|
|
using game;
|
|
using System.Collections.Generic;
|
|
using PlayFab.Internal;
|
|
|
|
public class EventChallengeFacePopupPanel : MonoBehaviour
|
|
{
|
|
// FishingChallengeCenter FCC;
|
|
|
|
private FishingChallengeManager _fishingChallengeManager;
|
|
|
|
Image bg_map;
|
|
TMP_Text text_map;
|
|
TMP_Text text_map1;
|
|
TMP_Text text_map2;
|
|
TMP_Text text_title;
|
|
TMP_Text text_title1;
|
|
TMP_Text text_title2;
|
|
TMP_Text text_remaing;
|
|
Button btn_enter;
|
|
Button btn_close;
|
|
private void Awake()
|
|
{
|
|
// FCC = GContext.container.Resolve<FishingChallengeCenter>();
|
|
_fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
|
|
bg_map = transform.Find("root/mask_map/img_map").GetComponent<Image>();
|
|
text_map = transform.Find("root/text_map").GetComponent<TMP_Text>();
|
|
text_map1 = transform.Find("root/text_map/text_map1").GetComponent<TMP_Text>();
|
|
text_map2 = transform.Find("root/text_map/text_map2").GetComponent<TMP_Text>();
|
|
text_title = transform.Find("root/text_title").GetComponent<TMP_Text>();
|
|
text_title1 = transform.Find("root/text_title/text_title1").GetComponent<TMP_Text>();
|
|
text_title2 = transform.Find("root/text_title/text_title2").GetComponent<TMP_Text>();
|
|
text_remaing = transform.Find("root/text_remaing").GetComponent<TMP_Text>();
|
|
btn_enter = transform.Find("root/btn_enter/btn_green").GetComponent<Button>();
|
|
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
|
}
|
|
private void Start()
|
|
{
|
|
Log("Start");
|
|
btn_enter.onClick.AddListener(OnEnterNewMap);
|
|
btn_close.onClick.AddListener(OnClose);
|
|
Init();
|
|
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("EventChallengeFacePopupPanel");
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(bg_map, _fishingChallengeManager.challengeMapData.Bg);
|
|
text_map.text = text_map1.text = text_map2.text = LocalizationMgr.GetText(_fishingChallengeManager.challengeMapData.Name_l10n_key);
|
|
|
|
text_title.gameObject.SetActive(false);
|
|
text_remaing.gameObject.SetActive(false);
|
|
// text_title.text = text_title1.text = text_title2.text = LocalizationMgr.GetFormatTextValue("UI_EventChallangePanel_7", _fishingChallengeManager.eventChallengeMain.leveL);
|
|
//int curCount = _fishingChallengeManager.number;
|
|
//int allCount = FCC.challengeMatchConfig.DailyTimes;
|
|
//text_remaing.text = LocalizationMgr.GetFormatTextValue("UI_EventChallangePanel_2", $"{allCount - curCount}/{allCount}");
|
|
|
|
}
|
|
async void OnEnterNewMap()
|
|
{
|
|
var tables = GContext.container.Resolve<Tables>();
|
|
var mapData = tables.TbMapData.DataMap[_fishingChallengeManager.challengeMapData.ID];
|
|
btn_enter.enabled = false;
|
|
var loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
|
var isCanEnter = await loadResourceService.Loads(new List<string>(){
|
|
mapData.EnvName, _fishingChallengeManager.PrefabName });
|
|
if (isCanEnter)
|
|
{
|
|
OnEnter();
|
|
}
|
|
else
|
|
{
|
|
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
|
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, OnEnter);
|
|
//var panel = await UIManager.Instance.ShowUI(UITypes.FishingDownLoadPopupPanel);
|
|
//panel.GetComponent<FishingDownLoadPopupPanel>().SetBtn(null, OnEnter);
|
|
btn_enter.enabled = true;
|
|
}
|
|
}
|
|
async void OnEnter()
|
|
{
|
|
btn_enter.enabled = false;
|
|
GContext.Publish(new ShowHomeMapEvent() { mapID = _fishingChallengeManager.challengeMapData.ID });
|
|
await new WaitForSeconds(0.5f);
|
|
OnClose();
|
|
|
|
// await UIManager.Instance.ShowUI(UITypes.EventChallengeMatchingPopupPanel);
|
|
// GContext.Publish(new EndTransition());
|
|
}
|
|
void OnClose()
|
|
{
|
|
UIManager.Instance.DestroyUI(UITypes.EventChallengeFacePopupPanel);
|
|
}
|
|
|
|
private static void Log(object t)
|
|
{
|
|
Debug.Log($"<color=yellow>EventChallangeFacePopupPanel -> {t} </color>");
|
|
}
|
|
}
|