public TopScoreFrugalList() { for (int i = 0; i < ItemsCount; i++) { TopScoreEntry item = this._items[i] = new TopScoreEntry(); item.Name = "...."; } }
public int Add(TopScoreEntry item) { for (int i = 0; i < ItemsCount; i++) { if (this._items[i].Score < item.Score) { for (int k = ItemsCount - 2; k >= i; k--) { this._items[k + 1] = this._items[k]; } this._items[i] = item; return(i); } } return(-1); }
private void UpdateRegister() { if (this._oldStatus != GameStatus.Registering) { this._oldStatus = GameStatus.Registering; //init local stage this._counter = 0; var entry = new TopScoreEntry(); entry.Score = this._context.CurrentScore; if (this._context.TopScores.Add(entry) >= 0) { //the current score enters in the hall of fame this._scoreEntry = entry; this._context.HighScore = this._context.TopScores.GetItem(0).Score; } else { //skip registration and quit to the intro this._context.Status = GameStatus.RegComplete; return; } } var flasher = (this._context.Clock & 4) != 0; if (this._context.LeftButton) { if (this._isButtonPressed == false) { this._isButtonPressed = true; if (this._counter > 0) { this._counter--; } } } else if (this._context.RightButton) { if (this._isButtonPressed == false) { this._isButtonPressed = true; if (this._counter < 38) //strip max index { this._counter++; } } } else if (this._context.FireButton) { if (this._isButtonPressed == false) { this._isButtonPressed = true; //gets the char at cursor char selected = RegisterStrip[this._counter]; switch ((int)selected) { case CharCodeDel: int length; if ((length = this._scoreEntry.Name.Length) > 0) { this._scoreEntry.Name = this._scoreEntry.Name.Substring(0, length - 1); } break; case CharCodeEnd: //registration complete: back to the intro this._context.Status = GameStatus.RegComplete; break; default: if (this._scoreEntry.Name.Length < 4) { this._scoreEntry.Name += selected; } break; } } } else { this._isButtonPressed = false; } //registration title this._composition.DrawString( "Enter your name:", null, Brushes.Black, 2, 0); //chararcter strips this._composition.DrawString( RegisterStrip.Substring(0, 20), null, Brushes.Black, 0, 1); this._composition.DrawString( RegisterStrip.Substring(20), null, Brushes.Black, 0, 2); //place the flashing cursor over the current character if (flasher) { this._composition.DrawPixel( this._counter % 20, 1 + this._counter / 20, Colors.White); } //display the user name this._composition.DrawString( ">>>____<<<", null, Brushes.Black, 5, 3); this._composition.DrawString( this._scoreEntry.Name, null, Brushes.Black, 8, 3); }
private void UpdateIdle() { if (this._oldStatus != GameStatus.Idle) { this._oldStatus = GameStatus.Idle; //init local stage this._counter = 0; } if (this._counter < 60) { //show top scores this._composition.DrawString("Hall", null, Brushes.Black, 0, 0); this._composition.DrawString("of", null, Brushes.Black, 1, 1); this._composition.DrawString("Fame", null, Brushes.Black, 0, 2); for (int i = 0, count = this._context.TopScores.Count; i < count; i++) { TopScoreEntry item = this._context.TopScores.GetItem(i); this._composition.DrawString( "00000", null, Brushes.Black, 14, i); this._composition.DrawString( item.Name, null, Brushes.Black, 8, i); var text = item.Score.ToString(); Size sz = this._composition.MeasureString(text, null); this._composition.DrawString( text, null, Brushes.Black, 19 - sz.Width, i); } } else if (this._counter < 150) { //show ads this._composition.DrawString("Just a Netduino 2,", null, Brushes.Black, 0, 0); this._composition.DrawString("a led-matrix, a LCD,", null, Brushes.Black, 0, 1); this._composition.DrawString("a few hardware more,", null, Brushes.Black, 0, 2); this._composition.DrawString("and have lot of fun!", null, Brushes.Black, 0, 3); } else { this._counter = 0; } this._counter++; }