| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using DG.Tweening;
- /* 弹窗-PK邀请通知提示 */
- public class PKInviteNotice : MonoBehaviour
- {
- Transform item;
- RectTransform itemRTF;
- void Awake() {
- item = transform.Find("Item");
- itemRTF = item.GetComponent<RectTransform>();
- item.Find("BtnYes").GetComponent<Button>().onClick.AddListener(() => {
- AudioMgr.ins.PlayBtn();
- agree();
- });
- item.Find("BtnNo").GetComponent<Button>().onClick.AddListener(() => {
- AudioMgr.ins.PlayBtn();
- reject();
- });
- Sequence seq = DOTween.Sequence();
- seq.Append(itemRTF.DOLocalMoveX(itemRTF.localPosition.x + itemRTF.sizeDelta.x, 0.6f));
- seq.AppendInterval(10f);
- seq.AppendCallback(() => {
- if (this && this.gameObject) Destroy(this.gameObject);
- });
- seq.SetUpdate(true);
- }
- bool hasDoneDestroy = false;
- void OnDestroy() {
- if (!hasDoneDestroy) {
- eventOnAutoDestroy?.Invoke();
- }
- }
- void agree() {
- hasDoneDestroy = true;
- if (this && this.gameObject) Destroy(this.gameObject);
- eventOnAgree?.Invoke();
- }
- void reject() {
- hasDoneDestroy = true;
- if (this && this.gameObject) Destroy(this.gameObject);
- eventOnReject?.Invoke();
- }
- public Action eventOnAgree;
- public Action eventOnReject;
- public Action eventOnAutoDestroy;
- public void SetAvatarSprite(int avatarID, string avatarUrl) {
- RoleMgr.SetAvatarToImage(
- item.Find("Avatar/Sprite").GetComponent<Image>(),
- avatarID, avatarUrl
- );
- }
- public void SetNameText(string text) {
- item.Find("Name").GetComponent<Text>().text = text;
- }
- public void SetTipText(string text) {
- item.Find("Tip").GetComponent<Text>().text = text;
- }
- }
|