Exemplo 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);
        }
Exemplo n.º 2
0
        private GameObject CreateCard(TimelineSerializableData item)
        {
            GameObject turnCard;

            if (BattleDictionary.IsActor(item.uniqId))
            {
                turnCard = Object.Instantiate((GameObject)Resources.Load("Prefabs/Battle/TurnCard"),
                                              Vector3.zero, Quaternion.identity, GameObject.Find("Timeline/TurnCards").transform);
            }
            else
            {
                turnCard = Object.Instantiate((GameObject)Resources.Load("Prefabs/Battle/EnemyTurnCard"),
                                              Vector3.zero, Quaternion.identity, GameObject.Find("Timeline/TurnCards").transform);
            }
            GameObject          battlerImage = turnCard.transform.Find("Mask/BattlerImage").gameObject;
            string              monsterId    = BattlerDictionary.GetBattlerByUniqId(item.uniqId).monsterId;
            MonsterSerializable monster      = MonsterDicionary.GetMonsterData(monsterId);
            var sprite = Resources.Load <Sprite>(monster.imageData.spritePath);
            //Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(monster.imageData.spritePath);
            var image = battlerImage.GetComponent <Image>();

            image.sprite = sprite;
            battlerImage.GetComponent <RectTransform>().sizeDelta =
                new Vector3(sprite.rect.width, sprite.rect.height);
            battlerImage.GetComponent <RectTransform>().localPosition = new Vector3(monster.imageData.timelineCard.x,
                                                                                    monster.imageData.timelineCard.y, 0);
            battlerImage.GetComponent <RectTransform>().localScale =
                new Vector3(monster.imageData.timelineCard.scaleX, monster.imageData.timelineCard.scaleY, 0);
            _turnCards.Add(new TimelineViewStruct()
            {
                Card = turnCard,
                Id   = item.id
            });
            return(turnCard);
        }
