Esempio n. 1
0
 public GamePiece(decimal x, decimal y, Direction d)
 {
     XPosition = x;
     YPosition = y;
     MovingDirection = d;
     _nextCertifafedPoint = new XYPointer() { XProperty = XPosition, YProperty = YPosition };
 }
Esempio n. 2
0
 public GamePiece(decimal x, decimal y, Direction d)
 {
     XPosition            = x;
     YPosition            = y;
     MovingDirection      = d;
     _nextCertifafedPoint = new XYPointer()
     {
         XProperty = XPosition, YProperty = YPosition
     };
 }
Esempio n. 3
0
        public virtual XYPointer getNextPointCordinates()
        {
            XYPointer nextPoint = new XYPointer();
            decimal xpositionToReturn = XPosition;
            decimal ypositionToReturn = YPosition;

            if (ShouldUpdateLocationOfNextPoint(xpositionToReturn, ypositionToReturn))
            {

                #region case directions...

                switch (MovingDirection)
                {
                    // when i move in need to change the cell i just left.
                    case Direction.Up:
                        {
                            ypositionToReturn--;
                            if (ypositionToReturn < 0)
                            {
                                ypositionToReturn = 9;
                            }
                        }
                        break;
                    case Direction.Down:
                        {
                            ypositionToReturn++;
                            if (ypositionToReturn > 9)
                            {
                                ypositionToReturn = 0;
                            }
                        }
                        break;
                    case Direction.Left:
                        {
                            xpositionToReturn--;
                            if (xpositionToReturn < 0)
                            {
                                xpositionToReturn = 9;
                            }
                        }
                        break;
                    case Direction.Right:
                        {
                            xpositionToReturn++;
                            if (xpositionToReturn > 9)
                            {
                                xpositionToReturn = 0;
                            }
                        }
                        break;
                    case Direction.None:
                        {

                        }
                        break;
                    default:
                        break;
                }
                #endregion

                nextCertifaedPoint = new XYPointer()
                {
                    XProperty = xpositionToReturn,
                    YProperty = ypositionToReturn
                };
            }

            nextPoint.XProperty = nextCertifaedPoint.XProperty;
            nextPoint.YProperty = nextCertifaedPoint.YProperty;

            return nextPoint;
        }
Esempio n. 4
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");
        }
Esempio n. 5
0
 private void MoveSnakeByUserNew(ObservableCollection<GamePiece> items, XYPointer nextPointCordinates)
 {
 }
Esempio n. 6
0
 private bool HasAnyDiff(GamePiece gamePiece, XYPointer nextCorindate)
 {
     return gamePiece.XPosition == nextCorindate.XProperty
         && gamePiece.YPosition == nextCorindate.YProperty;
 }
Esempio n. 7
0
 private void HandlePartMovment(GamePiece item, ObservableCollection<GamePiece> items, XYPointer nextPointCordinates)
 {
 }
Esempio n. 8
0
 private void GetSnakeItemAtPosition(XYPointer nextPoint, ObservableCollection<GamePiece> items)
 {
 }
Esempio n. 9
0
 private void getPositionPreviousToCurrentSnakeItem(XYPointer positionOfLatestSnakeItem, Direction direction)
 {
     //
 }
Esempio n. 10
0
 private void AddOrSubtractSnakeItemToXYpoint(GamePiece last, XYPointer nextPos)
 {
 }
Esempio n. 11
0
        public void MoveSnakeItemToNextYLocation(GamePiece p, XYPointer whereToMove)
        {
            decimal snakeYPosition = p.YPosition;
            decimal wantedSnakeYPosition = whereToMove.YProperty;

            if (snakeYPosition != wantedSnakeYPosition)
            {

                if (snakeYPosition > wantedSnakeYPosition)
                {
                    if (snakeYPosition - wantedSnakeYPosition > 1)
                    {
                        p.YPosition = whereToMove.YProperty;
                        return;
                    }
                    p.YPosition -= 0.1m;
                }
                else if (snakeYPosition < wantedSnakeYPosition)
                {
                    if (wantedSnakeYPosition - snakeYPosition > 1)
                    {
                        p.YPosition = whereToMove.YProperty;
                        return;
                    }
                    p.YPosition += 0.1m;
                }
            }
        }
Esempio n. 12
0
        public virtual XYPointer getNextPointCordinates()
        {
            XYPointer nextPoint         = new XYPointer();
            decimal   xpositionToReturn = XPosition;
            decimal   ypositionToReturn = YPosition;

            if (ShouldUpdateLocationOfNextPoint(xpositionToReturn, ypositionToReturn))
            {
                #region case directions...

                switch (MovingDirection)
                {
                // when i move in need to change the cell i just left.
                case Direction.Up:
                {
                    ypositionToReturn--;
                    if (ypositionToReturn < 0)
                    {
                        ypositionToReturn = 9;
                    }
                }
                break;

                case Direction.Down:
                {
                    ypositionToReturn++;
                    if (ypositionToReturn > 9)
                    {
                        ypositionToReturn = 0;
                    }
                }
                break;

                case Direction.Left:
                {
                    xpositionToReturn--;
                    if (xpositionToReturn < 0)
                    {
                        xpositionToReturn = 9;
                    }
                }
                break;

                case Direction.Right:
                {
                    xpositionToReturn++;
                    if (xpositionToReturn > 9)
                    {
                        xpositionToReturn = 0;
                    }
                }
                break;

                case Direction.None:
                {
                }
                break;

                default:
                    break;
                }
                #endregion

                nextCertifaedPoint = new XYPointer()
                {
                    XProperty = xpositionToReturn,
                    YProperty = ypositionToReturn
                };
            }



            nextPoint.XProperty = nextCertifaedPoint.XProperty;
            nextPoint.YProperty = nextCertifaedPoint.YProperty;

            return(nextPoint);
        }