83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using Invector;
|
|
using Invector.vCharacterController;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
[RequireComponent(typeof(vIHealthController))]
|
|
[RequireComponent(typeof(QuestObject))]
|
|
public class RestorationAnimator : HealAnimatorBase
|
|
{
|
|
private float m_threshold;
|
|
public static int ThresholdID = Shader.PropertyToID("_Threshold");
|
|
public bool blendhapeStartMax;
|
|
private SkinnedMeshRenderer m_smr;
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
m_threshold = m_material.GetFloat(ThresholdID);
|
|
m_smr = m_renderer as SkinnedMeshRenderer;
|
|
if (blendhapeStartMax && m_smr)
|
|
{
|
|
m_smr.SetBlendShapeWeight(0,100f);
|
|
}
|
|
}
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
}
|
|
|
|
private IEnumerator HealCoroutine(bool heal)
|
|
{
|
|
float timer = 0f;
|
|
for (timer =0f; timer<m_healTime; timer+=Time.deltaTime)
|
|
{
|
|
var a = timer / m_healTime;
|
|
if (!heal)
|
|
a = 1f - a;
|
|
m_material.SetFloat(ThresholdID, a);
|
|
if (m_smr != null)
|
|
{
|
|
a = blendhapeStartMax ? (1.0f - a) : a;
|
|
a *= 100f;
|
|
m_smr.SetBlendShapeWeight(0, a);
|
|
}
|
|
|
|
yield return null;
|
|
}
|
|
|
|
yield return null;
|
|
}
|
|
|
|
[Button]
|
|
public override void Heal()
|
|
{
|
|
base.Heal();
|
|
StartCoroutine(HealCoroutine(true));
|
|
/*
|
|
m_material.DOFloat(1f, ThresholdID, m_healTime);
|
|
var smr = m_renderer as SkinnedMeshRenderer;
|
|
if (smr)
|
|
{
|
|
smr.SetBlendShapeWeight();
|
|
}
|
|
*/
|
|
}
|
|
|
|
[Button]
|
|
public void Unheal()
|
|
{
|
|
base.Unheal();
|
|
StartCoroutine(HealCoroutine(false));
|
|
|
|
//m_material.DOFloat(m_threshold, ThresholdID, m_healTime);
|
|
}
|
|
|
|
}
|
|
}
|