12.10 进度 基本完成
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user