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


C# Vector3.ToVector2方法代码示例

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


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

示例1: IsFountain

 public static bool IsFountain(Vector3 position)
 {
     float fountainRange = 750;
     var map = Map.GetMap();
     if (map != null && map.Type == MapType.SummonersRift)
     {
         fountainRange = 1050;
     }
     return ObjectManager.Get<GameObject>().Where(spawnPoint => spawnPoint is Obj_SpawnPoint && spawnPoint.IsAlly).Any(spawnPoint => Vector2.Distance(position.ToVector2(), spawnPoint.Position.ToVector2()) < fountainRange);
 }
开发者ID:evangelineak1026,项目名称:LeagueSharp,代码行数:10,代码来源:Helpers.cs

示例2: GetAngle

 private static double GetAngle(Vector3 from, Obj_AI_Base target)
 {
     var c = target.ServerPosition.ToVector2();
     var a = target.GetWaypoints().Last();
     if (c == a)
     {
         return 60;
     }
     var b = from.ToVector2();
     var ab = Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2);
     var bc = Math.Pow(b.X - c.X, 2) + Math.Pow(b.Y - c.Y, 2);
     var ac = Math.Pow(a.X - c.X, 2) + Math.Pow(a.Y - c.Y, 2);
     return Math.Cos((ab + bc - ac) / (2 * Math.Sqrt(ab) * Math.Sqrt(bc))) * 180 / Math.PI;
 }
开发者ID:seniseviy,项目名称:LeagueSharp-6,代码行数:14,代码来源:Prediction.cs

