本文整理汇总了C#中World.FogObscures方法的典型用法代码示例。如果您正苦于以下问题:C# World.FogObscures方法的具体用法?C# World.FogObscures怎么用?C# World.FogObscures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.FogObscures方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActorsBitmap
public static Bitmap ActorsBitmap(World world)
{
var map = world.Map;
var size = Exts.NextPowerOf2(Math.Max(map.Bounds.Width, map.Bounds.Height));
var bitmap = new Bitmap(size, size);
var bitmapData = bitmap.LockBits(bitmap.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
unsafe
{
int* c = (int*)bitmapData.Scan0;
foreach (var t in world.ActorsWithTrait<IRadarSignature>())
{
if (world.FogObscures(t.Actor))
continue;
var color = t.Trait.RadarSignatureColor(t.Actor);
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
if (world.Map.IsInMap(cell))
*(c + ((cell.Y - world.Map.Bounds.Top) * bitmapData.Stride >> 2) + cell.X - world.Map.Bounds.Left) = color.ToArgb();
}
}
bitmap.UnlockBits(bitmapData);
return bitmap;
}
示例2: FriendlyGuardableUnits
static IEnumerable<Actor> FriendlyGuardableUnits(World world, MouseInput mi)
{
return world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a) && !a.IsDead &&
a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) &&
a.Info.HasTraitInfo<GuardableInfo>());
}
示例3: GetCursor
public string GetCursor(World world, CPos xy, MouseInput mi)
{
var useSelect = false;
var underCursor = world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a) && a.HasTrait<ITargetable>())
.WithHighestSelectionPriority();
if (underCursor != null && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()))
{
var selectable = underCursor.TraitOrDefault<Selectable>();
if (selectable != null && selectable.Info.Selectable)
useSelect = true;
}
Target target;
if (underCursor != null)
target = Target.FromActor(underCursor);
else
{
var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
.Where(a => a.Info.Traits.Contains<ITargetableInfo>() && !a.Footprint.All(world.ShroudObscures))
.WithHighestSelectionPriority();
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(world, xy);
}
var ordersWithCursor = world.Selection.Actors
.Select(a => OrderForUnit(a, target, mi))
.Where(o => o != null && o.Cursor != null);
var cursorOrder = ordersWithCursor.MaxByOrDefault(o => o.Order.OrderPriority);
return cursorOrder != null ? cursorOrder.Cursor : (useSelect ? "select" : "default");
}
示例4: GetCursor
public string GetCursor(World world, CPos xy, MouseInput mi)
{
var useSelect = false;
var underCursor = world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a) && a.HasTrait<ITargetable>())
.OrderByDescending(a => a.Info.SelectionPriority())
.FirstOrDefault();
if (underCursor != null && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()))
{
var selectable = underCursor.TraitOrDefault<Selectable>();
if (selectable != null && selectable.Info.Selectable)
useSelect = true;
}
Target target;
if (underCursor != null)
target = Target.FromActor(underCursor);
else
{
var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
.Where(a => a.Info.Traits.Contains<ITargetableInfo>())
.OrderByDescending(a => a.Info.SelectionPriority())
.FirstOrDefault();
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(xy);
}
var orders = world.Selection.Actors
.Select(a => OrderForUnit(a, target, mi))
.Where(o => o != null)
.ToArray();
var cursorName = orders.Select(o => o.Cursor).FirstOrDefault();
return cursorName ?? (useSelect ? "select" : "default");
}
示例5: OrderInner
static IEnumerable<Order> OrderInner(World world, MouseInput mi)
{
if (mi.Button != MouseButton.Left)
yield break;
var underCursor = world.ScreenMap.ActorsAt(mi)
.FirstOrDefault(a => a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) && !world.FogObscures(a));
if (underCursor == null)
yield break;
if (underCursor.GetDamageState() == DamageState.Undamaged)
yield break;
// Repair a building.
if (underCursor.Info.HasTraitInfo<RepairableBuildingInfo>())
yield return new Order("RepairBuilding", world.LocalPlayer.PlayerActor, false) { TargetActor = underCursor };
// Don't command allied units
if (underCursor.Owner != world.LocalPlayer)
yield break;
// Test for generic Repairable (used on units).
var repairable = underCursor.TraitOrDefault<Repairable>();
if (repairable == null)
yield break;
// Find a building to repair at.
var repairBuilding = repairable.FindRepairBuilding(underCursor);
if (repairBuilding == null)
yield break;
yield return new Order("Repair", underCursor, false) { TargetActor = repairBuilding };
}
示例6: Order
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{
var underCursor = world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a) && a.HasTrait<ITargetable>())
.WithHighestSelectionPriority();
Target target;
if (underCursor != null)
target = Target.FromActor(underCursor);
else
{
var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
.Where(a => a.Info.Traits.Contains<ITargetableInfo>() && !a.Footprint.All(world.ShroudObscures))
.WithHighestSelectionPriority();
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(world, xy);
}
var orders = world.Selection.Actors
.Select(a => OrderForUnit(a, target, mi))
.Where(o => o != null)
.ToList();
var actorsInvolved = orders.Select(o => o.Actor).Distinct();
if (actorsInvolved.Any())
yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, false)
{
TargetString = actorsInvolved.Select(a => a.ActorID).JoinWith(",")
};
foreach (var o in orders)
yield return CheckSameOrder(o.Order, o.Trait.IssueOrder(o.Actor, o.Order, o.Target, mi.Modifiers.HasModifier(Modifiers.Shift)));
}
示例7: ActorsBitmap
public static Bitmap ActorsBitmap(World world)
{
var map = world.Map;
var b = map.Bounds;
var size = Exts.NextPowerOf2(Math.Max(b.Width, b.Height));
var bitmap = new Bitmap(size, size);
var bitmapData = bitmap.LockBits(bitmap.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
unsafe
{
var colors = (int*)bitmapData.Scan0;
var stride = bitmapData.Stride / 4;
foreach (var t in world.ActorsWithTrait<IRadarSignature>())
{
if (world.FogObscures(t.Actor))
continue;
var color = t.Trait.RadarSignatureColor(t.Actor);
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
{
var uv = Map.CellToMap(map.TileShape, cell);
if (b.Contains(uv.X, uv.Y))
colors[(uv.Y - b.Top) * stride + uv.X - b.Left] = color.ToArgb();
}
}
}
bitmap.UnlockBits(bitmapData);
return bitmap;
}
示例8: Tick
public void Tick(World world)
{
actors.RemoveAll(a => !a.IsInWorld || (a.Owner != world.LocalPlayer && world.FogObscures(a)));
foreach (var cg in controlGroups.Values)
// note: NOT `!a.IsInWorld`, since that would remove things that are in transports.
cg.RemoveAll(a => a.Destroyed);
}
示例9: OrderInner
IEnumerable<Order> OrderInner(World world, CPos xy, MouseInput mi)
{
if (mi.Button == MouseButton.Left)
{
var underCursor = world.ScreenMap.ActorsAt(mi)
.FirstOrDefault(a => !world.FogObscures(a) && a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) && a.HasTrait<RepairableBuilding>());
if (underCursor == null)
yield break;
if (underCursor.Info.Traits.Contains<RepairableBuildingInfo>()
&& underCursor.GetDamageState() > DamageState.Undamaged)
yield return new Order("RepairBuilding", world.LocalPlayer.PlayerActor, false) { TargetActor = underCursor };
}
}
示例10: RenderAboveShroud
public IEnumerable<IRenderable> RenderAboveShroud(WorldRenderer wr, World world)
{
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
var targetUnits = power.UnitsInRange(xy).Where(a => !world.FogObscures(a));
foreach (var unit in targetUnits)
if (manager.Self.Owner.CanTargetActor(unit))
yield return new SelectionBoxRenderable(unit, Color.Red);
}
示例11: Order
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
if (mi.Button == Game.Settings.Game.MouseButtonPreference.Cancel)
{
world.CancelInputMode();
yield break;
}
var underCursor = world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a))
.MaxByOrDefault(a => a.Info.HasTraitInfo<SelectableInfo>()
? a.Info.TraitInfo<SelectableInfo>().Priority : int.MinValue);
if (mi.Button == Game.Settings.Game.MouseButtonPreference.Action && underCursor == null)
{
minelayer.World.CancelInputMode();
yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = cell };
}
}
示例12: SelectActorsInBox
static IEnumerable<Actor> SelectActorsInBox(World world, int2 a, int2 b, Func<Actor, bool> cond)
{
return world.ScreenMap.ActorsInBox(a, b)
.Where(x => x.HasTrait<Selectable>() && x.Trait<Selectable>().Info.Selectable && !world.FogObscures(x) && cond(x))
.GroupBy(x => x.GetSelectionPriority())
.OrderByDescending(g => g.Key)
.Select(g => g.AsEnumerable())
.DefaultIfEmpty(NoActors)
.FirstOrDefault();
}
示例13: ShroudBitmap
public static Bitmap ShroudBitmap(World world)
{
var map = world.Map;
var b = map.Bounds;
var size = Exts.NextPowerOf2(Math.Max(b.Width, b.Height));
var bitmap = new Bitmap(size, size);
if (world.RenderPlayer == null)
return bitmap;
var bitmapData = bitmap.LockBits(bitmap.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
var shroud = Color.Black.ToArgb();
var fog = Color.FromArgb(128, Color.Black).ToArgb();
var offset = new CVec(b.Left, b.Top);
unsafe
{
var c = (int*)bitmapData.Scan0;
foreach (var cell in map.Cells)
{
var uv = Map.CellToMap(map.TileShape, cell) - offset;
if (world.ShroudObscures(cell))
*(c + (uv.Y * bitmapData.Stride >> 2) + uv.X) = shroud;
else if (world.FogObscures(cell))
*(c + (uv.Y * bitmapData.Stride >> 2) + uv.X) = fog;
}
}
bitmap.UnlockBits(bitmapData);
return bitmap;
}
示例14: SelectActorsInBoxWithDeadzone
static IEnumerable<Actor> SelectActorsInBoxWithDeadzone(World world, int2 a, int2 b)
{
// For dragboxes that are too small, shrink the dragbox to a single point (point b)
if ((a - b).Length <= Game.Settings.Game.SelectionDeadzone)
a = b;
return world.ScreenMap.ActorsInBox(a, b)
.Where(x => x.Info.HasTraitInfo<SelectableInfo>() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))
.SubsetWithHighestSelectionPriority();
}
示例15: TargetForInput
static Target TargetForInput(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
var actor = world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a) && a.Info.HasTraitInfo<ITargetableInfo>())
.WithHighestSelectionPriority(worldPixel);
if (actor != null)
return Target.FromActor(actor);
var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
.Where(a => a.Info.HasTraitInfo<ITargetableInfo>() && a.Visible && a.HasRenderables)
.WithHighestSelectionPriority(worldPixel);
if (frozen != null)
return Target.FromFrozenActor(frozen);
return Target.FromCell(world, cell);
}