本文整理汇总了C#中Renderer.GetUnitSize方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.GetUnitSize方法的具体用法?C# Renderer.GetUnitSize怎么用?C# Renderer.GetUnitSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderer
的用法示例。
在下文中一共展示了Renderer.GetUnitSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
{
base.Draw(gameTime, renderer, localPlayer, offset);
Context g = renderer.Context;
Shape.Draw(renderer, GetPosition(renderer, offset), Direction, (Unit.Team == Teams.Home ? Arena.Config.HomeColor1 : Arena.Config.AwayColor1), (Unit.Team == Teams.Home ? Arena.Config.HomeColor2 : Arena.Config.AwayColor2), renderer.GetUnitSize((double)Arena.Config.ActorSize / 2));
foreach (Ability a in Unit.Abilities)
a.Draw(gameTime, g);
}
示例2: DrawUIAbove
public void DrawUIAbove(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
{
Context g = renderer.Context;
Vector2 position = GetPosition(renderer, offset);
renderer.DrawText(position, ((Player)Unit.Owner).Number.ToString(), renderer.GetUnitSize((double)Arena.Config.ActorSize / 2) * 0.7, TextAlign.Center, TextAlign.Middle, ColorPresets.White, (Unit.Team == Teams.Home ? Arena.Config.HomeColor2 : Arena.Config.AwayColor2), null, 0, "chunky_aa");
g.Save();
double rangeRadius = renderer.GetUnitSize() * Unit.AttackRange;
double rangeCircum = 2 * MathHelper.Pi * rangeRadius;
double start = gameTime.TotalGameTime.TotalSeconds / MathHelper.TwoPi * 1;
double[] dash = new double[] { rangeCircum / 80, rangeCircum / 120 };
g.SetDash(dash, 0);
g.LineWidth = 2;
g.Arc(position.X, position.Y, rangeRadius, start, start + MathHelper.TwoPi);
g.SetSourceRGBA(0, 0, 0, 0.1);
g.Stroke();
g.Restore();
}
示例3: Draw
public void Draw(Renderer renderer)
{
int polys = 0;
Context g = renderer.Context;
int padding = 32;
VGame.Rectangle r = new VGame.Rectangle((int)Math.Round(Client.Local.ViewOrigin.X) - padding, (int)Math.Round(Client.Local.ViewOrigin.Y) - padding, Client.Local.Game.Renderer.Width + 2 * padding, Client.Local.Game.Renderer.Height + 2 * padding);
double scale = renderer.GetUnitSize();
foreach (Polygon p in Terrain) {
Polygon sp = p.ScaleAndOffset(scale, -Client.Local.ViewPosition + Client.Local.ViewOrigin);
bool draw = false;
foreach (Line l in sp.Lines) {
if (r.IntersectsLine(new Vector2((float)(l.Point1.X), (float)(l.Point1.Y)), new Vector2((float)(l.Point2.X), (float)(l.Point2.Y)))) {
draw = true;
break;
}
}
if (draw || sp.Contains(r)) {
p.Draw(renderer, -Client.Local.ViewPosition + Client.Local.ViewOrigin, scale);
polys++;
}
/*g.MoveTo(r.X, r.Y);
g.LineTo(r.X + r.Width, r.Y);
g.LineTo(r.X + r.Width, r.Y + r.Height);
g.LineTo(r.X, r.Y + r.Height);
g.ClosePath();
renderer.StrokeAndFill(new Color(0.2, 0.5, 0.2, 0.5), new Color(0.2, 0.5, 0.2, 0.25));*/
}
foreach (Tuple<Line, Color> t in Decorations) {
if (r.IntersectsLine(t.Item1.Point1, t.Item1.Point2)) {
g.MoveTo((new Vector2((float)(t.Item1.Point1.X * scale), (float)(t.Item1.Point1.Y * scale)) - Client.Local.ViewPosition + Client.Local.ViewOrigin).ToPointD());
g.LineTo((new Vector2((float)(t.Item1.Point2.X * scale), (float)(t.Item1.Point2.Y * scale)) - Client.Local.ViewPosition + Client.Local.ViewOrigin).ToPointD());
renderer.SetColor(new Color(t.Item2.R, t.Item2.G, t.Item2.B, 0.4));
g.Stroke();
}
}
//renderer.DrawText(Client.Local.ViewOrigin, string.Format("polys: {0}", polys), 20, TextAlign.Left, TextAlign.Top, ColorPresets.White, ColorPresets.Black, null, 0, null);
}
示例4: Draw
public override void Draw(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
{
Context g = renderer.Context;
Shape.Draw(renderer, WorldPosition + offset, Direction, FillColor, StrokeColor, renderer.GetUnitSize());
}
示例5: DrawUIBelow
public void DrawUIBelow(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
{
Vector2 position = GetPosition(renderer, offset);
Context g = renderer.Context;
if (Unit.Health < 1)
return;
double percent = (double)Unit.Health / (double)Unit.MaxHealth;
double size = renderer.GetUnitSize((double)Arena.Config.ActorSize / 2) * 1.25;
Vector2 start = position + new Vector2(0, (float)-size);
g.MoveTo(start.X, start.Y);
g.ArcNegative(position.X, position.Y, size, 3 * MathHelper.PiOver2, 3 * MathHelper.PiOver2 - (MathHelper.TwoPi * percent));
if (percent < 1) {
g.LineTo(position.X, position.Y);
g.LineTo(start.X, start.Y);
}
renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor1 : Arena.Config.EnemyHealthColor1);
g.FillPreserve();
renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor2 : Arena.Config.EnemyHealthColor2);
double unit = MathHelper.TwoPi / Unit.MaxHealth;
for (int i = 0; i < Unit.Health; i++) {
Vector2 dest = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * size), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * size));
g.MoveTo(position.X, position.Y);
g.LineTo(dest.X, dest.Y);
renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor2 : Arena.Config.EnemyHealthColor2);
g.Stroke();
}
if (Unit.Energy < 1 || Unit.Team != localPlayer.Team)
return;
double ePercent = (double)Unit.Energy / (double)Unit.MaxEnergy;
g.MoveTo(position.X, position.Y - size);
double energy = 3 * MathHelper.PiOver2 - (MathHelper.TwoPi * ePercent);
double energySize = size / 7;
g.ArcNegative(position.X, position.Y, size, 3 * MathHelper.PiOver2, energy);
g.LineTo(position.X + Math.Cos(energy) * (energySize + size), position.Y + Math.Sin(energy) * (size + energySize));
g.Arc(position.X, position.Y, size + energySize, energy, 3 * MathHelper.PiOver2);
g.ClosePath();
renderer.SetColor(Arena.Config.EnergyColor1);
g.FillPreserve();
renderer.SetColor(Arena.Config.EnergyColor2);
g.Stroke();
unit = MathHelper.TwoPi / Unit.MaxEnergy;
for (int i = 0; i < Unit.Energy; i++) {
Vector2 src = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * size), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * size));
Vector2 dest = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * (size + energySize)), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * (size + energySize)));
g.MoveTo(src.X, src.Y);
g.LineTo(dest.X, dest.Y);
renderer.SetColor(Arena.Config.EnergyColor2);
g.Stroke();
}
}