public Snake(Canvas board, int Height, int Width) { this.board = board; width = Width; height = Height; Random pos = new Random(); this.Body = new List <BodyPart>(); for (int i = 1; i <= lenght; i++) { if (this.Body.Count == 0) { this.Body.Add(new BodyPart(pos.Next(5, Width), pos.Next(5, Height))); } else { this.Body.Add(new BodyPart(this.Head.position.x, this.Head.position.y + i * 20)); } } status = state.alive; CurrentOrientation = orientation.up; this.hasEaten += Eating; this.hasGrown += Growing; this.hasDied += Dying; this.hasOverlapped += Overlapping; }
private void reLocate() { Random pos = new Random(); this.location = new Position(pos.Next(15, width - 50), pos.Next(15, height - 50)); int quantity = pos.Next(0, 10); if (quantity == 7) { this.size = 2; } else { this.size = 1; } status = state.alive; translate.X = this.location.x; translate.Y = this.location.y; collision = new Rect(this.translate.X, this.translate.Y, 20, 20); }
private void Dying() { this.Body.Clear(); this.lenght = 0; this.status = state.dead; }
public void kill() { this.status = state.dead; reIncarnate(); }