12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- namespace ET.Client
- {
- public class StartFightCardItem : MonoBehaviour
- {
- public Image icon;
- public int val;
- public Action<int> cb;
- private bool isSelect = false;
- public bool IsSelect{ get => isSelect; set => isSelect = value; }
- public async void Init(Image icon,int val,Action<int> cb)
- {
- this.icon = icon;
- this.val = val;
- this.cb = cb;
- var sprite = await GameObjectPool.Instance.AcquireSprite(string.Concat(GameSetting.Instance.selfPlayCardCenterSpiteName, this.val));
- this.icon.sprite = sprite;
- this.icon.gameObject.GetComponent<RectTransform>().sizeDelta = GameUtil.Instance.myHandCardSize;
- this.icon.gameObject.OnClick(() =>
- {
- if (isSelect)
- {
- Log.Error("@@@@@。。。放下");
- GetDown();
- }
- else
- {
- Log.Error("@@@@@。。。抬起");
- StandUp();
- }
- });
- icon.gameObject.OnDoubleClick(() =>
- {
- Log.Error("@@@@@。。。出牌");
- this.cb?.Invoke(this.val);
- });
- }
- public void StandUp()
- {
- Log.Error("@@@@@。。。StandUp");
- if (IsSelect)
- {
- return;
- }
- IsSelect = true;
- RectTransform rt = icon.gameObject.GetComponent<RectTransform>();
- rt.localPosition = new Vector3(rt.localPosition.x, rt.localPosition.y + 30, rt.localPosition.z);
- GameObjectPool.Instance.OperatoRarealySelCardList(0, this.val);
- }
- public void GetDown()
- {
- if (!IsSelect)
- return;
- IsSelect = false;
- RectTransform rt = icon.gameObject.GetComponent<RectTransform>();
- rt.localPosition = new Vector3(rt.localPosition.x, rt.localPosition.y - 30, rt.localPosition.z);
- GameObjectPool.Instance.OperatoRarealySelCardList(1, this.val);
- }
- }
- }
|