Exemplo n.º 3
0
        public void SkillView(int uniqId)
        {
            _skillParent.SetActive(true);
            var canvasGroup = _skillParent.GetComponent <CanvasGroup>();

            DOTween.To(() => canvasGroup.alpha, (x) => canvasGroup.alpha = x, 1, 0.2f).Play();
            var battler  = BattlerDictionary.GetBattlerByUniqId(uniqId);
            var eqSkills = battler.skills;

            foreach (var(x, i) in _icons.Select((x, i) => (x, i)))
            {
                var image = x.Find("Image").GetComponent <Image>();
                if (i < eqSkills.Count)
                {
                    var skill = SkillsDicionary.GetSkillById(eqSkills[i]);

                    Sprite sprite = Resources.Load <Sprite>(skill.iconSpritePath);
                    //Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(skill.iconSpritePath);
                    image.sprite  = sprite;
                    image.enabled = true;
                }
                else
                {
                    image.sprite  = null;
                    image.enabled = false;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// タイムラインをすすめる
        /// </summary>
        private int TimeLineForward()
        {
            bool timelineFlg = false;
            int  id          = 0;

            while (!timelineFlg)
            {
                foreach (var x in _timelineData)
                {
                    var battler = BattlerDictionary.GetBattlerByUniqId(x.uniqId);
                    //死んでない場合のみ
                    if (BattlerDictionary.IsDead(battler) == false)
                    {
                        int rate = _timelineSchedule.FindAll(i => i == x.id).Count + 1;
                        x.timeLine += (battler.parameter.spd + ((_spdAverage - battler.parameter.spd) / 2)) / rate;

                        if (x.timeLine > _timeline)
                        {
                            x.timeLine = 0;
                            _timelineSchedule.Add(x.id);
                            id          = x.id;
                            timelineFlg = true;
                            break;
                        }
                    }
                }
            }
            return(id);
        }
Exemplo n.º 5
0
        public static int VirtualLevelUpSize(int uniqId, int addExp)
        {
            var levelUpSize   = 0;
            var battler       = BattlerDictionary.GetBattlerByUniqId(uniqId);
            var virtualHasExp = battler.hasExp;

            virtualHasExp += addExp;
            var virtualNeedExp = battler.needExp;
            var virtualLevel   = battler.level;

            while (true)
            {
                if (virtualHasExp >= virtualNeedExp)
                {
                    virtualHasExp -= virtualNeedExp;
                    levelUpSize++;
                    virtualLevel++;
                    virtualNeedExp = CalcNeedExp(battler.monsterId, virtualLevel);
                }
                else
                {
                    break;
                }
            }
            return(levelUpSize);
        }
Exemplo n.º 6
0
 private void DeadCheck(BattlerSerializable battler)
 {
     if (BattleLogic.DeadCheck(battler) && BattlerDictionary.IsDead(battler) == false)
     {
         BattleLogic.Dead(battler);
         BattlePresenter.GetInstance().BattlerSpriteModel.GetData(battler.uniqId).Dead.OnNext(true);
     }
 }
Exemplo n.º 7
0
        public void ViewSkillDescription(string skillId, int uniqId)
        {
            //スキル説明の表示

            /*_descriptionTextObject.GetComponent<TextMeshProUGUI>()
             *  .SetText(SkillLogic.CreateSkillDescription(skillId, BattlerDictionary.GetBattlerByUniqId(uniqId)));*/
            _descriptionTextObject.GetComponent <Text>()
            .text = SkillLogic.CreateSkillDescription(skillId, BattlerDictionary.GetBattlerByUniqId(uniqId));
        }
Exemplo n.º 8
0
        private void BattlerSpriteSubscribe()
        {
            List <int> uniqIds = EnemyDataModel.Instance.UniqIds();

            uniqIds.AddRange(MemberDataModel.Instance.UniqIds());
            uniqIds.ForEach(uniqId =>
            {
                //アクティブ時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Active.Subscribe(isActive =>
                {
                    if (isActive)
                    {
                        AnnounceTextView.Instance.TurnStartText(uniqId);
                        _battlerSpriteView.DeActiveOutline();
                        _battlerSpriteView.OnActiveOutline(uniqId);
                        //メンバーの場合
                        if (BattleDictionary.IsActor(uniqId))
                        {
                            _battleModel.ActiveUniqId = uniqId;
                            _skillsView.SkillView(uniqId);
                        }
                        //敵の場合
                        else
                        {
                            _skillsView.SkillHide();
                            _battleManager.AiAction(uniqId);
                        }
                    }
                    else
                    {
                        _battlerSpriteView.DeActiveOutline();
                        _skillsView.SkillHide();
                    }
                }));
                //HPに変動があった時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Hp.Subscribe(value =>
                {
                    _battlerSpriteView.HpBarRefresh(uniqId);
                }));
                //死んだ時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Dead.Subscribe(isDead =>
                {
                    if (isDead)
                    {
                        _battlerSpriteView.Dead(uniqId);
                        BattleLogic.Dead(BattlerDictionary.GetBattlerByUniqId(uniqId));
                        //PlaySe.GetInstance().Play("SE/Miscs/MonsterDie");
                    }
                }));
                //状態異常にかかった時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Status.Subscribe(_ =>
                {
                    _battlerSpriteView.StatusIconRefresh(uniqId);
                }));
            });
        }
Exemplo n.º 9
0
 /// <summary>
 /// タイムラインのゴールを計算する
 /// </summary>
 private void TimelineCalc()
 {
     _timeline = 0;
     _timelineData.ForEach(x =>
     {
         var battler = BattlerDictionary.GetBattlerByUniqId(x.uniqId);
         _timeline  += battler.parameter.spd;
     });
     _spdAverage = _timeline / _timelineData.Count;
     _timeline   = _spdAverage * TIMELINE_RATE;
 }
 /// <summary>
 /// バトラータイプが同一の選択時のアウトラインを消す
 /// </summary>
 public void DeSelectOutlineByBattlerType(BattlerEnum.BattlerType battlerType)
 {
     _sprites.ForEach(x =>
     {
         var battler = BattlerDictionary.GetBattlerByUniqId(x.UniqId);
         if (battler.battlerType == battlerType)
         {
             x.SpriteRenderer.material.DisableKeyword(ShaderProperties.OUTBASE_ON);
         }
     });
 }
