本文整理汇总了C#中CPos类的典型用法代码示例。如果您正苦于以下问题:C# CPos类的具体用法?C# CPos怎么用?C# CPos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CPos类属于命名空间,在下文中一共展示了CPos类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:35,代码来源:UnitOrderGenerator.cs
示例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;
}
开发者ID:ushardul,项目名称:OpenRA,代码行数:28,代码来源:D2kEditorResourceLayer.cs
示例3: Teleport
public Teleport(Actor chronosphere, CPos destination, bool killCargo, string sound)
{
this.chronosphere = chronosphere;
this.destination = destination;
this.killCargo = killCargo;
this.sound = sound;
}
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:7,代码来源:Teleport.cs
示例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));
}
开发者ID:Comanche93,项目名称:d2,代码行数:29,代码来源:D2ResourceLayer.cs
示例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");
}
开发者ID:ushardul,项目名称:OpenRA,代码行数:33,代码来源:UnitOrderGenerator.cs
示例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));
}
开发者ID:JamesDunne,项目名称:OpenRA,代码行数:7,代码来源:IonCannon.cs
示例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;
}
}
开发者ID:OpenRA,项目名称:OpenRA,代码行数:27,代码来源:SmudgeLayer.cs
示例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));
}
开发者ID:RunCraze,项目名称:OpenRA,代码行数:7,代码来源:Util.cs
示例9: GetBridge
// Used to check for neighbouring bridges
public Bridge GetBridge(CPos cell)
{
if (!bridges.Contains(cell))
return null;
return bridges[cell];
}
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:8,代码来源:BridgeLayer.cs
示例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);
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:Immobile.cs
示例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;
}
开发者ID:Comanche93,项目名称:d2,代码行数:34,代码来源:D2EditorResourceLayer.cs
示例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));
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:25,代码来源:Carryable.cs
示例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;
}
}
}
}
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:CoordinateTest.cs
示例14: CellInfo
public CellInfo(int costSoFar, int estimatedTotal, CPos previousPos, CellStatus status)
{
CostSoFar = costSoFar;
PreviousPos = previousPos;
Status = status;
EstimatedTotal = estimatedTotal;
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:7,代码来源:CellInfo.cs
示例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();
}
}
开发者ID:nevelis,项目名称:OpenRA,代码行数:25,代码来源:RadarWidget.cs
示例16: GetBuildingAt
public Actor GetBuildingAt(CPos cell)
{
if (!map.IsInMap(cell))
return null;
return influence[cell.X, cell.Y];
}
开发者ID:RunCraze,项目名称:OpenRA,代码行数:7,代码来源:BuildingInfluence.cs
示例17: AddSmudge
public void AddSmudge(CPos loc)
{
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
world.AddFrameEndTask(w => w.Add(new Smoke(w, world.Map.CenterOfCell(loc), Info.SmokeType)));
if (!dirty.ContainsKey(loc) && !tiles.ContainsKey(loc))
{
// No smudge; create a new one
var st = smudges.Keys.Random(world.SharedRandom);
dirty[loc] = new Smudge { Type = st, Depth = 0, Sprite = smudges[st][0] };
}
else
{
// Existing smudge; make it deeper
var tile = dirty.ContainsKey(loc) ? 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;
}
}
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:25,代码来源:SmudgeLayer.cs
示例18: 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)));
}
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:32,代码来源:UnitOrderGenerator.cs
示例19: FindClearSides
ClearSides FindClearSides(ResourceType t, CPos p)
{
var ret = ClearSides.None;
if (!CellContains(p + new CVec(0, -1), t))
ret |= ClearSides.Top | ClearSides.TopLeft | ClearSides.TopRight;
if (!CellContains(p + new CVec(-1, 0), t))
ret |= ClearSides.Left | ClearSides.TopLeft | ClearSides.BottomLeft;
if (!CellContains(p + new CVec(1, 0), t))
ret |= ClearSides.Right | ClearSides.TopRight | ClearSides.BottomRight;
if (!CellContains(p + new CVec(0, 1), t))
ret |= ClearSides.Bottom | ClearSides.BottomLeft | ClearSides.BottomRight;
if (!CellContains(p + new CVec(-1, -1), t))
ret |= ClearSides.TopLeft;
if (!CellContains(p + new CVec(1, -1), t))
ret |= ClearSides.TopRight;
if (!CellContains(p + new CVec(-1, 1), t))
ret |= ClearSides.BottomLeft;
if (!CellContains(p + new CVec(1, 1), t))
ret |= ClearSides.BottomRight;
return ret;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:29,代码来源:D2kEditorResourceLayer.cs
示例20: Reinforce
public Actor[] Reinforce(Player owner, string[] actorTypes, CPos[] entryPath, int interval = 25, LuaFunction actionFunc = null)
{
var actors = new List<Actor>();
for (var i = 0; i < actorTypes.Length; i++)
{
var af = actionFunc != null ? actionFunc.CopyReference() as LuaFunction : null;
var actor = CreateActor(owner, actorTypes[i], false, entryPath[0], entryPath.Length > 1 ? entryPath[1] : (CPos?)null);
actors.Add(actor);
var actionDelay = i * interval;
Action actorAction = () =>
{
Context.World.Add(actor);
for (var j = 1; j < entryPath.Length; j++)
Move(actor, entryPath[j]);
if (af != null)
{
actor.QueueActivity(new CallFunc(() =>
{
af.Call(actor.ToLuaValue(Context));
af.Dispose();
}));
}
};
Context.World.AddFrameEndTask(w => w.Add(new DelayedAction(actionDelay, actorAction)));
}
return actors.ToArray();
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:31,代码来源:ReinforcementsGlobal.cs
注:本文中的CPos类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论