Exemplo n.º 1
0
    ///评估不同距离的战意值
    private double[] getMoraleToPlayer(AssessPlayer assessPlayer)
    {
        //攻击防御分开,如果自身攻击无法压住对方生命,战意将大幅下降
        double[] selfAttackRange = this.selfAssess.getTypeMark(MarkVO.ASPECT_TYPE_RANGE, MarkVO.VALUE_TYPE_ATTACK);
        double   selfLife        = this.selfAssess.getMarkLife();

        double[] assessAttackRange = assessPlayer.getTypeMark(MarkVO.ASPECT_TYPE_RANGE, MarkVO.VALUE_TYPE_ATTACK);
        double   assessLife        = assessPlayer.getMarkLife();

        //一般性愤怒和针对性仇恨
        double anger   = this._aiPlayer.moodController.anger + assessPlayer.anger;
        double courage = this._aiPlayer.moodController.courage;

        //		string log = string.Format ("{0}({1:F2})对{2} 仇恨 {3:F2}", ownerPlayer.name, ai.moodController.anger, assessPlayer.player.name, assessPlayer.anger);
        //		Debug.Log (log);

        double[] moraleRange = new double[AIConstant.MARK_COUNT];

        for (int i = 0; i < AIConstant.MARK_COUNT; i++)
        {
            moraleRange [i] = (Math.Pow(selfAttackRange [i], 1.3) + selfLife) / (Math.Pow(assessLife, 1.3) + assessAttackRange [i]);
            //仇恨情绪够高,战意高昂,勇气不足,战意低下
            moraleRange [i] += anger * 0.4 + (courage - 0.5) * 0.6;
        }
        return(moraleRange);
    }
Exemplo n.º 2
0
 public void update()
 {
     foreach (KeyValuePair <string, AssessPlayer> pair in this._assessPlayerDic)
     {
         AssessPlayer assessPlayer = pair.Value;
         assessPlayer.update();
     }
 }
Exemplo n.º 3
0
    ///仇视某个玩家,最大值到1
    public void angerAssessPlayer(AssessPlayer assessPlayer, double value)
    {
        if (assessPlayer.anger < value)
        {
            assessPlayer.anger = value;
        }

        assessPlayer.anger += value * 0.5;
        assessPlayer.anger  = Math.Min(1, assessPlayer.anger);
    }
Exemplo n.º 4
0
    ///得到对某个玩家的评估,如果没有则新建
    public AssessPlayer getAssessPlayer(string uid)
    {
        AssessPlayer assessPlayer;

        if (this._assessPlayerDic.ContainsKey(uid))
        {
            assessPlayer = this._assessPlayerDic [uid];
        }
        else
        {
            PlayerEntity player = this._map.getPlayer(uid);
            assessPlayer = new AssessPlayer(this._aiPlayer, player);
            this._assessPlayerDic.Add(uid, assessPlayer);
        }
        return(assessPlayer);
    }
Exemplo n.º 5
0
 public AssessBuff(AssessPlayer assessPlayer) : base(assessPlayer)
 {
     this._buffs = this._assessPlayer.targetPlayer.buffs;
 }
Exemplo n.º 6
0
 public BaseAssessPlayer(AssessPlayer assessPlayer) : base(assessPlayer.aiPlayer)
 {
     this._assessPlayer = assessPlayer;
 }