Exemplo n.º 11
0
        /// <summary>
        /// ランダムの対象にスキル発動
        /// </summary>
        /// <param name="skillId"></param>
        /// <param name="fromBattler"></param>
        /// <param name="uniqIds"></param>
        /// <returns></returns>
        public static AsyncSubject <Unit> SkillToRandom(string skillId, BattlerSerializable fromBattler,
                                                        List <int> uniqIds)
        {
            AsyncSubject <Unit> subject   = new AsyncSubject <Unit>();
            List <SkillDamages> damageses = new List <SkillDamages>();

            var skill = SkillsDicionary.GetSkillById(skillId);

            var strikeSize = 1;

            if (skill.strikeSize.min != 0 && skill.strikeSize.max != 0)
            {
                strikeSize = Random.Range(skill.strikeSize.min, skill.strikeSize.max);
            }
            List <BattlerSerializable> toBattlers = new List <BattlerSerializable>();

            uniqIds.ForEach(uniqId =>
            {
                toBattlers.Add(BattlerDictionary.GetBattlerByUniqId(uniqId));
            });
            for (int i = 0; i < strikeSize; i++)
            {
                var toBattler = BattleDictionary.GetAliveBattlerByRandom(toBattlers);
                if (toBattler == null)
                {
                    break;
                }
                var isHit = HitCheck(skillId, fromBattler, toBattler);
                List <SkillDamage> damages = new List <SkillDamage>();
                if (isHit)
                {
                    damages = SkillToBattler(skillId, fromBattler, toBattler);
                }

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

            EffectManager.Instance.SkillToTarget(skillId, damageses).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            return(subject);
        }
Exemplo n.º 12
0
        private void SkillToSubscribe()
        {
            _container.Add(_battlerSpriteModel.SelectedSubject.Subscribe(_ =>
            {
                var skill   = SkillsDicionary.GetSkillById(_skillModel.SkillId);
                var battler = BattlerDictionary.GetBattlerByUniqId(_battleModel.ActiveUniqId);
                switch (skill.target)
                {
                case SkillConsts.ENEMY:
                case SkillConsts.MEMBER:
                    var uniqId    = _battlerSpriteModel.SelectUniqId;
                    var toBattler = BattlerDictionary.GetBattlerByUniqId(uniqId);
                    BattleLogic.SkillToSingle(skill.skillId, battler, toBattler)
                    .Subscribe(
                        __ => { _battleModel.NextTurn.OnNext(Unit.Default); });
                    break;

                case SkillConsts.ALL_ENEMY:
                    BattleLogic.SkillToAll(skill.skillId, battler,
                                           BattleDictionary.GetRivalBattlers(battler.battlerType)).Subscribe(__ =>
                    {
                        _battleModel.NextTurn.OnNext(Unit.Default);
                    });
                    break;

                case SkillConsts.ALL_MEMBER:
                    BattleLogic.SkillToAll(skill.skillId, battler,
                                           BattleDictionary.GetMemberBattlers(battler.battlerType)).Subscribe(__ =>
                    {
                        _battleModel.NextTurn.OnNext(Unit.Default);
                    });
                    break;

                case SkillConsts.RANDOM_ENEMY:
                    BattleLogic.SkillToRandom(skill.skillId, battler,
                                              BattleDictionary.GetRivalUniqIds(BattlerEnum.BattlerType.Actor)).Subscribe(
                        __ =>
                    {
                        _battleModel.NextTurn.OnNext(Unit.Default);
                    });
                    break;

                case SkillConsts.RANDOM_MEMBER:
                    BattleLogic.SkillToRandom(skill.skillId, battler,
                                              BattleDictionary.GetMemberUniqIds(BattlerEnum.BattlerType.Actor)).Subscribe(
                        __ =>
                    {
                        _battleModel.NextTurn.OnNext(Unit.Default);
                    });
                    break;
                }
            }));
        }
Exemplo n.º 13
0
        public void TurnStartText(int uniqId)
        {
            StringBuilder       sb      = new StringBuilder();
            BattlerSerializable battler = BattlerDictionary.GetBattlerByUniqId(uniqId);
            var nameColor = GuiDictionary.GetBattlerNameColor(battler.battlerType);

            sb.Append($"<color={nameColor}>{battler.name}</color>のターン");
            var texts = new List <string>();

            texts.Add(sb.ToString());
            AddText(texts);
        }
Exemplo n.º 14
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();
         });
     });
 }
