internal static IStep randomVectorStep(ICoordinates xy) { Random r = new Random (); ICoordinates t=xy; bool found=false; int i =-1; while (!found) { i = r.Next ( 3 ); switch (i) { case 0: { t = Helper.Coordinates ( xy.getX () + 1,xy.getY () + 0 ); found = EpsilonBot.api.isNorm ( t ); } break; case 1: { t = Helper.Coordinates ( xy.getX () - 1,xy.getY () + 0 ); found = EpsilonBot.api.isNorm ( t ); } break; case 2: { t = Helper.Coordinates ( xy.getX () + 0,xy.getY () + 1 ); found = EpsilonBot.api.isNorm ( t ); } break; case 3: { t = Helper.Coordinates ( xy.getX () + 0,xy.getY () - 1 ); found = EpsilonBot.api.isNorm ( t ); } break; } } return Helper.StepsBuilder ( t,Steps.STEP ); }
/// <summary> Рандомный шаг из данных координат /// </summary> /// <param name="xy"></param> /// <returns></returns> //----------------------------------------------- internal static IStep randomVectorStep(ICoordinates xy) { Random r = new Random (); ICoordinates t=xy; bool found=false; int i =-1; while (!found) { i = r.Next ( 3 ); switch (i) { case 0: { t = StepsAndCoord.Coordinates ( xy.getX () + 1,xy.getY () + 0 ); } break; case 1: { t = StepsAndCoord.Coordinates ( xy.getX () - 1,xy.getY () + 0 ); } break; case 2: { t = StepsAndCoord.Coordinates ( xy.getX () + 0,xy.getY () + 1 ); } break; case 3: { t = StepsAndCoord.Coordinates ( xy.getX () + 0,xy.getY () - 1 ); } break; } if (EpsilonBot.api.isNorm ( t )) { found = EpsilonBot.api.getTypeOfField ( t ) != TypesOfField.WALL; } } return StepsAndCoord.StepsBuilder ( t,Steps.STEP ); }
/// <summary> /// проверка на равенство координат /// </summary> /// <param name="c1"></param> /// <param name="c2"></param> /// <returns></returns> internal static bool isEcualCoord(ICoordinates c1,ICoordinates c2) { return c1.getX () == c2.getX () && c1.getY () == c2.getY (); }
internal static ICoordinates Coordinates(ICoordinates c,int x,int y) { ICoordinates temp = new CCoordinates (); //дальнейшей обработки если возможно otherPositionOfThis ( temp,c.getX()+x,c.getY()+y ); return temp; }
/// <summary>/// возможность стрельбы из бластера /// </summary> internal bool canBlasterFire(ICoordinates xy) { int x = System.Math.Abs ( xy.getX () - EpsilonBot.api.getCoordOfMe ().getX () ); int y = System.Math.Abs ( xy.getY () - EpsilonBot.api.getCoordOfMe ().getY () ); return (x <= 3) && (y <= 3) && (y != x) && this.canIFireOfAny; }
///Propeties ///Methods /// <summary>/// была ли обработана вершина /// </summary> internal static bool usableSector(ICoordinates xy) { return map[xy.getX (),xy.getY ()].usable; }
/// <summary> ////Получение значения карты по координате /// </summary> /// <param name="xy">координаты запрашиваемой ячейки</param> /// <returns>клетка карты</returns> internal MapSector getMapSector(ICoordinates xy) { return map[xy.getX (),xy.getY ()]; }
//----------------------------------------------- /// <summary> /// Получение типа для сектора карты из базы /// </summary> internal static TypesOfField getSectorsType(ICoordinates xy) { // тип клетки поля return map[xy.getX (),xy.getY ()].type; }
//----------------------------------------------- /// <summary> /// Вычисление предположительного местоположения Противника относительно предыдущих координат /// </summary> private void whereHe(ICoordinates xy,TypesOfField btype,TypesOfField type) { if (!mind.He.WasFound) { ICoordinates c ; c = StepsAndCoord.Coordinates ( xy.getX () + 0,xy.getY () + 0 ); mayBeHere ( c,mind.hisMayBeXY ); c = StepsAndCoord.Coordinates (xy.getX () + 1,xy.getY () + 0 ); mayBeHere ( c, mind.hisMayBeXY ); c = StepsAndCoord.Coordinates ( xy.getX () - 1,xy.getY () + 0 ); mayBeHere ( c,mind.hisMayBeXY ); c = StepsAndCoord.Coordinates ( xy.getX () + 0,xy.getY () - 1 ); mayBeHere ( c,mind.hisMayBeXY ); c = StepsAndCoord.Coordinates ( xy.getX () + 0,xy.getY () + 1 ); mayBeHere ( c,mind.hisMayBeXY ); } }
//----------------------------------------------- /// <summary> пердсказание координат противника (вспомогательная ф- ия для whereHe()) /// </summary> private void mayBeHere(ICoordinates xy,List<MapSector> hisMayBeXY) { if (EpsilonBot.api.isNorm(xy)){ // если внутри поля TypesOfField type = api.getTypeOfField ( xy ); if ( type != TypesOfField.WALL){ // если не стена if (!mind.He.WasFound) { // если не найден //if (type == TypesOfField.HI){ // если нашл то в базу заносим 1 значение - точные координаты //hisMayBeXY.Clear(); hisMayBeXY.Add(map[xy.getX(),xy.getY()]); map[xy.getX (),xy.getY ()].type = TypesOfField.NOTHING; } } } }
//----------------------------------------------- /// <summary> сохранение информации обнаружение противника /// </summary> /// <param name="xy">его координаты</param> private void heDetected(ICoordinates xy) { map.map[xy.getX (),xy.getY ()].type = TypesOfField.HI; mind.He.WasFound = true; mind.He.XY = xy; }
/// <summary>/// возможность стрельбы из бластера /// </summary> internal bool canBlasterFire(ICoordinates xy) { return System.Math.Abs ( xy.getX () - EpsilonBot.api.getCoordOfMe ().getX () ) <= 3 && System.Math.Abs ( xy.getY () - EpsilonBot.api.getCoordOfMe ().getY () ) <= 3 && this.canIFireOfAny; }