示例#1
0
        public void MoveSnakeItemToNextXLocation(GamePiece p, XYPointer whereToMove)
        {
            decimal snakeXPosition       = p.XPosition;
            decimal wantedSnakeXPosition = whereToMove.XProperty;

            if (snakeXPosition != wantedSnakeXPosition)
            {
                if (snakeXPosition > wantedSnakeXPosition)
                {
                    if (snakeXPosition - wantedSnakeXPosition > 1)
                    {
                        p.XPosition = whereToMove.XProperty;
                        return;
                    }
                    p.XPosition -= 0.1m;
                }
                else if (snakeXPosition < wantedSnakeXPosition)
                {
                    if (wantedSnakeXPosition - snakeXPosition > 1)
                    {
                        p.XPosition = whereToMove.XProperty;
                        return;
                    }
                    p.XPosition += 0.1m;
                }
            }
        }
示例#2
0
        private void tryEat(GamePiece gamePiece, XYPointer nextCorindate, ObservableCollection <BasePresenterItem> items)
        {
            var goingToBeEatten = items.Where((m) =>
            {
                //get the item that answers "next cordinate".
                if (m.CurrentGamePiece.XPosition == nextCorindate.XProperty &&
                    m.CurrentGamePiece.YPosition == nextCorindate.YProperty)
                {
                    return(true);
                }
                return(false);
            });

            var firstOrDeafult = goingToBeEatten.FirstOrDefault();

            if (firstOrDeafult != null)
            {
                if (firstOrDeafult is GrassPresenter)
                {
                    return;
                }
                if (firstOrDeafult is SnakePiecePresenter)
                {
                    //end game
                    DebugHelper.WriteLog("game eneded... bummer", "new snakes game manager");
                    return;
                }


                int index = items.IndexOf(firstOrDeafult);

                SnakePiecePresenter whoToFollow;
                if (snakeParts.Count > 0)
                {
                    whoToFollow = snakeParts.Last();
                }
                else
                {
                    whoToFollow = GetHeadItems(SnakePresenter.ArrayOfItems);
                }


                var snakePiece = new SnakePiece(nextCorindate.XProperty, nextCorindate.YProperty);
                SnakePiecePresenter newSnakepresetner = new SnakePiecePresenter(snakePiece, whoToFollow);
                snakeParts.Add(newSnakepresetner);
                items[index] = newSnakepresetner;
            }
            DebugHelper.WriteLog(string.Format("eatted {0},{1}", nextCorindate.XProperty, nextCorindate.YProperty), "new snakes game manager");
        }
示例#3
0
 private void GetSnakeItemAtPosition(XYPointer nextPoint, ObservableCollection <GamePiece> items)
 {
 }
示例#4
0
 private void AddOrSubtractSnakeItemToXYpoint(GamePiece last, XYPointer nextPos)
 {
 }
示例#5
0
 private void getPositionPreviousToCurrentSnakeItem(XYPointer positionOfLatestSnakeItem, Direction direction)
 {
     //
 }
示例#6
0
 private void HandlePartMovment(GamePiece item, ObservableCollection <GamePiece> items, XYPointer nextPointCordinates)
 {
 }
示例#7
0
 private void MoveSnakeByUserNew(ObservableCollection <GamePiece> items, XYPointer nextPointCordinates)
 {
 }
示例#8
0
 private bool HasAnyDiff(GamePiece gamePiece, XYPointer nextCorindate)
 {
     return(gamePiece.XPosition == nextCorindate.XProperty &&
            gamePiece.YPosition == nextCorindate.YProperty);
 }