Ejemplo n.º 1
0
        public static AsyncSubject <Unit> StatusEffect(List <StatusUpdateResult> results, int uniqId, int activeUniqId)
        {
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();
            int count       = 0;
            var subjects    = new SubjectContainer();
            var fromBattler = BattlerDictionary.GetBattlerByUniqId(uniqId);

            results.ForEach(x =>
            {
                switch (x.StatusType)
                {
                case StatusConsts.POISON:
                    AnnounceTextView.Instance.PoisonText(fromBattler, x.Value, x.IsDead);
                    List <SkillDamage> damage = new List <SkillDamage>();
                    damage.Add(new SkillDamage()
                    {
                        damage      = x.Value,
                        valueTarget = SkillConsts.HP
                    });
                    List <SkillDamages> damageses = new List <SkillDamages>();
                    damageses.Add(new SkillDamages()
                    {
                        isHit        = true,
                        SkillDamage  = damage,
                        targetUniqId = uniqId,
                        isDead       = x.IsDead
                    });

                    subjects.Add(EffectManager.Instance.PoisonEffect(uniqId, damageses));
                    break;

                case StatusConsts.SLEEP:
                    if (uniqId == activeUniqId)
                    {
                        AnnounceTextView.Instance.SleepText(fromBattler);
                        subjects.Add(EffectManager.Instance.SleepEffect(uniqId));
                    }
                    break;
                }
            });

            subjects.Play().Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });

            return(subject);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// ターン開始前の処理
    /// </summary>
    /// <returns></returns>
    private SubjectContainer TurnAwake(int activeUniqId)
    {
        SubjectContainer subjects = new SubjectContainer();

        //色々初期化
        BattlePresenter.GetInstance().Refresh();

        //味方の状態異常処理
        BattleDictionary.GetAllAliveBattlers().ForEach(battler =>
        {
            var results = StatusLogic.StatusUpdate(battler);
            if (results.Count != 0)
            {
                subjects.Add(StatusLogic.StatusEffect(results, battler.uniqId, activeUniqId));
            }

            DeadCheck(battler);
        });

        subjects.Add(BattleGuiManager.Instance.Timeline.TimelineScheduleRemove());

        return(subjects);
    }
Ejemplo n.º 3
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);
            });
        }