Example #1
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");
        }
Example #2
0
 private void updateSnakeItemToFinalCordinates(decimal FinalNextXposition, decimal FinalNextYposition, GamePiece snakeItemToBeInserted)
 {
 }
Example #3
0
 private void HandleYProperty(GamePiece last, decimal p)
 {
 }
Example #4
0
 private bool HasAnyDiff(GamePiece gamePiece, XYPointer nextCorindate)
 {
     return gamePiece.XPosition == nextCorindate.XProperty
         && gamePiece.YPosition == nextCorindate.YProperty;
 }
Example #5
0
 private void HandlePartMovment(GamePiece item, ObservableCollection<GamePiece> items, XYPointer nextPointCordinates)
 {
 }
Example #6
0
 private void AddOrSubtractSnakeItemToXYpoint(GamePiece last, XYPointer nextPos)
 {
 }
Example #7
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;
                }
            }
        }
Example #8
0
 public BasePresenterItem(GamePiece g)
 {
     CurrentGamePiece = g;
     CurrentGamePiece.PropertyChanged += new PropertyChangedEventHandler(CurrentGamePiece_PropertyChanged);
     OnPropertyChanged("CurrentGamePiece");
 }
Example #9
0
 public SnakePiecePresenter(GamePiece g, SnakePiecePresenter WhoToFollow)
     : base(g)
 {
     WhoToFollowSnakePresenter = WhoToFollow;
 }