先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
81 lines
2.9 KiB
C#
81 lines
2.9 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Assertions;
|
|
using UnityEngine.UI;
|
|
|
|
public class CommunityGuidanceSlot : MonoBehaviour
|
|
{
|
|
private Button _btnGo;
|
|
private GameObject _goReward;
|
|
private Image _iconReward;
|
|
private TMP_Text _textRewardCount;
|
|
private PlayerItemData _playerItemData;
|
|
private TbDrop _tbDrop;
|
|
private TbItem _tbItem;
|
|
private string _url;
|
|
private int _dropId;
|
|
private IFootPrintService _footPrintService;
|
|
private EFootPrint _footPrintRewardClaim;
|
|
private bool HasRewardToClaim => GContext.container.Resolve<FishingEventData>().IsJoinUsPanelOpen && _dropId != 0 &&
|
|
!_footPrintService.HasFootPrint(_footPrintRewardClaim);
|
|
private string _name;
|
|
public void Init(CommunityGuidancePanel.CommunityGuidanceCtx ctx)
|
|
{
|
|
_btnGo = transform.Find("btn_go/btn_green").GetComponent<Button>();
|
|
_goReward = transform.Find("reward").gameObject;
|
|
_iconReward = transform.Find("reward/p_icon").GetComponent<Image>();
|
|
_textRewardCount = transform.Find("reward/p_text_num").GetComponent<TMP_Text>();
|
|
Assert.IsTrue(_btnGo && _goReward && _iconReward && _textRewardCount,
|
|
$"{_btnGo}, {_goReward}, {_iconReward} and {_textRewardCount} should not be null.");
|
|
_url = ctx.Url;
|
|
_dropId = ctx.DropId;
|
|
_playerItemData = ctx.PlayerItemData;
|
|
_tbDrop = ctx.TableDrop;
|
|
_tbItem = ctx.TableItem;
|
|
_footPrintService = ctx.FootPrintService;
|
|
_footPrintRewardClaim = (EFootPrint)(1 << ctx.Index);
|
|
SetRewardPresentation();
|
|
_btnGo.onClick.AddListener(OnClickGo);
|
|
_name = ctx.Name;
|
|
gameObject.SetActive(ctx.Show && !string.IsNullOrEmpty(_url));
|
|
}
|
|
private void OnClickGo()
|
|
{
|
|
Application.OpenURL(_url);
|
|
var EVHasUnclaimedReward = HasRewardToClaim ? 1 : 0;
|
|
// Debug.Log($"{EVHasUnclaimedReward}");
|
|
// Debug.Log($"{_name}");
|
|
#if AGG
|
|
using (var e = GEvent.GameEvent("join_us"))
|
|
{
|
|
e.AddContent("unclaimed_reward", EVHasUnclaimedReward)
|
|
.AddContent("click_position", _name);
|
|
}
|
|
#endif
|
|
if (!HasRewardToClaim)
|
|
return;
|
|
_playerItemData.AddItemByDrop(_dropId, null);
|
|
GContext.Publish(new ShowData());
|
|
_footPrintService.UpdateFootPrint(_footPrintRewardClaim);
|
|
SetRewardPresentation();
|
|
|
|
}
|
|
|
|
private async void SetRewardPresentation()
|
|
{
|
|
if (!HasRewardToClaim)
|
|
{
|
|
_goReward.SetActive(false);
|
|
return;
|
|
}
|
|
var drop = _tbDrop[_dropId].DropList;
|
|
await GContext.container.Resolve<IUIService>().SetImageSprite(_iconReward, _tbItem[drop.DropIDList[0]].Icon);
|
|
_textRewardCount.text = drop.DropCountList[0].ToString();
|
|
_goReward.SetActive(true);
|
|
}
|
|
}
|