本文整理汇总了C#中CPos类的典型用法代码示例。如果您正苦于以下问题:C# CPos类的具体用法?C# CPos怎么用?C# CPos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CPos类属于命名空间,在下文中一共展示了CPos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: UpdateDirtyTile
public override CellContents UpdateDirtyTile(CPos c)
{
var t = Tiles[c];
// Empty tile
if (t.Type == null)
{
t.Sprite = null;
return t;
}
t.Density = ResourceDensityAt(c);
int index;
var clear = FindClearSides(t.Type, c);
if (clear == ClearSides.None)
{
var sprites = D2kResourceLayer.Variants[t.Variant];
var frame = t.Density > t.Type.Info.MaxDensity / 2 ? 1 : 0;
t.Sprite = t.Type.Variants.First().Value[sprites[frame]];
}
else if (D2kResourceLayer.SpriteMap.TryGetValue(clear, out index))
t.Sprite = t.Type.Variants.First().Value[index];
else
t.Sprite = null;
return t;
}
示例3: Teleport
public Teleport(Actor chronosphere, CPos destination, bool killCargo, string sound)
{
this.chronosphere = chronosphere;
this.destination = destination;
this.killCargo = killCargo;
this.sound = sound;
}
示例4: UpdateRenderedSprite
protected override void UpdateRenderedSprite(CPos p)
{
// Need to update neighbouring tiles too
UpdateRenderedTileInner(p);
UpdateRenderedTileInner(p + new CVec(-1, -1));
UpdateRenderedTileInner(p + new CVec(0, -1));
UpdateRenderedTileInner(p + new CVec(1, -1));
UpdateRenderedTileInner(p + new CVec(-1, 0));
UpdateRenderedTileInner(p + new CVec(1, 0));
UpdateRenderedTileInner(p + new CVec(-1, 1));
UpdateRenderedTileInner(p + new CVec(0, 1));
UpdateRenderedTileInner(p + new CVec(1, 1));
UpdateRenderedTileInner(p + new CVec(-2, -2));
UpdateRenderedTileInner(p + new CVec(-1, -2));
UpdateRenderedTileInner(p + new CVec(0, -2));
UpdateRenderedTileInner(p + new CVec(1, -2));
UpdateRenderedTileInner(p + new CVec(2, -2));
UpdateRenderedTileInner(p + new CVec(2, -1));
UpdateRenderedTileInner(p + new CVec(2, 0));
UpdateRenderedTileInner(p + new CVec(2, 1));
UpdateRenderedTileInner(p + new CVec(2, 2));
UpdateRenderedTileInner(p + new CVec(1, 2));
UpdateRenderedTileInner(p + new CVec(0, 2));
UpdateRenderedTileInner(p + new CVec(-1, 2));
UpdateRenderedTileInner(p + new CVec(-2, 2));
UpdateRenderedTileInner(p + new CVec(-2, 1));
UpdateRenderedTileInner(p + new CVec(-2, 0));
UpdateRenderedTileInner(p + new CVec(-2, -1));
}
示例5: 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");
}
示例6: IonCannon
public IonCannon(Actor firedBy, World world, CPos location)
{
this.firedBy = firedBy;
target = Target.FromCell(location);
anim = new Animation("ionsfx");
anim.PlayThen("idle", () => Finish(world));
}
示例7: AddSmudge
public void AddSmudge(CPos loc)
{
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
world.AddFrameEndTask(w => w.Add(new SpriteEffect(world.Map.CenterOfCell(loc), w, Info.SmokeType, Info.SmokeSequence, Info.SmokePalette)));
// A null Sprite indicates a deleted smudge.
if ((!dirty.ContainsKey(loc) || dirty[loc].Sprite == null) && !tiles.ContainsKey(loc))
{
// No smudge; create a new one
var st = smudges.Keys.Random(Game.CosmeticRandom);
dirty[loc] = new Smudge { Type = st, Depth = 0, Sprite = smudges[st][0] };
}
else
{
// Existing smudge; make it deeper
// A null Sprite indicates a deleted smudge.
var tile = dirty.ContainsKey(loc) && dirty[loc].Sprite != null ? dirty[loc] : tiles[loc];
var maxDepth = smudges[tile.Type].Length;
if (tile.Depth < maxDepth - 1)
{
tile.Depth++;
tile.Sprite = smudges[tile.Type][tile.Depth];
}
dirty[loc] = tile;
}
}
示例8: IsCellBuildable
public static bool IsCellBuildable(this World world, CPos a, BuildingInfo bi, Actor toIgnore)
{
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(a) != null) return false;
if (world.ActorMap.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
return world.Map.IsInMap(a) && bi.TerrainTypes.Contains(world.GetTerrainType(a));
}
示例9: GetBridge
// Used to check for neighbouring bridges
public Bridge GetBridge(CPos cell)
{
if (!bridges.Contains(cell))
return null;
return bridges[cell];
}
示例10: OccupiedCells
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
{
var occupied = OccupiesSpace ? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } } :
new Dictionary<CPos, SubCell>();
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
}
示例11: UpdateDirtyTile
public override CellContents UpdateDirtyTile(CPos c)
{
var t = Tiles[c];
// Empty tile
if (t.Type == null)
{
t.Sprite = null;
return t;
}
NetWorth -= t.Density * t.Type.Info.ValuePerUnit;
t.Density = ResourceDensityAt(c);
NetWorth += t.Density * t.Type.Info.ValuePerUnit;
int index;
var clear = FindClearSides(t.Type, c);
if (clear == ClearSides.None && CellContainsMaxDensity(c, t.Type))
{
var maxDensityClear = FindMaxDensityClearSides(t.Type, c);
if (D2ResourceLayer.SpriteMap.TryGetValue(maxDensityClear, out index))
t.Sprite = t.Type.Variants.First().Value[16 + index];
else
t.Sprite = null;
}
else if (D2ResourceLayer.SpriteMap.TryGetValue(clear, out index))
t.Sprite = t.Type.Variants.First().Value[index];
else
t.Sprite = null;
return t;
}
示例12: RequestTransport
public void RequestTransport(CPos destination, Activity afterLandActivity)
{
var destPos = self.World.Map.CenterOfCell(destination);
if (destination == CPos.Zero || (self.CenterPosition - destPos).LengthSquared < info.MinDistance.LengthSquared)
{
WantsTransport = false; // Be sure to cancel any pending transports
return;
}
Destination = destination;
this.afterLandActivity = afterLandActivity;
WantsTransport = true;
if (locked || Reserved)
return;
// Inform all idle carriers
var carriers = self.World.ActorsWithTrait<Carryall>()
.Where(c => !c.Trait.IsBusy && !c.Actor.IsDead && c.Actor.Owner == self.Owner && c.Actor.IsInWorld)
.OrderBy(p => (self.Location - p.Actor.Location).LengthSquared);
// Is any carrier able to transport the actor?
// Any will return once it finds a carrier that returns true.
carriers.Any(carrier => carrier.Trait.RequestTransportNotify(self));
}
示例13: CoarseToMapProjection
public void CoarseToMapProjection()
{
foreach (var gridType in Enum.GetValues(typeof(MapGridType)).Cast<MapGridType>())
{
for (var x = 0; x < 12; x++)
{
for (var y = 0; y < 12; y++)
{
var cell = new CPos(x, y);
try
{
Assert.That(cell, Is.EqualTo(cell.ToMPos(gridType).ToCPos(gridType)));
}
catch
{
// Known problem on isometric mods that shouldn't be visible to players as these are outside the map.
if (gridType == MapGridType.RectangularIsometric && y > x)
continue;
Console.WriteLine("Coordinate {0} on grid type {1} failed to convert back.".F(cell, gridType));
throw;
}
}
}
}
}
示例14: CellInfo
public CellInfo(int costSoFar, int estimatedTotal, CPos previousPos, CellStatus status)
{
CostSoFar = costSoFar;
PreviousPos = previousPos;
Status = status;
EstimatedTotal = estimatedTotal;
}
示例15: Draw
public override void Draw()
{
if (world == null) return;
var o = new float2(mapRect.Location.X, mapRect.Location.Y + world.Map.Bounds.Height * previewScale * (1 - radarMinimapHeight)/2);
var s = new float2(mapRect.Size.Width, mapRect.Size.Height*radarMinimapHeight);
var rsr = Game.Renderer.RgbaSpriteRenderer;
rsr.DrawSprite(terrainSprite, o, s);
rsr.DrawSprite(customTerrainSprite, o, s);
rsr.DrawSprite(actorSprite, o, s);
rsr.DrawSprite(shroudSprite, o, s);
// Draw viewport rect
if (hasRadar && !animating)
{
var wr = Game.viewport.WorldRect;
var wro = new CPos(wr.X, wr.Y);
var tl = CellToMinimapPixel(wro);
var br = CellToMinimapPixel(wro + new CVec(wr.Width, wr.Height));
Game.Renderer.EnableScissor((int)mapRect.Left, (int)mapRect.Top, (int)mapRect.Width, (int)mapRect.Height);
Game.Renderer.LineRenderer.DrawRect(tl, br, Color.White);
Game.Renderer.DisableScissor();
}
}