79 lines
2.7 KiB
C#
79 lines
2.7 KiB
C#
|
|
using System;
|
||
|
|
using Continentis.MainGame.Card;
|
||
|
|
using Continentis.MainGame.Character;
|
||
|
|
using DG.Tweening;
|
||
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
namespace Continentis.MainGame.UI
|
||
|
|
{
|
||
|
|
public class TeamSwitchButton : MonoBehaviour
|
||
|
|
{
|
||
|
|
public bool isTeam;
|
||
|
|
public Button button;
|
||
|
|
public TMP_Text buttonText;
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
isTeam = false;
|
||
|
|
|
||
|
|
button.onClick.AddListener(() =>
|
||
|
|
{
|
||
|
|
isTeam = !isTeam;
|
||
|
|
if (isTeam)
|
||
|
|
{
|
||
|
|
SwitchToTeam();
|
||
|
|
buttonText.text = "Team";
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
SwitchToCurrentCharacter();
|
||
|
|
buttonText.text = "Hero";
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
private void SwitchToTeam()
|
||
|
|
{
|
||
|
|
Sequence seq = DOTween.Sequence();
|
||
|
|
seq.Append(CombatUIManager.Instance.deckPage.handPile.rectTransform.DOAnchorPosY(-300f, 0.2f)
|
||
|
|
.OnComplete(() =>
|
||
|
|
{
|
||
|
|
CombatUIManager.Instance.deckPage.ClearAllCardViews();
|
||
|
|
MainGameManager.Instance.playerTeam.deckSubmodule.SetUpCardViews();
|
||
|
|
MainGameManager.Instance.playerTeam.deckSubmodule.GetAllCards().ForEach(c =>
|
||
|
|
{
|
||
|
|
c.user = CombatMainManager.Instance.currentCharacter;
|
||
|
|
c.cardLogic.RefreshCardAttributes();
|
||
|
|
CardDescriptionInterpreter.InterpretDescription(c.cardLogic);
|
||
|
|
c.handCardView.Setup(c);
|
||
|
|
});
|
||
|
|
}));
|
||
|
|
|
||
|
|
seq.AppendInterval(0.1f);
|
||
|
|
seq.Append(CombatUIManager.Instance.deckPage.handPile.rectTransform.DOAnchorPosY(150f, 0.2f));
|
||
|
|
seq.Play();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void SwitchToCurrentCharacter()
|
||
|
|
{
|
||
|
|
if (CombatMainManager.Instance.currentCharacter is PlayerHero playerHero)
|
||
|
|
{
|
||
|
|
Sequence seq = DOTween.Sequence();
|
||
|
|
seq.Append(CombatUIManager.Instance.deckPage.handPile.rectTransform.DOAnchorPosY(-300f, 0.2f)
|
||
|
|
.OnComplete(() =>
|
||
|
|
{
|
||
|
|
CombatUIManager.Instance.deckPage.ClearAllCardViews();
|
||
|
|
playerHero.deckSubmodule.SetUpCardViews();
|
||
|
|
}));
|
||
|
|
seq.AppendInterval(0.1f);
|
||
|
|
seq.Append(CombatUIManager.Instance.deckPage.handPile.rectTransform.DOAnchorPosY(150f, 0.2f));
|
||
|
|
seq.Play();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
throw new Exception("当前角色不是玩家角色,无法显示卡牌。");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|