mycj_demo/mycj/Assets/Game/Scripts/Application/02View/Select/FBUICard.cs
2024-12-02 09:37:47 +08:00

92 lines
2.3 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Felix-BangFBUICard
//   へ     /|
//  /7    ∠_/
//  / │    
//  Z _,    /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │
//  / へ   / ノ<|
//  ヽ_ノ  (_  │//
//  7       |
//  ―r ̄ ̄`ー―_
// Describe
// Createtime
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System;
namespace FBApplication
{
public class FBUICard : MonoBehaviour,IPointerDownHandler
{
//点击事件
public event Action<FBCard> OnClickAction;
[SerializeField]
private Image imgCard;
[SerializeField]
private Image imgLock;
//卡片属性
private FBCard f_card = null;
public FBCard Card
{
set
{
f_card = value;
BindCard();
}
}
//是否为半透明
private bool f_isTransparent;
public bool IsTransparent
{
get { return f_isTransparent; }
set
{
f_isTransparent = value;
Image[] images = new Image[] { imgCard, imgLock };
foreach (Image img in images)
{
Color c = img.color;
c.a = value ? 0.5f : 1f;
img.color = c;
}
}
}
private void BindCard()
{
//加载图片
string cardFile = "file://" + FBConsts.CardsDir +"\\"+ f_card.CardImage;
StartCoroutine(FBTools.LoadImage(cardFile,imgCard));
//是否锁定
imgLock.gameObject.SetActive(f_card.IsLocked);
}
public void OnPointerDown(PointerEventData eventData)
{
if (OnClickAction != null)
OnClickAction(f_card);
}
private void OnDestroy()
{
while (OnClickAction != null)
OnClickAction -= OnClickAction;
}
}
}