public IntPoint hunt(IntPoint whereNow, IntPoint toGo) { IntPoint whereNowOld = new IntPoint(whereNow.x, whereNow.y); if (whereNow.x < 0) whereNow.x = 0; if (whereNow.x >= maxWave) whereNow.x = maxWave - 1; if (toGo.x < 0) toGo.x = 0; if (toGo.x >= maxWave) toGo.x = maxWave - 1; if (whereNow.y < 0) whereNow.y = 0; if (whereNow.y >= maxWave) whereNow.y = maxWave - 1; if (toGo.y < 0) toGo.y = 0; if (toGo.y >= maxWave) toGo.y = maxWave - 1; build_wave(0, 0, toGo.x, toGo.y); int d = wave[whereNow.x, whereNow.y]; if (d != 0) { int size = wave.GetLength(0); int size2 = wave.GetLength(1); if (WorldLive.percent(50)) { if (whereNow.x > 0) if (wave[whereNow.x - 1, whereNow.y] == d - 1) return new IntPoint(whereNowOld.x-1, whereNowOld.y);// h.move("up"); if (whereNow.x < size - 1) if (wave[whereNow.x + 1, whereNow.y] == d - 1) return new IntPoint(whereNowOld.x+1, whereNowOld.y);//h.move("down"); if (whereNow.y > 0) if (wave[whereNow.x, whereNow.y - 1] == d - 1) return new IntPoint(whereNowOld.x, whereNowOld.y-1);//h.move("left"); if (whereNow.y < size2 - 1) if (wave[whereNow.x, whereNow.y + 1] == d - 1) return new IntPoint(whereNowOld.x, whereNowOld.y+1);//h.move("right"); } else { if (whereNow.y > 0) if (wave[whereNow.x, whereNow.y - 1] == d - 1) return new IntPoint(whereNowOld.x, whereNowOld.y - 1);//h.move("left"); if (whereNow.y < size2 - 1) if (wave[whereNow.x, whereNow.y + 1] == d - 1) return new IntPoint(whereNowOld.x, whereNowOld.y + 1);//h.move("right"); if (whereNow.x > 0) if (wave[whereNow.x - 1, whereNow.y] == d - 1) return new IntPoint(whereNowOld.x - 1, whereNowOld.y);// h.move("up"); if (whereNow.x < size - 1) if (wave[whereNow.x + 1, whereNow.y] == d - 1) return new IntPoint(whereNowOld.x + 1, whereNowOld.y);//h.move("down"); } } return new IntPoint(-1, -1); }
void TryToMove(IntPoint where) { if (where.x >= 0 && where.y >= 0 && where.x < WorldLive.worldSizeX && where.y < WorldLive.worldSizeY) { foreach (gameObjMain t in Program.gameList.objects) { if (t.i == where.x && t.j == where.y && t.IsBlocking == true) { say("Не пройти"); return; } } setPos(where.x, where.y); say(i.ToString() + " " + j.ToString()); } else say("Хм.."); }
void someSearch() { switch (stage) { case 0: say("Кушать хочу"); target = new IntPoint(-1, -1); foreach(gameObjMain t in Program.gameList.objects) { if (t is grassEat) { (target as IntPoint).x = t.i; (target as IntPoint).y = t.j; stage++; say("О вон какая вкусняшка!"); return; } } say("Похоже еды нет. Хнык хнык."); break; //выбор точки case 1: if (i == (target as IntPoint).x && j == (target as IntPoint).y) { priority = 0; say("Ну пришел вроде"); stage++; } else { IntPoint t = WorldLive.Wave.hunt(new IntPoint(i, j), new IntPoint((target as IntPoint).x, (target as IntPoint).y)); TryToMove(t); } break; //волна case 2: break; //съел } }