Beispiel #1
0
    /// <summary>
    /// ターン終了時の処理
    /// 死亡判定などを行う
    /// </summary>
    public void TurnEnd()
    {
        EnemyDataModel.Instance.Data.ForEach(battler =>
        {
            DeadCheck(battler);
        });
        MemberDataModel.Instance.GetActorData().ForEach(battler =>
        {
            DeadCheck(battler);
        });

        //タイムラインスケジュールから死んでいるキャラを削除する
        BattleGuiManager.Instance.Timeline.TimelineScheduleRemove().Subscribe(_ =>
        {
            ObservableUtils.Timer(400).Subscribe(__ =>
            {
                //敵がいない場合はリザルト画面に遷移
                if (BattleLogic.AllEnemyDeadCheck())
                {
                    var loots = BattleLogic.BattleResult();
                    BattleGuiManager.Instance.Result.ShowResult(loots).Subscribe(___ =>
                    {
                        End(loots);
                    });
                }
                else
                {
                    TimelineNext();
                }
            });
        });
    }
Beispiel #2
0
        /// <summary>
        /// 報酬追加
        /// </summary>
        /// <param name="loots"></param>
        /// <returns></returns>
        private AsyncSubject <Unit> AddLoots(List <LootItemStruct> loots)
        {
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();

            ObservableUtils.Timer(loots.Count * 100 + 400).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            foreach (var(loot, index) in loots.Select((x, i) => (x, i)))
            {
                var pos        = new Vector3(-500, -90 - (index * 60), 0);
                var itemObject = Object.Instantiate((GameObject)Resources.Load("Prefabs/GUI/ResultItem"),
                                                    Vector3.zero, Quaternion.identity, _itemTransform);
                itemObject.transform.localPosition            = pos;
                itemObject.GetComponent <CanvasGroup>().alpha = 0;
                var sprite = ItemDictionary.GetLootSprite(loot);
                //var sprite = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/Resources/Sprites/Items/" + item.imageData.spritePath);
                itemObject.transform.Find("Icon").GetComponent <Image>().sprite = sprite;
                var text = ItemDictionary.GetText(loot);
                itemObject.transform.Find("Text").GetComponent <Text>().text             = text;
                itemObject.transform.Find("Text").GetComponent <Text>().color            = ItemDictionary.GetColor(loot.ItemId);
                itemObject.transform.Find("Type").GetComponent <TextMeshProUGUI>().text  = ItemDictionary.GetCategoryName(loot.ItemId);
                itemObject.transform.Find("Type").GetComponent <TextMeshProUGUI>().color =
                    ItemDictionary.GetColor(loot.ItemId);
                ObservableUtils.Timer(100 * index).Subscribe(_ =>
                {
                    itemObject.transform.DOLocalMoveX(0, 0.4f).Play();
                    itemObject.transform.GetComponent <CanvasGroup>().DOFade(1f, 0.4f).Play();
                });
            }
            return(subject);
        }
        private AsyncSubject <Unit> RemoveStateAnimation(int uniqId, List <StateStruct> stateStructs)
        {
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();
            var sprite = GetSprite(uniqId);

            stateStructs.ForEach(state =>
            {
                DOTween.To(() => state.StateTransform.GetComponent <CanvasGroup>().alpha,
                           (x) => state.StateTransform.GetComponent <CanvasGroup>().alpha = x, 0f, 0.4f).Play();
                state.StateTransform.DOMoveY(1, 0.4f).Play();
            });
            ObservableUtils.Timer(500).Subscribe(_ =>
            {
                stateStructs.ForEach(state =>
                {
                    sprite.Statuses.Remove(state);
                    if (state.StateTransform != null)
                    {
                        Object.Destroy(state.StateTransform.gameObject);
                    }
                });
                foreach (var(icon, index) in sprite.Statuses.Select((x, index) => (x, index)))
                {
                    float posX = 60 + -40f * (sprite.Statuses.Count - 1);
                    icon.StateTransform.DOLocalMoveX(posX, 0.3f).Play();
                }
                ObservableUtils.Timer(400).Subscribe(__ =>
                {
                    subject.OnNext(Unit.Default);
                    subject.OnCompleted();
                });
            });
            return(subject);
        }
