public bool OnSelf(Coordinat coors) { foreach (var item in Cors) { if (coors.Equals(item)) { return(true); } } return(false); }
private void AddApple(int quantity, AppleType type = AppleType.GrowSize) { var rand = new Random(); for (int i = 0; i < quantity; i++) { var cors = new Coordinat(_field); while (_snake.OnSelf(cors)) { cors = new Coordinat(_field); } _apples.Add(new Apple(cors, type)); } }
public Coordinat GetOffset() { var cors = new Coordinat(); if (_oldDirection == Direction.Down) { cors.Y = 1; } else if (_oldDirection == Direction.Up) { cors.Y = -1; } else if (_oldDirection == Direction.Right) { cors.X = 1; } else if (_oldDirection == Direction.Left) { cors.X = -1; } return(cors); }
private void PrintSymbol(Coordinat coordinat, char symbol, ConsoleColor background = ConsoleColor.Black, ConsoleColor font = ConsoleColor.White) => PrintSymbol(coordinat.X, coordinat.Y, symbol, background, font);
private void RemoveApple(Coordinat coordinat) { _apples.RemoveAll(a => a.Cors.Equals(coordinat)); }
public Apple(Coordinat cors, AppleType type) { Type = type; Cors = cors; }