Exemplo n.º 15
0
        public static AiSelectSkillResultSerializableData Action(int uniqId)
        {
            var batter = BattlerDictionary.GetBattlerByUniqId(uniqId);

            switch (batter.ai)
            {
            case AiConsts.AI_NORMAL:
                var ai = new AiNormal();
                return(ai.SelectSkill(uniqId));
            }

            return(new AiSelectSkillResultSerializableData());
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        public static bool TurnSkipCheck(int uniqId)
        {
            var battler = BattlerDictionary.GetBattlerByUniqId(uniqId);

            foreach (var state in battler.status)
            {
                switch (state.type)
                {
                case SkillValueTarget.SLEEP:
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// 対象選択時のMaterial操作
        /// </summary>
        /// <param name="spriteStruct"></param>
        public void SelectOutline(BattlerSpriteStruct spriteStruct)
        {
            var battler = BattlerDictionary.GetBattlerByUniqId(spriteStruct.UniqId);

            spriteStruct.SpriteRenderer.material.EnableKeyword(ShaderProperties.OUTBASE_ON);
            spriteStruct.SpriteRenderer.GetPropertyBlock(spriteStruct.MaterialPropertyBlock);
            if (battler.battlerType == BattlerEnum.BattlerType.Actor)
            {
                spriteStruct.MaterialPropertyBlock.SetColor(ShaderProperties.OutlineColor, Color.green);
            }
            else
            {
                spriteStruct.MaterialPropertyBlock.SetColor(ShaderProperties.OutlineColor, Color.red);
            }
            spriteStruct.SpriteRenderer.SetPropertyBlock(spriteStruct.MaterialPropertyBlock);
        }
        private void AddStatusIcon(int uniqId)
        {
            var battler = BattlerDictionary.GetBattlerByUniqId(uniqId);
            var sprite  = GetSprite(uniqId);

            battler.status.ForEach(state =>
            {
                //まだ画面にステータスを表示させてない場合
                var stateStruct = sprite.Statuses.Find(f => f.Status.type == state.type);
                if (stateStruct == null)
                {
                    //ステータス表示させる必要がある時のみ
                    if (StatusDictionary.IsViewStatus(state.type))
                    {
                        StateStruct addStateStruct = new StateStruct
                        {
                            Status         = state,
                            StateTransform = Object.Instantiate((GameObject)Resources.Load("Prefabs/Battle/StateIcon"))
                                             .transform
                        };
                        var icon = addStateStruct.StateTransform.transform;

                        icon.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/Icons/Status/" + StatusDictionary.StatusIconName(state.type));

                        /*icon.GetComponent<Image>().sprite =
                         *  AssetDatabase.LoadAssetAtPath<Sprite>("Assets/Resources/Sprites/Icons/Status/" +
                         *                                        StatusDictionary.StatusIconName(state.type));*/


                        addStateStruct.StateTransform.transform.SetParent(sprite.StatusTransform,
                                                                          false);
                        sprite.Statuses.Add(addStateStruct);
                        StateIconValueRefresh(addStateStruct, state);
                        AddStateAnimation(uniqId, addStateStruct);
                    }
                }
                //すでに画面に表示させている場合は更新する
                else
                {
                    StateIconValueRefresh(stateStruct, state);
                }
            });
        }
Exemplo n.º 20
0
 /// <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);
                 }
             }
         }));
     }
     ;
 }
