94 lines
3.3 KiB
C#
94 lines
3.3 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FishConfrimPanel : MonoBehaviour
|
|
{
|
|
FishingDuelManager FDM;
|
|
IUIService uIService;
|
|
FishConfrimPlayerInfo playerInfo;
|
|
public TMP_Text text_name;
|
|
public TMP_Text text_name_enemy;
|
|
GameObject card_info;
|
|
Transform card_info_content;
|
|
Button btn_confrim;
|
|
TMP_Text p_text;
|
|
public float CardInfoShowDelay = 0.25f;
|
|
public float CardInfoShowInterval = 0.2f;
|
|
bool joined = false;
|
|
List<FishConfrimCardInfo> fishConfrimCardInfos = new List<FishConfrimCardInfo>();
|
|
private void Awake()
|
|
{
|
|
uIService = GContext.container.Resolve<IUIService>();
|
|
FDM = GContext.container.Resolve<FishingDuelManager>();
|
|
card_info = transform.Find("card_info_content/card_info").gameObject;
|
|
card_info.SetActive(false);
|
|
card_info_content = transform.Find("card_info_content");
|
|
playerInfo = transform.Find("card_info_content/player_info").GetComponent<FishConfrimPlayerInfo>();
|
|
playerInfo.SetData(FDM);
|
|
text_name.text = FDM.SelfModel.PlayerName;
|
|
text_name_enemy.text = FDM.EnemyModel.PlayerName;
|
|
btn_confrim = transform.Find("btn_confrim/btn_green").GetComponent<Button>();
|
|
p_text = transform.Find("btn_confrim/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
|
}
|
|
private void Start()
|
|
{
|
|
btn_confrim.transform.parent.gameObject.SetActive(false);
|
|
List<int> itemIds = FDM.FishItemIDs;
|
|
Tables tables = GContext.container.Resolve<Tables>();
|
|
|
|
for (int i = 0; i < itemIds.Count; i++)
|
|
{
|
|
Item item = tables.GetItemData(itemIds[i]);
|
|
if (item == null) continue;
|
|
GameObject go = Instantiate(card_info, card_info_content);
|
|
go.SetActive(true);
|
|
FishConfrimCardInfo cardInfo = go.GetComponent<FishConfrimCardInfo>();
|
|
if (cardInfo != null)
|
|
{
|
|
cardInfo.SetData(item, FDM.SelfModel.CarLevels[i], FDM.EnemyModel.CarLevels[i]);
|
|
}
|
|
cardInfo.root.SetActive(false);
|
|
fishConfrimCardInfos.Add(cardInfo);
|
|
}
|
|
StartCoroutine(Close());
|
|
}
|
|
IEnumerator Close()
|
|
{
|
|
yield return new WaitForSeconds(CardInfoShowDelay);
|
|
|
|
for (int i = 0; i < fishConfrimCardInfos.Count; i++)
|
|
{
|
|
fishConfrimCardInfos[i].root.SetActive(true);
|
|
yield return new WaitForSeconds(CardInfoShowInterval);
|
|
}
|
|
btn_confrim.onClick.AddListener(Join);
|
|
btn_confrim.transform.parent.gameObject.SetActive(true);
|
|
|
|
int allTime = FDM.eventSoloConfig.StartTime;
|
|
while (allTime > 0)
|
|
{
|
|
p_text.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_41", allTime);
|
|
yield return new WaitForSeconds(1);
|
|
allTime--;
|
|
}
|
|
p_text.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_41", 0);
|
|
Join();
|
|
}
|
|
async void Join()
|
|
{
|
|
joined = true;
|
|
StopAllCoroutines();
|
|
GContext.Publish(new UnloadActToNextAct("FishingDuelAct"));
|
|
FDM.OnJoin();
|
|
await Awaiters.Seconds(1f);
|
|
UIManager.Instance.DestroyUI(UITypes.EventFishingDuelPanel);
|
|
}
|
|
}
|