//ステートが変更された時にTriggerの遷移条件と一致するかcheck private void StateCheck() { foreach (var trigger in triggers) { if (trigger.invokeState == state) { if (trigger.lazyTime == 0) { anime.SetAnime(trigger.animeKey); return; } lazyCounter = 0; CurrentTrigger = trigger; return; } } if (defaultTrigger != null) { state = defaultTrigger.invokeState; if (defaultTrigger.lazyTime == 0) { anime.SetAnime(defaultTrigger.animeKey); return; } lazyCounter = 0; CurrentTrigger = defaultTrigger; return; } CurrentTrigger = null; }
//再利用できるように初期化 public AnimeData Reset() { state = defaultTrigger?.invokeState; lazyCounter = 0; CurrentTrigger = null; StateCheck(); return(this); }
public AnimeData(Anime anime, ITexture[] texes , AnimeTrigger[] triggers = null, int?defaultState = null) { this.texes = texes; this.triggers = triggers; this.anime = anime; if (defaultState != null) { defaultTrigger = triggers.First(x => x.invokeState == defaultState); state = defaultTrigger.invokeState; } }