Exemplo n.º 21
0
 private static void WakeUpCheck(List <SkillDamages> damageses)
 {
     foreach (var damagese in damageses)
     {
         var battler = BattlerDictionary.GetBattlerByUniqId(damagese.targetUniqId);
         if (StatusDictionary.IsSleep(battler))
         {
             if (damagese.isHit)
             {
                 //HPにダメージを与えたか検索
                 var damage = damagese.SkillDamage.Find(x => x.valueTarget == SkillValueTarget.HP);
                 if (damage != null && damage.damage > 0)
                 {
                     RemoveStatus(StatusConsts.SLEEP, battler);
                 }
             }
         }
     }
 }
Exemplo n.º 22
0
        public AiSelectSkillResultSerializableData SelectSkill(int uniqId)
        {
            BattlerSerializable battler = BattlerDictionary.GetBattlerByUniqId(uniqId);
            //スキルを無造作に選ぶ、アタックの重みは少ない
            var choice = new WeightChoice <string>();

            foreach (var x in battler.skills)
            {
                var _skill = SkillsDicionary.GetSkillById(x);
                if (_skill.skillId == SkillIds.ATTACK)
                {
                    choice.Add(SkillWeights.VERY_LOW, x);
                }
                else if (battler.parameter.mp >= _skill.mp)
                {
                    choice.Add(SkillWeights.NORMAL, x);
                }
            }

            AiSelectSkillResultSerializableData result = new AiSelectSkillResultSerializableData();
            var skill = SkillsDicionary.GetSkillById(choice.ChoiceOne());

            if (battler.parameter.mp >= skill.mp)
            {
                switch (skill.target)
                {
                case SkillConsts.ENEMY:
                case SkillConsts.MEMBER:
                    result.TargetUniqIds.Add(
                        AiLogic.ChoiceBattlerByHostile(BattleDictionary.GetAliveRivalBattlers(battler.battlerType)));
                    break;

                case SkillConsts.ALL_ENEMY:
                case SkillConsts.ALL_MEMBER:
                    result.TargetUniqIds = BattleDictionary.GetRivalUniqIds(battler.battlerType);
                    break;
                }
                result.SkillId = skill.skillId;
            }

            return(result);
        }
        public void HpBarRefresh(int uniqId)
        {
            var   sprite  = GetSprite(uniqId);
            var   battler = BattlerDictionary.GetBattlerByUniqId(uniqId);
            float rate    = (float)battler.parameter.hp /
                            battler.parameter.maxHp;

            if (rate < 0)
            {
                rate = 0;
            }
            //sprite.Ui.DoAnimation?.Kill();
            var slider = sprite.Ui.HpBar.GetComponent <Slider>();

            DOTween.To(() => slider.value, (x) => slider.value = x, rate, 0.6f)
            .Play();
            int hp = int.Parse(sprite.Ui.HpText.GetComponent <TextMeshProUGUI>().text);

            DOTween.To(() => hp, (x) => sprite.Ui.HpText.GetComponent <TextMeshProUGUI>().SetText(x.ToString()),
                       battler.parameter.hp, 0.6f).Play();
        }
Exemplo n.º 24
0
        public static int AddExp(int uniqId, int addExp)
        {
            var levelUpSize = 0;
            var battler     = BattlerDictionary.GetBattlerByUniqId(uniqId);

            battler.hasExp += addExp;
            while (true)
            {
                if (battler.hasExp >= battler.needExp)
                {
                    battler.hasExp -= battler.needExp;
                    levelUpSize++;
                    battler.level++;
                    battler.needExp = CalcNeedExp(battler.monsterId, battler.level);
                }
                else
                {
                    break;
                }
            }
            return(levelUpSize);
        }
        /// <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); });
            }
        }
Exemplo n.º 26
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);
            });
        }
