/// <summary> /// creates ellipse on a board in Point and gives it number i /// </summary> public Cop(Board board, Point node, int i) { myNode = new Node(node); myNeighbors = new List<int>(); myNode.number = i; board.pointCop(node, myNode); myNeighbors = board.findNeighbors(myNode.number); }
/// <summary> /// creates ellipse on a board in Point and gives it number i /// </summary> public Cop(Board board, Point node, int i) { myNode = new Node(node); myNeighbors = new List <int>(); myNode.number = i; board.pointCop(node, myNode); myNeighbors = board.findNeighbors(myNode.number); }
private void plansza_MouseDown(object sender, MouseButtonEventArgs e) { string elem = findElement(sender, e); if (elem == null || elem == "") { } else if (elem != "" && elem.Substring(0, 3) == "nod") { clickedElement = Convert.ToInt32(elem.Substring(4, elem.Length - 4)); if (copTurn) { if (copPlaced) { if (cop.myNeighbors.Contains(clickedElement)) { checkboard.Children.Remove(cop.myNode.elly); cop.myNode.number = clickedElement; cop.myNeighbors = board.findNeighbors(cop.myNode.number); board.pointCop(findPoint(elem), cop.myNode); checkboard.Children.Add(cop.myNode.elly); RobberMove(); } else { cop.myNeighbors = board.findNeighbors(cop.myNode.number); MessageBox.Show("tak daleko nie dobiegnę..."); } } else { int tmp; cop = new Cop(board, findPoint(elem, out tmp), tmp); checkboard.Children.Add(cop.myNode.elly); copPlaced = true; copTurn = false; lblTura.Text = "Złodziej"; } } else { if (!robberPlaced) { int tmp; robber = new Robber(board, findPoint(elem, out tmp), tmp); checkboard.Children.Add(robber.myNode.elly); robberPlaced = true; copTurn = true; lblTura.Text = "Gliniarz"; } } } else if (elem.Substring(0, 3) == "rob" || elem.Substring(0, 3) == "cop") { if (copTurn) { if (cop.myNeighbors.Contains(robber.myNode.number)) { gameEnd("cop"); } else { MessageBox.Show("jeszcze za daleko"); } } else { if (robber.myNeighbors.Contains(cop.myNode.number)) { gameEnd("robber"); } else { MessageBox.Show("no widze go i co?!"); } } } }