本文整理汇总了C#中Coordinates.getY方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinates.getY方法的具体用法?C# Coordinates.getY怎么用?C# Coordinates.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinates
的用法示例。
在下文中一共展示了Coordinates.getY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getBlockAt
public Block getBlockAt(Coordinates coordinates)
{
int x = (int)Math.Floor(coordinates.getX());
int y = (int)Math.Floor(coordinates.getY());
if(!blocks.ContainsKey(x.ToString() + "," + y.ToString())){
if (coordinates.getY() > -1) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Air()));
}
else if (coordinates.getY() == -1) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Grass()));
}
else if (coordinates.getY() == -2) {
Random rnd = new Random();
if (rnd.Next(0, 2) == 0) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Dirt()));
}
else {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
}
}
else if (coordinates.getY() < -2) {
blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
}
blocks[x.ToString() + "," + y.ToString()].setCoordinates(coordinates);
}
return blocks[x.ToString() + "," + y.ToString()];
}
示例2: FindDistance
/* DESCRIPTION:
* Finds ditect distance between two cities
*/
private static double FindDistance(Coordinates point1, Coordinates point2)
{
double distance;
// Calculate the distance
distance = Math.Sqrt(Math.Pow(point1.getX() - point2.getX(), 2) +
Math.Pow(point1.getY() - point2.getY(), 2));
return (distance);
}
示例3: update
public void update(SpriteBatch spriteBatch)
{
updateSize();
Coordinates upperExtreme = new Coordinates(Math.Floor(Game1.player.coordinates.getX()) + xLength, Math.Floor(Game1.player.coordinates.getY() + yLength));
Coordinates lowerExtreme = new Coordinates(Math.Floor(Game1.player.coordinates.getX()) - xLength, Math.Floor(Game1.player.coordinates.getY() - yLength));
int xDistance = (int)Math.Abs(upperExtreme.getX() - lowerExtreme.getX());
int yDistance = (int)Math.Abs(upperExtreme.getY() - lowerExtreme.getY());
for (int x = 0; x <= xDistance; x++) {
for (int y = 0; y <= yDistance; y++) {
double xCoord = upperExtreme.getX() + increment(x, (int)upperExtreme.getX(), (int)lowerExtreme.getX());
double yCoord = upperExtreme.getY() + increment(y, (int)upperExtreme.getY(), (int)lowerExtreme.getY());
Block block = getBlockAt(new Coordinates(xCoord,yCoord));
block.draw(spriteBatch, null, util.getPosition(block.getCoordinates()));
}
}
}