Exemplo n.º 27
0
        /// <summary>
        /// タイムラインスケジュールから対象バトラーを削除する
        /// </summary>
        /// <returns></returns>
        public AsyncSubject <Unit> TimelineScheduleRemove()
        {
            AsyncSubject <Unit> subject   = new AsyncSubject <Unit>();
            List <int>          deleteIds = new List <int>();

            _timelineData.ForEach(x =>
            {
                if (BattlerDictionary.IsDeadByUniqId(x.uniqId))
                {
                    deleteIds.AddRange(_timelineSchedule.FindAll(id => id == x.id));
                    _timelineSchedule.RemoveAll(id => id == x.id);
                }
            });

            if (deleteIds.Count != 0)
            {
                _timelineView.RemoveSchedule(deleteIds).Subscribe(_ =>
                {
                    FillTimelines().Subscribe(__ =>
                    {
                        subject.OnNext(Unit.Default);
                        subject.OnCompleted();
                    });
                });
            }
            else
            {
                ObservableUtils.AsyncSubjectTimeZeroCompleted(subject);
            }

            return(subject);

            /*
             * AsyncSubject<Unit> subject = new AsyncSubject<Unit>();
             * if (battlers.Count != 0)
             * {
             *  List<int> deleteIds = new List<int>();
             *  battlers.ForEach(battler =>
             *  {
             *      var timeline = _timelineData.Find(x => BattlerDictionary.GetBattlerForUniqId(x.uniqId) == battler);
             *      if (timeline != null)
             *      {
             *          deleteIds.Add(timeline.id);
             *          _timelineSchedule.RemoveAll(x => x == timeline.id);
             *      }
             *  });
             *
             *  if (deleteIds.Count != 0)
             *  {
             *      _timelineView.RemoveSchedule(deleteIds).Subscribe(_ =>
             *      {
             *          FillTimelines().Subscribe(__ =>
             *          {
             *              subject.OnNext(Unit.Default);
             *              subject.OnCompleted();
             *          });
             *      });
             *  }
             *  else
             *      ObservableUtils.AsyncSubjectTimeZeroCompleted(subject);
             * }
             * else
             *  ObservableUtils.AsyncSubjectTimeZeroCompleted(subject);
             *
             * return subject;
             */
        }
Exemplo n.º 28
0
        /// <summary>
        /// バトラー選択時
        /// </summary>
        private void BattlerSelectSubscribe()
        {
            _container.Add(BattlerSpriteModel.SkillSelectSubject.Subscribe(_ =>
            {
                _battlerSpriteView.DeActiveOutline();
            }));
            //全体選択時
            _container.Add(BattlerSpriteModel.AllSelectSubject.Subscribe(_ =>
            {
                var skill = SkillsDicionary.GetSkillById(_skillModel.SkillId);
                BattlerSpriteView.Sprites.ForEach(sprite =>
                {
                    var battler = BattlerDictionary.GetBattlerByUniqId(sprite.UniqId);
                    if ((skill.target == SkillConsts.ALL_ENEMY || skill.target == SkillConsts.RANDOM_ENEMY) && battler.battlerType == BattlerEnum.BattlerType.Enemy ||
                        (skill.target == SkillConsts.ALL_MEMBER || skill.target == SkillConsts.RANDOM_MEMBER) && battler.battlerType == BattlerEnum.BattlerType.Actor)
                    {
                        _battlerSpriteView.SelectOutline(sprite);
                    }
                });
            }));
            BattlerSpriteView.Sprites.ForEach(sprite =>
            {
                //ホバー時
                _container.Add(sprite.SpriteObject.OnMouseOverAsObservable().Subscribe(_ =>
                {
                    if (_skillModel.ActiveIndex != -1 && _battlerSpriteModel.HoverUniqId != sprite.UniqId)
                    {
                        var skill = SkillsDicionary.GetSkillById(_skillModel.SkillId);
                        if (SkillsDicionary.IsSingle(skill))
                        {
                            _battlerSpriteModel.HoverUniqId = sprite.UniqId;
                            var targetBattler = BattlerDictionary.GetBattlerByUniqId(sprite.UniqId);
                            _battlerSpriteView.DeSelectOutlineByBattlerType(targetBattler.battlerType);
                            if (BattleDictionary.IsAppropriate(skill.skillId, _battleModel.ActiveUniqId, sprite.UniqId))
                            {
                                _battlerSpriteView.SelectOutline(sprite);
                            }
                        }
                    }
                }));
                //ターゲット選択時の処理、選択したスキルが発動する
                _container.Add(sprite.SpriteObject.OnMouseUpAsButtonAsObservable().Subscribe(_ =>
                {
                    if (_skillModel.ActiveIndex != -1)
                    {
                        _skillsView.SkillHide();
                        var skill = SkillsDicionary.GetSkillById(_skillModel.SkillId);
                        if (BattleDictionary.IsAppropriate(skill.skillId, _battleModel.ActiveUniqId, sprite.UniqId))
                        {
                            _skillModel.ActiveIndex = -1;

                            switch (skill.target)
                            {
                            case SkillConsts.MEMBER:
                            case SkillConsts.ENEMY:
                                _battlerSpriteView.DeSelectOutline(sprite);
                                _battlerSpriteModel.SelectUniqId = sprite.UniqId;
                                break;

                            case SkillConsts.ALL:
                            case SkillConsts.ALL_ENEMY:
                            case SkillConsts.ALL_MEMBER:
                            case SkillConsts.RANDOM_ENEMY:
                            case SkillConsts.RANDOM_MEMBER:
                                BattlerSpriteView.Sprites.ForEach(x =>
                                {
                                    _battlerSpriteView.DeSelectOutline(x);
                                });
                                break;
                            }

                            _battlerSpriteModel.SelectedSubject.OnNext(Unit.Default);
                        }
                    }
                }));
            });
        }