Exemplo n.º 7
0
    ///评估按当前状况,面对指定对手时,战意值最佳距离,以及位移的能力评估
    public SituationVO getSituationVO(AssessPlayer assessPlayer)
    {
        //战意
        double[] moraleRange = this.getMoraleToPlayer(assessPlayer);
        //找到最高值
        double moraleMax      = 0;
        double moraleAverage  = 0;
        int    moraleMaxIndex = 0;
        int    distanceMin    = 0;
        int    distanceMax    = 10000;


        for (int i = 0; i < AIConstant.MARK_COUNT; i++)
        {
            double morale = moraleRange [i];
            moraleAverage += morale;
            if (moraleRange [i] > moraleMax)
            {
                moraleMax      = morale;
                moraleMaxIndex = i;
            }
        }
        moraleAverage /= AIConstant.MARK_COUNT;

        if (moraleAverage < AIConstant.MORALE_NEAR_MIN)
        {
            //如果平均值很低,逃跑保命吧还是
            distanceMin = AIConstant.RANGE_DISTANCE_MAX;
            distanceMax = AIConstant.RANGE_DISTANCE_AFOCAL;
        }
        else if (moraleAverage >= AIConstant.MORALE_NEAR_MAX)
        {
            //如果战力差距巨大,任意距离都是ok的,尽量靠近些
            distanceMin = AIConstant.RANGE_DISTANCE_MIN;
            distanceMax = AIConstant.RANGE_DISTANCE_MIDDLE;
        }
        else
        {
            if (moraleMaxIndex == 0)
            {
                //近距离最优
                distanceMin = AIConstant.RANGE_DISTANCE_MIN;
                if (moraleRange [1] >= AIConstant.MORALE_MIDDLE)
                {
                    //中距离也不错,中近战位
                    if (moraleRange [2] >= AIConstant.MORALE_MIDDLE)
                    {
                        //远距离都还行
                        distanceMax = AIConstant.RANGE_DISTANCE_MIDDLE;
                    }
                    else
                    {
                        distanceMax = AIConstant.RANGE_DISTANCE_NEAR;
                    }
                }
                else
                {
                    //只在近战位
                    distanceMax = AIConstant.RANGE_DISTANCE_VERY_NEAR;
                }
            }
            else if (moraleMaxIndex == 1)
            {
                //中距离最优
                if (moraleRange [0] >= AIConstant.MORALE_MIDDLE)
                {
                    //近距离也不错
                    distanceMin = AIConstant.RANGE_DISTANCE_VERY_NEAR;
                    if (moraleRange [2] >= AIConstant.MORALE_MIDDLE)
                    {
                        //远距离也不错
                        distanceMax = AIConstant.RANGE_DISTANCE_VERY_FAR;
                    }
                    else
                    {
                        //不要远距离
                        distanceMax = AIConstant.RANGE_DISTANCE_FAR;
                    }
                }
                else
                {
                    distanceMin = AIConstant.RANGE_DISTANCE_NEAR;
                    if (moraleRange [2] >= AIConstant.MORALE_MIDDLE)
                    {
                        //近距离不行,远距离不错
                        distanceMax = AIConstant.RANGE_DISTANCE_VERY_FAR;
                    }
                    else
                    {
                        //只在中位
                        distanceMax = AIConstant.RANGE_DISTANCE_FAR;
                    }
                }
            }
            else
            {
                //远距离最优
                distanceMax = AIConstant.RANGE_DISTANCE_MAX;
                if (moraleRange [1] >= AIConstant.MORALE_MIDDLE)
                {
                    //中距离也不错,中远位
                    if (moraleRange [0] >= AIConstant.MORALE_MIDDLE)
                    {
                        //近距离都还行
                        distanceMin = AIConstant.RANGE_DISTANCE_VERY_NEAR;
                    }
                    else
                    {
                        distanceMin = AIConstant.RANGE_DISTANCE_MIDDLE;
                    }
                }
                else
                {
                    //只在远程位
                    distanceMin = AIConstant.RANGE_DISTANCE_FAR;
                }
            }

            //战意越高,越倾向于靠近,反之保持距离,幅度
            double rate;
            if (moraleAverage > AIConstant.MORALE_MIDDLE)
            {
                //自身越强越靠近
                rate        = (moraleAverage - AIConstant.MORALE_MIDDLE) / (AIConstant.MORALE_NEAR_MAX - AIConstant.MORALE_MIDDLE);
                distanceMin = (int)(distanceMin * (1 - rate) + AIConstant.RANGE_DISTANCE_MIN * rate);
                distanceMax = (int)(distanceMax * (1 - rate) + AIConstant.RANGE_DISTANCE_NEAR * rate);
            }
            else if (moraleAverage < AIConstant.MORALE_MIDDLE)
            {
                //自身越弱越拉远
                rate        = (AIConstant.MORALE_MIDDLE - moraleAverage) / (AIConstant.MORALE_MIDDLE - AIConstant.MORALE_NEAR_MIN);
                distanceMin = (int)(distanceMin * (1 - rate) + AIConstant.RANGE_DISTANCE_FAR * rate);
                distanceMax = (int)(distanceMax * (1 - rate) + AIConstant.RANGE_DISTANCE_AFOCAL * rate);
            }
        }
        return(new SituationVO(moraleAverage, distanceMax, distanceMin));
    }
