本文整理汇总了C#中System.Vector3.IsOnScreen方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.IsOnScreen方法的具体用法?C# Vector3.IsOnScreen怎么用?C# Vector3.IsOnScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector3
的用法示例。
在下文中一共展示了Vector3.IsOnScreen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetScreenPosition
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: Camp
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: IsOnScreen
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);
}