角色死亡

This commit is contained in:
SoulliesOfficial
2025-12-12 01:37:30 -05:00
parent b54c5f796b
commit 40660b41e0
19 changed files with 1147 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Card;
using Continentis.MainGame.Combat;
using Lean.Pool;
using NaughtyAttributes;
using SLSFramework.UModAssistance;
using UnityEngine;
@@ -131,5 +132,10 @@ namespace Continentis.MainGame.Character
this.characterView = characterView;
return characterView;
}
public virtual void Die()
{
CombatMainManager.Instance.characterController.RemoveCharacter(this);
}
}
}

View File

@@ -226,6 +226,11 @@ namespace Continentis.MainGame.Character
{
ModifyAttribute("Health", -damage);
MainGameManager.Instance.basePrefabs.GenerateHurtText(damage, characterView);
if (GetAttribute("Health") <= 0)
{
Die();
}
}
public void Heal(int heal)

View File

@@ -1,11 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Character;
using Lean.Pool;
using SLSFramework.UModAssistance;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Continentis.MainGame.Combat
{
[Serializable]
public partial class CombatCharacterController
{
[Header("References")]
@@ -100,30 +104,42 @@ namespace Continentis.MainGame.Combat
public void SetViewPositions()
{
float playerSideLeftBound = -7f;
float playerSideRightBound = -1f;
float playerSideLeftBound = -7.5f;
float playerSideRightBound = -1.5f;
float playerBaseInterval = 2f;
if (playerHeroes.Count > 4)
{
playerBaseInterval = (playerSideRightBound - playerSideLeftBound) / (playerHeroes.Count - 1);
}
playerHeroes.Sort((x, y) => x.data.combatPositionOrder.CompareTo(y.data.combatPositionOrder));
for (int index = 0; index < playerHeroes.Count; index++)
{
float xPos = playerHeroes.Count > 1
? Mathf.Lerp(playerSideLeftBound, playerSideRightBound, (float)index / (playerHeroes.Count - 1))
: (playerSideLeftBound + playerSideRightBound) / 2;
float xPos = playerSideLeftBound + index * playerBaseInterval;
Vector3 position = new Vector3(xPos, -1, 0);
playerHeroes[index].characterView.transform.position = position;
}
float enemySideLeftBound = 1f;
float enemySideRightBound = 7f;
float enemySideLeftBound = 1.5f;
float enemySideRightBound = 7.5f;
float enemyBaseInterval = 2f;
if (enemies.Count > 4)
{
enemyBaseInterval = (enemySideRightBound - enemySideLeftBound) / (enemies.Count - 1);
}
enemies.Sort((x, y) => y.data.combatPositionOrder.CompareTo(x.data.combatPositionOrder));
for (int index = 0; index < enemies.Count; index++)
{
float xPos = enemies.Count > 1
? Mathf.Lerp(enemySideLeftBound, enemySideRightBound, (float)index / (enemies.Count - 1))
: (enemySideLeftBound + enemySideRightBound) / 2;
float xPos = enemySideLeftBound + index * enemyBaseInterval;
Vector3 position = new Vector3(xPos, -1, 0);
enemies[index].characterView.transform.position = position;
}
Debug.Log($"Enemy are sorted: {string.Join(", ", enemies.Select(e => e.data.displayName))}");
}
public void SetViewHUDs()
@@ -170,6 +186,31 @@ namespace Continentis.MainGame.Combat
}
}
public partial class CombatCharacterController
{
public void RemoveCharacter(CharacterBase character)
{
characters.Remove(character);
actionOrderList.Remove(character);
combatCharacterViews.Remove(character.characterView);
if (character is PlayerHero playerHero)
{
playerHeroes.Remove(playerHero);
}
else if (character is CombatNPC npc)
{
npcs[character.fraction].Remove(npc);
}
Object.Destroy(character.characterView.hudContainer.gameObject);
Object.Destroy(character.characterView.gameObject);
SetViewPositions();
SetViewHUDs();
}
}
public partial class CombatCharacterController
{
public List<CharacterBase> GetAllAllies(CharacterBase character, bool includeSelf = false)

View File

@@ -88,6 +88,9 @@ namespace Continentis.MainGame.Combat
public void NextRound()
{
currentRound++;
CombatUIManager.Instance.combatMainPage.roundHint.PlayRoundHint(currentRound);
eventCollection.onRoundStart.Invoke();
foreach (CharacterBase character in characterController.characters)
{

View File

@@ -19,6 +19,7 @@ namespace Continentis.MainGame.UI
public CustomCardSelectionInterface customCardSelector;
public CombatResourcesDisplayer combatResourcesDisplayer;
public ActionOrderDisplayer actionOrderDisplayer;
public RoundHint roundHint;
public Button endActionButton;
protected override void Awake()

View File

@@ -0,0 +1,38 @@
using DG.Tweening;
using I2.Loc;
using SLSFramework.General;
using TMPro;
using UnityEngine;
namespace Continentis.MainGame.UI
{
public class RoundHint : MonoBehaviour
{
public TMP_Text hintText;
public LocalizationParamsManager locParams;
private Sequence textAnimationSeq;
public void PlayRoundHint(int round)
{
gameObject.SetActive(true);
locParams.SetParameterValue("Round", round.ToString());
hintText.text = "GameUI/Round_Hint".Localize(hintText.gameObject);
Material textMat = hintText.fontMaterial;
float fadeInDuration = 1f;
float holdDuration = 1f;
float fadeOutDuration = 0.5f;
textAnimationSeq?.Kill();
textAnimationSeq = DOTween.Sequence();
textAnimationSeq.Append(textMat.DOFloat(1f, "_FullGlowDissolveFade", fadeInDuration).From(0f));
textAnimationSeq.AppendInterval(holdDuration);
textAnimationSeq.Append(textMat.DOFloat(0f, "_FullDistortionFade", fadeOutDuration).From(1f));
textAnimationSeq.OnComplete(() => { gameObject.SetActive(false); });
textAnimationSeq.Play();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 68138f41a2b8c2644ab4773a6db99b54