示例3: update_

        private void update_(Vector3 startV3)
        {
            //raycast to test how far we could go..
                     Vector3 MaxRangeTestVector3=MathEx.GetPointAt(startV3, Range, MathEx.ToRadians(DirectionDegrees));

                     Vector2 RaycastTestV2;
                     //we use main grid providers raycast to test since we are looking at how far we can travel and not if anything is blocking us.
                     if (Navigation.MGP.Raycast(startV3.ToVector2(), MaxRangeTestVector3.ToVector2(), out RaycastTestV2))
                     {//Set our endpoint at the Hit point
                          MaxRangeTestVector3=RaycastTestV2.ToVector3();
                          MaxRangeTestVector3.Z=Navigation.MGP.GetHeight(MaxRangeTestVector3.ToVector2()); //adjust height acordingly!
                     }
                     Range=Vector3.Distance2D(ref startV3, ref MaxRangeTestVector3);

                     //lets see if we can stand here at all?
                     if (!Navigation.MGP.CanStandAt(MaxRangeTestVector3))
                     {

                          //just because raycast set our max range, we need to see if we can use that cell as a walking point!
                          if (!Navigation.CanRayCast(startV3, MaxRangeTestVector3, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
                          {
                                //loop to find a walkable range.
                                float currentRange=Range-2.5f;
                                float directionRadianFlipped=Navigation.FindDirection(MaxRangeTestVector3, startV3, true);
                                int maxTestAttempts=(int)(currentRange/2.5f);

                                for (int i=0; i<maxTestAttempts; i++)
                                {
                                     Vector3 newtestPoint=MathEx.GetPointAt(MaxRangeTestVector3, currentRange, directionRadianFlipped);
                                     newtestPoint.Z=Navigation.MGP.GetHeight(newtestPoint.ToVector2());//update Z
                                     if (Navigation.CanRayCast(startV3, newtestPoint, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
                                     {
                                          MaxRangeTestVector3=newtestPoint;
                                          break;
                                     }

                                     if (currentRange-2.5f<=0f) break;
                                     currentRange=-2.5f;
                                }
                                Range=currentRange;
                          }

                     }

                     EndingPoint=MaxRangeTestVector3;
                     StartingPoint=startV3;
                     Range=startV3.Distance2D(MaxRangeTestVector3); //(float)GridPoint.GetDistanceBetweenPoints(StartingPoint, EndingPoint);
                     Center=MathEx.GetPointAt(startV3, Range/2, MathEx.ToRadians(DirectionDegrees));
        }
开发者ID:NEVEROYATNII,项目名称:Funky,代码行数:49,代码来源:DirectionPoint.cs

示例4: RingPoly

 /// <summary>
 ///     Initializes a new instance of the <see cref="RingPoly" /> class.
 /// </summary>
 /// <param name="center">
 ///     The Center
 /// </param>
 /// <param name="width">
 ///     The ring width
 /// </param>
 /// <param name="outerRadius">
 ///     Outer Radius
 /// </param>
 /// <param name="quality">
 ///     The Quality
 /// </param>
 public RingPoly(Vector3 center, float width, float outerRadius, int quality = 20)
     : this(center.ToVector2(), width, outerRadius, quality)
 {
 }
开发者ID:CONANLXF,项目名称:Berb.Common,代码行数:19,代码来源:RingPoly.cs

示例5: IsPathSafe

 public bool IsPathSafe(Vector3[] path)
 {
     return IsPathSafe(path.ToVector2());
 }
开发者ID:stefsot,项目名称:EloBuddyAddons,代码行数:4,代码来源:EvadePlus.cs

示例6: MoveTowards


//.........这里部分代码省略.........
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement,
                            "Tempest rush failed!: {0:00.0} / {1} distance: {2:00.0} / {3} Raycast: {4} MS: {5:0.0} lastUse={6:0}",
                            Trinity.Player.PrimaryResource,
                            Trinity.Settings.Combat.Monk.TR_MinSpirit,
                            destinationDistance,
                            Trinity.Settings.Combat.Monk.TR_MinDist,
                            canRayCastTarget,
                            GetMovementSpeed(),
                            lastUse);

                        Trinity.MaintainTempestRush = false;
                    }

                    // Always set this from PlayerMover
                    MonkCombat.LastTempestRushLocation = vTargetAimPoint;

                }

                // Dashing Strike OOC
                if (Trinity.Player.ActorClass == ActorClass.Monk && CombatBase.CanCast(SNOPower.X1_Monk_DashingStrike) && Trinity.Settings.Combat.Monk.UseDashingStrikeOOC &&
                    (destinationDistance > 12f || !NavHelper.CanRayCast(destination) || TargetUtil.UnitsPlayerFacing(15, 90) >=3)
                    && (!(Legendary.Ingeom.IsEquipped && CurrentTarget != null && CurrentTarget.Type == TrinityObjectType.Item) && Skills.Monk.DashingStrike.TimeSinceUse > 200))
                {
                    var charges = Skills.Monk.DashingStrike.Charges;

                    //Logger.LogVerbose("OOC Dash Charges={0}", charges);
                    if (Sets.ThousandStorms.IsSecondBonusActive && !Trinity.ShouldWaitForLootDrop &&
                        (charges > 1 || CacheData.BuffsCache.Instance.HasCastingShrine))
                    {
                        if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Dashing Strike for OOC movement, distance={0} charges={1}", destinationDistance, Skills.Monk.DashingStrike.Charges);
                        Skills.Monk.DashingStrike.Cast(destination);
                        return;
                    }

                    if (!Sets.ThousandStorms.IsSecondBonusActive && charges > 0 && PowerManager.CanCast(Skills.Monk.DashingStrike.SNOPower) && !Trinity.ShouldWaitForLootDrop)
                    {
                        Skills.Monk.DashingStrike.Cast(destination);
                        if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                            Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Dashing Strike for OOC movement, distance={0}", destinationDistance);
                        return;  
                    }
                }

                // Teleport for a wizard 
                if (!Runes.Wizard.Calamity.IsActive && CombatBase.CanCast(SNOPower.Wizard_Teleport, CombatBase.CanCastFlags.NoTimer) &&
                    CombatBase.TimeSincePowerUse(SNOPower.Wizard_Teleport) > 250 &&
                    destinationDistance >= 10f && !ShrinesInArea(destination))
                {
                    const float maxTeleportRange = 75f;

                    Vector3 vThisTarget = destination;
                    if (destinationDistance > maxTeleportRange)
                        vThisTarget = MathEx.CalculatePointFrom(destination, MyPosition, maxTeleportRange);
                    ZetaDia.Me.UsePower(SNOPower.Wizard_Teleport, vThisTarget, Trinity.CurrentWorldDynamicId, -1);
                    SpellHistory.RecordSpell(SNOPower.Wizard_Teleport);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Teleport for OOC movement, distance={0}", destinationDistance);
                    return;
                }

                // Archon Teleport for a wizard 
                if (CacheData.Hotbar.ActivePowers.Contains(SNOPower.Wizard_Archon_Teleport) && destinationDistance >= 10f &&
                PowerManager.CanCast(SNOPower.Wizard_Archon_Teleport) && !ShrinesInArea(destination))
                {
                    Vector3 vThisTarget = destination;
                    if (destinationDistance > 35f)
                        vThisTarget = MathEx.CalculatePointFrom(destination, MyPosition, 35f);
                    ZetaDia.Me.UsePower(SNOPower.Wizard_Archon_Teleport, vThisTarget, Trinity.CurrentWorldDynamicId, -1);
                    SpellHistory.RecordSpell(SNOPower.Wizard_Archon_Teleport);
                    if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                        Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Using Archon Teleport for OOC movement, distance={0}", destinationDistance);
                    return;
                }


            }

            if (MyPosition.Distance2D(destination) > 3f)
            {
                // Default movement
                ZetaDia.Me.UsePower(SNOPower.Walk, destination, Trinity.CurrentWorldDynamicId, -1);

                if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                    Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "PlayerMover Moved to:{0} dir:{1} Speed:{2:0.00} Dist:{3:0} ZDiff:{4:0} CanStand:{5} Raycast:{6}",
                        NavHelper.PrettyPrintVector3(destination), MathUtil.GetHeadingToPoint(destination), MovementSpeed, MyPosition.Distance2D(destination),
                        Math.Abs(MyPosition.Z - destination.Z),
                        Trinity.MainGridProvider.CanStandAt(Trinity.MainGridProvider.WorldToGrid(destination.ToVector2())),
                        !Navigator.Raycast(MyPosition, destination)
                        );

            }
            else
            {
                if (Trinity.Settings.Advanced.LogCategories.HasFlag(LogCategory.Movement))
                    Logger.Log(TrinityLogLevel.Debug, LogCategory.Movement, "Reached MoveTowards Destination {0} Current Speed: {1:0.0}", destination, MovementSpeed);
            }

            //Trinity.IsMoveRequested = false;
        }
