Пример #1
0
        public static PositionInfo GetScreenPosition(Vector3 position3D)
        {
            var position = position3D.To2D();

            var worldCenter = GetWorldCenter();
            var screenCenter = Drawing.WorldToScreen(worldCenter.To3D().SetZ(0));

            if (position3D.IsOnScreen())
            {
                var screenPosition = Drawing.WorldToScreen(position3D);

                return new PositionInfo
                {
                screenPosition = screenPosition,
                direction = (screenPosition - screenCenter).Normalized(),
                distance = worldCenter.Distance(position),
                screenCollisionDistance = worldCenter.Distance(position)
                };
            }

            var worldDir = (position - worldCenter).Normalized();
            var worldClosePosition = worldCenter + worldDir * 100;

            var screenClosePosition = Drawing.WorldToScreen(worldClosePosition.To3D().SetZ(0));

            var dir = (screenClosePosition - screenCenter).Normalized();
            var screenFarPosition = screenCenter + dir * (Math.Max(Drawing.Width, Drawing.Height) + 100);

            var ray = new Ray(screenFarPosition.To3D().SetZ(0), -dir.To3D().SetZ(0));

            var boundingBox = new BoundingBox(new Vector3(0, 0, -1),
                new Vector3(Drawing.Width, Drawing.Height, 1));

            float dist;
            var hasIntersection = ray.Intersects(ref boundingBox, out dist);

            if (hasIntersection)
            {
                var rayDirection = dir;
                var distance = worldCenter.Distance(position);
                var finalScreenPos = screenFarPosition - dir * (dist);

                return new PositionInfo
                {
                    screenPosition = position3D.IsOnScreen() ?
                            Drawing.WorldToScreen(position3D) : finalScreenPos,
                    direction = rayDirection,
                    distance = distance,
                    screenCollisionDistance = dist
                };
            }

            //Console.WriteLine("no intersect");

            return null;
        }
Пример #2
0
            public Camp(string name,
                float spawnTime,
                int respawnTimer,
                Vector3 position,
                List<Mob> mobs,
                Utility.Map.MapType mapType,
                GameObjectTeam team,
                Color colour,
                Timers timer,
                bool isRanged = false,
                int state = 0,
                int respawnTime = 0,
                int lastChangeOnState = 0,
                bool shouldping = true,
                int lastPing = 0)
            {
                Name = name;
                SpawnTime = spawnTime;
                RespawnTimer = respawnTimer;
                Position = position;
                MapPosition = Drawing.WorldToScreen(Position);
                MinimapPosition = Drawing.WorldToMinimap(Position);
                Mobs = mobs;
                MapType = mapType;
                Team = team;
                Colour = colour;
                IsRanged = isRanged;
                State = state;
                RespawnTime = respawnTime;
                LastChangeOnState = lastChangeOnState;
                Timer = timer;
                ShouldPing = shouldping;
                LastPing = lastPing;

                #region Load Text

                TextMinimap = new Render.Text(0, 0, "", Program._menu.Item("timerfontminimap").GetValue<Slider>().Value, Program.White)
                {
                    VisibleCondition =
                        sender =>
                            Program.Timeronminimap && RespawnTime > Environment.TickCount && State == 7,
                    PositionUpdate = delegate
                    {
                        Vector2 v2 = Timer.MinimapPosition;
                        return v2;
                    },
                    TextUpdate = () => Timer.TextOnMinimap,
                    OutLined = false,
                    Centered = true
                };
                TextMinimap.Add();

                TextMap = new Render.Text(0, 0, "", Program._menu.Item("timerfontmap").GetValue<Slider>().Value, Program.White)
                {
                    VisibleCondition =
                        sender =>
                            Program.Timeronmap && RespawnTime > Environment.TickCount && State == 7 && Position.IsOnScreen(),
                    PositionUpdate = delegate
                    {
                        Vector2 v2 = Timer.Position;
                        return v2;
                    },
                    TextUpdate = () => Timer.TextOnMap,
                    OutLined = false,
                    Centered = true
                };
                TextMap.Add();

                #endregion

                //Drawing.OnEndScene += Drawing_OnEndScene;
            }
Пример #3
0
 private bool IsOnScreen(Vector3 position)
 {
     if (position.IsOnScreen())
     {
         return true;
     }
     if (!(Game.CursorPos.Distance(position) > 250f))
     {
         return true;
     }
     return (Drawing.WorldToScreen(Game.CursorPos).Distance(Utils.GetCursorPos()) <= 100f);
 }