本文整理汇总了C#中Square.getY方法的典型用法代码示例。如果您正苦于以下问题:C# Square.getY方法的具体用法?C# Square.getY怎么用?C# Square.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Square
的用法示例。
在下文中一共展示了Square.getY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: enlargeMoveable
static void enlargeMoveable(int moveRange)
{
int forceBreak=0;
bool inMoveable=false;
for (int c=0; c<moveable.Count; c++) {
if (forceBreak >= 250){
Debug.Log ("Force break at c. moveable.count:" + moveable.Count);
break;
}
else {
forceBreak++;
}
// Take current moveable cell and check around it
current = moveable[c];
int loopCount=0;
//Debug.Log("Current is x:" + current.getX () + " y:" + current.getY() + ". G is " + current.getG());
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
loopCount += 1;
if (loopCount % 2 == 1)
continue; //skipping diagonal movement
if (walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)] == 0) // Check if cell is walkable
continue;
if ((current.getG () + (moveWeight * walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)])) > (moveRange*moveWeight+10)){ // Check if cell is way too far
doneCheck = true;
return;
}
// if (moveRange*moveWeight+10 < current.getG () + moveWeight * walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)]) // Check if cell is reachable
// continue;
//Debug.Log("G of x:" + (current.getX () - 1 + j) + ", y: " + (current.getY () - 1 + i) + "is " + (current.getG()+moveWeight));
inMoveable = false;
for (int k=0; k<moveable.Count; k++){ // Check if cell is already in list
if (moveable[k].getX () == (current.getX () - 1 + j) && moveable[k].getY() == (current.getY () - 1 + i)){
inMoveable = true;
break;
}
}
if (inMoveable)
continue;
// Add squares into moveable
moveable.Add (new Square (
(int)current.getX() - 1 + j,
(int)current.getY() - 1 + i,
(current.getG () + (moveWeight * walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)])),
0));
}
}
}
}
示例2: findPath
public static void findPath(int[][] map, Vector3 start, Vector3 end)
{
//Step 0: Clear existing static lists
openLists.Clear ();
closedLists.Clear ();
//Step 1: set start as current, prepare openLists and closedLists
current = new Square ((int)start.x, (int)start.y);
target = new Square ((int)end.x, (int)end.y);
walkable = map;
closedLists.Add (current); // Add current into closed list.
int loopCount = 0;
//Step 1.1: Loop around current, add into openLists.
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
loopCount += 1;
if (loopCount % 2 == 1) /*Skip diagonal movement*/
continue;
//Debug.Log ("Floor " + ((current.getX () - 1 + i) + "," + (current.getY () - 1 + j) + " is " + walkable [(current.getY () - 1 + j)] [(current.getX () - 1 + i)]));
if (walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)] == 0) // Check if cell is walkable
continue;
//Debug.Log ("G of " + (current.getX () - 1 + i) + "," + (current.getY () - 1 + j) + " is " + (current.getG () + moveWeight*walkable [(current.getY () - 1 + j)] [(current.getX () - 1 + i)]));
//Step 1.2: Calculate heuristics before add into openLists
int heuristics = 10 * (int)(Mathf.Abs (current.getX () - 1 + j - target.getX ()) + Mathf.Abs (current.getY () - 1 + i - target.getY ()));
//Step 1.3: Add squares into openLists
openLists.Add (new Square (
(int)start.x - 1 + j,
(int)start.y - 1 + i,
(current.getG () + (moveWeight * walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)])),
heuristics,
current));
}
}
// Loop until end is reached.
int counting = 0;
while (current.getX () != target.getX () || current.getY ()!=target.getY ()) {
if (counting == 250)
break;
// Step 2: Loop through open list to get next current
//Debug.Log ("____________________ CalculateLists called!!!!!");
calculateLists ();
//Step 3: Using next current, add neighbours to open lists
growOpenLists ();
counting++;
}
Debug.Log ("openLists size is " + openLists.Count);
return;
}
示例3: highlightMoveable
public static void highlightMoveable(int[][] map, Vector3 start, int moveRange)
{
//Step 0: Clear existing static lists
moveable.Clear();
//Step 1: set start as current, prepare some variables
int loopCount=0;
current = new Square ((int)start.x, (int)start.y);
walkable = map;
//Step 1.1: Loop around current, add into openLists.
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
loopCount += 1;
if (loopCount % 2 == 1) /*Skip diagonal movement*/
continue;
if (walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)] == 0) // Check if cell is walkable
continue;
if (moveRange*moveWeight < (current.getG () + (moveWeight * walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)]))) // Check if cell is reachable
continue;
//Step 1.3: Add squares into moveable
moveable.Add (new Square (
(int)start.x - 1 + j,
(int)start.y - 1 + i,
(current.getG () + (moveWeight * walkable [(current.getY () - 1 + i)] [(current.getX () - 1 + j)])),
0));
}
}
//Loop until all squares within move range is selected
int counting = 0;
doneCheck = false;
while (doneCheck == false) {
if (counting == 250)
// Step 2: Loop through open list to get next current
enlargeMoveable (moveRange);
counting++;
}
colourMoveable(true, moveRange);
}