Beispiel #4
0
 public void EffectPlay(int targetUniqId)
 {
     Instantiate(effectPrefab, BattleDictionary.GetTransformByUniqId(targetUniqId).localPosition,
         gameObject.transform.rotation);
     PlaySound();
     //TODO
     ObservableUtils.Timer(400).Subscribe(_ => { Destroy(gameObject); });
 }
Beispiel #5
0
 /// <summary>
 /// タイムラインを次に進行する
 /// </summary>
 private void TimelineNext()
 {
     BattleGuiManager.Instance.Timeline.TimelineNext().Subscribe(_ =>
     {
         ObservableUtils.Timer(300).Subscribe(__ =>
         {
             TurnStart();
         });
     });
 }
Beispiel #6
0
 public void AiAction(int uniqId)
 {
     ObservableUtils.Timer(1000).Subscribe(__ =>
     {
         var battler = BattlerDictionary.GetBattlerByUniqId(uniqId);
         var ai      = AiManager.Action(uniqId);
         BattleLogic.SkillByAi(ai, battler).Subscribe(___ =>
         {
             TurnEnd();
         });
     });
 }
Beispiel #7
0
        public AsyncSubject <Unit> SleepEffect(int uniqId)
        {
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();
            var sleep         = Instantiate((GameObject)Resources.Load("Prefabs/Status/Sleep"));
            var skillBehavior = sleep.GetComponent <SkillBehavior>();

            skillBehavior.EffectPlay(uniqId);
            ObservableUtils.Timer(200).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            return(subject);
        }
        public AsyncSubject <Unit> Hide()
        {
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();

            _sprites.ForEach(x =>
            {
                x.SpriteRenderer.DOFade(0, 0.4f).Play();
                x.Ui.UiParent.GetComponent <CanvasGroup>().DOFade(0, 0.4f).Play();
            });
            ObservableUtils.Timer(60).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            return(subject);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        private void PlaySound()
        {

            sound.ForEach(x =>
            {
                ObservableUtils.Timer(frame * 100).Subscribe(__ =>
                {
                    if (x.pitch == 0)
                        x.pitch = 1;
                    if (x.volume == 0)
                        x.volume = 1 * _volumeRate;
                    x.volume = x.volume * _volumeRate;
                    _audioSource.pitch = x.pitch;
                    _audioSource.volume = x.volume;
                    _audioSource.PlayOneShot(x.sound);
                });
            });
        }
        /// <summary>
        /// 状態異常アイコンの追加
        /// </summary>
        public void StatusIconRefresh(int uniqId)
        {
            var battler = BattlerDictionary.GetBattlerByUniqId(uniqId);
            var sprite  = GetSprite(uniqId);
            List <StateStruct> deletes = new List <StateStruct>();

            //削除判定
            sprite.Statuses.ForEach(stateStruct =>
            {
                if (battler.status.Find(state => state.type == stateStruct.Status.type) == null)
                {
                    deletes.Add(stateStruct);
                }
            });
            if (deletes.Count != 0)
            {
                RemoveStateAnimation(uniqId, deletes).Subscribe(_ => { AddStatusIcon(uniqId); });
            }
            else
            {
                ObservableUtils.Timer(0).Subscribe(_ => { AddStatusIcon(uniqId); });
            }
        }
Beispiel #12
0
    /// <summary>
    /// ターン開始
    /// </summary>
    private void TurnStart()
    {
        _disposableContainer = new IDisposableContainer();
        TimelineSerializableData timelineData =
            BattleDictionary.GetTimelineById(BattleGuiManager.Instance.Timeline.TimelineData, BattleGuiManager.Instance.Timeline.TimelineSchedule[0]);

        TurnAwake(timelineData.uniqId).Play().Subscribe(_ =>
        {
            ObservableUtils.Timer(300).Subscribe(__ =>
            {
                //行動不能判定
                if (StatusLogic.TurnSkipCheck(timelineData.uniqId))
                {
                    TurnEnd();
                }
                else
                {
                    //行動開始 アクターなら選択処理 エネミー、ミニオンならAI
                    BattlePresenter.GetInstance().BattlerSpriteModel.GetData(timelineData.uniqId).Active.OnNext(true);
                }
            });
        });
    }
Beispiel #13
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);
            });
        }