91 lines
3.2 KiB
C#
91 lines
3.2 KiB
C#
using System;
|
|
using Continentis.MainGame.Card;
|
|
using Continentis.MainGame.Character;
|
|
using Continentis.MainGame.Combat;
|
|
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;
|
|
public TMP_Text teamPileText;
|
|
private void Awake()
|
|
{
|
|
isTeam = false;
|
|
|
|
button.onClick.AddListener(() =>
|
|
{
|
|
isTeam = !isTeam;
|
|
if (isTeam)
|
|
{
|
|
SwitchToTeam();
|
|
buttonText.text = "Team";
|
|
teamPileText.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
SwitchToCurrentCharacter();
|
|
buttonText.text = "Hero";
|
|
teamPileText.gameObject.SetActive(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void SwitchToTeam()
|
|
{
|
|
Sequence seq = DOTween.Sequence();
|
|
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(-300f, 0.2f)
|
|
.OnComplete(() =>
|
|
{
|
|
CombatUIManager.Instance.combatMainPage.ClearAllCardViews();
|
|
CombatMainManager.Instance.characterController.playerTeam.deckSubmodule.SetUpHandCardViews();
|
|
CombatMainManager.Instance.characterController.playerTeam.deckSubmodule.GetAllCards().ForEach(card =>
|
|
{
|
|
card.user = CombatMainManager.Instance.currentCharacter;
|
|
card.RefreshCardAttributes();
|
|
});
|
|
}));
|
|
|
|
seq.AppendInterval(0.1f);
|
|
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(80f, 0.2f));
|
|
seq.Play();
|
|
}
|
|
|
|
private void SwitchToCurrentCharacter()
|
|
{
|
|
if (CombatMainManager.Instance.currentCharacter is PlayerHero playerHero)
|
|
{
|
|
Sequence seq = DOTween.Sequence();
|
|
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(-300f, 0.2f)
|
|
.OnComplete(() =>
|
|
{
|
|
CombatUIManager.Instance.combatMainPage.ClearAllCardViews();
|
|
playerHero.deckSubmodule.SetUpHandCardViews();
|
|
}));
|
|
seq.AppendInterval(0.1f);
|
|
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(80f, 0.2f));
|
|
seq.Play();
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("当前角色不是玩家角色,无法显示卡牌。");
|
|
}
|
|
}
|
|
|
|
public void UpdateTeamPileText(CombatTeam team)
|
|
{
|
|
int currentCardCount = team.deckSubmodule.HandPile.Count;
|
|
|
|
gameObject.SetActive(currentCardCount != 0);
|
|
|
|
teamPileText.text = $"{currentCardCount}/10";
|
|
Debug.Log($"Updated team pile text: {teamPileText.text}");
|
|
}
|
|
}
|
|
} |