Example #1
0
        //private static Orbwalking.Orbwalker Orbwalker;
        static Vector3 GetWardPos(Vector3 lastPos, int radius = 165, int precision = 3)
        {
            Vector3 averagePos = Vector3.Zero;

            int count = precision;

            //int calculated = 0;

            while (count > 0)
            {
                int vertices = radius;

                WardLocation[] wardLocations = new WardLocation[vertices];
                double         angle         = 2 * Math.PI / vertices;

                for (int i = 0; i < vertices; i++)
                {
                    double  th  = angle * i;
                    Vector3 pos = new Vector3((float)(lastPos.X + radius * Math.Cos(th)), (float)(lastPos.Y + radius * Math.Sin(th)), 0); //wardPos.Z
                    wardLocations[i] = new WardLocation(pos, NavMesh.IsWallOfGrass(pos.X, pos.Y, 15));
                }

                List <GrassLocation> grassLocations = new List <GrassLocation>();

                for (int i = 0; i < wardLocations.Length; i++)
                {
                    if (wardLocations[i].Grass)
                    {
                        if (i != 0 && wardLocations[i - 1].Grass)
                        {
                            grassLocations.Last().Count++;
                        }
                        else
                        {
                            grassLocations.Add(new GrassLocation(i, 1));
                        }
                    }
                }

                GrassLocation grassLocation = grassLocations.OrderByDescending(x => x.Count).FirstOrDefault();

                if (grassLocation != null) //else: no pos found. increase/decrease radius?
                {
                    int midelement = (int)Math.Ceiling((float)grassLocation.Count / 2f);
                    //averagePos += wardLocations[grassLocation.Index + midelement - 1].Pos; //uncomment if using averagePos
                    lastPos = wardLocations[grassLocation.Index + midelement - 1].Pos; //comment if using averagePos
                    radius  = (int)Math.Floor((float)radius / 2f);                     //precision recommended: 2-3; comment if using averagePos

                    //calculated++; //uncomment if using averagePos
                }

                count--;
            }

            return(lastPos);//averagePos /= calculated; //uncomment if using averagePos
        }
Example #2
0
        //private static Orbwalking.Orbwalker Orbwalker;
        static Vector3 GetWardPos(Vector3 lastPos, int radius = 165, int precision = 3)
        {
            Vector3 averagePos = Vector3.Zero;

            int count = precision;
            //int calculated = 0;

            while (count > 0)
            {
                int vertices = radius;

                WardLocation[] wardLocations = new WardLocation[vertices];
                double angle = 2 * Math.PI / vertices;

                for (int i = 0; i < vertices; i++)
                {
                    double th = angle * i;
                    Vector3 pos = new Vector3((float)(lastPos.X + radius * Math.Cos(th)), (float)(lastPos.Y + radius * Math.Sin(th)), 0); //wardPos.Z
                    wardLocations[i] = new WardLocation(pos, NavMesh.IsWallOfGrass(pos.X,pos.Y,15));
                }

                List<GrassLocation> grassLocations = new List<GrassLocation>();

                for (int i = 0; i < wardLocations.Length; i++)
                {
                    if (wardLocations[i].Grass)
                    {
                        if (i != 0 && wardLocations[i - 1].Grass)
                            grassLocations.Last().Count++;
                        else
                            grassLocations.Add(new GrassLocation(i, 1));
                    }
                }

                GrassLocation grassLocation = grassLocations.OrderByDescending(x => x.Count).FirstOrDefault();

                if (grassLocation != null) //else: no pos found. increase/decrease radius?
                {
                    int midelement = (int)Math.Ceiling((float)grassLocation.Count / 2f);
                    //averagePos += wardLocations[grassLocation.Index + midelement - 1].Pos; //uncomment if using averagePos
                    lastPos = wardLocations[grassLocation.Index + midelement - 1].Pos; //comment if using averagePos
                    radius = (int)Math.Floor((float)radius / 2f); //precision recommended: 2-3; comment if using averagePos

                    //calculated++; //uncomment if using averagePos
                }

                count--;
            }

            return lastPos;//averagePos /= calculated; //uncomment if using averagePos
        }