Ejemplo n.º 1
0
        SMonsterInfo SearchMonsterAndLootNew(out int MonsterRoundCount, out List <SMonsterInfo> NearbyMonster)
        {
            NearbyMonster = new List <SMonsterInfo>();
            //搜索周围战利品,加入到记忆列表
            //    double NearestTrophyDis = 50.0;
            foreach (var item in trophyList)
            {
                if (LootFilter.Contains(item.ObjPtr))
                {
                    continue;
                }
                GPoint tpos = new GPoint();
                tpos.x = (ushort)item.X;
                tpos.y = (ushort)item.Y;
                if (LootMemory.Contains(tpos) == false)
                {
                    LootMemory.Add(tpos);
                }
            }
            //优先攻击怪,近身怪,目标怪身边数量
            //金色和优先攻击怪物的放弃时间加长
            //   double SearchNearByDis = NEARBY_DIS;
            MonsterRoundCount = 0;
            GPoint searchCenter = new GPoint();

            searchCenter.x = player.Pos.x;
            searchCenter.y = player.Pos.y;
            double       NearestMonsterDis = 1000.0;
            SMonsterInfo targetMonster     = null;

            //搜索怪物,找最近的,再找最近的身边的
            foreach (var item in monsterList)
            {
                if (item.MaxHP == 0 || item.HP == 0)
                {
                    continue;
                }
                if (FilterMonsterList.Contains(item.Pos))
                {
                    continue;
                }
                if (LastTargetMonster != null)
                {
                    if (LastTargetMonster.ID == item.ID)
                    {
                        targetMonster = item;
                        break;
                    }
                }
                double dis = CalcDis(player.Pos, item.Pos);
                if (item.Priority == 0)
                {
                    if (dis > 60.0)
                    {
                        continue;
                    }
                }
                else if (item.Priority > 0)
                {
                    if (dis > 90.0)
                    {
                        continue;
                    }
                }

                if (dis < 17.0)
                {
                    NearbyMonster.Add(item);
                }
                //if (dis > NearestMonsterDis)
                //    continue;
                double Astardis = GGetAstarDis(player.Pos.x, player.Pos.y, (ushort)item.Pos.x, (ushort)item.Pos.y);

                double bi = Astardis / dis;
                if (bi < 1.3)
                {
                    //已经有目标
                    if (targetMonster != null)
                    {
                        if (targetMonster.Priority < item.Priority)
                        {
                            targetMonster     = item;
                            NearestMonsterDis = dis;
                        }
                        else if (targetMonster.Priority == item.Priority)
                        {
                            if (dis < NearestMonsterDis)
                            {
                                targetMonster     = item;
                                NearestMonsterDis = dis;
                            }
                        }
                    }
                    else//没有目标的话
                    {
                        targetMonster     = item;
                        NearestMonsterDis = dis;
                    }
                }
            }
            if (targetMonster == null)
            {
                LastTargetMonster = null;
                return(null);
            }
            foreach (var item in monsterList)
            {
                if (item.MaxHP == 0 || item.HP == 0)
                {
                    continue;
                }
                if (FilterMonsterList.Contains(item.Pos))
                {
                    continue;
                }
                if (targetMonster.ID == item.ID)
                {
                    continue;
                }
                double dis = CalcDis(targetMonster.Pos, item.Pos);
                if (dis < 25.0)
                {
                    MonsterRoundCount++;
                }
            }
            LastTargetMonster = targetMonster;
            return(targetMonster);
        }
Ejemplo n.º 2
0
        SMonsterInfo SearchMonsterAndLoot(out int MonsterRoundCount)
        {
            //搜索周围战利品,加入到记忆列表
            //    double NearestTrophyDis = 50.0;
            foreach (var item in trophyList)
            {
                if (LootFilter.Contains(item.ObjPtr))
                {
                    continue;
                }
                GPoint tpos = new GPoint();
                tpos.x = (ushort)item.X;
                tpos.y = (ushort)item.Y;
                if (LootMemory.Contains(tpos) == false)
                {
                    LootMemory.Add(tpos);
                }
            }

            //   double SearchNearByDis = NEARBY_DIS;
            MonsterRoundCount = 0;
            GPoint searchCenter = new GPoint();

            searchCenter.x = player.Pos.x;
            searchCenter.y = player.Pos.y;
            double       NearestMonsterDis = 1000.0;
            SMonsterInfo targetMonster     = null;

            //搜索怪物,找最近的,再找最近的身边的
            foreach (var item in monsterList)
            {
                if (item.MaxHP == 0 || item.HP == 0)
                {
                    continue;
                }
                if (FilterMonsterList.Contains(item.Pos))
                {
                    continue;
                }
                double dis = CalcDis(player.Pos, item.Pos);
                if (dis > 50.0)
                {
                    continue;
                }
                if (dis < 17.0)
                {
                    targetMonster = item;
                    break;
                }
                if (dis > NearestMonsterDis)
                {
                    continue;
                }
                double Astardis = GGetAstarDis(player.Pos.x, player.Pos.y, (ushort)item.Pos.x, (ushort)item.Pos.y);

                double bi = Astardis / dis;
                if (bi < 1.3)
                {
                    targetMonster     = item;
                    NearestMonsterDis = dis;
                }
            }
            if (targetMonster == null)
            {
                return(null);
            }
            foreach (var item in monsterList)
            {
                if (item.MaxHP == 0 || item.HP == 0)
                {
                    continue;
                }
                if (FilterMonsterList.Contains(item.Pos))
                {
                    continue;
                }
                if (targetMonster.ID == item.ID)
                {
                    continue;
                }
                double dis = CalcDis(targetMonster.Pos, item.Pos);
                if (dis < 17.0)
                {
                    MonsterRoundCount++;
                }
            }
            return(targetMonster);
        }