public Snake(Snake other) { _body = new List <Position>(); for (int i = 0; i < other.Count(); i++) { _body.Add(new Position(other.GetBody(i).X, other.GetBody(i).Y)); } }
/// <summary> /// aktualizacia pozicie hadika /// </summary> /// <param name="x">x os</param> /// <param name="y">y os</param> /// <param name="direction">smerovanie hlavy hadika</param> /// <returns>true/false</returns> private bool UpdateSnakePosition(int x, int y, Direction direction) { if (GameStatus) { var tmpSnake = new Snake(Snake); Snake.UpdatePosition(x, y, direction); GameStatus = Collision(); if (!GameStatus) { return(false); } for (int i = 0; i < tmpSnake.Count(); i++) { var pp = tmpSnake.GetBody(i); GameField.gameField[pp.X, pp.Y].SetToNaN(); } GameField.gameField[Snake.GetHead().X, Snake.GetHead().Y].SetSnakeHead(direction); if (Snake.Count() > 1) { for (int i = 1; i < Snake.Count(); i++) { var oldPos = Snake.GetBody(i); GameField.gameField[oldPos.X, oldPos.Y].SetSnakeBody(); } } return(true); } return(false); }