public static AsyncSubject <Unit> SkillByAi(AiSelectSkillResultSerializableData ai, BattlerSerializable fromBattler) { AsyncSubject <Unit> subject = new AsyncSubject <Unit>(); if (ai == null) { ObservableUtils.AsyncSubjectTimeZeroCompleted(subject); } else { var skill = SkillsDicionary.GetSkillById(ai.SkillId); if (SkillsDicionary.IsAll(skill)) { List <BattlerSerializable> toBattlers = new List <BattlerSerializable>(); ai.TargetUniqIds.ForEach(x => { toBattlers.Add(BattlerDictionary.GetBattlerByUniqId(x)); }); SkillToAll(ai.SkillId, fromBattler, toBattlers).Subscribe(_ => { subject.OnNext(Unit.Default); subject.OnCompleted(); }); } else { var uniqId = ai.TargetUniqIds.First(); var toBattler = BattlerDictionary.GetBattlerByUniqId(uniqId); var targetTransform = BattleDictionary.GetTransformByUniqId(uniqId); SkillToSingle(ai.SkillId, fromBattler, toBattler).Subscribe(_ => { subject.OnNext(Unit.Default); subject.OnCompleted(); }); } } return(subject); }
/// <summary> /// スキル選択時 /// </summary> private void SkillSelectSubscribe() { foreach (var(icon, index) in _skillsView.Icons.Select((icon, index) => (icon, index))) { var image = icon.Find("Image").GetComponent <Image>(); //マウスホバー時 _container.Add(image.OnMouseEnterAsObservable().Subscribe(_ => { var battler = BattlerDictionary.GetBattlerByUniqId(_battleModel.ActiveUniqId); var skill = SkillsDicionary.GetEquippedSkillByIndex(battler, index); if (skill != null) { _skillModel.HoverIndex = index; _skillsView.Refresh(_skillModel); _skillsView.ViewSkillDescription(skill.skillId, _battleModel.ActiveUniqId); } })); //マウスホバーアウト時 _container.Add(image.OnMouseExitAsObservable().Subscribe(_ => { _skillModel.HoverIndex = -1; _skillsView.Refresh(_skillModel); //_skillsView.CleanSkillDescription(); })); //クリック _container.Add(image.OnMouseUpAsButtonAsObservable().Subscribe(_ => { var battler = BattlerDictionary.GetBattlerByUniqId(_battleModel.ActiveUniqId); var skill = SkillsDicionary.GetEquippedSkillByIndex(battler, index); if (skill != null) { _skillModel.SkillId = skill.skillId; _skillModel.ActiveIndex = index; BattlerSpriteModel.SkillSelectSubject.OnNext(Unit.Default); if (SkillsDicionary.IsAll(skill) || SkillsDicionary.IsRandom(skill)) { BattlerSpriteModel.AllSelectSubject.OnNext(Unit.Default); } } })); } ; }