当前位置: 首页>>代码示例>>C#>>正文


C# Obj_AI_Base.RealPath方法代码示例

本文整理汇总了C#中Obj_AI_Base.RealPath方法的典型用法代码示例。如果您正苦于以下问题:C# Obj_AI_Base.RealPath方法的具体用法?C# Obj_AI_Base.RealPath怎么用?C# Obj_AI_Base.RealPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Obj_AI_Base的用法示例。


在下文中一共展示了Obj_AI_Base.RealPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CastPredictedSpell

        public static void CastPredictedSpell(SpellSlot spellslot, float range, SkillShotType type, float delay, float speed, float width, Obj_AI_Base target, bool minioncollision, bool championcollision)
        {
            if (speed > 1f)
            {
            float ax = ObjectManager.Player.ServerPosition.X;
            float ay = ObjectManager.Player.ServerPosition.Y;

            float bx = target.ServerPosition.X;
            float by = target.ServerPosition.Y;

            float cx = target.RealPath().LastOrDefault().X;
            float cy = target.RealPath().LastOrDefault().Y;

            float bc = (float)(Math.Sqrt((bx-cx)*(bx-cx)+(by-cy)*(by-cy)));
            float vx = ( cx - bx ) / bc;
            float vy = ( cy - by ) / bc;

            float bv = target.MoveSpeed;
            float ab = (float)(Math.Sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)));

            float hx = bx + ( vx * bv * ( delay + ab / speed ) );
            float hy = by + ( vy * bv * ( delay + ab / speed ) );
            float ah = (float)(Math.Sqrt((hx-ax)*(hx-ax)+(hy-ay)*(hy-ay)));

            float ix = bx + ( vx * bv * ( delay + ah / speed ) );
            float iy = by + ( vy * bv * ( delay + ah / speed ) );
            float ai = (float)(Math.Sqrt((ix-ax)*(ix-ax)+(iy-ay)*(iy-ay)));

            float jx = bx + ( vx * bv * ( delay + ai / speed ) );
            float jy = by + ( vy * bv * ( delay + ai / speed ) );

            float aj = (float)(Math.Sqrt((ax-jx)*(ax-jx)+(ay-jy)*(ay-jy)));
            float bj = (float)(Math.Sqrt((bx-jx)*(bx-jx)+(by-jy)*(by-jy)));

            float at = delay + aj / speed;
            float bt = bj / bv;
            if (at - bt > -0.05f && at - bt < 0.05f)
            {
                float x = jx - ( vx * ( width / 2f - Game.Ping / 2.15f ) );
                float y = jy - ( vy * ( width / 2f - Game.Ping / 2.15f ) );
                float bp = (float)(Math.Sqrt((bx-x)*(bx-x)+(by-y)*(by-y)));
                if (bp > bc)
                {
                    x = cx;
                    y = cy;
                }
                float ap = (float)(Math.Sqrt((ax-x)*(ax-x)+(ay-y)*(ay-y)));
                if (ap < range + ObjectManager.Player.BoundingRadius)
                {
                    Vector3 pos = new Vector3 {X = x, Y = y};
                    float pl = (float)(Math.Sqrt((target.RealPath().LastOrDefault().X-cx)*(target.RealPath().LastOrDefault().X-cx)+(target.RealPath().LastOrDefault().Y-cy)*(target.RealPath().LastOrDefault().Y-cy)));
                    if (pl < 50f)
                    {
                        if (minioncollision || championcollision)
                        {
                            var MinionCollision = EntityManager.MinionsAndMonsters.EnemyMinions.Any(minion=>minion.IsValidTarget(ap+200f) && CollisionDetection(minion, ObjectManager.Player, pos, ap, delay, speed, width));
                            var HeroesCollision = EntityManager.Heroes.Enemies.Any(hero=>hero != target && hero.IsValidTarget(ap+200f) && CollisionDetection(hero, ObjectManager.Player, pos, ap, delay, speed, width));
                            if ((!minioncollision || !MinionCollision) && (!championcollision || !HeroesCollision))
                            {
                                Player.CastSpell(spellslot, pos);
                            }
                        }
                        else
                        {
                            Player.CastSpell(spellslot, pos);
                        }
                    }
                }
            }
              	}
            else
            {
            float ax = ObjectManager.Player.ServerPosition.X;
            float ay = ObjectManager.Player.ServerPosition.Y;

            float bx = target.ServerPosition.X;
            float by = target.ServerPosition.Y;

            float cx = target.RealPath().LastOrDefault().X;
            float cy = target.RealPath().LastOrDefault().Y;

            float bc = (float)(Math.Sqrt((bx-cx)*(bx-cx)+(by-cy)*(by-cy)));
            float vx = ( cx - bx ) / bc;
            float vy = ( cy - by ) / bc;

            float x = bx + ( vx * target.MoveSpeed * delay );
            float y = by + ( vy * target.MoveSpeed * delay );

            float xx = x - vx * ( width / 2f - Game.Ping / 2.15f );
            float yy = y - vy * ( width / 2f - Game.Ping / 2.15f );

            float bp = (float)(Math.Sqrt((bx-xx)*(bx-xx)+(by-yy)*(by-yy)));
            if (bp > bc)
            {
                xx = cx;
                yy = cy;
            }
            float ap = (float)(Math.Sqrt((ax-xx)*(ax-xx)+(ay-yy)*(ay-yy)));
            if (ap < range + ObjectManager.Player.BoundingRadius)
            {
//.........这里部分代码省略.........
开发者ID:giaanthunder,项目名称:EloBuddy,代码行数:101,代码来源:myPrediction.cs

示例2: GetAngle

        internal static double GetAngle(Vector3 from, Obj_AI_Base target)
        {
            var C = target.ServerPosition.To2D();
            var A = target.RealPath().LastOrDefault().To2D();

            if (C == A)
                return 60;

            var B = from.To2D();

            var AB = Math.Pow((double)A.X - (double)B.X, 2) + Math.Pow((double)A.Y - (double)B.Y, 2);
            var BC = Math.Pow((double)B.X - (double)C.X, 2) + Math.Pow((double)B.Y - (double)C.Y, 2);
            var AC = Math.Pow((double)A.X - (double)C.X, 2) + Math.Pow((double)A.Y - (double)C.Y, 2);

            return Math.Cos((AB + BC - AC) / (2 * Math.Sqrt(AB) * Math.Sqrt(BC))) * 180 / Math.PI;
        }
开发者ID:giaanthunder,项目名称:EloBuddy,代码行数:16,代码来源:myPrediction.cs

示例3: CollisionDetection

        static bool CollisionDetection(Obj_AI_Base unit, Obj_AI_Base startlinepoint, Vector3 endlinepoint, float distPlayertoT, float delay, float speed, float width)
        {
            float sx = startlinepoint.ServerPosition.X;
              float sy = startlinepoint.ServerPosition.Y;

              float ex = endlinepoint.X;
              float ey = endlinepoint.Y;

              float ux = unit.ServerPosition.X;
              float uy = unit.ServerPosition.Y;
              float uv = unit.MoveSpeed;

              float unx = unit.RealPath().LastOrDefault().X;
              float uny = unit.RealPath().LastOrDefault().Y;

              float eu = (float)Math.Sqrt((ex - ux) * ( ex - ux ) + ( ey - uy ) * ( ey - uy ));
              float su = (float)Math.Sqrt(( sx - ux ) * ( sx - ux ) + ( sy - uy ) * ( sy - uy ));
              float unu = (float)(Math.Sqrt((ux-unx)*(ux-unx)+(uy-uny)*(uy-uny)));

              if (eu < distPlayertoT + 250f && su < distPlayertoT + 250f)
              {
            float a = ey - sy;
            float b = ex - sx;
            float d = Math.Abs(a * (sx - ux) + b * (uy - sy )) / (float)Math.Sqrt(a * a + b * b);
            float r = width / 2 + unit.BoundingRadius / 2 + speed * ( delay + su / speed ) / unit.BoundingRadius / 2 + 25f;
            if (eu <= distPlayertoT + 50f && su <= distPlayertoT + 50f && r >= d)
            {
              return true;
            }
            if (r < d)
            {
              float vx = ( unx - ux ) / unu;
              float vy = ( uny - uy ) / unu;

              float ab = (float)(Math.Sqrt((sx-ux)*(sx-ux)+(sy-uy)*(sy-uy)));

              float hx = ux + ( vx * uv * ( delay + ab / speed ) );
              float hy = uy + ( vy * uv * ( delay + ab / speed ) );
              float ah = (float)(Math.Sqrt((hx-sx)*(hx-sx)+(hy-sy)*(hy-sy)));

              float ix = ux + ( vx * uv * ( delay + ah / speed ) );
              float iy = uy + ( vy * uv * ( delay + ah / speed ) );
              float ai = (float)(Math.Sqrt((ix-sx)*(ix-sx)+(iy-sy)*(iy-sy)));

              float jx = ux + ( vx * uv * ( delay + ai / speed ) );
              float jy = uy + ( vy * uv * ( delay + ai / speed ) );

              float sj = (float)(Math.Sqrt((sx-jx)*(sx-jx)+(sy-jy)*(sy-jy)));
              float ej = (float)(Math.Sqrt((ex-jx)*(ex-jx)+(ey-jy)*(ey-jy)));
              float uj = (float)(Math.Sqrt((ux-jx)*(ux-jx)+(uy-jy)*(uy-jy)));

              float at = delay + sj / speed;
              float bt = uj / uv;

              if (at - bt > -0.05f && at - bt < 0.05f)
              {
            if (uj > unu)
            {
              jx = unx;
              jy = uny;
            }
            if (sj < distPlayertoT + 50f && ej < distPlayertoT + 50f)
            {
              float pl = (float)(Math.Sqrt((unit.RealPath().LastOrDefault().X-unx)*(unit.RealPath().LastOrDefault().X-unx)+(unit.RealPath().LastOrDefault().Y-uny)*(unit.RealPath().LastOrDefault().Y-uny)));
              if (pl < 25f)
              {
                float dd = Math.Abs(a * (sx - jx) + b * (jy - sy )) / (float)Math.Sqrt(a * a + b * b);
                if (r >= dd)
                {
                  return true;
                }
              }
            }
              }
            }
              }
              return false;
        }
开发者ID:giaanthunder,项目名称:EloBuddy,代码行数:78,代码来源:myPrediction.cs

示例4: GetHitChance

        public static HitChance GetHitChance(SpellSlot spellslot, float range, SkillShotType type, float delay, float speed, float radius,Vector3 fromPoint, Obj_AI_Base target)
        {
            // CAN'T MOVE SPELLS ///////////////////////////////////////////////////////////////////////////////////

            if (UnitTracker.GetSpecialSpellEndTime(target) > 0 || target.HasBuff("recall") || (UnitTracker.GetLastStopMoveTime(target) < 0.1d && target.IsRooted))
            {
            return HitChance.High;
            }

            // PREPARE MATH ///////////////////////////////////////////////////////////////////////////////////

            var tempHitchance = HitChance.Low;

            var lastWaypiont = target.RealPath().Last();
            var distanceUnitToWaypoint = lastWaypiont.Distance(target.ServerPosition);
            var distanceFromToUnit = fromPoint.Distance(target.ServerPosition);
            var distanceFromToWaypoint = lastWaypiont.Distance(fromPoint);
            var getAngle = GetAngle(fromPoint, target);
            float speedDelay = distanceFromToUnit / speed;

            if (Math.Abs(speed - float.MaxValue) < float.Epsilon)
            speedDelay = 0;

            float totalDelay = speedDelay + delay;
            float moveArea = target.MoveSpeed * totalDelay;
            float fixRange = moveArea * 0.4f;
            float pathMinLen = 900 + + moveArea;
            double angleMove = 31;

            if (radius > 70)
            angleMove ++;
            else if (radius <= 60)
            angleMove--;
            if (delay < 0.3)
            angleMove++;

            if (UnitTracker.GetLastNewPathTime(target) < 0.1d)
            {
            tempHitchance = HitChance.High;
            pathMinLen = 700f + moveArea;
            angleMove += 1.5;
            fixRange = moveArea * 0.3f;
            }

            if (type == SkillShotType.Circular)
            {
            fixRange -= radius / 2;
            }

            // FIX RANGE ///////////////////////////////////////////////////////////////////////////////////
            if (distanceFromToWaypoint <= distanceFromToUnit)
            {
            if (distanceFromToUnit > range - fixRange)
            {
                tempHitchance = HitChance.Medium;
                // return tempHitchance;
            }
            }
            else if (distanceUnitToWaypoint > 350)
            {
            angleMove += 1.5;
            }

            // SPAM CLICK ///////////////////////////////////////////////////////////////////////////////////

            if (UnitTracker.PathCalc(target))
            {
            //OktwCommon.debug("PRED: SPAM CLICK");
            if(distanceFromToUnit < range - fixRange)
                tempHitchance = HitChance.High;
            else
                tempHitchance = HitChance.Medium;
            // return tempHitchance;
            }

            // SPAM POSITION ///////////////////////////////////////////////////////////////////////////////////

            if (UnitTracker.SpamSamePlace(target))
            {
            //OktwCommon.debug("PRED: SPAM POSITION");
            return HitChance.High;
            }

            // SPECIAL CASES ///////////////////////////////////////////////////////////////////////////////////

            if (distanceFromToUnit < 250)
            {
            //OktwCommon.debug("PRED: SPECIAL CASES NEAR");
            return HitChance.High;
            }
            else if( target.MoveSpeed < 250)
            {
            //OktwCommon.debug("PRED: SPECIAL CASES SLOW");
            return HitChance.High;
            }
            else if(distanceFromToWaypoint < 250)
            {
            //OktwCommon.debug("PRED: SPECIAL CASES ON WAY");
            return HitChance.High;
            }
//.........这里部分代码省略.........
开发者ID:giaanthunder,项目名称:EloBuddy,代码行数:101,代码来源:myPrediction.cs


注:本文中的Obj_AI_Base.RealPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。