62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PictureItem : MonoBehaviour
|
|
{
|
|
public Button btn_click;
|
|
public GameObject mask_empty;
|
|
Action<PictureItem> action;
|
|
public PictureAttribute pictureAttribute;
|
|
public GameObject effect_kapai_loop;
|
|
public GameObject effect_tuowei;
|
|
private void Awake()
|
|
{
|
|
pictureAttribute = transform.Find("Item").GetComponent<PictureAttribute>();
|
|
mask_empty = transform.Find("Item/mask_empty").gameObject;
|
|
btn_click = transform.Find("Item").GetComponent<Button>();
|
|
//Transform star = transform.Find("Item/star");
|
|
effect_kapai_loop = transform.Find("effect_kapai_loop").gameObject;
|
|
effect_tuowei = transform.Find("effect_tuowei").gameObject;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
btn_click.onClick.AddListener(OnClick);
|
|
}
|
|
|
|
public void SetData(Picture _data, Action<PictureItem> _action, bool isChat = false)
|
|
{
|
|
effect_kapai_loop.SetActive(!_data.IsTradable);
|
|
effect_tuowei.SetActive(!_data.IsTradable);
|
|
action = _action;
|
|
pictureAttribute.Init(_data);
|
|
int count = GContext.container.Resolve<AlbumData>().GetPictureProgress(pictureAttribute.data.ID);
|
|
mask_empty.SetActive(count <= 0);
|
|
pictureAttribute.img_card.gameObject.SetActive(count > 0);
|
|
if (isChat)
|
|
{
|
|
return;
|
|
}
|
|
pictureAttribute.text_num.transform.parent.gameObject.SetActive(count > 1);
|
|
if (count > 1)
|
|
{
|
|
pictureAttribute.text_num.text = $"+{count - 1}";
|
|
}
|
|
bool isNew = GContext.container.Resolve<AlbumData>().IsNewPicture(pictureAttribute.data.ID);
|
|
pictureAttribute.SetNewState(isNew);
|
|
if (isNew)
|
|
{
|
|
GContext.container.Resolve<AlbumData>().RemoveNewPicture(pictureAttribute.data.ID);
|
|
}
|
|
}
|
|
|
|
public void OnClick()
|
|
{
|
|
action?.Invoke(this);
|
|
}
|
|
}
|