Exemplo n.º 8
0
    ///发现了敌对玩家
    public void findEnemyPlayer(string uid)
    {
        AssessPlayer assessPlayer = this.getAssessPlayer(uid);

        this.angerAssessPlayer(assessPlayer, 0.1);
    }
Exemplo n.º 9
0
    ///决策,生成该战术的细节,出牌位置和移动方案
    public override void thinkTactic()
    {
        PlayerEntity targetPlayer       = (PlayerEntity)this.target;
        AssessPlayer targetAssessPlayer = this._aiPlayer.assessController.getAssessPlayer(targetPlayer.uid);

        PlayerEntity selfPlayer       = this._aiPlayer.player;
        AssessPlayer selfAssessPlayer = this._aiPlayer.selfAssess;


        //评估好的理想作战距离
        SituationVO situationVO = this._aiPlayer.assessController.getSituationVO(targetAssessPlayer);
        double      morale      = situationVO.morale;
        int         distanceMin = situationVO.distanceMin;
        int         distanceMax = situationVO.distanceMax;

//		string log = string.Format ("{0:F2},[{1},{2}]", morale,distanceMin,distanceMax);
//		ownerPlayer.ShowAILog (log);
//		ownerPlayer.ShowAILog ("战意:" + morale + ",最佳作战距离[" + distanceMin + "," + distanceMax + "]");
//		Debug.Log ("战意:"+morale+",最佳作战距离[" + distanceMin+"," +distanceMax+"]");
        morale = this.randomValue(morale, AIConstant.MARK_RANDOM);



        //评估预判最佳作战距离,方向,尽可能达成
        Vector2D targetForecastPosition = targetAssessPlayer.getForecastPosition(AIConstant.FORECAST_TIME * (0.5 + this._aiPlayer.IQ));
        Vector2D selfForecastPosition   = selfAssessPlayer.getForecastPosition(AIConstant.FORECAST_TIME * this._aiPlayer.IQ);

        Vector2D deltaPosition = Collision.realPosition(selfForecastPosition, targetForecastPosition, this._map.mapData).deltaPos;
        double   deltaDistance = deltaPosition.length;
        //对方朝向我的速度分量,威胁速度(正值为靠近,负值为远离)
        double warnSpeed = -targetPlayer.velocity.projectionOn(deltaPosition);
        //我和对方的最大最小相对速度(正值为靠近,负值为远离)
        double selfSpeedMax  = selfAssessPlayer.currentSpeedMax;
        double deltaSpeedMax = warnSpeed + selfSpeedMax;
        double deltaSpeedMin = warnSpeed - selfSpeedMax;
        //手上可用卡牌有爆发移动力(非装备)
        bool canBurstMove = selfAssessPlayer.canBurstMove;

        //自身擅长的攻击角度
        double[] selfStrengthAngle = selfAssessPlayer.getMarkStrengthAngle();
        //敌方擅长的攻击角度
        double[] targetStrengthAngle = targetAssessPlayer.getMarkStrengthAngle();
        //自身擅长的攻击角度,最大值为1
        double[] selfStrengthAngleNormalize = ArrayUtils.normalize((double[])selfStrengthAngle.Clone());
        //敌方擅长的攻击角度,最大值为1
        double[] targetStrengthAngleNormalize = ArrayUtils.normalize((double[])targetStrengthAngle.Clone());

        //预处理各种需要分析的数据,我的当前角度相对于位置向量角度-180 , 180
        double selfDeltaAngle = Math2.deltaAngle(selfPlayer.angle, deltaPosition.angle);
        //敌方当前角度相对于位置向量角度 0面对我,90侧对我,180背对我
        double targetDeltaAngle = Math2.deltaAngle(targetPlayer.angle, deltaPosition.angle + Math.PI);

        double[] targetFitnessAngleMarks = MarkVO.getFitnessAngleMarks(targetDeltaAngle);

//		double absDeltaAngle = Mathf.Abs (deltaAngle);

        //追击倾向{靠近,保持,拉远}
        double[] sickMarks = new double[AIConstant.MARK_COUNT];
        //正向面对倾向{正面,侧面,背面}
        double[] faceMarks = selfStrengthAngleNormalize;
//		double[] faceMarks = ArrayUtils.SubtractArray(ownerStrengthAngleNormalize, ArrayUtils.MultiplyArray(aimStrengthAngleNormalize,0.2));
        //对手如果正背面能力超强,尽量使用迂回战术
        faceMarks[0] += -targetStrengthAngleNormalize[0] * 0.4 * targetFitnessAngleMarks[0] - targetStrengthAngleNormalize[2] * 0.4 * targetFitnessAngleMarks[2];
        faceMarks[1] += targetStrengthAngleNormalize[0] * 0.3 + targetStrengthAngleNormalize[2] * 0.1 - targetStrengthAngleNormalize[1] * 0.5;

        double[] selfFitnessAngleMarks = MarkVO.getFitnessAngleMarks(selfDeltaAngle);
        ArrayUtils.multiplyArrayValue(selfFitnessAngleMarks, 0.1);
        ArrayUtils.addArray(faceMarks, selfFitnessAngleMarks);

        //击杀倾向,决定输出伤害是否最划算
        double attackMark = 1 - targetAssessPlayer.hpPer;

        faceMarks [0] += attackMark * 0.8;

        //速率倾向
        double speedMark = 1 + AIConstant.MARK_RANDOM;
        //放弃倾向
        double giveUpMark = 0;
        //左翼倾向
        double leftMark = MarkVO.getLeftMark(selfDeltaAngle);
        //生存倾向(越近越倾向护盾技能)
        double lifeMark = deltaDistance >= AIConstant.RANGE_DISTANCE_FAR ? 0: (double)(AIConstant.RANGE_DISTANCE_FAR - deltaDistance) / AIConstant.RANGE_DISTANCE_FAR;

        //面对倾向影响追击倾向
        sickMarks[0] += faceMarks[0] * 0.5 + faceMarks[1] * 0.1;
        sickMarks[1] += faceMarks[0] * 0.1 + faceMarks[1] * 0.4 + faceMarks[2] * 0.1;
        sickMarks[2] += faceMarks[1] * 0.1 + faceMarks[2] * 0.5;

        //AI智商低下,不容易做出保持距离和侧面面对的决策
        sickMarks[1] -= (1 - this._aiPlayer.IQ) * 0.8;
        faceMarks[1] -= (1 - this._aiPlayer.IQ) * 2.5;

        //自身正面能力低下(很可能没有可用卡牌,尽可能放弃直接战斗或直接逃跑)
        if (selfStrengthAngle [0] < AIConstant.MARK_ATTACK_ANGLE_MIN)
        {
            double temp = (AIConstant.MARK_ATTACK_ANGLE_MIN - selfStrengthAngle[0]) / AIConstant.MARK_ATTACK_ANGLE_MIN;
            giveUpMark   += temp * 1.2;
            sickMarks[2] += temp * 1.2;
        }

        //temp
//		sickMarks [0] += 5;
//		faceMarks [1] += 5;

        if (morale >= AIConstant.MORALE_NEAR_MIN)
        {
            //认真作战
            if (deltaDistance > distanceMax)
            {
                //应该靠近,对方正高速逃离,我的最大速度无法追击,如果存在目标距离内可秒杀或追击技能则使用,追击超出距离就放弃
                if (deltaSpeedMax < 0 && deltaDistance >= AIConstant.RANGE_DISTANCE_VERY_FAR)
                {
                    //追不上,放弃
                    giveUpMark += 0.5 + (-deltaSpeedMax / selfSpeedMax) + (deltaDistance - AIConstant.RANGE_DISTANCE_VERY_FAR) / AIConstant.RANGE_DISTANCE_VERY_FAR;
                }
                //距离远,追击动机足
                sickMarks[0] += 1;
            }
            else if (deltaDistance < distanceMin)
            {
                //应该拉远,对方正朝向我高速移动,我的最大速度无法拉开距离,放控制技能后再后撤
                if (deltaSpeedMin > 0)
                {
                    //距离近,无法拉开距离,停下来打
                    sickMarks[1] += 1;
                    sickMarks[2] += 0.2;
                }
                else
                {
                    //距离近,拉开距离来打
                    sickMarks[1] += 0.2;
                    sickMarks[2] += 1;
                }
            }
            else
            {
                //保持距离

                //理想距离中值偏移,大于0 应适当拉近,小于0 应适当拉远
                double deltaAimDistance = deltaDistance - (distanceMin + distanceMax) / 2;
                //理想速率,大于0 应适当拉近,小于0 应适当拉远
                double tempAimSpeedScale = deltaAimDistance / 5 / selfSpeedMax;
                if (tempAimSpeedScale < 0.5)
                {
                    //距离相差不多,可选择侧翼包抄(我的侧方向可以攻击,而敌方侧方向或后方向(近战)比较薄弱)
                    sickMarks[0] += 0.3;
                    sickMarks[1] += 0.7;
                }
                else
                {
                    //还是需要很快追逐
                    sickMarks[0] += 0.7;
                    sickMarks[1] += 0.3;
                }
                speedMark = Math.Max(this.getRandom() * 0.8 + 0.2, tempAimSpeedScale + 0.2);
            }
        }
        else if (morale >= AIConstant.MORALE_MIN)
        {
            //稍有信心战斗
            if (!canBurstMove && deltaSpeedMin > 0 && deltaDistance <= AIConstant.RANGE_DISTANCE_MIDDLE)
            {
                //逃不掉,死磕
                sickMarks[0] += 1;
                sickMarks[1] += 0.8;
                sickMarks[2] += 0.2;
                speedMark     = this.getRandom() * 0.8 + 0.2;
            }
            else
            {
                //不可力敌,逃跑
                sickMarks [2] += 1;
                faceMarks [2] += 0.6;
            }
        }
        else
        {
            //如果逃不掉,死磕
            if (!canBurstMove && deltaSpeedMin > 0 && deltaDistance <= AIConstant.RANGE_DISTANCE_MIDDLE)
            {
                //逃不掉,死磕
                sickMarks[0] += 1;
                sickMarks[1] += 0.6;
                speedMark     = this.getRandom() * 0.6 + 0.4;
            }
            else
            {
                //不可力敌,逃跑
                sickMarks [2] += 2;
                faceMarks [2] += 2;
            }
        }



        //适度的随机
        this.randomArrayValue(sickMarks, AIConstant.MARK_RANDOM);
        this.randomArrayValue(faceMarks, AIConstant.MARK_RANDOM);
        this.randomValue(attackMark, AIConstant.MARK_RANDOM);
        this.randomValue(speedMark, AIConstant.MARK_RANDOM);
        this.randomValue(giveUpMark, AIConstant.MARK_RANDOM);
        this.randomValue(leftMark, AIConstant.MARK_RANDOM);
        this.randomValue(lifeMark, AIConstant.MARK_RANDOM);

        //真正的策略

        if (giveUpMark >= 1)
        {
            this.subType = GIVE_UP;
        }
        else
        {
            int sickType = ArrayUtils.getMaxValueIndex(sickMarks);
            int faceType = ArrayUtils.getMaxValueIndex(faceMarks);
            if (sickType == 0)
            {
                //靠近
                if (faceType == 0)
                {
                    this.subType = IN_LINE;
                }
                else
                {
                    this.subType = IN_SIDE;
                }
            }
            else if (sickType == 1)
            {
                ///保持
                if (faceType == 0)
                {
                    this.subType = HOLD_HEAD;
                }
                else if (faceType == 1)
                {
                    this.subType = HOLD_SIDE;
                }
                else
                {
                    this.subType = HOLD_TAIL;
                }
            }
            else
            {
                //远离
                if (faceType == 1)
                {
                    this.subType = OUT_SIDE;
                }
                else
                {
                    this.subType = OUT_LINE;
                }
            }
        }


        this.cardPriority    = 1 * this.important;
        this.movePriority    = 1 * this.important;
        this.cardAimPosition = targetForecastPosition;
        if (morale > AIConstant.MORALE_NEAR_MAX)
        {
            //全力击杀
            this.cardPriority += 0.2;
        }

//		string log2 = string.Format ("{0} > {1}\n相对距离{2},头差角度{3:F1},左翼倾向{4:F2},战术{5}", ownerPlayer.name, aimPlayer.name, deltaDistance,deltaAngle,leftMark , type);
//		Debug.Log (log2);
//		Debug.Log (ownerPlayer.name + " > " + aimPlayer.name +
//			"\n左翼倾向" + leftMark + ",相对角度" + deltaAngle+",战术" + type);

        switch (this.subType)
        {
        case GIVE_UP:
        {
            this.cardPriority = 0;
            this.movePriority = 0;
            break;
        }

        case IN_LINE:
        {
            this.life    = 500 + 500 * lifeMark;
            this.move    = 200 + 1000 * speedMark;
            this.damage  = 4000;
            this.control = 3000;
            this.push    = -2000;

            Vector2D tempV2d = deltaPosition.clone().multiply(0.5);
            this.forwardMoveAim(tempV2d, tempV2d.angle, speedMark + 0.3);
            this.floatMoveAim(50);
            tempV2d.clear();
            break;
        }

        case IN_SIDE:
        {
            this.life    = 200 + 500 * lifeMark;
            this.move    = 500 + 500 * speedMark;
            this.damage  = 4000;
            this.control = 3000;
            this.push    = 0;

            Vector2D tempV2d     = deltaPosition.clone().reverse();
            double   offsetAngle = 2.1 / Math.Max(1, deltaDistance / AIConstant.RANGE_DISTANCE_VERY_NEAR);
            //左右翼包抄(距离越近选择角度越大) 左翼包抄是以目标的右侧作为目标点
            if (leftMark > 0)
            {
                tempV2d.angle -= offsetAngle;
            }
            else
            {
                tempV2d.angle += offsetAngle;
            }
            //缩短距离
            tempV2d.multiply(0.7);
            tempV2d.add(targetPlayer.position);
            this.setMoveAim(tempV2d, tempV2d.angle);
            this.floatMoveAim(50);
            tempV2d.clear();
            break;
        }

        case HOLD_HEAD:
        {
            this.life    = 500 + 500 * lifeMark;
            this.move    = 0;
            this.damage  = 3000 + 1000 * attackMark;
            this.control = 3000 + 1000 * attackMark;
            this.push    = 0;

            Vector2D tempV2d = deltaPosition.clone().multiply(0.3);
            this.forwardMoveAim(tempV2d, tempV2d.angle, speedMark);
            this.floatMoveAim(20);
            tempV2d.clear();
            break;
        }

        case HOLD_WING:
        {
            break;
        }

        case HOLD_TAIL:
        {
            this.life    = 500 + 500 * lifeMark;
            this.move    = 0;
            this.damage  = 1000 + 3000 * attackMark;
            this.control = 3000 + 1000 * attackMark;
            this.push    = 0;

            Vector2D tempV2d = deltaPosition.clone().reverse();
            this.forwardMoveAim(tempV2d, tempV2d.angle, speedMark);
            this.floatMoveAim(100);
            tempV2d.clear();
            break;
        }

        case HOLD_SIDE:
        {
            this.life    = 200 + 500 * lifeMark;
            this.move    = 500 + 500 * speedMark;
            this.damage  = 3000 + 1000 * attackMark;
            this.control = 3000 + 1000 * attackMark;
            this.push    = 0;

            Vector2D tempV2d     = deltaPosition.clone().reverse();
            double   offsetAngle = 2.1 / Math.Max(1, deltaDistance / AIConstant.RANGE_DISTANCE_VERY_NEAR);
            //左右翼包抄(距离越近选择角度越大)
            if (leftMark > 0)
            {
                tempV2d.angle -= offsetAngle;
            }
            else
            {
                tempV2d.angle += offsetAngle;
            }
            //加大距离
            tempV2d.multiply(1.2);
            tempV2d.add(targetPlayer.position);
            this.setMoveAim(tempV2d, tempV2d.angle, (speedMark + 1) * 0.5);
            this.floatMoveAim(100);
            tempV2d.clear();
            break;
        }

        case OUT_LINE:
        {
            this.life    = 1000 + 500 * lifeMark;
            this.move    = 3000 - 3000 * attackMark + 1000 * speedMark;
            this.damage  = 500 + 4000 * attackMark;
            this.control = 3000;
            this.push    = 2000;

            Vector2D tempV2d = deltaPosition.clone().reverse();
            this.forwardMoveAim(tempV2d, tempV2d.angle, (speedMark + 1) * 0.5);
            this.floatMoveAim(100);
            tempV2d.clear();
            break;
        }

        case OUT_SIDE:
        {
            this.life    = 1000 + 500 * lifeMark;
            this.move    = 1000 - 3000 * attackMark + 1000 * speedMark;
            this.damage  = 500 + 4000 * attackMark;
            this.control = 3000;
            this.push    = 0;

            Vector2D tempV2d     = deltaPosition.clone().reverse();
            double   offsetAngle = 2.1 / Math.Max(1, deltaDistance / AIConstant.RANGE_DISTANCE_VERY_NEAR);
            //左右翼撤退(距离越近选择角度越大)
            if (leftMark > 0)
            {
                tempV2d.angle -= offsetAngle;
            }
            else
            {
                tempV2d.angle += offsetAngle;
            }
            //加大距离
            tempV2d.multiply(2);
            tempV2d.add(targetPlayer.position);
            this.setMoveAim(tempV2d, tempV2d.angle, (speedMark + 1) * 0.5);
            this.floatMoveAim(100);
            tempV2d.clear();
            break;
        }
        }
    }
