예제 #1
0
파일: AIExt.cs 프로젝트: moto2002/Avocat
        // 计算目标优先级分数
        public static void GetTargetPriorityScore(Warrior warrior, Warrior target, Action <int> onScore)
        {
            var score = 0;

            // 不能反击,5 分
            if (!target.CanAttackBack(warrior))
            {
                score += 5;
            }

            // 能击杀的,10 分
            var damage = 0;

            warrior.Battle.SimulateAttackingDamage(warrior, target, null, null, (d) => damage = d);
            if (damage >= target.HP + target.ES)
            {
                score += 10;
            }

            // 无护盾的目标,3 分
            if (target.ES <= 0)
            {
                score += 3;
            }

            // 血量 < 50% ,3 分
            if (target.HP * 2 < target.MaxES)
            {
                score += 3;
            }
            else if (target.HP * 4 < target.MaxES * 3) // 血量 < 75%,1 分
            {
                score += 1;
            }

            // 没有相邻队友,2 分
            if (CheckTeammateInDistance(warrior, 1).Length == 0)
            {
                score += 2;
            }

            // 被围攻,3 分
            if (CheckThreatenedEnemies(warrior).Length > 1)
            {
                score += 3;
            }

            onScore(score);
        }
예제 #2
0
파일: AIExt.cs 프로젝트: moto2002/Avocat
        // 远程攻击者的站位逻辑
        public static void CheckoutPosition4FarAttacking(Warrior attacker, Warrior target, Action <int, int> onStandPos)
        {
            var standPos2Targets = GetPosListWithTargetReachable(attacker, target);

            // 对这些位置进行评分
            var pos2Score = new Dictionary <KeyValuePair <int, int>, int>();

            foreach (var pos in standPos2Targets.Keys)
            {
                var x = pos.Key;
                var y = pos.Value;

                var score = 0;
                foreach (var t in standPos2Targets[pos])
                {
                    // 进战敌人,2 分,远程敌人,1 分
                    score += t.IsCloseAttack() ? 2 : 1;

                    // 敌人没有反击能力,2 分
                    if (t.CanAttackBack(attacker))
                    {
                        score += 2;
                    }

                    // 能攻击到自己,并且自己无法反击,则 -2 分,能反击则 1
                    if (t.InAttackRange(x, y))
                    {
                        score += attacker.CanAttackBack(t) ? 1 : -2;
                    }
                }

                pos2Score[pos] = score;
            }

            var posArr = standPos2Targets.Keys.ToArray();

            posArr.SwiftSort((a, b) => pos2Score[b] - pos2Score[a]);
            onStandPos(posArr[0].Key, posArr[0].Value);
        }