Exemplo n.º 29
0
        public void AddDamageText(BattlerSerializable fromBattler, string skillName, List <SkillDamages> damageses)
        {
            List <string> texts = new List <string>();
            StringBuilder sb    = new StringBuilder();

            var fromColor = GuiDictionary.GetBattlerNameColor(fromBattler.battlerType);

            sb.Append($"<color={fromColor}>").Append(fromBattler.name).Append("</color>の").Append(skillName)
            .Append("!");
            texts.Add(sb.ToString());
            List <BattlerSerializable> deadBattlers = new List <BattlerSerializable>();

            damageses.ForEach(x =>
            {
                sb.Clear();
                var toBattler =
                    BattlerDictionary.GetBattlerByUniqId(x.targetUniqId);
                var toColor = GuiDictionary.GetBattlerNameColor(toBattler.battlerType);
                if (x.isHit)
                {
                    x.SkillDamage.ForEach(damage =>
                    {
                        var targetText = SkillsDicionary.SkillAnnounceValueTargetText(damage.valueTarget);
                        if (SkillsDicionary.IsDamageSkill(damage.valueTarget))
                        {
                            sb.Clear();
                            var damageColor = SkillsDicionary.SkillColor(damage.valueTarget);
                            sb.Append($"<color={toColor}>").Append(toBattler.name).Append("</color>に")
                            .Append($"<color={damageColor}>").Append(damage.damage)
                            .Append($"</color>の{targetText}");
                            texts.Add(sb.ToString());
                        }
                        else
                        {
                            sb.Clear();
                            if (damage.damage != 0)
                            {
                                sb.Append($"<color={toColor}>").Append(toBattler.name).Append("</color>は")
                                .Append($"{targetText}");
                                texts.Add(sb.ToString());
                            }
                            else
                            {
                                var missText = SkillsDicionary.SkillAnnounceStateMissText(damage.valueTarget);
                                sb.Append($"<color={toColor}>").Append(toBattler.name).Append("</color>は")
                                .Append($"{missText}");
                                texts.Add(sb.ToString());
                            }
                        }
                    });
                }
                else
                {
                    sb.Append($"<color={toColor}>").Append(toBattler.name).Append("</color>は回避した!");
                    texts.Add(sb.ToString());
                }

                if (x.isDead && deadBattlers.Find(battler => battler == toBattler) == null)
                {
                    deadBattlers.Add(toBattler);
                }
            });
            deadBattlers.ForEach(battler => { texts.Add(DeadText(battler)); });
            AddText(texts);
        }
        public void DeSelectOutline(BattlerSpriteStruct spriteStruct)
        {
            var battler = BattlerDictionary.GetBattlerByUniqId(spriteStruct.UniqId);

            spriteStruct.SpriteRenderer.material.DisableKeyword(ShaderProperties.OUTBASE_ON);
        }