Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public void EffectPlay(int targetUniqId)
 {
     Instantiate(effectPrefab, BattleDictionary.GetTransformByUniqId(targetUniqId).localPosition,
         gameObject.transform.rotation);
     PlaySound();
     //TODO
     ObservableUtils.Timer(400).Subscribe(_ => { Destroy(gameObject); });
 }
Esempio n. 3
0
        public AsyncSubject <Unit> PoisonEffect(int uniqId, List <SkillDamages> damageses)
        {
            var targetTransform         = BattleDictionary.GetTransformByUniqId(uniqId);
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();
            var poison       = Instantiate((GameObject)Resources.Load("Prefabs/Status/Poison"));
            var poisonEffect = poison.GetComponent <SkillBehavior>();

            poisonEffect.Play(damageses);
            poison.transform.localPosition = targetTransform.localPosition;
            ObservableUtils.Timer(200).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            return(subject);
        }
Esempio n. 4
0
        /// <summary>
        /// 全体にスキル発動
        /// </summary>
        /// <param name="skillId"></param>
        /// <param name="fromBattler"></param>
        /// <param name="toBattlers"></param>
        /// <returns></returns>
        public static AsyncSubject <Unit> SkillToAll(string skillId, BattlerSerializable fromBattler,
                                                     List <BattlerSerializable> toBattlers)
        {
            AsyncSubject <Unit> subject   = new AsyncSubject <Unit>();
            List <SkillDamages> damageses = new List <SkillDamages>();
            var skill = SkillsDicionary.GetSkillById(skillId);
            List <Transform> targetTransforms = new List <Transform>();

            toBattlers.ForEach(battler =>
            {
                var targetTransform        = BattleDictionary.GetTransformByUniqId(battler.uniqId);
                var isHit                  = HitCheck(skillId, fromBattler, battler);
                List <SkillDamage> damages = new List <SkillDamage>();
                if (isHit)
                {
                    damages = SkillToBattler(skillId, fromBattler, battler);
                }

                var isDead = DeadCheck(battler);
                damageses.Add(new SkillDamages()
                {
                    SkillDamage  = damages,
                    targetUniqId = battler.uniqId,
                    isHit        = isHit,
                    isDead       = isDead
                });
                targetTransforms.Add(targetTransform);
            });
            //ダメージテキストの表示
            AnnounceTextView.Instance.AddDamageText(fromBattler, skill.name, damageses);

            EffectManager.Instance.SkillToAll(skillId, damageses).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            return(subject);
        }
Esempio n. 5
0
        public void Play(List<SkillDamages> damageses)
        {
            SubjectContainer container = new SubjectContainer();
            
            if (isAll)
            {
                if (isAllOneEffect)
                {
                    Instantiate(effectPrefab,
                        BattleDictionary.GetTransformByUniqId(damageses.First().targetUniqId).localPosition,
                        gameObject.transform.rotation);
                }
                else
                {
                    damageses.ForEach(damage =>
                    {
                        if (BattlerDictionary.IsDead(damage.targetUniqId) == false)
                        {
                            Instantiate(effectPrefab,
                                BattleDictionary.GetTransformByUniqId(damage.targetUniqId).localPosition,
                                gameObject.transform.rotation);
                        }
                    });
                }
            }

            var maxTime = damageses.Count * 300;
            foreach (var (x, index) in damageses.Select((x, index) => (x, index)))
            {
                ObservableUtils.Timer(300 * index).Subscribe(_ =>
                {
                    if (isAll == false)
                    {
                        Instantiate(effectPrefab, BattleDictionary.GetTransformByUniqId(damageses.First().targetUniqId).localPosition,
                            gameObject.transform.rotation);
                    }

                    if (x.isHit)
                    {
                        HitEffect(x.targetUniqId);
                        x.SkillDamage.ForEach(damage =>
                        {
                            DamagePopup(BattleDictionary.GetTransformByUniqId(damageses.First().targetUniqId), damage, x.targetUniqId);
                        });
                        hitSound.ForEach(item =>
                        {
                            ObservableUtils.Timer(frame * 100f).Subscribe(__ =>
                            {
                                if (item.pitch == 0)
                                    item.pitch = 1;
                                if (item.volume == 0)
                                    item.volume = 1;
                                item.volume = item.volume * _volumeRate;
                                _audioSource.pitch = item.pitch;
                                _audioSource.volume = item.volume;
                                _audioSource.PlayOneShot(item.sound);
                            });
                        });
                    }
                    else
                    {
                        DodgePopup(BattleDictionary.GetTransformByUniqId(damageses.First().targetUniqId));
                    }
                });
            }
            if (maxTime < sound.Count * 100)
                maxTime = sound.Count * 100;
            PlaySound();
            //TODO
            ObservableUtils.Timer(maxTime + 100).Subscribe(_ =>
            {
                Destroy(gameObject);
            });
        }