private void Start() { _TalkEventSystem = TalkEventSystem.Instance; _ProcesserDictionary = new Dictionary <BehaviourSwitchData, EnemyProcesser> (); var orderedSwitchData = _SwitchData.OrderByDescending(data => { return(data.HPRatio); }); var enemy = GetComponent <Enemy> (); _CurrentProcesser = new EnemyProcesser(enemy, _FirstProcessData); foreach (var s in orderedSwitchData.Take(orderedSwitchData.Count() - 1)) { //ラムダキャプチャ対策 var switchData = s; enemy.Life .Where(life => ((float)life / (float)enemy.MaxLife) < switchData.HPRatio) .First() .Subscribe(_ => { _CurrentProcesser = _ProcesserDictionary[switchData]; if (switchData.Escape.IsEscape) { enemy.StartCoroutine(_EscapeTimer(enemy, switchData)); } }); _ProcesserDictionary.Add(switchData, new EnemyProcesser(enemy, switchData.Data)); } var lastSwitchData = orderedSwitchData.Last(); //死亡時の処理 enemy.Life .Where(life => (float)life / (float)enemy.MaxLife < lastSwitchData.HPRatio) .First() .Subscribe(life => { if (life > 0) { UIManager.Score.AddScore(GetComponent <Enemy> ().Score); } _CurrentProcesser = _ProcesserDictionary[lastSwitchData]; if (lastSwitchData.Escape.IsEscape) { enemy.StartCoroutine(_EscapeTimer(enemy, lastSwitchData)); } foreach (var c in transform.root.GetComponentsInChildren <AnimatorSpeedController> (true)) { c.ControllStop(); } //_TalkEventSystem.TalkStart (_EventData.Message); アニメーションからにした }); _ProcesserDictionary.Add(lastSwitchData, new EnemyProcesser(enemy, lastSwitchData.Data)); this.UpdateAsObservable() .TakeUntil(enemy.Life.Where(life => life < 0)) .Subscribe(_ => _CurrentProcesser.Update()); }
private void Start() { var enemy = GetComponent <Enemy> (); var processer = new EnemyProcesser(enemy, _Data); this.UpdateAsObservable() .TakeUntil(enemy.LifeAsObservable().Where(life => life <= 0)) .Subscribe(_ => processer.Update()); #region Hidden /* _ManagerList = new List<IProcesserManager> (); * * //_ManagerList.Add (new _EnemyProcesserManager (enemy, _Data.ActionData)); * * for (int i = 0; i < _Data.EnemyActionData.Count(); i++) * { * var data = _Data.EnemyActionData.ElementAt (i); * var manager = new EnemyProcesserManager (enemy, _Data.EnemyActionData.Skip (i).Take (1).Select (_data => _data.ActionData)); * _ManagerList.Add (manager); * if(data.LoopIndex.LoopCount != 0) * { * if (data.LoopIndex.InfinitLoop) * { * var infManager = new InfinitLoopEnemyProcesserManager (enemy, _Data.EnemyActionData * .Skip ((int)data.LoopIndex.LoopStartIndex) * .Take (1 + (int)(data.LoopIndex.LoopEndIndex - data.LoopIndex.LoopStartIndex)) * .Select (_data => _data.ActionData)); * _ManagerList.Add (infManager); * break; * } * var repManager = new RepeateEnemyProcesserManager ((int)data.LoopIndex.LoopCount, enemy, _Data.EnemyActionData * .Skip ((int)data.LoopIndex.LoopStartIndex) * .Take (1 + (int)(data.LoopIndex.LoopEndIndex - data.LoopIndex.LoopStartIndex)) * .Select (_data => _data.ActionData)); * _ManagerList.Add (repManager); * continue; * } * } * /*LoopIndex loopData; * * if (_Data.LoopIndex.Count () != 0) * { * for (int i = 0; i < _Data.LoopIndex.Count (); i++) * { * loopData = _Data.LoopIndex.ElementAt (i); * if (loopData.InfinitLoop) * { * _ManagerList.Add (new _InfinitLoopEnemyProcesserManager (enemy, _Data.ActionData * .Skip ((int)loopData.LoopStartIndex) * .Take (1+(int)(loopData.LoopEndIndex - loopData.LoopStartIndex)))); * break; * } * _ManagerList.Add (new _RepeateEnemyProcesserManager ((int)loopData.LoopCount-1, enemy, _Data.ActionData * .Skip ((int)loopData.LoopStartIndex) * .Take (1+(int)(loopData.LoopEndIndex - loopData.LoopStartIndex)))); * } * }*/ /* _Manager = _ManagerList.GetEnumerator (); * _Manager.MoveNext (); * _OnComlete (); * this.UpdateAsObservable () * .TakeUntil(enemy.LifeAsObservable().Where(life => life <= 0)) * .Subscribe (_ => * { * _Manager.Current.Update (); * });*/ #endregion Hidden }