角色死亡
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
|
||||
38
Assets/Scripts/MainGame/UI/CombatMainPage/RoundHint.cs
Normal file
38
Assets/Scripts/MainGame/UI/CombatMainPage/RoundHint.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68138f41a2b8c2644ab4773a6db99b54
|
||||
@@ -5,6 +5,11 @@ namespace SLSFramework.General
|
||||
{
|
||||
public static class StringExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 本地化字符串,不使用参数替换
|
||||
/// </summary>
|
||||
/// <param name="original">原始字符串</param>
|
||||
/// <returns></returns>
|
||||
public static string Localize(this string original)
|
||||
{
|
||||
if (LocalizationManager.TryGetTranslation(original, out string translated))
|
||||
@@ -14,5 +19,26 @@ namespace SLSFramework.General
|
||||
|
||||
return original;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地化字符串,使用指定的根GameObject进行i2Loc参数替换
|
||||
/// </summary>
|
||||
/// <param name="original">原始字符串</param>
|
||||
/// <param name="rootGameObject">用于参数替换,含有LocalizationParamsManager的根GameObject,设为null则表明使用全局参数</param>
|
||||
/// <returns></returns>
|
||||
public static string Localize(this string original, GameObject rootGameObject)
|
||||
{
|
||||
if (rootGameObject != null && rootGameObject.GetComponent<LocalizationParamsManager>() == null)
|
||||
{
|
||||
throw new System.ArgumentException("The provided rootGameObject does not contain a LocalizationParamsManager component.");
|
||||
}
|
||||
|
||||
if (LocalizationManager.TryGetTranslation(original, out string translated, true, 0, true, true, rootGameObject))
|
||||
{
|
||||
return translated;
|
||||
}
|
||||
|
||||
return original;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user