Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 回避判定
        /// 味方に対するスキル、もしくは必中でない限り回避チェックを行う
        /// 物理属性が含まれる場合は命中率-回避率
        /// 魔法属性のみの場合は100%-魔法回避率
        /// </summary>
        /// <param name="skill"></param>
        /// <param name="fromBattler"></param>
        /// <param name="toBattler"></param>
        /// <returns></returns>
        private static bool HitCheck(string skillId, BattlerSerializable fromBattler,
                                     BattlerSerializable toBattler)
        {
            var skill = SkillsDicionary.GetSkillById(skillId);

            if (skill.target == SkillConsts.MEMBER || skill.target == SkillConsts.ALL_MEMBER ||
                skill.target == SkillConsts.RANDOM_MEMBER)
            {
                return(true);
            }

            float hitRate = fromBattler.parameter.hit;

            hitRate = hitRate * (skill.effect.hitRate / 100);
            if (skill.effect.elements.Contains(SkillConsts.ELEMENTS_PHYSICS))
            {
                hitRate -= toBattler.parameter.dodge;
            }
            else if (skill.effect.elements.Contains(SkillConsts.ELEMENTS_MAGIC))
            {
                hitRate -= toBattler.parameter.magicDodge;
            }

            if (Random.Range(0, 100) < hitRate)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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;
                }
            }));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// スキル説明テキストの作成
        /// </summary>
        /// <param name="skillId"></param>
        /// <param name="battler"></param>
        /// <returns></returns>
        public static string CreateSkillDescription(string skillId, BattlerSerializable battler)
        {
            var           skill = SkillsDicionary.GetSkillById(skillId);
            StringBuilder sb    = new StringBuilder();
            string        name  = skill.name;

            sb.Append("<b><size=18>");
            sb.Append(name);
            sb.Append("</size></b>");
            sb.Append("\n--------------------\n");
            sb.Append(skill.description);
            sb.Append("\n--------------------\n");
            sb.Append(SkillsDicionary.SkillTargetText(skill.target));
            if (skill.strikeSize.min == 0 && skill.strikeSize.max == 0)
            {
                //敵単体(敵全体)に
                sb.Append("に\n");
            }
            else
            {
                //敵単体をx回から
                sb.Append("を");
                if (skill.strikeSize.min == skill.strikeSize.max)
                {
                    sb.Append(skill.strikeSize.min).Append("回\n");
                }
                else
                {
                    sb.Append(skill.strikeSize.min).Append("回から").Append(skill.strikeSize.max).Append("回\n");
                }
            }
            skill.effect.value.ForEach(item =>
            {
                item.rates.ForEach(rate =>
                {
                    StringBuilder msb = new StringBuilder();
                    msb.Append(SkillsDicionary.SkillDependenceText(rate.dependence)).Append("(").Append(rate.rate * 100)
                    .Append("%)\n").Append(SkillsDicionary.SkillDamageDescriptionTargetText(item.valueTarget)).Append("\n");
                    sb.Append(msb);
                });
            });
            //属性
            sb.Append("\n--------------------\n");
            skill.effect.elements.ForEach(x =>
            {
                sb.Append(SkillsDicionary.SkillElementsText(x)).Append("\n");
            });
            return(sb.ToString());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 単体の対象に向けてスキルを使う
        /// </summary>
        /// <param name="skillId"></param>
        /// <param name="fromBattler"></param>
        /// <param name="toBattler"></param>
        /// <returns></returns>
        public static List <SkillDamage> SkillToBattler(string skillId, BattlerSerializable fromBattler,
                                                        BattlerSerializable toBattler)
        {
            List <SkillDamage> skillDamages = new List <SkillDamage>();
            var skill = SkillsDicionary.GetSkillById(skillId);

            foreach (var(x, i) in skill.effect.value.Select((x, i) => (x, i)))
            {
                var skillDamage = new SkillDamage();
                var damage      = SkillLogic.GetTotalDamageByTarget(x, fromBattler);
                skillDamage.damage      = damage;
                skillDamage.valueTarget = x.valueTarget;
                skillDamage.turn        = x.turn;
                skillDamages.Add(skillDamage);
                skillDamage.damage = CalcDamage(skillDamage, toBattler);
            }

            return(skillDamages);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        public AsyncSubject <Unit> SkillToTarget(string skillId, List <SkillDamages> damageses)
        {
            AsyncSubject <Unit> subject = new AsyncSubject <Unit>();
            var skill  = SkillsDicionary.GetSkillById(skillId);
            var effect = Instantiate((GameObject)Resources.Load("Prefabs/Skills/" + skill.effectAnimationId));

            effect.GetComponent <SkillBehavior>().Play(damageses);
            //演出が終わったタイミングではなく
            effect.GetComponent <ParticleSystem>().OnDestroyAsObservable().Subscribe(_ =>
            {
                //subject.OnNext(Unit.Default);
                //subject.OnCompleted();
            });
            Observable.Timer(TimeSpan.FromMilliseconds(400)).Subscribe(_ =>
            {
                subject.OnNext(Unit.Default);
                subject.OnCompleted();
            });
            return(subject);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
                        }
                    }
                }));
            });
        }