本文整理汇总了C#中Coords类的典型用法代码示例。如果您正苦于以下问题:C# Coords类的具体用法?C# Coords怎么用?C# Coords使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Coords类属于命名空间,在下文中一共展示了Coords类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNode
public static Node GetNode(Coords coords)
{
int x = Mathf.Clamp(coords.x, 0, gridSize.x - 1);
int y = Mathf.Clamp(coords.y, 0, gridSize.y - 1);
return grid[x, y];
}
示例2: Satellite
public Satellite(Satellite s)
: this(s.Pos.Lat, s.Pos.Lon, s.Speed, s.RotSpeed, s.MaxRot, s.Id)
{
CurrentRot = new Coords(s.CurrentRot);
CurrentTurn = s.CurrentTurn;
Range = new Range(s.Range);
}
示例3: CaptureAll
public bool CaptureAll(GameState state, Coords start, Coords end, Direction dir, out IEnumerable<Coords> capture)
{
if (pattern.Count() == 0)
{
capture = new List<Coords>();
return true;
}
if (end != null && !OnSameLine(start, end))
{
capture = new List<Coords>();
return false;
}
if (!pattern.ElementAt(0).IsTarget)
{
throw new NotImplementedException("Target other than the beginning is not supported yet.");
}
List<Coords> cAll = new List<Coords>();
bool retVal = false;
foreach (var incrementer in ToIncrementers(dir))
{
// Try every direction
List<Coords> c = new List<Coords>();
if (FindMatch(state, start, end, incrementer, pattern, out c))
{
cAll.AddRange(c);
retVal = true;
}
}
capture = cAll;
return retVal;
}
示例4: Exit
/// <summary>
/// Constructor for Exit class
/// </summary>
/// <param name="from">Coordinates of teleporter in entrance room</param>
/// <param name="fromRoom">Filename of entrance room</param>
/// <param name="to">Coordinates of teleporter in exit room</param>
/// <param name="toRoom">Filename of exit room</param>
public Exit(Coords from, string fromRoom, Backend.Coords to = null, string toRoom = "")
{
_from = from;
_fromRoom = fromRoom;
_toRoom = toRoom;
_to = to;
}
示例5: greedyCoordsSearch
//Greedy BFS starting at "from" Coords
//Returns null or a Coords that satisfies the test
public static Coords greedyCoordsSearch(GameState gs, Coords from, Func<Coords, Coords, bool> test, bool isBombPassable, List<Coords> visited)
{
List<Coords> allCoords = new List<Coords>();
List<Coords> adjCoords = gs.GetAdjacentAccessibleTiles(from.getTileNum(), isBombPassable, false);
if (adjCoords.Count == 0) { return null; }
allCoords.AddRange(adjCoords);
while (allCoords.Count > 0) {
Coords coord = allCoords[0];
//Console.WriteLine("removing " + coord);
allCoords.Remove(coord);
visited.Add(coord);
if (test(coord, from)) {
return coord;
} else {
List<Coords> newCoords = gs.GetAdjacentAccessibleTiles(coord.getTileNum(), isBombPassable, false);
//Console.WriteLine("adding " + newCoords);
foreach(Coords potentialCoord in newCoords) {
if (!visited.Contains(potentialCoord) && !allCoords.Contains(potentialCoord)) {
allCoords.Add(potentialCoord);
}
}
}
}
return null;
}
示例6: Match
public bool Match(GameState state, Coords start, Coords end, Direction dir)
{
if (pattern.Count() == 0)
{
return true;
}
if (end != null && !OnSameLine(start, end))
{
return false;
}
if (!pattern.ElementAt(0).IsTarget)
{
throw new NotImplementedException("Target other than the beginning is not supported yet.");
}
foreach (var incrementer in ToIncrementers(dir))
{
// Try every direction
List<Coords> c;
if (FindMatch(state, start, end, incrementer, pattern, out c))
{
return true;
}
}
return false;
}
示例7: CanTakePicture
public static bool CanTakePicture(this Satellite s, Coords c, TimeRange t, out int pictureTurn, int maxTurn)
{
pictureTurn = 0;
if (s.CurrentTurn > t.End)
return false;
s = new Satellite(s); //clone
if(s.CurrentTurn < t.Start)
{
s.Move(t.Start - s.CurrentTurn);
}
for (int turn = Math.Max(t.Start, s.CurrentTurn); turn < Math.Min(t.End, maxTurn); turn++)
{
if(c.IsInRange(s.Range, s.Pos))
{
pictureTurn = turn;
return true;
}
s.Move(1);
}
return false;
}
示例8: calcWallToDestroy
//modified pathfinding... assume that agent can path through destructible walls
//and simply calc path
public Coords calcWallToDestroy(Coords from, Coords destination)
{
//path to destination, counting destructible walls as pathable
PathPlan pathPlan = new PathPlan (this.gs);
Graph g = pathPlan.mapQuantization (this.isBombPassable, true);
List<Coords> path = pathPlan.calculateMovementPlan (g, from, destination);
if ((path.Count == 0) && isBombPassable) {
Console.WriteLine("MAP FAIL!"); //TODO JDP ????
this.cannotExecuteStrategy = true;
}
for (int i = 0; i < path.Count; i++) {
//foreach (Coords coord in path) {
Coords coord = path[i];
//first destructible wall encountered on path is the target
LocationData datum = this.gs.GetLocationData (coord);
if (datum.HasDestructibleWall ()) {
Console.WriteLine("BlowUpWall found wall to blow up: " + coord);
//find previous coord
if (i-1 < 0) { //case where we can't move anywhere but we can blow up ourselves and a wall!
return from;
} else {
Coords bombDropCoord = path[i-1];
return bombDropCoord;
}
}
}
return null;
}
示例9: ChunkCoords
public ChunkCoords(ref Coords coords)
{
X = coords.Xblock / Chunk.CHUNK_SIZE;
Z = coords.Zblock / Chunk.CHUNK_SIZE;
WorldCoordsX = X * Chunk.CHUNK_SIZE;
WorldCoordsZ = Z * Chunk.CHUNK_SIZE;
}
示例10: NeighbourCoordsResult
public NeighbourCoordsResult(bool sameTree, Coords coordsResult, IOctree tree)
{
Assert.IsNotNull(tree, "Cannot have a null tree for a neighbour Coords result, return null instead");
this.sameTree = sameTree;
this.coordsResult = coordsResult;
this.tree = tree;
}
示例11: MousePositionCondition
public MousePositionCondition(string name, Coords coordType, Operator inputOperator,
int compareValue)
{
Name = name;
CoordType = coordType;
Operator = inputOperator;
CompareValue = compareValue;
}
示例12: coordsXY
public static Coords coordsXY(int x, int y, int width, int height)
{
Coords coords = new Coords (x, y, width, height);
if (!(coords.isValid ())) {
String msg = coords.ToString () + " invalid due to max width of " + width + " and max height of " + height;
throw new ArgumentException (msg);
}
return coords;
}
示例13: Range
/// <summary>
/// creates a range of size zero on the delta between coords and orig
/// </summary>
public Range(Coords origin, Coords coords)
{
var lat = coords.Lat - origin.Lat;
var lon = coords.Lon - origin.Lon;
DeltaLatMin = lat;
DeltaLatMax = lat;
DeltaLonMin = lon;
DeltaLonMax = lon;
}
示例14: DisplaceEvent
private void DisplaceEvent(GameToken origin, Coords toLoc)
{
if (origin.id != ID)
{
return;
}
animationQueue.Enqueue (toLoc);
}
示例15: GetClip
public Rectangle GetClip(Coords coords)
{
if(_labyrinth == null || !IsHandleCreated) return Rectangle.Empty;
var xFactor = Width / (double)_labyrinth.ColsCount;
var yFactor = (Height - MESSAGE_HEIGHT) / (double)_labyrinth.RowsCount;
var x = (int)(xFactor * (coords.Col - 1));
var y = (int)(yFactor * (coords.Row - 1));
return new Rectangle(x, y, (int)xFactor, (int)yFactor);
}