示例#1
0
        /// <summary>
        /// Ops the by skill.
        /// </summary>
        /// <param name="op_list">Op list.</param>
        /// <param name="skill">Skill.</param>
        /// <param name="dir_limit">Dir limit.</param>
        /// <param name="simGrid">假定棋子站在这里发起攻击.</param>
        public void OpBySkill(ref List <Operation> op_list, Skill_Info skill, eDirection dir_limit, ChessContainer simGrid)
        {
            List <ChessContainer> attack_grids = BKTools.GetSkillScope(skill, simGrid);

            //筛选攻击目标
            //有效性筛选
            for (int i = attack_grids.Count - 1; i >= 0; i--)
            {
                ChessContainer cc = (ChessContainer)attack_grids[i];
                if (cc.my_chess == null || !BKTools.IsTargetFit(skill.my_TargetBelong, cc.my_chess.belong, my_chess.belong))
                {
                    attack_grids.RemoveAt(i);
                    continue;
                }
            }
            //数量筛选
            //目标数量有限时,选择合适的目标(大部分时候为随机)
            //TODO 这边的随机选择也是不严谨的, [!]注意operation中的目标不会被用于生成ToDoListItem,不影响实际执行
            if (skill.target_number != 0)
            {
                List <ChessContainer> list_copy = new List <ChessContainer>();
                foreach (var item in attack_grids)
                {
                    list_copy.Add(item);
                }
                attack_grids.Clear();
                for (int i = 0; i < skill.target_number && list_copy.Count > 0; i++)
                {
                    int index = UnityEngine.Random.Range(0, list_copy.Count);
                    attack_grids.Add(list_copy[index]);
                    list_copy.Remove(list_copy[index]);
                }
            }

            Operation op = new Operation();

            op.targetGridIndex = simGrid.number;
            op.direcion        = dir_limit;
            op.skill_id        = skill.id;
            op.skill           = skill;
            op.attack_target.AddRange(
                from grid in attack_grids
//				where grid.my_chess != null
                select grid.my_chess);

            foreach (var target in attack_grids)
            {
                //评估行动价值
                if (skill.skill_damage > target.my_chess.attribute.mana)
                {
                    op.iWouldKillTarget++;
                }
//				else
//					op.iWouldKillTarget = false;
                op.bMayBeKilled = false;
                op.exDamage    += my_chess.attribute.GetSklDmg(skill);
                // TODO 此处使用了非正式的受伤判断,可能要很久很久的将来才能补正
                op.exInjure = target.my_chess.attribute.Pow;
            }
            op_list.Add(op);
        }
    IEnumerator SkillCoroutine(Skill_Info skill)
    {
        Main.Inst.addDancer(STR_Skill_Coroutine[0]);
        driving_skill_list.Add(this);
        //技能发动提示
        Ritual_Display(skill);
        yield return(new WaitForSeconds(1));

        //播放表现
        float delay = CG_Display(skill);

        yield return(new WaitUntil(BKTools.ISCWithArgu(STR_Skill_Coroutine)));

        //ArrayList scope_list = getSkillScope(skill);
        List <ChessContainer> scope_list = BKTools.GetSkillScope(skill, container, attack_Direction);

        //展示攻击范围
        for (int i = scope_list.Count - 1; i >= 0; i--)
        {
            ChessContainer cc  = (ChessContainer)scope_list[i];
            BK_AnimEvts    vfx = BKTools.addVFX_Dancer(Main.Inst.GetComponent <VFX_Dictionary>().Skill_Scope_Mark);
            vfx.transform.SetParent(cc.transform, false);
        }
        yield return(new WaitUntil(BKTools.ISCWithArgu(STR_Skill_Coroutine)));

        //筛选攻击目标
        //有效性筛选
        for (int i = scope_list.Count - 1; i >= 0; i--)
        {
            ChessContainer cc = (ChessContainer)scope_list[i];
            if (cc.my_chess == null || !BKTools.IsTargetFit(skill.my_TargetBelong, cc.my_chess.belong, belong))
            {
                scope_list.RemoveAt(i);
                continue;
            }
        }
        //目标数量有限时,选择合适的目标(大部分时候为随机)
        //info.target_number
        if (skill.target_number != 0)
        {
            List <ChessContainer> list_copy = new List <ChessContainer>();
            foreach (var item in scope_list)
            {
                list_copy.Add(item);
            }
            scope_list.Clear();
            for (int i = 0; i < skill.target_number && list_copy.Count > 0; i++)
            {
                int index = UnityEngine.Random.Range(0, list_copy.Count);
                scope_list.Add(list_copy[index]);
                list_copy.Remove(list_copy[index]);
            }
        }


        //展示攻击目标
        for (int i = scope_list.Count - 1; i >= 0; i--)
        {
            ChessContainer cc  = (ChessContainer)scope_list[i];
            BK_AnimEvts    vfx = BKTools.addVFX_Dancer(Main.Inst.GetComponent <VFX_Dictionary>().Skill_Target_Mark);
            vfx.transform.SetParent(cc.transform, false);
        }
        yield return(new WaitUntil(BKTools.ISCWithArgu(STR_Skill_Coroutine)));

        //计算效果
        Main.Inst.b_attacked = true;
        AnalyseSkillKouKa(skill, scope_list);
        //计算结果后等待
        yield return(new WaitForSeconds(Data.DELAY_AFTER_SKILL));

        driving_skill_list.Remove(this);
        attack_Direction = eDirection.All;
        Main.Inst.redDancer(STR_Skill_Coroutine[0]);
        yield return(null);
    }