コード例 #1
0
        /// <summary>
        /// 自分から出すターゲットラインを更新します
        /// </summary>
        private void updateTargetLine()
        {
            if (tasks.Count <= 0)
            {
                return;
            }

            BattleTask task = tasks[0];

            if (task.getIsSkill())
            {
                IActiveSkill useSkill = task.getSkill();
                if (ActiveSkillSupporter.isAffectSkill(useSkill))
                {
                    List <IBattleable> targets = task.getTargets();
                    drawTargetingLine(player, targets, useSkill.getName(), useSkill.isFriendly());
                }
            }
            else
            {
                List <IBattleable> targets = task.getTargets();
                var item = task.getItem();
                drawTargetingLine(player, targets, item.getName(), true);
            }
        }
コード例 #2
0
 public void canseledTask(BattleTask task)
 {
     if (task.getSkill().getActiveSkillType() == ActiveSkillType.MOVE)
     {
         goingPos -= task.getMove();
     }
     if (ActiveSkillSupporter.isAffectSkill(task.getSkill()) && task.getIsProssesing())
     {
         deleteTargetingLine(player);
     }
     tasks.Remove(task);
 }
コード例 #3
0
        /// <summary>
        /// BattleTaskを生成します
        /// </summary>
        /// <returns>生成したタスク</returns>
        private BattleTask creatTask()
        {
            if (!isReady)
            {
                throw new InvalidOperationException("manager hasn't readied yet");
            }

            IActiveSkill skill = ai.decideSkill();

            if (ActiveSkillSupporter.isAffectSkill(skill))
            {
                Extent     extent = ActiveSkillSupporter.searchExtent(skill);
                BattleTask returnTask;
                //効果範囲に応じてタスクを生成
                switch (extent)
                {
                case Extent.SINGLE:
                    IBattleable        target           = ai.decideSingleTarget(skill);
                    List <IBattleable> singleTargetList = new List <IBattleable>()
                    {
                        target
                    };
                    returnTask = new BattleTask(user.getUniqueId(), skill, singleTargetList, battletaskIdCount);
                    break;

                case Extent.AREA:
                    FieldPosition pos = ai.decideAreaTarget(skill);
                    returnTask = new BattleTask(user.getUniqueId(), skill, pos, battletaskIdCount);
                    break;

                case Extent.ALL:
                    List <IBattleable> allTargetList = BattleManager.getInstance().getJoinedBattleCharacter();
                    returnTask = new BattleTask(user.getUniqueId(), skill, allTargetList, battletaskIdCount);
                    break;

                default: throw new NotSupportedException("unkonwn extent");
                }
                battletaskIdCount++;
                return(returnTask);
            }
            else if (skill.getActiveSkillType() == ActiveSkillType.MOVE)
            {
                MoveSkill  moveSkill  = (MoveSkill)skill;
                int        move       = ai.decideMove(moveSkill);
                BattleTask returnTask = new BattleTask(user.getUniqueId(), skill, move, battletaskIdCount);
                battletaskIdCount++;
                return(returnTask);
            }
            throw new InvalidOperationException("unknown skillType");
        }
コード例 #4
0
 /// <summary>
 /// スキル対象のリストを取得します
 /// </summary>
 /// <returns>スキル対象のリスト</returns>
 public List <IBattleable> getTargets()
 {
     if (isSkill)
     {
         if (!ActiveSkillSupporter.isAffectSkill(skill))
         {
             throw new InvalidOperationException("this task isn't an action");
         }
         if (targets.Count < 0)
         {
             targets = BattleManager.getInstance().getAreaCharacter(targetPos);
         }
         return(targets);
     }
     else
     {
         return(targets);
     }
 }
コード例 #5
0
        /// <summary>
        /// skillNodeが選択された時の処理
        /// </summary>
        /// <param name="chosenSkill">選択されたIActiveSkill</param>
        public void skillChose(IActiveSkill chosenSkill)
        {
            this.chosenActiveSkill = chosenSkill;

            if (ActiveSkillSupporter.isAffectSkill(chosenSkill))
            {
                Extent extent = ActiveSkillSupporter.searchExtent(chosenSkill);
                int    range  = ActiveSkillSupporter.searchRange(chosenSkill, player);
                inputTargetList(extent, range);
            }
            else if (chosenSkill.getActiveSkillType() == ActiveSkillType.MOVE)
            {
                int move = ActiveSkillSupporter.searchMove(chosenSkill, player);
                inputMoveAreaList(move);
            }
            else
            {
                throw new NotSupportedException("Unkonwn skillType");
            }
        }
コード例 #6
0
        public FieldPosition decideAreaTarget(IActiveSkill useSkill)
        {
            if (!ActiveSkillSupporter.isAffectSkill(useSkill))
            {
                throw new ArgumentException("the skill " + useSkill + " dosen't has to decide target.");
            }
            if (ActiveSkillSupporter.searchExtent(useSkill) != Extent.AREA)
            {
                throw new ArgumentException("the skill " + useSkill + " isn't a skill for single");
            }

            if (useSkill.isFriendly())
            {
                return(this.decideAreaFriendlyTarget(useSkill));
            }
            else
            {
                return(this.decideHostileAreaTarget(useSkill));
            }
        }
