本文整理汇总了C#中Coord类的典型用法代码示例。如果您正苦于以下问题:C# Coord类的具体用法?C# Coord怎么用?C# Coord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Coord类属于命名空间,在下文中一共展示了Coord类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SimpleCircle
public SimpleCircle(Coord center, int radius)
: base(center, radius)
{
pts = new List<Coord>();
int x0 = center.X;
int y0 = center.Y;
int x = radius;
int y = 0;
int decisionOver2 = 1 - x; // Decision criterion divided by 2 evaluated at x=r, y=0
while (y <= x)
{
pts.Add(new Coord(x + x0, y + y0)); // Octant 1
pts.Add(new Coord(y + x0, x + y0)); // Octant 2
pts.Add(new Coord(-x + x0, y + y0)); // Octant 4
pts.Add(new Coord(-y + x0, x + y0)); // Octant 3
pts.Add(new Coord(-x + x0, -y + y0)); // Octant 5
pts.Add(new Coord(-y + x0, -x + y0)); // Octant 6
pts.Add(new Coord(x + x0, -y + y0)); // Octant 7
pts.Add(new Coord(y + x0, -x + y0)); // Octant 8
y++;
if (decisionOver2 <= 0)
{
decisionOver2 += 2 * y + 1; // Change in decision criterion for y -> y+1
}
else
{
x--;
decisionOver2 += 2 * (y - x) + 1; // Change for y -> y+1, x -> x-1
}
}
}
开发者ID:Fux90,项目名称:GodsWill_ASCIIRPG,代码行数:33,代码来源:Circle.cs
示例2: OnUserJoinedMessage
public User OnUserJoinedMessage(EMMServerMessage message)
{
// make sure user exists in database
using (EMMDataContext db = Manager.GetContext)
{
User user = db.Users.SingleOrDefault(i => i.Username == message.Data["username"]);
if (user == null)
{
user = CreateDefaultUser(message.Data["username"]);
}
// parse their current location from the join message
Coord position = new Coord(message);
user.LocX = position.X;
user.LocY = position.Y;
user.LocZ = position.Z;
user.LastSeen = DateTime.Now;
db.SubmitChanges();
// save the current location to the tracking table
TrackUserPosition(user);
return user;
}
}
开发者ID:Cylindric,项目名称:Enigma-MM-old,代码行数:25,代码来源:UserManager.cs
示例3: StraightTrajectory
public void StraightTrajectory()
{
this.board.RemovePinAt(1, 1);
Coord from = new Coord(0, 1), to = new Coord(2, 1);
this.AssertBestProbToArrive(from, to, 1);
}
开发者ID:yngwie74,项目名称:PegGame,代码行数:7,代码来源:WalkerTest.cs
示例4: makeLine
// Generate a line from one coordinate to another
// You can ask for it to be totaly walls or totally floor, based on the bool
// False: Walls
// True: Floor
public static void makeLine(Tile[,] map, Coord begin, Coord end, bool applyFloor) {
// Assert in range
if( begin.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) ||
end.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) )
return;
int startX = begin.x;
int endX = end.x;
int startY = begin.y;
int endY = end.y;
// Find the linear spacing appropriate from point
// including the endpoint
int lengthX = Math.Abs( endX - startX );
var linspace = new List<Double>();
linspace = LinSpace (startY, endY, lengthX, true).ToList ();
// Now it's time to actually put our money where our mouth is
for(int i = startX; i < endX; i++) {
int j = (int) linspace[i] ;
map[i,j].property = applyFloor ? TileType.Floor1 : TileType.OuterWall1;
}
// Phew! Thought this one was so easy, didn't cha!?
return;
}
开发者ID:starrodkirby86,项目名称:Better-Game-App,代码行数:34,代码来源:RoomUtilityFunctions.cs
示例5: Distance
public int Distance(Coord start, Coord end)
{
// Debug.Log ("Chain Start: " + start.ToString());
// Debug.Log ("Chain End: " + end.ToString());
return GetChain(start,end).Count;
}
开发者ID:CaveExplorerStudio,项目名称:ProjectDarkZone,代码行数:7,代码来源:Graph.cs
示例6: RenderOverlay
public override void RenderOverlay(Scene scene)
{
// compute the current frame rate
if (_stopwatch.IsRunning)
{
var fps = 1.0 / _stopwatch.Elapsed.TotalSeconds;
_stopwatch.Reset();
_fpsAverager.Add(fps);
}
else
{
_stopwatch.Start();
}
// get the last mouse position
Coord pos;
if (_lastMouseEvent != null)
pos = _lastMouseEvent.Pos;
else
pos = new Coord();
_label.Body = String.Format("{0:###.#} fps -- {1} ({2} x {3})",
_fpsAverager.Compute(), pos, Scene.Width, Scene.Height);
OnSceneResized(Scene);
base.RenderOverlay(scene);
}
开发者ID:erisonliang,项目名称:monoworks,代码行数:27,代码来源:SceneInfoOverlay.cs
示例7: DemoCardContents
public DemoCardContents() : base(Orientation.Vertical)
{
var label = new Label(Name);
AddChild(label);
UserSize = new Coord(320, 480);
}
开发者ID:erisonliang,项目名称:monoworks,代码行数:7,代码来源:DemoCardContents.cs
示例8: IsJumpableFrom
public static bool IsJumpableFrom(Game game, Coord src, Coord toJump)
{
Coord diff = new Coord() { Row = toJump.Row - src.Row, Col = toJump.Col - src.Col };
Coord toLand = new Coord() { Row = src.Row + diff.Row * 2, Col = src.Col + diff.Col * 2 };
// TODO add out of bounds checking
return game.GetPieceAt(toLand) == BoardSpaceState.None && game.GetPieceAt(toJump) != BoardSpaceState.None;
}
开发者ID:NickHeiner,项目名称:chivalry,代码行数:7,代码来源:GameUtils.cs
示例9: CopyTo
/// <summary>
/// 拷贝源本到新元素
/// </summary>
/// <param name="desPos">目标坐标</param>
public void CopyTo(Coord desPos)
{
if (SouVersion != null)
{
MotaWorld.GetInstance().MapManager.CopyNode(SouVersion, desPos);
}
}
开发者ID:sleepandeat,项目名称:Program,代码行数:11,代码来源:Edit.cs
示例10: Line
public Line(Coord ptA, Coord ptB)
{
pts = new List<Coord>();
int x0 = ptA.X;
int y0 = ptA.Y;
int x1 = ptB.X;
int y1 = ptB.Y;
bool steep = Math.Abs(y1 - y0) > Math.Abs(x1 - x0);
if (steep) { Utilities.Swap<int>(ref x0, ref y0); Utilities.Swap<int>(ref x1, ref y1); }
if (x0 > x1) { Utilities.Swap<int>(ref x0, ref x1); Utilities.Swap<int>(ref y0, ref y1); }
int dX = (x1 - x0), dY = Math.Abs(y1 - y0), err = (dX / 2), ystep = (y0 < y1 ? 1 : -1), y = y0;
for (int x = x0; x <= x1; ++x)
{
pts.Add(steep ? new Coord(y, x) : new Coord(x, y));
err = err - dY;
if (err < 0) { y += ystep; err += dX; }
}
if (pts.Count > 0 && pts[0] != ptA)
{
pts.Reverse();
}
}
开发者ID:Fux90,项目名称:GodsWill_ASCIIRPG,代码行数:26,代码来源:Line.cs
示例11: ArrowDirectionOfCoords
public static BoardSpace.ArrowDirection ArrowDirectionOfCoords(Coord from, Coord to)
{
Coord diff = to - from;
if (diff.Row < 0 && diff.Col == 0)
{
return BoardSpace.ArrowDirection.NORTH;
}
if (diff.Row < 0 && diff.Col < 0)
{
return BoardSpace.ArrowDirection.NORTHWEST;
}
if (diff.Row == 0 && diff.Col < 0)
{
return BoardSpace.ArrowDirection.WEST;
}
if (diff.Row > 0 && diff.Col < 0)
{
return BoardSpace.ArrowDirection.SOUTHWEST;
}
if (diff.Row > 0 && diff.Col == 0)
{
return BoardSpace.ArrowDirection.SOUTH;
}
if (diff.Row > 0 && diff.Col > 0)
{
return BoardSpace.ArrowDirection.SOUTHEAST;
}
if (diff.Row == 0 && diff.Col > 0)
{
return BoardSpace.ArrowDirection.EAST;
}
return BoardSpace.ArrowDirection.NORTHEAST;
}
开发者ID:NickHeiner,项目名称:chivalry,代码行数:35,代码来源:GameUtils.cs
示例12: Main
static void Main(string[] args)
{
string delim = new string('-', 50);
string st1 = "Niki";
string st2 = "Niki";
string st3 = st2;
st3 = "Gosho";
Console.WriteLine(Object.ReferenceEquals(st3, st2)); // returns false, because for strings assigning new value doesn`t change the value in heap, but creates new instance, writes the new value there and changes the address of the string to point to the new address with the new value. st2 value is unchanged
//st3 = Console.ReadLine();
Console.WriteLine(st3.Equals(st2)); // if we entered "Niki" at the console this will return true, because Equals is overriden for string types to compare by value
Console.WriteLine(Object.ReferenceEquals(st3, st2)); // this will return false because st3 has different address than st2, although its value is the same it was dynamically (at runtime) assigned, so it was stored in a new address in heap. If it was compile time aassigned, it was going to be at the same address as st2, so this would have returned true
Console.WriteLine(delim);
int i1 = 1;
//int i2 = int.Parse(Console.ReadLine());
int i2 = 1;
Console.WriteLine(ReferenceEquals(i1, i2));
Console.WriteLine(Equals(i1, i2));
Console.WriteLine(i1 == i2);
Console.WriteLine(delim);
Coord c1 = new Coord(1, 2);
Coord c2 = new Coord(1, 2);
Console.WriteLine(ReferenceEquals(c1, c2)); // always gives false for value types
Console.WriteLine(Equals(c1, c2)); // actually compares them
//Console.WriteLine(c1 == c2); // must be overriden first
}
开发者ID:tddold,项目名称:TelerikAcademy-5,代码行数:31,代码来源:Program.cs
示例13: Play
public void Play(Player p, Coord start, Coord end)
{
if (CanSelectToPlay(p, start.x, start.y) && board.IsEmpty(end.x, end.y))
{
var distance = end - start;
int travelLength = Math.Abs(distance.x) + Math.Abs(distance.y);
//Move -> Remove original
if (travelLength == 2)
{
board[start.x, start.y] = null;
}
//Copy (or Move) -> Put token
PutToken(p, end.x, end.y);
var offsetCalc = new OffsetCalculator(end.x, end.y);
for (int i = 0; i < 9; i++)
{
offsetCalc.setDirection(i);
offsetCalc.MakeOffset(1);
if (board.CanOvertakeToken(p, offsetCalc.ResultX, offsetCalc.ResultY))
{
PutToken(p, offsetCalc.ResultX, offsetCalc.ResultY);
}
}
HandlePlayerChange();
if (SnapshotContainer != null)
{
SnapshotContainer.TakeSnapShot(new TwoPartTurn() { Start = start, End = end, PlayerThatPlayed = p, PlayerToPlay = CurrentPlayer, Board = board.Clone() });
}
}
}
开发者ID:cslecours,项目名称:RevLib,代码行数:35,代码来源:ChineseChessGame.cs
示例14: DeviceRect
public void DeviceRect(Coord x0, Coord y0, Coord x1, Coord y1)
{
int x = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
int y = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
int w = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
int h = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
}
开发者ID:Helen1987,项目名称:edu,代码行数:7,代码来源:XWindowImp.cs
示例15: MoveElement
/// <summary>
/// 以一定的移动速度创建可移动元素对象
/// </summary>
/// <param name="faceIndex">移动对象的图像索引</param>
/// <param name="pos">可移动对象的初始位置</param>
/// <param name="name">移动对象名称</param>
public MoveElement(MotaElement faceIndex, Coord pos, string name)
: base(faceIndex, pos, TouchMethod.ImmediatelyTouch, true, name)
{
this.Speed = GameIni.IniHeroSpeed;
MoveDirection = Direction.No;
}
开发者ID:sleepandeat,项目名称:Program,代码行数:13,代码来源:MoveElement.cs
示例16: FrmEdit
/// <summary>
/// 以待编辑的元素坐标创建窗口
/// </summary>
public FrmEdit(Coord editPos)
{
InitializeComponent();
this.CurPosation = editPos;
this.content.Text = MotaWorld.GetInstance().MapManager.GetNodeString(editPos);
}
开发者ID:sleepandeat,项目名称:Program,代码行数:10,代码来源:FrmEdit.cs
示例17: AddCoordToAppropriateSequence
public void AddCoordToAppropriateSequence(Coord coord)
{
bool flag = false;
foreach (Sequence current in this.Sequences)
{
if (current.LastCoord.I + 1 == coord.I && current.LastCoord.J + 1 == coord.J)
{
current.LastCoord = coord;
flag = true;
break;
}
}
if (!flag)
{
this.Sequences.Add(new Sequence
{
FirstCoord = new Coord
{
I = coord.I - coord.Size + 1,
J = coord.J - coord.Size + 1,
Size = 1
},
LastCoord = coord
});
}
}
开发者ID:akordowski,项目名称:Source-Code-Atomiq,代码行数:26,代码来源:AllSequences.cs
示例18: Node
public Node(NodeMapping mapping, Coord c)
{
m_coord = c;
m_mapping = mapping;
if (mapping.hasCPU(c.ID))
{
m_cpu = new CPU(this);
}
if (mapping.hasMem(c.ID))
{
Console.WriteLine("Proc/Node.cs : MC locations:{0}", c.ID);
m_mem = new MemCtlr(this);
}
m_inj_pool = Simulator.controller.newPrioPktPool(m_coord.ID);
Simulator.controller.setInjPool(m_coord.ID, m_inj_pool);
m_injQueue_flit = new Queue<Flit>();
m_injQueue_evict = new Queue<Flit>();
m_local = new Queue<Packet>();
m_rxbuf_naive = new RxBufNaive(this,
delegate(Flit f) { m_injQueue_evict.Enqueue(f); },
delegate(Packet p) { receivePacket(p); });
}
开发者ID:hoangt,项目名称:NOCulator,代码行数:25,代码来源:Node.cs
示例19: Apple
public Apple(Renderer renderer, PlayField playField)
{
_renderer = renderer;
AppleCoordinate = new Coord();
_playFieldHeight = playField.Height;
_playFieldWidth = playField.Width;
}
开发者ID:Racksay,项目名称:SnakeRefactored,代码行数:7,代码来源:Apple.cs
示例20: ShouldConvertToVector3
public void ShouldConvertToVector3()
{
Coord coord = new Coord(2, 2);
Vector2 vector = coord.ToVector2();
Assert.AreEqual(2f, vector.x, 0.001f);
Assert.AreEqual(2f, vector.y, 0.001f);
}
开发者ID:Mojopon,项目名称:ThreeSeven,代码行数:7,代码来源:CoordTest.cs
注:本文中的Coord类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论