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