public void InsertBegin(nodeL node) { node.next = head.next; node.prev = head; head.next.prev = node; head.next = node; length++; }
public void InsertEnd(nodeL node) { node.prev = tail.prev; node.next = tail; tail.prev.next = node; tail.prev = node; length++; }
public List() { head = new nodeL(); tail = new nodeL(); length = 0; head.prev = null; tail.next = null; head.next = tail; tail.prev = head; }
public void DeleteAppearSnake(int sid) { //snake curs = Snakes[sid]; nodeL tempn = Snakes[sid].position.tail.prev; while (tempn != Snakes[sid].position.head) { MainMatrix[tempn.x, tempn.y].update_info(0, false); Snakes[sid].position.DelEnd(); tempn = Snakes[sid].position.tail.prev; } Appear(sid); }
public void UpdateA(int[] A, int sid) { int prevscore = score; int nextid = MainMatrix[A[0], A[1]].snakeid; nodeL n = new nodeL(A[0], A[1]); if (nextid != 0) { isCrash = true; if (Snakes[sid].colour != Snakes[nextid].colour) { DeleteAppearSnake(nextid); score += 100; } else { DeleteAppearSnake(sid); DeleteAppearSnake(nextid); score = (score - 50); if (life > 0) { life--; } } } else { Snakes[sid].position.InsertBegin(n); MainMatrix[A[0], A[1]].update_info(sid, true); } int slength = rnd.Next(3, 13); if (Snakes[sid].position.length > slength) { nodeL n1 = Snakes[sid].position.tail.prev; MainMatrix[n1.x, n1.y].update_info(0, false); Snakes[sid].position.DelEnd(); } if (prevscore / 500 < score / 500 && life < 5) { life++; } }
public void UpdateA(int[] A, int sid) { int prevscore = score; int nextid = MainMatrix[A[0], A[1]].snakeid; nodeL n = new nodeL(A[0], A[1]); if (nextid!= 0) { isCrash = true; if (Snakes[sid].colour != Snakes[nextid].colour) { DeleteAppearSnake(nextid); score += 100; } else { DeleteAppearSnake(sid); DeleteAppearSnake(nextid); score = (score - 50); if (life > 0) { life--; } } } else { Snakes[sid].position.InsertBegin(n); MainMatrix[A[0], A[1]].update_info(sid, true); } int slength = rnd.Next(3, 13); if (Snakes[sid].position.length > slength) { nodeL n1 = Snakes[sid].position.tail.prev; MainMatrix[n1.x, n1.y].update_info(0, false); Snakes[sid].position.DelEnd(); } if (prevscore / 500 < score / 500 && life < 5 ) { life++; } }