コード例 #7
0
        /// <summary>
        /// スキルの対象を決定します
        /// </summary>
        /// <returns>対象のリスト</returns>
        /// <param name="useSkill">使用するスキル</param>
        public IBattleable decideSingleTarget(IActiveSkill useSkill)
        {
            if (!ActiveSkillSupporter.isAffectSkill(useSkill))
            {
                throw new ArgumentException("the skill " + useSkill + " dosen't has to decide target.");
            }
            if (ActiveSkillSupporter.searchExtent(useSkill) != Extent.SINGLE)
            {
                throw new ArgumentException("the skill " + useSkill + " isn't a skill for single");
            }

            if (useSkill.isFriendly())
            {
                return(this.decideFriendlySingleTarget(useSkill));
            }
            else
            {
                return(this.decideHostileSingleTarget(useSkill));
            }
        }
コード例 #8
0
 public void deleteTaskFromTarget(IBattleable target)
 {
     foreach (BattleTask task in tasks)
     {
         foreach (IBattleable bal in task.getTargets())
         {
             if (bal.Equals(target))
             {
                 if (task.getIsProssesing())
                 {
                     battleState = BattleState.IDLE;
                     if (ActiveSkillSupporter.isAffectSkill(task.getSkill()))
                     {
                         deleteTargetingLine(player);
                     }
                     state.advanceProgress(1);
                 }
                 tasks.Remove(task);
             }
         }
     }
 }
コード例 #9
0
        /// <summary>
        /// ステートがACTIONの時に毎フレーム行う処理
        /// </summary>
        private void actionState()
        {
            BattleTask runTask = tasks[0];

            Debug.Log("run " + runTask.getName());
            if (runTask.getIsSkill())
            {
                IActiveSkill runSkill = runTask.getSkill();
                runSkill.action(player, runTask);
                if (ActiveSkillSupporter.isAffectSkill(runSkill))
                {
                    Debug.Log("into isAffect");
                    deleteTargetingLine(player);
                }
            }
            else
            {
                IItem runItem = runTask.getItem();
                player.getInventory().useItem(runItem, player);
            }

            tasks.Remove(runTask);
            battleState = BattleState.IDLE;
        }
コード例 #10
0
        public IActiveSkill decideSkill()
        {
            //ボーナス値のテーブルです。最終的に足されます。
            Dictionary <ActiveSkillCategory, int> probalityBonus = new Dictionary <ActiveSkillCategory, int>()
            {
                { ActiveSkillCategory.NORMAL, 0 },
                { ActiveSkillCategory.CAUTION, 0 },
                { ActiveSkillCategory.DANGER, 0 },
                { ActiveSkillCategory.POWER, 0 },
                { ActiveSkillCategory.FULL_POWER, 0 },
                { ActiveSkillCategory.SUPPORT, 0 },
                { ActiveSkillCategory.HEAL, 0 },
                { ActiveSkillCategory.MOVE, 0 }
            };

            //div0を防ぐための処理
            int maxMp = (user.getMaxMp() > 0) ? user.getMaxMp() : 1;

            //HPが50%以下の場合、caution可能性値を+20します
            if (this.user.getHp() / maxMp <= 0.5f)
            {
                probalityBonus[ActiveSkillCategory.CAUTION] += 20;
            }

            //HPが20%以下の場合、danger可能性値を+30します
            if (this.user.getHp() / maxMp <= 0.2f)
            {
                probalityBonus[ActiveSkillCategory.DANGER] += 30;
            }

            //HPが70%以下の場合、攻撃する可能性値を-5、移動する可能性を+10します
            if (this.user.getHp() / maxMp <= 0.7f)
            {
                probalityBonus[ActiveSkillCategory.NORMAL]     -= 5;
                probalityBonus[ActiveSkillCategory.POWER]      -= 5;
                probalityBonus[ActiveSkillCategory.FULL_POWER] -= 5;
                probalityBonus[ActiveSkillCategory.MOVE]       += 10;
            }

            List <ActiveSkillCategory> categories = new List <ActiveSkillCategory>(probalityBonus.Keys);

            //スキルの射程内に何もいない、またはコスト外の時、ボーナス値を使って可能性値を0にします。
            foreach (ActiveSkillCategory category in categories)
            {
                IActiveSkill categorySkill = activeSkills.getSkillFromSkillCategory(category);

                if (!ActiveSkillSupporter.isAffectSkill(categorySkill))
                {
                    continue;
                }

                int  range     = ActiveSkillSupporter.searchRange(categorySkill, user);
                bool isInRange = BattleManager.getInstance().sumFromAreaTo(user, range) > 0;

                bool canUse = categorySkill.getCost() <= user.getMp();

                if (!isInRange || !canUse)
                {
                    probalityBonus[category] = -1 * probalityTable[category];
                }
            }

            //基礎値 + ボーナス値が負の値の場合、可能性値が0になるように設定し直します
            foreach (ActiveSkillCategory category in categories)
            {
                if (probalityTable[category] + probalityBonus[category] < 0)
                {
                    probalityBonus[category] = -1 * probalityTable[category];;
                }
            }

            //可能性値を合計します
            int sum = 0;

            foreach (ActiveSkillCategory category in categories)
            {
                sum += probalityTable[category] + probalityBonus[category];
            }

            //合計が0の場合、攻撃不可と判断して移動します
            if (sum <= 0)
            {
                return(activeSkills.getSkillFromSkillCategory(ActiveSkillCategory.MOVE));
            }

            //乱数でスキルを選択します
            int choose = UnityEngine.Random.Range(0, sum);

            foreach (ActiveSkillCategory category in categories)
            {
                int probality = probalityTable[category] + probalityBonus[category];
                if (choose < probality)
                {
                    return(activeSkills.getSkillFromSkillCategory(category));
                }
                choose -= probalityTable[category] + probalityBonus[category];
            }

            throw new InvalidOperationException("exception state");
        }