继续搞点新机制
This commit is contained in:
@@ -29,8 +29,8 @@ namespace Continentis.MainGame
|
||||
public GameObject intentionCardObject;
|
||||
public GameObject inspectionCardObject;
|
||||
public SerializableDictionary<string, CardViewCollection> cardViewCollections;
|
||||
|
||||
[Header("GeneralUI")]
|
||||
|
||||
[Header("GeneralUI")] public GameObject customImage;
|
||||
public GameObject informationBox;
|
||||
public SerializableDictionary<Fraction, List<Sprite>> fractionFrames;
|
||||
public SerializableDictionary<Rarity, Color> rarityColors;
|
||||
|
||||
35
Assets/Scripts/MainGame/Base/GameElement.cs
Normal file
35
Assets/Scripts/MainGame/Base/GameElement.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.MainGame
|
||||
{
|
||||
public interface IGameElement
|
||||
{
|
||||
public static readonly Dictionary<Guid, IGameElement> Instances = new Dictionary<Guid, IGameElement>();
|
||||
|
||||
public Guid elementID { get; set; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
elementID = Guid.NewGuid();
|
||||
|
||||
if (!Instances.ContainsKey(this.elementID))
|
||||
{
|
||||
Instances.Add(this.elementID, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"GameElement with ID {this.elementID} is already registered.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Unregister()
|
||||
{
|
||||
if (Instances.ContainsKey(this.elementID))
|
||||
{
|
||||
Instances.Remove(this.elementID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/MainGame/Base/GameElement.cs.meta
Normal file
2
Assets/Scripts/MainGame/Base/GameElement.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7cc23cb9dea5f94187db2e14ce646af
|
||||
@@ -10,7 +10,7 @@ namespace Continentis.MainGame
|
||||
{
|
||||
Basic = 0, //弱驱散
|
||||
Strong = 10, //强驱散
|
||||
Immune = 20, //不可驱散(死亡除外)
|
||||
DeathOnly = 20, //不可驱散(死亡除外)
|
||||
Undispellable = 100 //不可驱散(包括死亡)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace Continentis.MainGame
|
||||
}
|
||||
|
||||
public abstract partial class BuffBase<T> : IPrioritized
|
||||
{
|
||||
{
|
||||
public string identification;
|
||||
public BuffType buffType;
|
||||
public BuffDispelLevel dispelThreshold;
|
||||
public ContentSubmodule contentSubmodule;
|
||||
@@ -35,6 +36,11 @@ namespace Continentis.MainGame
|
||||
this.dispelThreshold = dispelThreshold;
|
||||
this.Priority = priority + (buffType == BuffType.Focusing ? 10000 : 0);
|
||||
}
|
||||
|
||||
protected void SetIdentification(string id)
|
||||
{
|
||||
this.identification = id;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class BuffBase<T>
|
||||
|
||||
@@ -126,6 +126,8 @@ namespace Continentis.MainGame
|
||||
public OrderedDictionary<string, EventUnit> onActionStart; //每次行动开始时
|
||||
public OrderedDictionary<string, EventUnit> onActionEnd; //每次行动结束时
|
||||
|
||||
public OrderedDictionary<string, EventUnit<CharacterBase, IntendedCard, CharacterBase>> onOpponentDecideAction; //对手AI决定行动时,参数为对手,和原定的目标角色
|
||||
|
||||
public OrderedDictionary<string, EventUnit<AttackResult>> onGetAttacked; //被攻击后,参数为伤害结果
|
||||
|
||||
public OrderedDictionary<string, EventUnit<CardInstance>> onDrawCard; //抽到卡牌时
|
||||
@@ -146,6 +148,7 @@ namespace Continentis.MainGame
|
||||
onActionEnd = new OrderedDictionary<string, EventUnit>();
|
||||
|
||||
onGetAttacked = new OrderedDictionary<string, EventUnit<AttackResult>>();
|
||||
onOpponentDecideAction = new OrderedDictionary<string, EventUnit<CharacterBase, IntendedCard, CharacterBase>>();
|
||||
|
||||
onDrawCard = new OrderedDictionary<string, EventUnit<CardInstance>>();
|
||||
onBeforePlayCard = new OrderedDictionary<string, EventUnit<CardInstance, List<CharacterBase>>>();
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Continentis.MainGame.Card
|
||||
/// 注意,此函数依赖ModManager的类型注册功能,请确保在Mod加载时已注册对应Buff类型
|
||||
/// 此函数中的T并不是原型参数,而是获取Mod中注册的类型用的
|
||||
/// </summary>
|
||||
protected CharacterCombatBuffBase CreateCharacterBuff<T>(params object[] parameters) where T :CharacterCombatBuffBase
|
||||
protected T CreateCharacterBuff<T>(params object[] parameters) where T :CharacterCombatBuffBase
|
||||
{
|
||||
string buffTypeID = ModManager.GetTypeID(typeof(T));
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace Continentis.MainGame.Card
|
||||
return null;
|
||||
}
|
||||
|
||||
return ModManager.CreateInstance<CharacterCombatBuffBase>(buffTypeID, parameters);
|
||||
return ModManager.CreateInstance<T>(buffTypeID, parameters);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Continentis.MainGame.Card;
|
||||
using Continentis.MainGame.Combat;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Continentis.MainGame.Character
|
||||
{
|
||||
@@ -20,8 +23,10 @@ namespace Continentis.MainGame.Character
|
||||
DeckSubmodule deckSubmodule { get; }
|
||||
}
|
||||
|
||||
public partial class CharacterBase : ICardOwner
|
||||
public partial class CharacterBase : ICardOwner, IGameElement
|
||||
{
|
||||
public Guid elementID { get; set; }
|
||||
|
||||
public CharacterData data;
|
||||
|
||||
public Fraction fraction;
|
||||
@@ -52,6 +57,8 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
public void Initialize(Fraction fraction)
|
||||
{
|
||||
(this as IGameElement).Initialize();
|
||||
|
||||
this.fraction = fraction;
|
||||
|
||||
switch (fraction)
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Continentis.MainGame.Character
|
||||
}
|
||||
else
|
||||
{
|
||||
existingBuff.iconSubmodule?.buffIcon.UpdateIcon();
|
||||
existingBuff.iconSubmodule?.Update();
|
||||
}
|
||||
|
||||
RefreshAttributes();
|
||||
|
||||
@@ -22,6 +22,11 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
return (T)buffList.Find(x => x.GetType() == typeof(T));
|
||||
}
|
||||
|
||||
public T GetBuff<T>(string identification) where T : CharacterCombatBuffBase
|
||||
{
|
||||
return (T)buffList.FindAll(x => x.GetType() == typeof(T)).Find(x => x.identification == identification);
|
||||
}
|
||||
|
||||
public bool HasBuff<T>() where T : CharacterCombatBuffBase
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
//中性状态
|
||||
Taunt = 2000, //嘲讽
|
||||
Protected = 2001, //被保护
|
||||
}
|
||||
|
||||
public partial class StatusSubmodule : SubmoduleBase<CharacterBase>
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Continentis.MainGame.UI
|
||||
public List<TMP_Text> textList;
|
||||
public TMP_Text iconText => textList[0];
|
||||
|
||||
protected InformationBox infoBox;
|
||||
public InformationBox infoBox;
|
||||
|
||||
public virtual void UpdateIcon()
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace Continentis.MainGame.UI
|
||||
public CharacterBuffBase buff;
|
||||
|
||||
public Image buffTypeBackground;
|
||||
public Image mainIcon;
|
||||
|
||||
public Sprite positive;
|
||||
public Sprite negative;
|
||||
@@ -38,12 +37,13 @@ namespace Continentis.MainGame.UI
|
||||
|
||||
public void PlayApplyAnimation()
|
||||
{
|
||||
Image spreadImage = LeanPool.Spawn(mainIcon.gameObject, rectTransform).GetComponent<Image>();
|
||||
Image spreadImage = LeanPool.Spawn(MainGameManager.Instance.basePrefabs.customImage, rectTransform).GetComponent<Image>();
|
||||
spreadImage.sprite = buff.iconSubmodule.icon;
|
||||
spreadImage.rectTransform.rect.Set(0, 0, rectTransform.rect.width, rectTransform.rect.height);
|
||||
spreadImage.rectTransform.localScale = Vector3.zero;
|
||||
spreadImage.color = Color.white;
|
||||
spreadImage.DOColor(new Color(1f, 1f, 1f, 0f), 1.1f).SetEase(Ease.Linear).Play();
|
||||
spreadImage.rectTransform.DOScale(5f, 1.2f).SetEase(Ease.OutQuad).OnComplete(() =>
|
||||
spreadImage.rectTransform.DOScale(4f, 1.2f).SetEase(Ease.OutQuad).OnComplete(() =>
|
||||
{
|
||||
LeanPool.Despawn(spreadImage.gameObject);
|
||||
}).Play();
|
||||
@@ -51,7 +51,7 @@ namespace Continentis.MainGame.UI
|
||||
|
||||
public void PlayHintAnimation()
|
||||
{
|
||||
mainIcon.rectTransform.DOScale(1.25f, 0.2f).SetLoops(2, LoopType.Yoyo).SetEase(Ease.OutQuad).Play();
|
||||
icon.rectTransform.DOScale(1.25f, 0.2f).SetLoops(2, LoopType.Yoyo).SetEase(Ease.OutQuad).Play();
|
||||
}
|
||||
|
||||
public override void UpdateIcon()
|
||||
@@ -101,7 +101,7 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
BuffDispelLevel.Basic => "Buff_DispelThreshold_Basic_Suffix",
|
||||
BuffDispelLevel.Strong => "Buff_DispelThreshold_Strong_Suffix",
|
||||
BuffDispelLevel.Immune => "Buff_DispelThreshold_Immune_Suffix",
|
||||
BuffDispelLevel.DeathOnly => "Buff_DispelThreshold_Immune_Suffix",
|
||||
BuffDispelLevel.Undispellable => "Buff_DispelThreshold_Undispellable_Suffix",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
@@ -109,10 +109,14 @@ namespace Continentis.MainGame.UI
|
||||
|
||||
string finalDescription = buff.contentSubmodule.interpretedFunctionText + "\n" + dispelThreshold;
|
||||
infoBox.Initialize(buff.contentSubmodule.displayName, finalDescription, canvasTransform.InverseTransformPoint(rectTransform.position));
|
||||
|
||||
Debug.Log("Pointer Enter Buff Icon");
|
||||
}
|
||||
|
||||
public override void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("Pointer Exit Buff Icon");
|
||||
|
||||
if (infoBox != null)
|
||||
{
|
||||
LeanPool.Despawn(infoBox.gameObject);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
@@ -55,5 +56,39 @@ namespace SLSFramework.General
|
||||
action.Invoke(arg1, arg2);
|
||||
}
|
||||
}
|
||||
|
||||
public class EventUnit<T1, T2, T3> : IPrioritized
|
||||
{
|
||||
private readonly UnityAction<T1, T2, T3> action;
|
||||
public int Priority { get; set; }
|
||||
|
||||
public EventUnit(UnityAction<T1, T2, T3> action, int priority = 0)
|
||||
{
|
||||
this.action = action;
|
||||
this.Priority = priority;
|
||||
}
|
||||
|
||||
public void Invoke(T1 arg1, T2 arg2, T3 arg3)
|
||||
{
|
||||
action.Invoke(arg1, arg2, arg3);
|
||||
}
|
||||
}
|
||||
|
||||
public class PrioritizedFunc<T1, T2, T3, TR> : IPrioritized
|
||||
{
|
||||
private readonly Func<T1, T2, T3, TR> func;
|
||||
public int Priority { get; set; }
|
||||
|
||||
public PrioritizedFunc(Func<T1, T2, T3, TR> func, int priority = 0)
|
||||
{
|
||||
this.func = func;
|
||||
this.Priority = priority;
|
||||
}
|
||||
|
||||
public TR Invoke(T1 arg1, T2 arg2, T3 arg3)
|
||||
{
|
||||
return func.Invoke(arg1, arg2, arg3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user