Beispiel #1
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;
                }
            }));
        }
Beispiel #2
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);
        }