12.10 进度 基本完成
This commit is contained in:
@@ -127,8 +127,7 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
GameObject prefab = data.combatCharacterView;
|
||||
CombatCharacterViewBase characterView = Object.Instantiate(prefab, position, Quaternion.identity).GetComponent<CombatCharacterViewBase>();
|
||||
characterView.InitializeAnimations();
|
||||
characterView.character = this;
|
||||
characterView.Initialize(this);
|
||||
this.characterView = characterView;
|
||||
return characterView;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Continentis.MainGame.Character
|
||||
[Header("View")]
|
||||
public int combatPositionOrder;
|
||||
public GameObject combatCharacterView;
|
||||
public SerializableDictionary<string, AnimationClip> animations;
|
||||
|
||||
[Header("References")]
|
||||
public List<string> prefabRefs = new List<string>();
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Continentis.MainGame.Character
|
||||
eventSubmodule.onFinishAttack.Invoke(target, attackResult);
|
||||
combatBuffSubmodule.buffList.For(buff =>
|
||||
{
|
||||
buff?.eventSubmodule.onDealAttack.Invoke(attackResult);
|
||||
buff.eventSubmodule?.onDealAttack.Invoke(attackResult);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AnimatorPlus;
|
||||
using Continentis.MainGame.UI;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.MainGame.Character
|
||||
{
|
||||
public class CombatCharacterViewBase : MonoBehaviour
|
||||
public partial class CombatCharacterViewBase : MonoBehaviour
|
||||
{
|
||||
public CharacterBase character;
|
||||
|
||||
|
||||
public GameObject mainView;
|
||||
public Animator animator;
|
||||
public Dictionary<string, AnimationClip> animationClips;
|
||||
public AnimatorPlus2D animatorPlus2D;
|
||||
public SerializableDictionary<string, AnimationClip> animations;
|
||||
|
||||
public Collider selector;
|
||||
|
||||
@@ -21,19 +24,54 @@ namespace Continentis.MainGame.Character
|
||||
public Transform centerPoint => hudPivot;
|
||||
public HUDContainer hudContainer;
|
||||
|
||||
public void InitializeAnimations()
|
||||
public List<SpriteRenderer> spriteRenderers;
|
||||
public List<Material> materials;
|
||||
|
||||
public void Initialize(CharacterBase character)
|
||||
{
|
||||
animationClips = new Dictionary<string, AnimationClip>();
|
||||
this.character = character;
|
||||
|
||||
if (animator == null || animator.runtimeAnimatorController == null)
|
||||
spriteRenderers = new List<SpriteRenderer>(mainView.GetComponentsInChildren<SpriteRenderer>());
|
||||
materials = new List<Material>();
|
||||
foreach (SpriteRenderer sr in spriteRenderers)
|
||||
{
|
||||
Debug.LogWarning("Animator or RuntimeAnimatorController is null.");
|
||||
return;
|
||||
materials.Add(sr.material);
|
||||
}
|
||||
SetOutline(false);
|
||||
|
||||
animations = new SerializableDictionary<string, AnimationClip>();
|
||||
|
||||
foreach (KeyValuePair<string, AnimationClip> anim in character.data.animations)
|
||||
{
|
||||
animations.Add(anim.Key, anim.Value);
|
||||
}
|
||||
|
||||
foreach (AnimationClip clip in animator.runtimeAnimatorController.animationClips)
|
||||
if (animations.TryGetValue("Idle", out AnimationClip idle))
|
||||
{
|
||||
animationClips.TryAdd(clip.name, clip);
|
||||
animatorPlus2D.defaultIdleClip = idle;
|
||||
animatorPlus2D.Initialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"No Idle animation found for character {character.data.displayName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CombatCharacterViewBase
|
||||
{
|
||||
public void SetOutline(bool isEnabled)
|
||||
{
|
||||
if (isEnabled)
|
||||
{
|
||||
Color fractionColor = MainGameManager.Instance.basePrefabs.fractionColors[character.fraction];
|
||||
materials.ForEach(material => material.SetFloat("_InnerOutlineFade", 1));
|
||||
materials.ForEach(material => material.SetColor("_InnerOutlineColor", fractionColor * 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
materials.ForEach(material => material.SetFloat("_InnerOutlineFade", 0));
|
||||
materials.ForEach(material => material.SetColor("_InnerOutlineColor", Color.white));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace Continentis.MainGame.Character
|
||||
// View
|
||||
private SerializedProperty _combatPositionOrderProp;
|
||||
private SerializedProperty _combatCharacterViewProp;
|
||||
private SerializedProperty _animationsProp;
|
||||
|
||||
// Deck & References
|
||||
private SerializedProperty _initialDeckRefsProp;
|
||||
@@ -58,6 +59,7 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
_combatPositionOrderProp = serializedObject.FindProperty("combatPositionOrder");
|
||||
_combatCharacterViewProp = serializedObject.FindProperty("combatCharacterView");
|
||||
_animationsProp = serializedObject.FindProperty("animations");
|
||||
|
||||
_initialDeckRefsProp = serializedObject.FindProperty("initialDeckRef");
|
||||
_prefabRefsProp = serializedObject.FindProperty("prefabRefs");
|
||||
@@ -100,6 +102,7 @@ namespace Continentis.MainGame.Character
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.PropertyField(_combatPositionOrderProp);
|
||||
EditorGUILayout.PropertyField(_combatCharacterViewProp);
|
||||
EditorGUILayout.PropertyField(_animationsProp, true);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("References", EditorStyles.boldLabel);
|
||||
|
||||
Reference in New Issue
Block a user