备份CatanBuilding瘦身独立工程
This commit is contained in:
110
Assets/Scripts/UI/PartnerFishBowl/EventPartnerCharaSlot.cs
Normal file
110
Assets/Scripts/UI/PartnerFishBowl/EventPartnerCharaSlot.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using cfg;
|
||||
|
||||
public class EventPartnerCharaSlot : MonoBehaviour
|
||||
{
|
||||
private TMP_Text _textScoreAdd;
|
||||
private Button _btn;
|
||||
private Image _iconHead, _bar, _iconGrandPrize;
|
||||
private RewardItemNew _reward;
|
||||
private GameObject _GoHead, _GoEmpty, _redPoint;
|
||||
private PlayerItemData _playerItemData;
|
||||
private EventPartnerData.Component _component;
|
||||
private EventPartnerAct.Context _ctx;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private Tables _tables;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// _textNameHead = transform.Find("head/text_name").GetComponent<TMP_Text>();
|
||||
// _textNameEmpty = transform.Find("empty/text_name").GetComponent<TMP_Text>();
|
||||
_btn = GetComponent<Button>();
|
||||
_iconHead = transform.Find("head/mask/icon_head").GetComponent<Image>();
|
||||
_bar = transform.Find("head/bg_bar/bar").GetComponent<Image>();
|
||||
_reward = transform.Find("head/bg_bar/reward").GetComponent<RewardItemNew>();
|
||||
_GoHead = transform.Find("head").gameObject;
|
||||
_GoEmpty = transform.Find("empty").gameObject;
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_redPoint = transform.Find("head/redpoints").gameObject;
|
||||
_textScoreAdd = transform.Find("head/text_add").GetComponent<TMP_Text>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_btn.onClick.AddListener(() => _ = OnClickBtn());
|
||||
_iconGrandPrize = transform.Find("head/bg_bar/icon_grand_reward").GetComponent<Image>();
|
||||
}
|
||||
|
||||
public void Init(EventPartnerData.Component c)
|
||||
{
|
||||
var ctx = EventPartnerAct.Ctx;
|
||||
_ctx = ctx;
|
||||
_component = c;
|
||||
_eventAggregator = ctx.EventAggregator;
|
||||
// string name = c.GetComponentName();
|
||||
// _textNameEmpty.text = name;
|
||||
// _textNameHead.text = name;
|
||||
_bar.fillAmount = _component.GetPartialProgress(_component.Score);
|
||||
_GoEmpty.SetActive(!_component.IsMatched);
|
||||
_GoHead.SetActive(_component.IsMatched);
|
||||
if (!_component.IsMatched)
|
||||
return;
|
||||
if (!_component.IsPartnerRobot)
|
||||
c.SetComponent(_component.PartnerId);
|
||||
//else has been when adding bot.
|
||||
// Debug.Log($"<color=#22a6f2>[EventPartner]CharaSlot: Set icon {_component.PartnerAvatarUrl} for slot {_component.ComponentIndex}. Robot: {_component.IsPartnerRobot}</color>");
|
||||
GContext.container.Resolve<IUIService>().SetHeadImage(_iconHead, _component.PartnerAvatarUrl);
|
||||
if (_component.DisplayStageProgress <
|
||||
_tables.TbEventPartnerMain[_component.RedirectID].StagePoint.Count - 1)
|
||||
{
|
||||
_reward.SetData( _playerItemData.GetItemDataByDropId(_component.GetNextRewardId(_component.Score))[0]);
|
||||
_reward.text_num.gameObject.SetActive(false);
|
||||
_iconGrandPrize.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// _reward.SetIcon(_tables.TbEventPartnerMain[_component.RedirectID].RewardIcon);
|
||||
_iconGrandPrize.gameObject.SetActive(true);
|
||||
_reward.text_num.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (_component.Score < _component.MaxScore)
|
||||
_redPoint.SetActive(_bar.fillAmount >= 1);
|
||||
else
|
||||
{
|
||||
_reward.SetReceived(_component.LastProgressReceived >= 5);
|
||||
_redPoint.SetActive(_component.LastProgressReceived < 5);
|
||||
}
|
||||
|
||||
if (_component.Score > _component.ScoreDisplay)
|
||||
{
|
||||
int delta = _component.Score - _component.ScoreDisplay;
|
||||
_textScoreAdd.text = "+" + delta.ToString();
|
||||
_textScoreAdd.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_textScoreAdd.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Match()
|
||||
{
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_iconHead, _component.PartnerAvatarUrl);
|
||||
_GoEmpty.SetActive(false);
|
||||
_GoHead.SetActive(true);
|
||||
_bar.fillAmount = 0f;
|
||||
_reward.SetData(_playerItemData.GetItemDataByDropId(_component.GetNextRewardId(_component.Score))[0]);
|
||||
_reward.text_num.gameObject.SetActive(false);
|
||||
_redPoint.SetActive(false);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task OnClickBtn()
|
||||
{
|
||||
if (_component.IsMatched)
|
||||
_ctx.ShowBuildPanel(_component.ComponentIndex);
|
||||
else
|
||||
await UIManager.Instance.ShowUI(UITypes.EventPartnerInvitationPanel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user