12.10 进度 基本完成
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SLSFramework.General;
|
||||
using UI_Spline_Renderer;
|
||||
@@ -29,6 +30,11 @@ namespace Continentis.MainGame.UI
|
||||
[Range(1, 100)]
|
||||
public int lineSegments = 50;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GetComponent<Canvas>().sortingLayerName = "UI";
|
||||
}
|
||||
|
||||
public void SetArrow(Vector3 start, Vector3 end)
|
||||
{
|
||||
startPoint.position = start;
|
||||
@@ -47,6 +53,8 @@ namespace Continentis.MainGame.UI
|
||||
Vector2 direction = (uiEnd - uiStart).normalized;
|
||||
Vector2 perpendicular = new Vector2(-direction.y, direction.x); // 计算垂直向量
|
||||
Vector2 controlPoint = midPoint + perpendicular * (isEndOnLeftSide ? -curveOffset : curveOffset);
|
||||
controlPoint += new Vector2(0, Mathf.Abs(uiEnd.y - uiStart.y)); //增加一些垂直偏移
|
||||
//controlPoint += new Vector2(0f, 500f);
|
||||
splineContainer.Spline.Clear();
|
||||
|
||||
// 2. 计算贝塞尔曲线上所有的点
|
||||
@@ -66,8 +74,21 @@ namespace Continentis.MainGame.UI
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
endImage.color = color;
|
||||
arrowBody.color = color;
|
||||
if (color == Color.clear)
|
||||
{
|
||||
endImage.material.SetFloat("_SineGlowFade", 0);
|
||||
arrowBody.material.SetFloat("_SineGlowFade", 0);
|
||||
endImage.material.SetColor("_SineGlowColor", Color.white);
|
||||
arrowBody.material.SetColor("_SineGlowColor", Color.white);
|
||||
}
|
||||
else
|
||||
{
|
||||
float emissionIntensity = 1.5f;
|
||||
endImage.material.SetFloat("_SineGlowFade", 1);
|
||||
arrowBody.material.SetFloat("_SineGlowFade", 1);
|
||||
endImage.material.SetColor("_SineGlowColor", color * Mathf.Pow(2, emissionIntensity));
|
||||
arrowBody.material.SetColor("_SineGlowColor", color * Mathf.Pow(2, emissionIntensity));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Continentis.MainGame.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis
|
||||
@@ -6,6 +7,7 @@ namespace Continentis
|
||||
public abstract class UIElementBase : MonoBehaviour
|
||||
{
|
||||
public RectTransform rectTransform;
|
||||
public InformationBox infoBox;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using Continentis.MainGame.Combat;
|
||||
using DG.Tweening;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Continentis.MainGame.UI
|
||||
@@ -13,15 +14,16 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
[Header("UI References")]
|
||||
[SerializeField] private GameObject portraitPrefab;
|
||||
[SerializeField] private Transform portraitsContainer;
|
||||
[SerializeField] private RectTransform currentTurnPointer;
|
||||
|
||||
[FormerlySerializedAs("portraitsContainer")] public Transform avatarContainer;
|
||||
|
||||
[Header("Animation Settings")]
|
||||
[SerializeField] private float rearrangeAnimDuration = 0.4f; // 头像重新排列的动画时长
|
||||
|
||||
[FormerlySerializedAs("portraitWidth")]
|
||||
[Header("Layout Settings")]
|
||||
[SerializeField] private float portraitWidth = 133f; // 单个头像的宽度
|
||||
[SerializeField] private float portraitSpacing = 0f; // 头像之间的间距
|
||||
[SerializeField] private float avatarWidth = 133f; // 单个头像的宽度
|
||||
[FormerlySerializedAs("portraitSpacing")] [SerializeField] private float avatarSpacing = 0f; // 头像之间的间距
|
||||
|
||||
private List<CharacterBase> actionOrder => CombatMainManager.Instance.characterController.actionOrderList;
|
||||
public List<CharacterAvatar> avatars = new List<CharacterAvatar>();
|
||||
@@ -57,7 +59,7 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
LeanPool.Despawn(currentAvatar.gameObject);
|
||||
}).Play();
|
||||
|
||||
|
||||
// 播放重新排列动画
|
||||
RearrangePortraitsWithAnimation();
|
||||
}
|
||||
@@ -69,7 +71,7 @@ namespace Continentis.MainGame.UI
|
||||
// 核心函数:创建单个头像UI
|
||||
private CharacterAvatar CreatePortraitUI(CharacterBase character, int index)
|
||||
{
|
||||
CharacterAvatar avatar = LeanPool.Spawn(portraitPrefab, portraitsContainer).GetComponent<CharacterAvatar>();
|
||||
CharacterAvatar avatar = LeanPool.Spawn(portraitPrefab, avatarContainer).GetComponent<CharacterAvatar>();
|
||||
avatar.Initialize(character);
|
||||
avatar.GetComponent<RectTransform>().anchoredPosition = new Vector2(-900, 0);
|
||||
if (index >= 0 && index < avatars.Count)
|
||||
@@ -81,6 +83,7 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
avatars.Add(avatar);
|
||||
}
|
||||
|
||||
return avatar;
|
||||
}
|
||||
|
||||
@@ -89,7 +92,7 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
for (int i = 0; i < avatars.Count; i++)
|
||||
{
|
||||
float targetX = -110 - i * (portraitWidth + portraitSpacing);
|
||||
float targetX = -110 - i * (avatarWidth + avatarSpacing);
|
||||
avatars[i].GetComponent<RectTransform>().anchoredPosition = new Vector2(targetX, 0);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +105,7 @@ namespace Continentis.MainGame.UI
|
||||
for (int i = 0; i < avatars.Count; i++)
|
||||
{
|
||||
// 计算每个头像的目标X坐标
|
||||
float targetX = -110 - i * (portraitWidth + portraitSpacing);
|
||||
float targetX = -110 - i * (avatarWidth + avatarSpacing);
|
||||
RectTransform rt = avatars[i].GetComponent<RectTransform>();
|
||||
|
||||
// 将移动动画加入到序列中
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
using Continentis.MainGame.Card;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Continentis.MainGame.UI
|
||||
{
|
||||
public class DiscardPile : PileBase
|
||||
public class DiscardPile : PileBase, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
string title = "Discard Pile";
|
||||
string description = $"When you discard cards, they go here. Currently, it has {cardViews.Count} cards.\n" +
|
||||
$"If the draw pile is empty, the discard pile will be shuffled to form a new draw pile.";
|
||||
RectTransform canvasTransform = CombatUIManager.Instance.combatMainPage.rectTransform;
|
||||
Vector2 basePosition = canvasTransform.InverseTransformPoint(rectTransform.position);
|
||||
InformationBox.Create(canvasTransform, ref infoBox).Initialize(title, description, basePosition);
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
InformationBox.Despawn(ref infoBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
using Continentis.MainGame.Card;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Continentis.MainGame.UI
|
||||
{
|
||||
public class DrawPile : PileBase
|
||||
public class DrawPile : PileBase, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
string title = "Draw Pile";
|
||||
string description = $"Contains the cards you can draw during your turn, now it have {cardViews.Count} cards.";
|
||||
RectTransform canvasTransform = CombatUIManager.Instance.combatMainPage.rectTransform;
|
||||
Vector2 basePosition = canvasTransform.InverseTransformPoint(rectTransform.position);
|
||||
InformationBox.Create(canvasTransform, ref infoBox).Initialize(title, description, basePosition);
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
InformationBox.Despawn(ref infoBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,23 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Continentis.MainGame.UI
|
||||
{
|
||||
public class ExhaustPile : PileBase
|
||||
public class ExhaustPile : PileBase, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
string title = "Exhaust Pile";
|
||||
string description = $"When you exhaust cards, they go here. Currently, it has {cardViews.Count} cards.\n" +
|
||||
$"Exhausted cards are usually removed from play for the rest of the combat.";
|
||||
RectTransform canvasTransform = CombatUIManager.Instance.combatMainPage.rectTransform;
|
||||
Vector2 basePosition = canvasTransform.InverseTransformPoint(rectTransform.position);
|
||||
InformationBox.Create(canvasTransform, ref infoBox).Initialize(title, description, basePosition);
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
InformationBox.Despawn(ref infoBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +83,11 @@ namespace Continentis.MainGame.UI
|
||||
targetPos.y = 0;
|
||||
|
||||
cardRect.localPosition =
|
||||
Vector3.Lerp(cardRect.localPosition, targetPos + new Vector3(0, 150f, 0), Time.deltaTime * 20f);
|
||||
Vector3.Lerp(cardRect.localPosition, targetPos + new Vector3(0, 100f, 0), Time.deltaTime * 20f);
|
||||
cardRect.localRotation =
|
||||
Quaternion.Lerp(cardRect.localRotation, Quaternion.identity, Time.deltaTime * 20f);
|
||||
cardRect.localScale =
|
||||
Vector3.Lerp(cardRect.localScale, Vector3.one * 1.2f, Time.deltaTime * 20f);
|
||||
Vector3.Lerp(cardRect.localScale, Vector3.one, Time.deltaTime * 20f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -10,7 +10,14 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
public List<CardViewBase> cardViews;
|
||||
public TMP_Text cardCountText;
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
cardViews = new List<CardViewBase>();
|
||||
UpdateCountText();
|
||||
}
|
||||
|
||||
public virtual void AddCard(CardViewBase cardObject)
|
||||
{
|
||||
cardViews.Add(cardObject);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Continentis.MainGame.UI
|
||||
}));
|
||||
|
||||
seq.AppendInterval(0.1f);
|
||||
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(150f, 0.2f));
|
||||
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(80f, 0.2f));
|
||||
seq.Play();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Continentis.MainGame.UI
|
||||
playerHero.deckSubmodule.SetUpHandCardViews();
|
||||
}));
|
||||
seq.AppendInterval(0.1f);
|
||||
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(150f, 0.2f));
|
||||
seq.Append(CombatUIManager.Instance.combatMainPage.handPile.rectTransform.DOAnchorPosY(80f, 0.2f));
|
||||
seq.Play();
|
||||
}
|
||||
else
|
||||
@@ -81,6 +81,9 @@ namespace Continentis.MainGame.UI
|
||||
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}");
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@ namespace Continentis.MainGame
|
||||
if (hit.collider.gameObject.CompareTag("Character"))
|
||||
{
|
||||
hoveringCharacterView ??= hit.collider.GetComponent<CombatCharacterViewBase>();
|
||||
|
||||
hoveringCharacterView.SetOutline(true);
|
||||
|
||||
if (Mouse.current.leftButton.wasPressedThisFrame)
|
||||
{
|
||||
if (hoveringCharacterView == selectingCharacterView)
|
||||
@@ -88,6 +89,7 @@ namespace Continentis.MainGame
|
||||
}
|
||||
else
|
||||
{
|
||||
hoveringCharacterView?.SetOutline(false);
|
||||
hoveringCharacterView = null;
|
||||
|
||||
if (Mouse.current.leftButton.wasPressedThisFrame)
|
||||
|
||||
@@ -6,18 +6,36 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
public class CharacterAvatar : MonoBehaviour
|
||||
{
|
||||
public CharacterBase character;
|
||||
public Image characterImage;
|
||||
public Image frame;
|
||||
|
||||
public Sprite normalFrame;
|
||||
public Sprite actionFrame;
|
||||
|
||||
public void Initialize(CharacterBase character)
|
||||
{
|
||||
this.character = character;
|
||||
characterImage.sprite = character.data.avatar;
|
||||
normalFrame = MainGameManager.Instance.basePrefabs.fractionFrames[character.fraction][0];
|
||||
actionFrame = MainGameManager.Instance.basePrefabs.fractionFrames[character.fraction][1];
|
||||
frame.sprite = normalFrame;
|
||||
frame.color = MainGameManager.Instance.basePrefabs.fractionColors[character.fraction];
|
||||
frame.material = Instantiate(frame.material);
|
||||
Highlight(false);
|
||||
}
|
||||
|
||||
public void Highlight(bool isHighlighted)
|
||||
{
|
||||
Debug.Log($"Highlighting {character.data.displayName}: {isHighlighted}");
|
||||
|
||||
if (isHighlighted)
|
||||
{
|
||||
frame.material.SetFloat("_SineGlowFade", 1);
|
||||
frame.material.SetColor("_SineGlowColor", frame.color * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.material.SetFloat("_SineGlowFade", 0);
|
||||
frame.material.SetColor("_SineGlowColor", Color.white);
|
||||
}
|
||||
|
||||
Mask mask = CombatUIManager.Instance.combatMainPage.actionOrderDisplayer.avatarContainer.GetComponent<Mask>();
|
||||
MaskUtilities.NotifyStencilStateChanged(mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Lean.Pool;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -10,8 +11,24 @@ namespace Continentis.MainGame.UI
|
||||
public Image titleBackground, contentBackground;
|
||||
public TMP_Text titleText, contentText;
|
||||
|
||||
public static InformationBox Create(RectTransform parent, ref InformationBox exclusivity)
|
||||
{
|
||||
GameObject infoBoxPrefab = MainGameManager.Instance.basePrefabs.informationBox;
|
||||
exclusivity ??= LeanPool.Spawn(infoBoxPrefab, parent).GetComponent<InformationBox>();
|
||||
return exclusivity;
|
||||
}
|
||||
|
||||
public static void Despawn(ref InformationBox infoBox)
|
||||
{
|
||||
if (infoBox != null)
|
||||
{
|
||||
LeanPool.Despawn(infoBox.gameObject);
|
||||
infoBox = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卡牌的关键词和描述
|
||||
/// 处于LayoutGroup中时的初始化
|
||||
/// </summary>
|
||||
public void Initialize(string title, string content)
|
||||
{
|
||||
@@ -21,7 +38,7 @@ namespace Continentis.MainGame.UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Buff的名称和描述
|
||||
/// 非LayoutGroup中时的初始化
|
||||
/// </summary>
|
||||
public void Initialize(string title, string content, Vector2 basePosition)
|
||||
{
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace Continentis.MainGame.UI
|
||||
public Image icon;
|
||||
public List<TMP_Text> textList;
|
||||
public TMP_Text iconText => textList[0];
|
||||
|
||||
public InformationBox infoBox;
|
||||
|
||||
public virtual void UpdateIcon()
|
||||
{
|
||||
|
||||
@@ -95,14 +95,6 @@ namespace Continentis.MainGame.UI
|
||||
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
GameObject infoBoxPrefab = MainGameManager.Instance.basePrefabs.informationBox;
|
||||
RectTransform canvasTransform = CombatUIManager.Instance.hudPage.rectTransform;
|
||||
|
||||
if (infoBox == null)
|
||||
{
|
||||
infoBox = LeanPool.Spawn(infoBoxPrefab, canvasTransform).GetComponent<InformationBox>();
|
||||
}
|
||||
|
||||
BuffTextInterpreter.InterpretText(buff);
|
||||
string dispelThreshold = buff.dispelThreshold switch
|
||||
{
|
||||
@@ -115,16 +107,14 @@ namespace Continentis.MainGame.UI
|
||||
dispelThreshold = dispelThreshold.Localize();
|
||||
|
||||
string finalDescription = buff.contentSubmodule.interpretedFunctionText + "\n" + dispelThreshold;
|
||||
Vector2 basePosition = canvasTransform.InverseTransformPoint(rectTransform.position);
|
||||
infoBox.Initialize(buff.contentSubmodule.displayName, finalDescription, basePosition);
|
||||
|
||||
Debug.Log("Pointer Enter Buff Icon");
|
||||
RectTransform canvasTransform = CombatUIManager.Instance.hudPage.rectTransform;
|
||||
Vector2 basePosition = canvasTransform.InverseTransformPoint(rectTransform.position);
|
||||
InformationBox.Create(canvasTransform, ref infoBox).Initialize(buff.contentSubmodule.displayName, finalDescription, basePosition);
|
||||
}
|
||||
|
||||
public override void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("Pointer Exit Buff Icon");
|
||||
|
||||
if (infoBox != null)
|
||||
{
|
||||
LeanPool.Despawn(infoBox.gameObject);
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace Continentis.MainGame.UI
|
||||
public EquipmentBase equipment;
|
||||
public Image background;
|
||||
public Image icon;
|
||||
private InformationBox infoBox;
|
||||
|
||||
public void Initialize(EquipmentBase equipment = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user