public static Snake ProduceSnake(int x, int y, int size, Config.Player player) { switch (player) { case Config.Player.Player1: { return(new Snake(x, y, size, Config.Player.Player1)); } case Config.Player.Player2: { return(new Snake(x, y, size, Config.Player.Player2)); } case Config.Player.Player3: { return(new Snake(x, y, size, Config.Player.Player3)); } default: { throw new MissingFieldException(); } } }
public Snake(Point point, int size, Config.Player player) { this.currentDirection = Config.GetPlayerDirection(player); this.controller = Config.GetPlayerControl(player); this.brush = Config.GetPlayerColor(player); this.player = player; this.score = 0; this.isAlive = true; this.moveTrigger = new Trigger(1); this.moveTrigger.Triggered += Move; this.moveTrigger.Start(); this.speedTimeTrigger = new Trigger((1000 / MainForm.FPS) * 10); this.speedTimeTrigger.Triggered += StopSpeedUp; body.Add(new SnakeBody(point, this)); expand(size); Move(); }
private Point GetStartLocation(int tilesX, int tilesY, Config.Player player) { switch (player) { case Config.Player.Player1: var startPoint1 = new Point(1, 2); return(startPoint1); case Config.Player.Player2: var startPoint2 = new Point(tilesX - 2, 2); return(startPoint2); case Config.Player.Player3: var startPoint3 = new Point(tilesX / 2, tilesY - 2); return(startPoint3); default: { throw new MissingFieldException(); } } }
public Snake(int x, int y, int size, Config.Player player) : this(new Point(x, y), size, player) { }