本文整理汇总了C#中GuiRenderer.AddQuad方法的典型用法代码示例。如果您正苦于以下问题:C# GuiRenderer.AddQuad方法的具体用法?C# GuiRenderer.AddQuad怎么用?C# GuiRenderer.AddQuad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuiRenderer
的用法示例。
在下文中一共展示了GuiRenderer.AddQuad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTarget
/// <summary>
/// Draw a target at center of screen
/// </summary>
/// <param name="renderer"></param>
void DrawTarget( GuiRenderer renderer )
{
Unit playerUnit = GetPlayerUnit();
Weapon weapon = null;
{
//PlayerCharacter specific
PlayerCharacter playerCharacter = playerUnit as PlayerCharacter;
if( playerCharacter != null )
weapon = playerCharacter.ActiveWeapon;
//Turret specific
Turret turret = playerUnit as Turret;
if( turret != null )
weapon = turret.MainGun;
//Tank specific
Tank tank = playerUnit as Tank;
if( tank != null )
weapon = tank.MainGun;
}
//draw quad
if( weapon != null || currentAttachedGuiObject != null || currentSwitch != null )
{
Texture texture = TextureManager.Instance.Load( "Cursors/Target.png" );
float size = .02f;
float aspect = RendererWorld.Instance.DefaultCamera.AspectRatio;
Rect rectangle = new Rect(
.5f - size, .5f - size * aspect,
.5f + size, .5f + size * aspect );
renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), texture );
}
//Tank specific
DrawTankGunTarget( renderer );
}
示例2: RenderFadingOut
private void RenderFadingOut(GuiRenderer renderer)
{
if (IsScreenFadingOut())
{
if (fadingOutTimer != 0)
{
float alpha = 1.0f - fadingOutTimer / fadingTime;
MathFunctions.Saturate(ref alpha);
renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha));
}
}
}
示例3: OnRenderUI
protected override void OnRenderUI( GuiRenderer renderer )
{
base.OnRenderUI( renderer );
Vec2I size = GetNeededSize();
if( browser == null )
CreateBrowser();
//update brower engine and texture
if( browser != null )
{
if( viewSize != size /*&& !browser.IsResizing */)
{
var oldSize = viewSize;
viewSize = size;
OnResized( oldSize, viewSize );
}
//create texture
if( texture == null || textureSize != size )
{
if( texture != null )
{
texture.Dispose();
texture = null;
}
textureSize = size;
string textureName = TextureManager.Instance.GetUniqueName( "WebBrowserControl" );
texture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize,
1, 0, PixelFormat.A8R8G8B8, Texture.Usage.DynamicWriteOnlyDiscardable );
forceUpdateTexture = true;
}
//update texture
if( /*browser.IsDirty ||*/ forceUpdateTexture )
{
if( texture != null )
UpdateTexture();
forceUpdateTexture = false;
}
}
//draw texture
{
bool backColorZero = BackColor == new ColorValue( 0, 0, 0, 0 );
ColorValue color = backColorZero ? new ColorValue( 1, 1, 1 ) : BackColor;
if( texture == null )
color = new ColorValue( 0, 0, 0, color.Alpha );
color *= GetTotalColorMultiplier();
color.Clamp( new ColorValue( 0, 0, 0, 0 ), new ColorValue( 1, 1, 1, 1 ) );
Rect rect;
GetScreenRectangle( out rect );
if( renderer.IsScreen && !renderer._OutGeometryTransformEnabled )
{
//screen per pixel accuracy
Vec2 viewportSize = renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();
Vec2 leftTop = rect.LeftTop;
leftTop *= viewportSize;
leftTop = new Vec2( (int)( leftTop.X + .9999f ), (int)( leftTop.Y + .9999f ) );
if( RenderSystem.Instance.IsDirect3D() )
leftTop -= new Vec2( .5f, .5f );
leftTop /= viewportSize;
Vec2 rightBottom = rect.RightBottom;
rightBottom *= viewportSize;
rightBottom = new Vec2( (int)( rightBottom.X + .9999f ), (int)( rightBottom.Y + .9999f ) );
if( RenderSystem.Instance.IsDirect3D() )
rightBottom -= new Vec2( .5f, .5f );
rightBottom /= viewportSize;
Rect fixedRect = new Rect( leftTop, rightBottom );
renderer.AddQuad( fixedRect, new Rect( 0, 0, 1, 1 ), texture, color, true );
}
else
{
renderer.AddQuad( rect, new Rect( 0, 0, 1, 1 ), texture, color, true );
}
}
if( !IsSupportedByThisPlatform() )
{
renderer.AddText( string.Format( "WebBrowserControl: {0} is not supported.", PlatformInfo.Platform ),
new Vec2( .5f, .5f ), Renderer.HorizontalAlign.Center, Renderer.VerticalAlign.Center, new ColorValue( 1, 0, 0 ) );
}
}
示例4: DrawTankGunTarget
//Tank specific
void DrawTankGunTarget( GuiRenderer renderer )
{
Tank tank = GetPlayerUnit() as Tank;
if( tank == null )
return;
Gun gun = tank.MainGun;
if( gun == null )
return;
Vec3 gunPosition = gun.GetInterpolatedPosition();
Vec3 gunDirection = gun.GetInterpolatedRotation() * new Vec3( 1, 0, 0 );
RayCastResult[] piercingResult = PhysicsWorld.Instance.RayCastPiercing(
new Ray( gunPosition, gunDirection * 1000 ),
(int)ContactGroup.CastOnlyContact );
bool finded = false;
Vec3 pos = Vec3.Zero;
foreach( RayCastResult result in piercingResult )
{
bool ignore = false;
MapObject obj = MapSystemWorld.GetMapObjectByBody( result.Shape.Body );
Dynamic dynamic = obj as Dynamic;
if( dynamic != null && dynamic.GetParentUnit() == tank )
ignore = true;
if( !ignore )
{
finded = true;
pos = result.Position;
break;
}
}
if( !finded )
pos = gunPosition + gunDirection * 1000;
Vec2 screenPos;
RendererWorld.Instance.DefaultCamera.ProjectToScreenCoordinates( pos, out screenPos );
//draw quad
{
Texture texture = TextureManager.Instance.Load( "Cursors/Target.png" );
float size = .015f;
float aspect = RendererWorld.Instance.DefaultCamera.AspectRatio;
Rect rectangle = new Rect(
screenPos.X - size, screenPos.Y - size * aspect,
screenPos.X + size, screenPos.Y + size * aspect );
renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), texture,
new ColorValue( 0, 1, 0 ) );
}
}
示例5: DrawHUD
void DrawHUD( GuiRenderer renderer )
{
if( selectMode && selectDraggedMouse )
{
Rect rect = new Rect( selectStartPos );
rect.Add( EngineApp.Instance.MousePosition );
Vec2i windowSize = EngineApp.Instance.VideoMode.Size;
Vec2 thickness = new Vec2( 1.0f / (float)windowSize.X, 1.0f / (float)windowSize.Y );
renderer.AddQuad( new Rect( rect.Left, rect.Top + thickness.Y,
rect.Right, rect.Top + thickness.Y * 2 ), new ColorValue( 0, 0, 0, .5f ) );
renderer.AddQuad( new Rect( rect.Left, rect.Bottom,
rect.Right, rect.Bottom + thickness.Y ), new ColorValue( 0, 0, 0, .5f ) );
renderer.AddQuad( new Rect( rect.Left + thickness.X, rect.Top,
rect.Left + thickness.X * 2, rect.Bottom ), new ColorValue( 0, 0, 0, .5f ) );
renderer.AddQuad( new Rect( rect.Right, rect.Top,
rect.Right + thickness.X, rect.Bottom ), new ColorValue( 0, 0, 0, .5f ) );
renderer.AddQuad( new Rect( rect.Left, rect.Top,
rect.Right, rect.Top + thickness.Y ), new ColorValue( 0, 1, 0, 1 ) );
renderer.AddQuad( new Rect( rect.Left, rect.Bottom - thickness.Y,
rect.Right, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) );
renderer.AddQuad( new Rect( rect.Left, rect.Top,
rect.Left + thickness.X, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) );
renderer.AddQuad( new Rect( rect.Right - thickness.X, rect.Top,
rect.Right, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) );
}
}
示例6: OnRenderUI
protected override void OnRenderUI( GuiRenderer renderer )
{
base.OnRenderUI( renderer );
if( Map.Instance == null )
{
renderer.AddQuad( new Rect( 0, 0, 1, 1 ),
new ColorValue( .2f, .2f, .2f ) * window.ColorMultiplier );
}
}
示例7: GenerateTrianglesFromCurve
public static GuiRenderer.TriangleVertex[] GenerateTrianglesFromCurve(GuiRenderer renderer, Curve curve, float step, Vec2 thickness, ColorValue color)
{
float maxTime = curve.Times[curve.Times.Count - 1];
float end = maxTime + step;
List<Vec2> points = new List<Vec2>();
for (float time = 0; time < end; time += step)
{
points.Add(curve.CalculateValueByTime(time).ToVec2());
}
#if DebugDraw
Vec2 xHalf = new Vec2(thickness.X / 16, 0f);
Vec2 yHalf = new Vec2(0f, thickness.Y / 16);
float g = 1f;
// The green progression here is so we can tell which
// direction the curve was heading.
foreach (Vec2 point in points)
{
renderer.AddQuad(new Rect(point - xHalf, point + yHalf), new ColorValue(1f, g, 0f));
g -= 0.05f;
}
#endif
return GenerateTriangles(points, thickness, color);
}
示例8: OnRenderUI
protected override void OnRenderUI( GuiRenderer renderer )
{
base.OnRenderUI( renderer );
Vec2 size = new Vec2( 512, 215.0f );
size *= 1.0f + Time * .015f;
size /= new Vec2( 768.0f * renderer.AspectRatio, 768.0f );
Rect rectangle = new Rect( -size / 2, size / 2 ) + new Vec2( .5f, .5f );
float alpha = 0;
if( Time > 2 && Time <= 3 )
alpha = Time - 2;
else if( Time > 3 && Time <= lifeTime - 2 - 2 )
alpha = 1;
else if( Time >= lifeTime - 2 - 2 && Time < lifeTime - 1 )
alpha = 1 - ( Time - ( lifeTime - 2 - 2 ) ) / 3;
if( alpha != 0 )
renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), engineTexture,
new ColorValue( 1, 1, 1, alpha ) );
}
示例9: DrawArea_RenderUI
private void DrawArea_RenderUI(Control sender, GuiRenderer renderer)
{
Rect rectangle = sender.GetScreenRectangle();
bool clipRectangle = true;
ColorValue[] colors = new ColorValue[]{
new ColorValue( 1 ,0, 0 ),
new ColorValue( 0, 1, 0 ),
new ColorValue( 0, 0, 1 ),
new ColorValue( 1, 1, 0 ),
new ColorValue( 1, 1, 1 )};
if (clipRectangle)
renderer.PushClipRectangle(rectangle);
//draw triangles
if (GetDrawAreaMode() == DrawAreaModes.Triangles)
{
float distance = rectangle.GetSize().X / 2;
List<GuiRenderer.TriangleVertex> triangles = new List<GuiRenderer.TriangleVertex>(256);
Radian angle = -EngineApp.Instance.Time;
const int steps = 30;
Vec2 lastPosition = Vec2.Zero;
for (int step = 0; step < steps + 1; step++)
{
Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
Vec2 pos = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);
if (step != 0)
{
ColorValue color = colors[step % colors.Length];
ColorValue color2 = color;
color2.Alpha = 0;
triangles.Add(new GuiRenderer.TriangleVertex(rectangle.GetCenter(), color));
triangles.Add(new GuiRenderer.TriangleVertex(lastPosition, color2));
triangles.Add(new GuiRenderer.TriangleVertex(pos, color2));
}
angle += (MathFunctions.PI * 2) / steps;
lastPosition = pos;
}
renderer.AddTriangles(triangles);
}
//draw quads
if (GetDrawAreaMode() == DrawAreaModes.Quads)
{
//draw background
{
Texture texture = TextureManager.Instance.Load("GUI\\Textures\\NeoAxisLogo.png");
renderer.AddQuad(rectangle, new Rect(0, -.3f, 1, 1.4f), texture,
new ColorValue(1, 1, 1), true);
}
//draw bars
{
float time = EngineApp.Instance.Time;
EngineRandom random = new EngineRandom(0);
int count = 15;
float stepOffset = rectangle.GetSize().X / count;
float size = stepOffset * .9f;
for (int n = 0; n < count; n++)
{
float v = MathFunctions.Cos(time * random.NextFloat());
float v2 = (v + 1) / 2;
ColorValue color = colors[n % colors.Length];
Rect rect = new Rect(
rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y * v2,
rectangle.Left + stepOffset * n + size, rectangle.Bottom);
renderer.AddQuad(rect, color);
}
}
}
//draw lines
if (GetDrawAreaMode() == DrawAreaModes.Lines)
{
float maxDistance;
{
Vec2 s = rectangle.GetSize() / 2;
maxDistance = MathFunctions.Sqrt(s.X * s.X + s.Y * s.Y);
}
int step = 0;
float distance = 0;
Radian angle = -EngineApp.Instance.Time;
Vec2 lastPosition = Vec2.Zero;
while (distance < maxDistance)
{
Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
Vec2 pos = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);
if (step != 0)
//.........这里部分代码省略.........
示例10: DoRenderUI
public void DoRenderUI( GuiRenderer renderer )
{
if( transparency == 0.0f )
return;
if( firstRender )
{
texture = TextureManager.Instance.Load( "Gui\\Various\\Console.dds",
Texture.Type.Type2D, 0 );
font = FontManager.Instance.LoadFont( "Default", .025f );
firstRender = false;
}
if( font == null )
return;
Rect textureRect = new Rect( 0, 0, 1, 1 );
textureRect += textureOffset;
renderer.AddQuad( new Rect( 0, 0, 1, .5f ), textureRect, texture,
new ColorValue( 1, 1, 1, transparency ), false, new Rect( 0, 0, 1, 1 ) );
renderer.AddQuad( new Rect( 0, .495f, 1, .5f ),
new ColorValue( .8f, .8f, .8f, transparency ) );
string staticText = "Version " + EngineVersionInformation.Version;
if( staticText != null && staticText != "" )
{
renderer.AddText( font, staticText, new Vec2( .99f, .5f - font.Height ),
HorizontalAlign.Right, VerticalAlign.Center, new ColorValue( 1, 1, 1, transparency ) );
}
float fontheight = font.Height;
float x = .01f;
float y = .5f - fontheight;
string str;
if( stringDownPosition != strings.Count - 1 )
{
str = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
}
else
str = currentString + "_";
renderer.AddText( font, str, new Vec2( x, y ), HorizontalAlign.Left,
VerticalAlign.Center, new ColorValue( 1, 1, 1, transparency ) );
y -= fontheight + fontheight * .5f;
int startpos = stringDownPosition;
if( startpos > strings.Count - 1 )
startpos = strings.Count - 1;
for( int n = startpos; n >= 0 && y - fontheight > 0; n-- )
{
renderer.AddText( font, strings[ n ].text, new Vec2( x, y ), HorizontalAlign.Left,
VerticalAlign.Center, strings[ n ].color * new ColorValue( 1, 1, 1, transparency ) );
y -= fontheight;
}
}
示例11: DisplayTextureOverPosition
private void DisplayTextureOverPosition(Vec2 screenPos, Texture texture, GuiRenderer renderer, ColorValue color)
{
Vec2I size = texture.SourceSize / 2;
float sizeX = (float)size.X / (float)EngineApp.Instance.VideoMode.X;
float sizeY = (float)size.Y / (float)EngineApp.Instance.VideoMode.Y;
if (screenPos.X != 0 && screenPos.Y != 0)
{
renderer.AddQuad(new Rect(new Vec2(screenPos.X - sizeX / 2, screenPos.Y - sizeY / 2), new Vec2(screenPos.X + sizeX / 2, screenPos.Y + sizeY / 2)), new Rect(0, 0, 1f, 1f), texture, color);
}
}
示例12: OnRenderUI
protected override void OnRenderUI(GuiRenderer renderer)
{
Rect r = new Rect();
var pos = this.GetScreenPosition();
var sz = this.GetScreenSize();
r.Left = pos.X;
r.Right = r.Left + sz.X;
r.Top = pos.Y;
r.Bottom = r.Top + sz.Y;
if (mBorderRadius.Value != Vec2.Zero)
{
#if DebugDraw
ColorValue debugColor = new ColorValue(0f, 1f, 0f, .5f);
ColorValue debugColor2 = new ColorValue(0f, 0f, 1f, .5f);
#endif
Vec2 screenRelRad = this.ScreenFromValue(mBorderRadius);
// By using clipping and a set of 3 rectangles, we ensure that each point
// on the screen is only drawn once, thus allowing the alpha value to be
// used in the color without it looking weird.
// Top-Left
#if DebugDraw
renderer.AddCircle(r.LeftTop + screenRelRad, debugColor, screenRelRad, (float)Math.PI, (float)(Math.PI * 1.5f));
#else
renderer.AddCircle(r.LeftTop + screenRelRad, mColor, screenRelRad, (float)Math.PI, (float)(Math.PI * 1.5f));
#endif
// Top-Right
#if DebugDraw
renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Top + screenRelRad.Y), debugColor, screenRelRad, (float)(Math.PI * 1.5f));
#else
renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Top + screenRelRad.Y), mColor, screenRelRad, (float)(Math.PI * 1.5f));
#endif
// Bottom-Right
#if DebugDraw
renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Bottom - screenRelRad.Y), debugColor, screenRelRad, 0f, (float)(Math.PI * 0.5f));
#else
renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Bottom - screenRelRad.Y), mColor, screenRelRad, 0f, (float)(Math.PI * 0.5f));
#endif
// Bottom-Left
#if DebugDraw
renderer.AddCircle(new Vec2(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y), debugColor, screenRelRad, (float)(Math.PI * 0.5), (float)Math.PI);
#else
renderer.AddCircle(new Vec2(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y), mColor, screenRelRad, (float)(Math.PI * 0.5), (float)Math.PI);
#endif
// Middle-Middle
#if DebugDraw
renderer.AddQuad(new Rect(r.Left, r.Top + screenRelRad.Y, r.Right, r.Bottom - screenRelRad.Y), debugColor2);
#else
renderer.AddQuad(new Rect(r.Left, r.Top + screenRelRad.Y, r.Right, r.Bottom - screenRelRad.Y), mColor);
#endif
// Middle-Top
renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Top, r.Right - screenRelRad.X, r.Top + screenRelRad.Y), mColor);
// Middle-Bottom
renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y, r.Right - screenRelRad.X, r.Bottom), mColor);
if (mBorderWidth.Value != Vec2.Zero)
{
Vec2 screenRel = this.ScreenFromValue(mBorderWidth);
float xHalfWidth = screenRel.X / 2;
float yHalfWidth = screenRel.Y / 2;
// Top
renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Top + yHalfWidth, r.Right - screenRelRad.X, r.Top - yHalfWidth), mBorderColor);
// Right
renderer.AddQuad(new Rect(r.Right - xHalfWidth, r.Top + screenRelRad.Y, r.Right + xHalfWidth, r.Bottom - screenRelRad.Y), mBorderColor);
// Bottom
renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Bottom - yHalfWidth, r.Right - screenRelRad.X, r.Bottom + yHalfWidth), mBorderColor);
// Left
renderer.AddQuad(new Rect(r.Left - xHalfWidth, r.Top + screenRelRad.Y, r.Left + xHalfWidth, r.Bottom - screenRelRad.Y), mBorderColor);
// Top-Left
BezierCurve curve = new BezierCurve();
curve.AddValue(0, new Vec3(r.Left, r.Top + screenRelRad.Y, 0f));
curve.AddValue(1, new Vec3(r.LeftTop, 0f));
curve.AddValue(2, new Vec3(r.Left + screenRelRad.X, r.Top, 0f));
renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));
// Top-Right
curve = new BezierCurve();
curve.AddValue(0, new Vec3(r.Right - screenRelRad.X, r.Top, 0f));
curve.AddValue(1, new Vec3(r.RightTop, 0f));
curve.AddValue(2, new Vec3(r.Right, r.Top + screenRelRad.Y, 0f));
renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));
// Bottom-Right
curve = new BezierCurve();
curve.AddValue(0, new Vec3(r.Right, r.Bottom - screenRelRad.Y, 0f));
curve.AddValue(1, new Vec3(r.RightBottom, 0f));
curve.AddValue(2, new Vec3(r.Right - screenRelRad.X, r.Bottom, 0f));
renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));
// Bottom-Left
curve = new BezierCurve();
//.........这里部分代码省略.........
示例13: RenderFadingIn
private void RenderFadingIn(GuiRenderer renderer)
{
if (fadingInRemainingTime > 0)
{
//we are skip some amount of frames because resources can be loaded during it.
if (fadingInSkipFirstFrames == 0)
{
fadingInRemainingTime -= RendererWorld.Instance.FrameRenderTimeStep;
if (fadingInRemainingTime < 0)
fadingInRemainingTime = 0;
}
else
fadingInSkipFirstFrames--;
float alpha = (float)fadingInRemainingTime / 1;
MathFunctions.Saturate(ref alpha);
renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha));
}
}
示例14: DrawPlayersStatistics
void DrawPlayersStatistics( GuiRenderer renderer )
{
if( IsCutSceneEnabled() )
return;
if( PlayerManager.Instance == null )
return;
renderer.AddQuad( new Rect( .1f, .2f, .9f, .8f ), new ColorValue( 0, 0, 1, .5f ) );
renderer.AddText( "Players statistics", new Vec2( .5f, .25f ),
HorizontalAlign.Center, VerticalAlign.Center );
if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() )
{
float posy = .3f;
ICollection<Entity> icol = Entities.Instance.EntitiesCollection;
String fact = "";
foreach( PlayerManager.ServerOrSingle_Player player in
PlayerManager.Instance.ServerOrSingle_Players )
{
foreach (Entity ent in icol)
{
Console.WriteLine(ent.UIN + " : "+ent.NetworkUIN+" : "+ent.Name);
Console.WriteLine(player.Identifier + " : " + " : " + player.User.Identifier + " : " + player.Name);
if (ent.Name.ToString().Contains("Human"))
{
fact = "Human";
}
if (ent.Name.ToString().Contains("Statue") && ent.NetworkUIN.Equals(player.User.Identifier))
{
fact = "Statue";
}
}
string text = string.Format("{0}, Frags: {1}, Faction: {3}, Ping: {2} ms", player.Name,
player.Frags, (int)( player.Ping * 1000 ), fact );
renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left,
VerticalAlign.Center );
posy += .025f;
}
}
if( EntitySystemWorld.Instance.IsClientOnly() )
{
float posy = .3f;
ICollection<Entity> icol = Entities.Instance.EntitiesCollection;
String fact = "";
foreach( PlayerManager.Client_Player player in PlayerManager.Instance.Client_Players )
{
foreach (Entity ent in icol)
{
if (ent.Name.ToString().Contains("Human") && ent.UIN.Equals(player.User.Identifier))
{
fact = "Human";
}
if (ent.Name.ToString().Contains("Statue") && ent.UIN.Equals(player.User.Identifier))
{
fact = "Statue";
}
}
string text = string.Format("{0}, Frags: {1}, Faction: {3}, ID: {4}, Ping: {2} ms", player.Name,
player.Frags, (int)( player.Ping * 1000 ), fact, player.Identifier );
renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left,
VerticalAlign.Center );
posy += .025f;
}
}
}
示例15: RenderScreenUI
public void RenderScreenUI(GuiRenderer renderer)
{
for (int viewIndex = 0; viewIndex < views.Count; viewIndex++)
{
View view = views[viewIndex];
//draw view on screen
if (view.Opacity > 0)
{
renderer.PushTextureFilteringMode(GuiRenderer.TextureFilteringModes.Point);
renderer.AddQuad(view.Rectangle, new Rect(0, 0, 1, 1), view.Texture,
new ColorValue(1, 1, 1, view.Opacity), true);
renderer.PopTextureFilteringMode();
}
//draw debug info
if (drawDebugInfo)
{
Viewport screenViewport = renderer.ViewportForScreenGuiRenderer;
Vec2 pixelOffset = 1.0f / screenViewport.DimensionsInPixels.Size.ToVec2();
ColorValue color = new ColorValue(1, 1, 0);
renderer.AddRectangle(new Rect(
view.Rectangle.LeftTop + pixelOffset,
view.Rectangle.RightBottom - pixelOffset * 2),
color);
renderer.AddLine(view.Rectangle.LeftTop, view.Rectangle.RightBottom, color);
renderer.AddLine(view.Rectangle.RightTop, view.Rectangle.LeftBottom, color);
if (debugFont == null)
debugFont = FontManager.Instance.LoadFont("Default", .03f);
string sizeString = "";
if (view.Texture != null)
sizeString = string.Format("{0}x{1}", view.Texture.Size.X, view.Texture.Size.Y);
string text = string.Format("View {0}, {1}", viewIndex, sizeString);
Vec2 position = new Vec2(view.Rectangle.Right - pixelOffset.X * 5, view.Rectangle.Top);
AddTextWithShadow(renderer, debugFont, text, position, HorizontalAlign.Right,
VerticalAlign.Top, new ColorValue(1, 1, 1));
}
}
}