private void PutIntoMatrix(int row, int col, Field[,] currentMatrix,Directions drawDirection) { currentMatrix[row, col] = new SnakeField(row,col,drawDirection); }
public void RePaintPlatform(Field[,] currentMatrix) { foreach (var item in currentMatrix) { if (item is EmptyField) { EmptyField unpackedItem = (EmptyField)item; unpackedItem.CallCreateEvent(); } if (item is SnakeField) { SnakeField unpackedItem = (SnakeField)item; unpackedItem.CallCreateEvent(); } if (item is FoodField) { FoodField unpackedItem = (FoodField)item; unpackedItem.CallCreateEvent(); } if (item is WallField) { WallField unpackedItem = (WallField)item; unpackedItem.CallCreateEvent(); } } }
public SnakeFragment(int row, int col,Field[,] currentMatrix,Snake currentSnake,Directions drawDirection) { this.Row = row; this.Col = col; this.drawDirection = drawDirection; PutIntoMatrix(this.Row, this.Col, currentMatrix,drawDirection); }
private void OnlyMove(Field directionField) { this.snakeBody.Add (new SnakeFragment(directionField.Row,directionField.Col,gamePlatform.Matrix,this,this.Direction)); this.SetHeadFragment(); EmptyUsedField(); this.snakeBody.RemoveAt(0); }
private bool IsPreviousField(Field directionField) { return (directionField.Row == snakeBody[snakeBody.Count - 2].Row && directionField.Col == snakeBody[snakeBody.Count - 2].Col); }
private void IncreaseSnake(Field directionField) { this.snakeBody.Add (new SnakeFragment(directionField.Row, directionField.Col, gamePlatform.Matrix, this,this.Direction)); this.SetHeadFragment(); }
private void CheckField(Field directionField) { if (directionField is EmptyField) { this.OnlyMove(directionField); } if (directionField is FoodField) { this.IncreaseSnake(directionField); this.gamePlatform.GenerateFoodField(); } if (directionField is SnakeField) { if (IsPreviousField(directionField)) { this.NormalizeDirection(); } else { this.SnakeOverlap(); } } if (directionField is WallField) { this.WallHit(); } }