Esempio n. 1
0
 public static List <EvaluateInfo> Evaluates(PeEntity npc, Enemy enemy, List <ItemObject> objs)
 {
     infos.Clear();
     for (int i = 0; i < objs.Count; i++)
     {
         EvaluateInfo info = Evaluate(npc, enemy, objs[i]);
         if (info.EvaluateValue > 0)
         {
             infos.Add(info);
         }
     }
     return(infos);
 }
Esempio n. 2
0
        static EvaluateInfo GetEvaluateInfo()
        {
            EvaluateInfo retInfo = null;

            if (infoPool.Count > 0)
            {
                retInfo = infoPool.Pop();
            }
            if (null == retInfo)
            {
                retInfo = new EvaluateInfo();
            }
            return(retInfo);
        }
Esempio n. 3
0
        public ItemObject GetBetterAtkObj(PeEntity npc, Enemy enemy)
        {
            List <EvaluateInfo> infos = EvaluateMgr.Evaluates(npc, enemy, _hasSelectsAtkEq);

            if (infos == null || infos.Count <= 0)
            {
                //在水中需要收回当前装备的武器(如果远程 INFOS可能是0个,此时应用拳头)
                if (npc.biologyViewCmpt != null && !npc.biologyViewCmpt.monoPhyCtrl.Equals(null) && npc.biologyViewCmpt.monoPhyCtrl.feetInWater)
                {
                    SelectItem.TakeOffEquip(npc);
                }

                return(null);
            }
            ;
            if (infos.Count == 1)
            {
                _BetterAtkObj = infos[0].ItemObj;
                return(_BetterAtkObj);
            }

            EvaluateInfo tmpInfo = infos[0];

            for (int i = 1; i < infos.Count; i++)
            {
                if (tmpInfo.EvaluateValue < infos[i].EvaluateValue)
                {
                    tmpInfo = infos[i];
                }

                EvaluateMgr.Recyle(infos[i]);
            }

            _BetterAtkObj = tmpInfo.ItemObj;
            return(_BetterAtkObj);
        }
Esempio n. 4
0
        public static EvaluateInfo  Evaluate(PeEntity npc, Enemy enemy, ItemObject obj)
        {
            float RANGE_DATA = 5.0f;

            ItemProto.WeaponInfo weaponInfo = obj.protoData.weaponInfo;
            AttackMode           mode       = obj.protoData.weaponInfo.attackModes[0];

            EvaluateInfo info = new EvaluateInfo();

            //当前装备
            if (npc.motionEquipment.PEHoldAbleEqObj == obj)
            {
                info.setEquipment(1.2f);
            }
            else
            {
                info.setEquipment(1.0f);
            }

            if (mode.type == AttackType.Ranged)
            {
                info.SetRangeFir(2.0f);
            }
            else
            {
                info.SetRangeFir(1.0f);
            }

            //bool npcFeetInwater =  npc.biologyViewCmpt != null &&  npc.biologyViewCmpt.monoPhyCtrl != null ? npc.biologyViewCmpt.monoPhyCtrl.feetInWater : false;
            float hpNpc = npc.GetAttribute(AttribType.Hp);
            //float atkNpc = npc.GetAttribute(AttribType.Atk);
            float defNpc   = npc.GetAttribute(AttribType.Def);
            float enemyAtk = enemy.entityTarget.GetAttribute(AttribType.Atk);

            bool rangeFrist = ((enemyAtk - defNpc > hpNpc * 0.1f) && mode.type == AttackType.Ranged) ? true : false; // && !enemy.IsInWater && !npcFeetInwater

            //飞行怪物或者boss 只能远程攻击
            if (enemy.entityTarget.Field == MovementField.Sky || enemy.entityTarget.IsBoss || rangeFrist)
            {
                if (mode.type == AttackType.Ranged)
                {
                    info.SetLongRange(2.0f);
                }
                else
                {
                    info.SetLongRange(0);
                }
            }
            //}//水中 只能用近战
            //else if(npcFeetInwater)
            //{
            //    if(mode.type == AttackType.Melee)
            //        info.SetLongRange(2.0f);
            //    else
            //        info.SetLongRange(0);
            //}
            else
            {
                info.SetLongRange(1.0f);
            }

            //
            float distance = PETools.PEUtil.MagnitudeH(npc.position, enemy.position);

            if (mode.IsInRange(distance))
            {
                info.SetRangeValue(2.0f);
            }
            else
            {
                if (distance < mode.minRange && distance + RANGE_DATA > mode.minRange)
                {
                    info.SetRangeValue(1.0f + Mathf.Clamp01(distance / mode.minRange));
                }
                else if (distance > mode.maxRange && mode.maxRange + RANGE_DATA > distance)
                {
                    info.SetRangeValue(1.0f + Mathf.Clamp01(RANGE_DATA - (distance - mode.maxRange) / RANGE_DATA));
                }
                else
                {
                    if (mode.type == AttackType.Ranged)
                    {
                        info.SetRangeValue(1.8f);
                    }
                    else
                    {
                        info.SetRangeValue(1.0f);
                    }
                }
            }
            //
            info.SetDPS(mode.damage / (mode.frequency < PETools.PEMath.Epsilon ? 1.0f : mode.frequency));

            if (weaponInfo.useEnergry)
            {
                GunAmmo gunAmmo = obj.GetCmpt <GunAmmo>();
                if (gunAmmo != null)
                {
                    int shootCount = gunAmmo.count / Mathf.Max(weaponInfo.costPerShoot, 1);
                    //float energy = npc.GetAttribute(AttribType.Energy);
                    if (shootCount > 3)
                    {
                        info.SetSurplusCnt(1.0f);
                    }
                    else if (shootCount >= 1 || npc.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon)
                    {
                        info.SetSurplusCnt(0.5f);
                    }
                    else
                    {
                        info.SetSurplusCnt(0);
                    }
                }
                else
                {
                    info.SetSurplusCnt(0);
                }
            }
            else if (weaponInfo.costItem > 0)
            {
                GunAmmo gunAmmo = obj.GetCmpt <GunAmmo>();
                if (gunAmmo == null)
                {
                    if (npc.GetItemCount(weaponInfo.costItem) < 3)
                    {
                        info.SetSurplusCnt(0.5f);
                    }
                    else
                    {
                        info.SetSurplusCnt(1.0f);
                    }
                }
                else
                {
                    if (gunAmmo.count < 3)
                    {
                        if (npc.GetItemCount(weaponInfo.costItem) < 3)
                        {
                            info.SetSurplusCnt(0.5f);
                        }
                        else
                        {
                            info.SetSurplusCnt(1.0f);
                        }
                    }
                    else
                    {
                        info.SetSurplusCnt(1.0f);
                    }
                }
            }
            else
            {
                info.SetSurplusCnt(1.0f);
            }

            info.SetObj(obj);
            return(info);
        }
Esempio n. 5
0
 public static void Recyle(EvaluateInfo info)
 {
     infoPool.Push(info);
 }