开发者ID:FalseApple,项目名称:d3db,代码行数:101,代码来源:PlayerMover.cs

示例7: IsHitCollision

        private static bool IsHitCollision(Obj_AI_Base collision, ICloneable input, Vector3 pos, float extraRadius)
        {
            var inputSub = input.Clone() as PredictionInput;

            if (inputSub == null)
            {
                return false;
            }

            inputSub.Unit = collision;
            var radius = inputSub.Unit.BoundingRadius;
            var predPos = Movement.GetPrediction(inputSub, false, false).UnitPosition.ToVector2();

            return (collision is Obj_AI_Minion
                    && (predPos.Distance(inputSub.From) < 10 + radius || predPos.Distance(pos) < radius))
                   || predPos.LSDistanceSquared(inputSub.From.ToVector2(), pos.ToVector2(), true)
                   <= Math.Pow(inputSub.Radius + radius + extraRadius, 2);
        }
开发者ID:CONANLXF,项目名称:Berb.Common,代码行数:18,代码来源:Collision.cs

示例8: Rectangle

 /// <summary>
 ///     Initializes a new instance of the <see cref="Rectangle" /> class.
 /// </summary>
 /// <param name="start">The start.</param>
 /// <param name="end">The end.</param>
 /// <param name="width">The width.</param>
 public Rectangle(Vector3 start, Vector3 end, float width)
     : this(start.ToVector2(), end.ToVector2(), width)
 {
 }
开发者ID:yashine59fr,项目名称:PortAIO,代码行数:10,代码来源:Geometry.cs

示例9: WillHit

        /// <summary>
        ///     Returns if the spell will hit the point when casted
        /// </summary>
        /// <param name="point">
        ///     Vector3 Target
        /// </param>
        /// <param name="castPosition">
        ///     Cast Position
        /// </param>
        /// <param name="extraWidth">
        ///     Extra Width
        /// </param>
        /// <returns>
        ///     Will Spell Hit
        /// </returns>
        public bool WillHit(Vector3 point, Vector3 castPosition, int extraWidth = 0)
        {
            switch (this.Type)
            {
                case SkillshotType.SkillshotCircle:
                    if (point.LSDistanceSquared(castPosition) < this.WidthSqr)
                    {
                        return true;
                    }

                    break;

                case SkillshotType.SkillshotLine:
                    if (point.ToVector2().LSDistanceSquared(castPosition.ToVector2(), this.From.ToVector2(), true)
                        < Math.Pow(this.Width + extraWidth, 2))
                    {
                        return true;
                    }

                    break;
                case SkillshotType.SkillshotCone:
                    var edge1 = (castPosition.ToVector2() - this.From.ToVector2()).Rotated(-this.Width / 2);
                    var edge2 = edge1.Rotated(this.Width);
                    var v = point.ToVector2() - this.From.ToVector2();
                    if (point.LSDistanceSquared(this.From) < this.RangeSqr && edge1.CrossProduct(v) > 0
                        && v.CrossProduct(edge2) > 0)
                    {
                        return true;
                    }

                    break;
            }

            return false;
        }
