145 lines
5.3 KiB
C#
145 lines
5.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AlbumPictureReviewPopupPanel : MonoBehaviour
|
|
{
|
|
public Button btn_close;
|
|
public Button btn_mask;
|
|
// public GameObject mask_empty;
|
|
public TMP_Text text_left_time;
|
|
public TMP_Text text_tips;
|
|
public TMP_Text text_disable;
|
|
public Button btn_askforfriend;
|
|
public Button btn_join;
|
|
|
|
public PictureItem pictureItem;
|
|
int count = 0;
|
|
ClubService _socialData;
|
|
Picture data;
|
|
private void Awake()
|
|
{
|
|
_socialData = GContext.container.Resolve<ClubService>();
|
|
pictureItem = transform.Find("root/album_photo").GetComponent<PictureItem>();
|
|
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
|
btn_mask = transform.Find("mask").GetComponent<Button>();
|
|
text_left_time = transform.Find("root/text_left_time").GetComponent<TMP_Text>();
|
|
text_tips = transform.Find("root/text_tips").GetComponent<TMP_Text>();
|
|
text_disable = transform.Find("root/text_disable").GetComponent<TMP_Text>();
|
|
btn_askforfriend = transform.Find("root/btn_askforfriend/btn_green").GetComponent<Button>();
|
|
btn_join = transform.Find("root/btn_join/btn_green").GetComponent<Button>();
|
|
}
|
|
private void Start()
|
|
{
|
|
btn_close.onClick.AddListener(OnClickClose);
|
|
btn_mask.onClick.AddListener(OnClickClose);
|
|
btn_askforfriend.onClick.AddListener(OnClickDown);
|
|
btn_join.onClick.AddListener(OnClickJoin);
|
|
}
|
|
|
|
void OnClickClose()
|
|
{
|
|
UIManager.Instance.HideUI(UITypes.AlbumPictureReviewPopupPanel);
|
|
}
|
|
async void OnClickJoin()
|
|
{
|
|
if (GContext.container.Resolve<ClubService>().IsOpenClubJoined)
|
|
{
|
|
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
|
|
btn_join.enabled = false;
|
|
//打开俱乐部界面
|
|
await UIManager.Instance.ShowUI(UITypes.FishingSocialPanel);
|
|
btn_join.enabled = true;
|
|
OnClickClose();
|
|
}
|
|
else
|
|
{
|
|
GContext.Publish(new VibrationData(HapticTypes.Failure));
|
|
ToastPanel.Show(GContext.container.Resolve<FishingEventData>().GetTipforUnlocked(GContext.container.Resolve<ClubService>().socialTipforUnlocked));
|
|
}
|
|
|
|
}
|
|
async void OnClickDown()
|
|
{
|
|
if (GContext.container.Resolve<AlbumData>().GetPhotoRequestCountByDay() < GContext.container.Resolve<Tables>().TbGlobalConfig.PictureGiftedLimitDaily)
|
|
{
|
|
btn_askforfriend.enabled = false;
|
|
//社交求助帖
|
|
bool resut = await _socialData.SendGetPhoto(data.ID);
|
|
if (resut)
|
|
{
|
|
int giftToFriendsDay = GContext.container.Resolve<AlbumData>().SetPhotoRequestCountByDay();
|
|
int PictureGiftedLimitDaily = GContext.container.Resolve<Tables>().TbGlobalConfig.PictureGiftedLimitDaily;
|
|
text_left_time.text = LocalizationMgr.GetFormatTextValue("UI_AlbumPictureReviewPopupPanel_101001",
|
|
PictureGiftedLimitDaily - giftToFriendsDay,
|
|
PictureGiftedLimitDaily);
|
|
//ToastPanel求助成功
|
|
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_37"));
|
|
GContext.container.Resolve<AlbumData>().UpdatePlayerStatistics();
|
|
}
|
|
btn_askforfriend.enabled = true;
|
|
}
|
|
else
|
|
{
|
|
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_8"));
|
|
}
|
|
}
|
|
|
|
public void SetData(Picture _data)
|
|
{
|
|
data = _data;
|
|
gameObject.SetActive(true);
|
|
pictureItem.SetData(_data, null);
|
|
//pictureAttribute.Init(_data);
|
|
SetState();
|
|
}
|
|
|
|
void SetState()
|
|
{
|
|
count = GContext.container.Resolve<AlbumData>().GetPictureProgress(data.ID);
|
|
|
|
// mask_empty.SetActive(count <= 0);
|
|
// img_card.gameObject.SetActive(count > 0);
|
|
//pictureAttribute.text_num.transform.parent.gameObject.SetActive(count > 1);
|
|
bool isJoin = _socialData.IsClubJoined();
|
|
text_left_time.gameObject.SetActive(false);
|
|
text_tips.gameObject.SetActive(false);
|
|
btn_askforfriend.gameObject.SetActive(false);
|
|
btn_join.gameObject.SetActive(false);
|
|
|
|
if (!data.IsTradable)
|
|
{
|
|
text_disable.gameObject.SetActive(true);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
text_disable.gameObject.SetActive(false);
|
|
}
|
|
|
|
if (count <= 0)
|
|
{
|
|
if (isJoin)
|
|
{
|
|
text_left_time.gameObject.SetActive(true);
|
|
int giftToFriendsDay = GContext.container.Resolve<AlbumData>().GetPhotoRequestCountByDay();
|
|
int PictureGiftedLimitDaily = GContext.container.Resolve<Tables>().TbGlobalConfig.PictureGiftedLimitDaily;
|
|
text_left_time.text = LocalizationMgr.GetFormatTextValue("UI_AlbumPictureReviewPopupPanel_101001",
|
|
PictureGiftedLimitDaily - giftToFriendsDay,
|
|
PictureGiftedLimitDaily);
|
|
btn_askforfriend.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
text_tips.gameObject.SetActive(true);
|
|
btn_join.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
} |