Ver.0.3.0.33
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class AnimatorScenePart : AbsScenePart
|
||||
{
|
||||
private Animator _animator;
|
||||
|
||||
public override void Init(TimesOfDay timesOfDay, Weather weather = Weather.Sunny)
|
||||
{
|
||||
_animator = GetComponent<Animator>();
|
||||
|
||||
curWeather = weather;
|
||||
OnTimeChange(timesOfDay);
|
||||
}
|
||||
|
||||
public override void OnTimeChange(TimesOfDay time)
|
||||
{
|
||||
curTime = time;
|
||||
ResetTriggers();
|
||||
_animator.SetTrigger(time.ToString());
|
||||
}
|
||||
|
||||
public override void OnWeatherChange(Weather weather)
|
||||
{
|
||||
curWeather = weather;
|
||||
ResetTriggers();
|
||||
_animator.SetTrigger(weather.ToString());
|
||||
}
|
||||
|
||||
private void ResetTriggers()
|
||||
{
|
||||
foreach (var timeStr in Enum.GetNames(typeof(TimesOfDay)))
|
||||
{
|
||||
_animator.ResetTrigger(timeStr);
|
||||
}
|
||||
|
||||
foreach (var weatherStr in Enum.GetNames(typeof(Weather)))
|
||||
{
|
||||
_animator.ResetTrigger(weatherStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user