开发者ID:CONANLXF,项目名称:Berb.Common,代码行数:50,代码来源:Spell.cs

示例10: FindAngleBetween

 /// <summary>
 ///     Angle between a entity and a vector in degrees
 /// </summary>
 /// <param name="entity">
 ///     The entity.
 /// </param>
 /// <param name="vector">
 ///     The vector.
 /// </param>
 /// <param name="radian">
 ///     The radian.
 /// </param>
 /// <returns>
 ///     The <see cref="float" />.
 /// </returns>
 public static float FindAngleBetween(this Entity entity, Vector3 vector, bool radian = false)
 {
     return entity.Position.ToVector2().FindAngleBetween(vector.ToVector2(), radian);
 }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:19,代码来源:EntityExtensions.cs

示例11: TraceRay_Projectile_CanPass

 public bool TraceRay_Projectile_CanPass(Vector3 from, Vector3 to)
 {
     Cell cellByPoint = this.GetCellByPoint(from);
     Cell cellByPoint2 = this.GetCellByPoint(to);
     bool result;
     if (cellByPoint2 == null || cellByPoint == null)
     {
         result = false;
     }
     else
     {
         if (cellByPoint2 == cellByPoint)
         {
             result = true;
         }
         else
         {
             if (!cellByPoint.AllowWalk || !cellByPoint2.AllowWalk)
             {
                 result = false;
             }
             else
             {
                 LineSegment lineSegment_ = new LineSegment(from.ToVector2(), to.ToVector2());
                 Cell cell = cellByPoint;
                 int num = 0;
                 List<Cell> list = new List<Cell>();
                 list.Add(cellByPoint);
                 while (cell != cellByPoint2)
                 {
                     if (++num >= 15)
                     {
                         result = false;
                         return result;
                     }
                     cell = cell.method_0(lineSegment_);
                     if (cell == null)
                     {
                         result = false;
                         return result;
                     }
                     if (!cell.AllowWalk)
                     {
                         result = false;
                         return result;
                     }
                     list.Add(cell);
                 }
                 result = true;
             }
         }
     }
     return result;
 }
开发者ID:JohnDeerexx,项目名称:project-respawn,代码行数:54,代码来源:Navi.cs

示例12: IsThroughWall

 private static bool IsThroughWall(Vector3 from, Vector3 to)
 {
     if (wallLeft == null || wallRight == null)
     {
         return false;
     }
     wallPoly = new RectanglePoly(wallLeft.Position, wallRight.Position, 75);
     for (var i = 0; i < wallPoly.Points.Count; i++)
     {
         var inter = wallPoly.Points[i].LSIntersection(
             wallPoly.Points[i != wallPoly.Points.Count - 1 ? i + 1 : 0],
             from.ToVector2(),
             to.ToVector2());
         if (inter.Intersects)
         {
             return true;
         }
     }
     return false;
 }
开发者ID:yashine59fr,项目名称:PortAIO-1,代码行数:20,代码来源:Yasuo.cs