Exemplo n.º 10
0
 public AssessTrigger(AssessPlayer assessPlayer) : base(assessPlayer)
 {
     this._skillManager = this._assessPlayer.targetPlayer.skillManager;
 }
Exemplo n.º 11
0
    ///判断条件,满足条件的战术,都压进去
    public void addTactics()
    {
        //判断条件,满足条件的战术,都压进去
        double important;
        int    i, len;
        double distance;
        //自身中了控制

        //ai级别
        double IQ = this._aiPlayer.IQ;
        //对自己的评估
        AssessPlayer   selfAssess     = this._aiPlayer.selfAssess;
        FindController findController = this._aiPlayer.findController;

        //自身血量低,回复生命类
//		important = (AIConstant.HP_PER_MIDDLE - this._aiPlayer.selfAssess.hpPer)/AIConstant.HP_PER_MIDDLE * IQ;
//		if (important>0) {
//			CheckAddTactic (new DyingTactic (ai, null, important));
//		}
        //自身短暂未来会出现在的位置,子弹、玩家、道具与之判断距离和重要性时都依照此位置判断
        Vector2D ownerForecastPosition = selfAssess.getForecastPosition(AIConstant.FORECAST_TIME * (0.5 + IQ));

        if (this._map.mapData.isTeam)
        {
            //如果抢萝卜模式,之后再实现AI
        }


        //应对附近有子弹,只考虑最近4个,中低级AI几乎不用
//		if (this.getRandom() < IQ*0.8) {
//			len = findController.findBulletList.Count;
//			for (i = 0; i < len; i++) {
//				BulletEntity bullet = findController.findBulletList [i];
//				if (bullet.alived) {
//					distance = Collision.realPosition(ownerForecastPosition,bullet.position,this._map.mapData).deltaPos.length;
////					important = Math.Min (Math.Min ((AIConfig.AI_FIND_RADIUS - distance) / 1500, 1), 1) * AIValue;
//					important = Math.Min (Math.Min ((2500- distance) / 1500, 1) * (0.9 + bullet.atk / this._aiPlayer.player.hp), 1) * (IQ+0.2);
//
//					checkAddTactic (new BulletTactic (this._aiPlayer, bullet, important));
//				}
//			}
//		}
        //应对附近有敌人玩家
        if (this.getRandom() < IQ * 2)
        {
            len = findController.findEnemyPlayerList.Count;
            for (i = 0; i < len; i++)
            {
                PlayerEntity player = findController.findEnemyPlayerList [i];
                if (player.alived)
                {
                    distance  = Collision.realPosition(ownerForecastPosition, player.position, this._map.mapData).deltaPos.length;
                    important = Math.Min((2500 - distance) / 1500, 1) * (IQ * 0.5 + 0.5);

                    if (this._map.mapData.isChaos)
                    {
                        //如果是乱斗前3名玩家,有更高可能性被针对
                        int scoreIndex = this._map.getSortPlayer(1).IndexOf(player);
                        if (scoreIndex < 3)
                        {
                            important += (3 - scoreIndex) * 0.25 * IQ;
                        }
                    }
                    //如果血很少,很容易被针对
                    double hpPer = selfAssess.hpPer;
                    if (hpPer < AIConstant.HP_PER_NEAR_MAX)
                    {
                        important += (AIConstant.HP_PER_NEAR_MAX - hpPer) * 0.8 * IQ;
                    }
                    //仇恨列表中的玩家,针对性大大提升
                    AssessPlayer assessPlayer = this._aiPlayer.assessController.getAssessPlayer(player.uid);
                    important += assessPlayer.anger * 0.6 * (IQ + 0.5);

                    this.checkAddTactic(new PlayerTactic(this._aiPlayer, player, important));
                }
            }
        }

        //应对附近有多个道具,低级AI几乎不用
        if (this.getRandom() < IQ * 1.4)
        {
            len = findController.findBeanList.Count;

            if (len > 0)
            {
                //确定玩家对于能量和生命的需求
                double powerImportant = selfAssess.needPowerCardCount * 0.34;
                double scoreImportant = 1;
                double hpImportant    = 0.05 + (1 - selfAssess.hpPer);
                //每种类型的道具只考虑最近的一个
                Dictionary <int, BeanEntity> beans = new Dictionary <int, BeanEntity> ();

                //如果数量特别庞大,以格子内的总价值集中地作为特殊目标策略进行思考
                for (i = 0; i < len; i++)
                {
                    BeanEntity bean = findController.findBeanList [i];
                    if (bean.canUse)
                    {
                        if (beans.ContainsKey(bean.itemType))
                        {
                            continue;
                        }
                        beans.Add(bean.itemType, bean);

                        distance = Collision.realPosition(ownerForecastPosition, bean.position, this._map.mapData).deltaPos.length;
//						Debug.Log ("distance  "+distance);

                        //该道具吻合玩家需求的程度
                        important  = bean.beanVO.power * 0.001 * powerImportant * (IQ + 0.5);
                        important += bean.beanVO.score * 0.0001 * scoreImportant * (IQ + 1);
                        important += bean.beanVO.cure * hpImportant * 30 * (IQ + 1);

                        //根据距离修正,但如果没有需求,就基本不重要
                        important *= Math.Min((2500 - distance) / 1500, 1);
                        if (important > AIConstant.MESS_IMPORTANT)
                        {
                            this.checkAddTactic(new BeanTactic(this._aiPlayer, bean, important));
                        }
                    }
                }
            }
        }

        //如果有装备冷却完毕,立即使用,低级AI几乎不用
        if (this.getRandom() < IQ * 1)
        {
            important = IQ + 0.1;
            this.checkAddTactic(new PartTactic(this._aiPlayer, null, important));
        }

        //无条件的乱走乱扔牌战术
        important = AIConstant.MESS_IMPORTANT;
        addTactic(new MessTactic(this._aiPlayer, null, important));

        //遗忘上一次考虑过的战术
        this.lastTacticTargetList.Clear();
    }
Exemplo n.º 12
0
 public AssessPart(AssessPlayer assessPlayer) : base(assessPlayer)
 {
     this._partGroup = this._assessPlayer.targetPlayer.partGroup;
 }
Exemplo n.º 13
0
 public AssessCard(AssessPlayer assessPlayer) : base(assessPlayer)
 {
     this._cardGroup = this._assessPlayer.targetPlayer.cardGroup;
 }