示例13: CastSkillShot

        /// <summary>
        ///     Uses prediction to cast given skill shot ability
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="sourcePosition">
        ///     The source Position.
        /// </param>
        /// <param name="abilityName">
        ///     The ability Name.
        /// </param>
        /// <param name="soulRing">
        ///     The soul Ring.
        /// </param>
        /// <param name="otherTargets">
        ///     Targets which are supposed to be hit by AOE Skill Shot
        /// </param>
        /// <returns>
        ///     returns true in case of successful cast
        /// </returns>
        public static bool CastSkillShot(
            this Ability ability, 
            Unit target, 
            Vector3 sourcePosition, 
            string abilityName = null, 
            Ability soulRing = null, 
            List<Unit> otherTargets = null)
        {
            if (ability == null || !ability.IsValid)
            {
                return false;
            }

            if (target == null || !target.IsValid)
            {
                return false;
            }

            if (!Utils.SleepCheck("CastSkillshot" + ability.Handle))
            {
                return false;
            }

            var name = abilityName ?? ability.StoredName();
            var owner = ability.Owner as Unit;
            var position = sourcePosition;
            var delay = ability.GetHitDelay(target, name);
            var data = ability.CommonProperties();

            // delay += data.AdditionalDelay;
            if (target.IsInvul() && !Utils.ChainStun(target, delay, null, false))
            {
                return false;
            }

            var xyz = ability.GetPrediction(target, abilityName: name);
            if (otherTargets != null)
            {
                var avPosX = otherTargets.Average(x => ability.GetPrediction(x, abilityName: name).X);
                var avPosY = otherTargets.Average(x => ability.GetPrediction(x, abilityName: name).Y);
                xyz = (xyz + new Vector3(avPosX, avPosY, 0)) / 2;
            }

            var radius = ability.GetRadius(name);
            var range = ability.TravelDistance();

            if (data.AllyBlock)
            {
                if (
                    Creeps.All.Any(
                        x =>
                        x.IsValid && x.IsAlive && x.Team == owner.Team && x.Distance2D(xyz) <= range
                        && x.Distance2D(owner) < owner.Distance2D(target)
                        && x.Position.ToVector2().DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                        <= radius + x.HullRadius))
                {
                    return false;
                }

                if (
                    Heroes.GetByTeam(owner.Team)
                        .Any(
                            hero =>
                            hero.IsAlive && !hero.Equals(owner) && !hero.Equals(target) && hero.Distance2D(xyz) <= range
                            && hero.Distance2D(owner) < owner.Distance2D(target)
                            && hero.Position.ToVector2()
                                   .DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                            <= radius + hero.HullRadius))
                {
                    return false;
                }
            }

            if (data.EnemyBlock)
            {
                if (
//.........这里部分代码省略.........
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:101,代码来源:AbilityExtensions.cs

示例14: LaneClear

        private static void LaneClear()
        {
            if (ObjectManager.Player.ManaPercent < main_menu["taliyah.laneclear"]["taliyah.laneclear.manaperc"].GetValue<MenuSlider>().Value)
                return;

            if (main_menu["taliyah.laneclear"]["taliyah.laneclear.useq"].GetValue<MenuBool>().Value && Q.IsReady())
            {
                var farm = Q.GetCircularFarmLocation(ObjectManager.Get<Obj_AI_Minion>().Where(p => p.IsEnemy && p.DistanceToPlayer() < Q.Range).ToList());
                if (farm.MinionsHit >= main_menu["taliyah.laneclear"]["taliyah.laneclear.minq"].GetValue<MenuSlider>().Value)
                    Q.Cast(farm.Position);
            }

            if (main_menu["taliyah.laneclear"]["taliyah.laneclear.useew"].GetValue<MenuBool>().Value && W.IsReady() && E.IsReady())
            {
                var farm = W.GetCircularFarmLocation(ObjectManager.Get<Obj_AI_Minion>().Where(p => p.IsEnemy && p.DistanceToPlayer() < W.Range).ToList());
                if (farm.MinionsHit >= main_menu["taliyah.laneclear"]["taliyah.laneclear.minew"].GetValue<MenuSlider>().Value)
                {
                    E.Cast(farm.Position);
                    lastE = ObjectManager.Player.ServerPosition;
                    if (W.Instance.Name == "TaliyahW")
                        W.Cast(farm.Position, lastE.ToVector2());
                }
            }
        }
开发者ID:ShineSharp,项目名称:LeagueSharp,代码行数:24,代码来源:Program.cs

示例15: PositionInsideIgnoredScene

        /// <summary>
        /// Determines if a given Vector3 is in a provided IgnoreScene (if the scene is loaded)
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        private bool PositionInsideIgnoredScene(Vector3 position)
        {
            List<Scene> ignoredScenes=ZetaDia.Scenes.GetScenes()
                .Where(scn => IgnoreScenes.Any(igscn => !String.IsNullOrEmpty(igscn.SceneName)&&scn.Name.ToLower().Contains(igscn.SceneName.ToLower()))||
                              IgnoreScenes.Any(igscn => scn.SceneInfo.SNOId==igscn.SceneId)&&
                              !PriorityScenes.Any(psc => !String.IsNullOrEmpty(psc.SceneName.Trim())&&scn.Name.ToLower().Contains(psc.SceneName))&&
                              !PriorityScenes.Any(psc => psc.SceneId!=-1&&scn.SceneInfo.SNOId!=psc.SceneId)).ToList();

            foreach (Scene scene in ignoredScenes)
            {
                if (scene.Mesh.Zone==null)
                    return true;

                Vector2 pos=position.ToVector2();
                Vector2 min=scene.Mesh.Zone.ZoneMin;
                Vector2 max=scene.Mesh.Zone.ZoneMax;

                if (pos.X>=min.X&&pos.X<=max.X&&pos.Y>=min.Y&&pos.Y<=max.Y)
                    return true;
            }
            return false;
        }
开发者ID:NEVEROYATNII,项目名称:Funky,代码行数:27,代码来源:TrinityExploreDungeon.cs


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