/// <summary> /// Load the high scores from the save. /// </summary> void loadHighScores() { if (PlayerPrefs.HasKey("HighScores")) { scores = JsonUtility.FromJson<HighScores>(PlayerPrefs.GetString("HighScores")); } }
public void added_20_scores_to_highscores_result_10_scores() { var highScores = new HighScores(); for (int i = 0; i < 20; i++) { highScores.Add(new Score(i.ToString(CultureInfo.InvariantCulture), i)); } Assert.AreEqual(10, highScores.Count()); }
public void added_20_scores_to_highscores_result_10_scores() { var highScores = new HighScores(); for (int i = 0; i < 20; i++) { highScores.Add(new Score(i)); } Assert.AreEqual(10, highScores.Count()); }
public void Personal_top_highest_to_lowest() { var sut = new HighScores(new List <int> { 20, 10, 30 }); Assert.Equal(new List <int> { 30, 20, 10 }, sut.PersonalTopThree()); }
public void Personal_top_when_there_is_a_tie() { var sut = new HighScores(new List <int> { 40, 20, 40, 30 }); Assert.Equal(new List <int> { 40, 40, 30 }, sut.PersonalTopThree()); }
// Use this for initialization void Start() { highscoresManager = GetComponent <HighScores>(); //Store the final score into highscoreText finalScore = PlayerPrefs.GetInt("finalScore"); highscoreText.text = "Your Score: " + finalScore; StartCoroutine("RefreshHighscores"); }
public void Personal_top_when_there_is_only_one() { var sut = new HighScores(new List <int> { 40 }); Assert.Equal(new List <int> { 40 }, sut.PersonalTop()); }
public void Personal_top() { var sut = new HighScores(new List <int> { 50, 30, 10 }); Assert.Equal(new List <int> { 50, 30, 10 }, sut.PersonalTop()); }
public void Personal_top_when_there_are_less_than_3() { var sut = new HighScores(new List <int> { 30, 70 }); Assert.Equal(new List <int> { 70, 30 }, sut.PersonalTopThree()); }
public void Personal_top_three_from_a_list_of_scores() { var sut = new HighScores(new List <int> { 10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70 }); Assert.Equal(new List <int> { 100, 90, 70 }, sut.PersonalTopThree()); }
public void List_of_scores() { var sut = new HighScores(new List <int> { 30, 50, 20, 70 }); Assert.Equal(new List <int> { 30, 50, 20, 70 }, sut.Scores()); }
public void Personal_top_from_a_long_list() { var sut = new HighScores(new List <int> { 10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70 }); Assert.Equal(new List <int> { 100, 90, 70 }, sut.PersonalTop()); }
public void endRace() { //save total time var playerName = GameController.getName(); var playerTime = Time.time - racestartTime; HighScores.newTotalTime(playerName, playerTime, track); game.SaveGame(); finishScreen(); }
void Start() { for (int i = 0; i < highscoreFields.Length; i++) { highscoreFields[i].text = i + 1 + ". Fetching..."; } highscoresManager = GetComponent<HighScores>(); StartCoroutine("RefreshHighscores"); }
private void Awake() { instance = this; path = Methods.GenerateFilePath(highScoreSavePath); highScores = Methods.Load <HighScores>(path); if (highScores == null) { highScores = new HighScores(); } }
private void Start() { int score = PlayerPrefs.GetInt("Score"); string s = PlayerPrefs.GetString("Highscores"); if (string.IsNullOrEmpty(s)) { highscore = new HighScores(); highscore.scores = new List <int>(); } else { highscore = JsonUtility.FromJson <HighScores>(s); } if (highscore.scores.Count < totalHighScores) { int amount = totalHighScores - highscore.scores.Count; for (int i = 0; i < amount; i++) { highscore.scores.Add(0); } } if (score > highscore.scores[totalHighScores - 1]) { ; } { highscore.scores[totalHighScores - 1] = score; } highscore.scores.Sort(); highscore.scores.Reverse(0, totalHighScores); highscoreText.text = "HIGH SCORES\n"; for (int i = 0; i < totalHighScores; i++) { if (highscore.scores[i] == score) { highscoreText.text += "<color=#FF0000FF>" + (i + 1).ToString() + "." + highscore.scores[i].ToString() + "<color>\n"; } else { highscoreText.text += (i + 1).ToString() + "." + highscore.scores[i].ToString() + "\n"; } } string scoresJSON = JsonUtility.ToJson(highscore); PlayerPrefs.SetString("HighScores", scoresJSON); }
public void ShowGUI() { GameData.playerName = GUI.TextField(new Rect(Screen.width / 2 - 75, Screen.height / 2 - 30, 150, 30), GameData.playerName); if (GUI.Button(new Rect(Screen.width / 2 - 135, Screen.height / 2, 270, 30), "Back to menu")) { HighScores.AddHighScore(GameData.playerName, manager.gameDataRef.score); HighScores.SaveScores(); manager.Restart(); } }
// Use this for initialization void Start() { for (int i = 0; i < highscoreText.Length; i++) { highscoreText[i].text = i + 1 + ". Loading..."; } highscoresManager = GetComponent <HighScores>(); StartCoroutine("RefreshHighscores"); }
private void Awake() { entryContainer = GameObject.FindGameObjectWithTag("HighScoreBox"); realEntryContainer = entryContainer.transform; entryTemplate = realEntryContainer.Find("HighScoreEntryTemplate"); entryTemplate.gameObject.SetActive(false); highScoreEntryList = new List <HighScoreEntry>() { new HighScoreEntry { Score = 500 }, new HighScoreEntry { Score = 120 }, new HighScoreEntry { Score = 150 }, new HighScoreEntry { Score = 320 }, new HighScoreEntry { Score = 400 }, }; for (int i = 0; i < highScoreEntryList.Count; i++) { for (int j = 0; j < highScoreEntryList.Count; j++) { if (highScoreEntryList[i].Score > highScoreEntryList[j].Score) { HighScoreEntry tmp = highScoreEntryList[i]; highScoreEntryList[i] = highScoreEntryList[j]; highScoreEntryList[j] = tmp; } } } highScoreEntryTransformList = new List <Transform>(); foreach (HighScoreEntry highScoreEntry in highScoreEntryList) { createHighScoreEntry(highScoreEntry, realEntryContainer, highScoreEntryTransformList); } HighScores allHighScores = new HighScores { HighScoreEntryList = highScoreEntryList }; string json = JsonUtility.ToJson(allHighScores); PlayerPrefs.SetString("HighScoreTables", json); PlayerPrefs.Save(); print(PlayerPrefs.GetString("HighScoreTables")); }
public void TestHighScoreSaving() { HighScores hss = new HighScores(); hss.AddHighScore(new HighScore { points = 100, name = "TEST2" }); hss.SaveHighScores(); hss.LoadHighScores(); Assert.AreEqual(hss[0].points, 100); }
// Use this for initialization void Start() { m_gameBoard = GameObject.FindObjectOfType <Board>(); m_spawner = GameObject.FindObjectOfType <Spawner>(); m_soundManager = GameObject.FindObjectOfType <SoundManager> (); m_scoreManager = GameObject.FindObjectOfType <ScoreManager> (); m_highScores = GameObject.FindObjectOfType <HighScores>(); m_holder = GameObject.FindObjectOfType <Holder> (); m_input = GameObject.FindObjectOfType <InputField>(); m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight; m_timeToNextKeyDown = Time.time + m_keyRepeatRateDown; m_timeToNextKeyRotate = Time.time + m_keyRepeatRateRotate; if (!m_gameBoard) { Debug.LogWarning("WARNING! There is no game board defined!"); } if (!m_soundManager) { Debug.LogWarning("WARNING! There is no sound manager defined!"); } if (!m_scoreManager) { Debug.LogWarning("WARNING! There is no score manager defined!"); } if (!m_spawner) { Debug.LogWarning("WARNING! There is no spawner defined!"); } else { m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position); if (!m_activeShape) { m_activeShape = m_spawner.SpawnShape(); m_settleTime = 1; } } if (!m_gameOver) { m_gameOverPanel.transform.localScale = new Vector3(0, 0, 0); } if (m_pausePanel) { m_pausePanel.SetActive(false); } }
public void submitScore() { //If score is on the Leaderboard, add it to the server //if(inputWrapper.activeSelf == true) //{ HighScores.addNewHighScore(inputField.text, finalScore); //inputWrapper.SetActive (false); addedScore = true; highscoreText.text = "Score: " + finalScore + "\nScore Submitted!"; //} }
public void TestIsHighScoreWithFullScoreList2() { HighScores higScoresList = new HighScores(2); higScoresList.AddTopScore(new Player("a", 10)); higScoresList.AddTopScore(new Player("b", 2)); bool actual = higScoresList.IsHighScore(1); bool expected = false; Assert.AreEqual(expected, actual); }
public void OnClearButtonClick() { foreach (var highscoreEntry in this.highScoreEntriesTransforms) { highscoreEntry.gameObject.SetActive(false); } highScores = new HighScores(); PlayerPrefs.DeleteKey("highscoresTable"); PlayerPrefs.Save(); }
private void ResetList() { string jsonString = PlayerPrefs.GetString("highscores"); HighScores highscores = JsonUtility.FromJson <HighScores>(jsonString); highscores.highscoresList.Clear(); string json = JsonUtility.ToJson(highscores); PlayerPrefs.SetString("highscores", json); PlayerPrefs.Save(); }
public HighScores Parse(string filename) { XmlSerializer xs = new XmlSerializer(typeof(HighScores)); TextReader tr = new StreamReader(filename); HighScores hs = xs.Deserialize(tr) as HighScores; tr.Close(); return(hs); }
public void SubmitScore() { if (highScores == null) { highScores = GameObject.Find("References").GetComponent <References>().hs; } highScores.gameObject.SetActive(true); highScores.isReady = true; highScores.SubmitHighscore(inputField.text, score); highScores.gameObject.SetActive(false); }
public void highscore_cleared_highscore_is_empty() { var highScores = new HighScores(); for (int i = 0; i < 20; i++) { highScores.Add(new Score(i)); } highScores.Clear(); CollectionAssert.IsEmpty(highScores); }
public override void ProcessMessage(WorldMessage message) { switch (message.Name) { case MessageName.ShowIntro: LoadLevel(new IntroLevel(this)); break; case MessageName.ShowMenu: LoadLevel(new MenuLevel(this)); break; case MessageName.ShowHelp: LoadLevel(new HelpLevel(this)); break; case MessageName.Quit: Quit(); break; case MessageName.ShowReady: TotalPlayers = ((PlayerReadyMessage)message).Players; LoadLevel(new ReadyLevel(this, CurrentPlayer = 1, CurrentLevel = 1)); break; case MessageName.StartGame: LoadLevel(new GameLevel(this, CurrentLevel, new GameLevel.LevelConfig(@"invaders\resources\levels"))); break; case MessageName.NextLevel: if (CurrentLevel < 3) { LoadLevel(new ReadyLevel(this, CurrentPlayer, ++CurrentLevel)); } else { LoadLevel(new WinLevel(this, CurrentPlayer, ((GameFinishedMessage)message).Score)); } break; case MessageName.NextPlayer: if (CurrentPlayer < TotalPlayers) { LoadLevel(new ReadyLevel(this, ++CurrentPlayer, CurrentLevel = 1)); } else { LoadLevel(new MenuLevel(this)); } break; case MessageName.GameOver: HighScores.Record(((GameFinishedMessage)message).Player, ((GameFinishedMessage)message).Score); LoadLevel(new LostLevel(this, CurrentPlayer, ((GameFinishedMessage)message).Score)); break; case MessageName.GameCompleted: HighScores.Record(((GameFinishedMessage)message).Player, ((GameFinishedMessage)message).Score); LoadLevel(new WinLevel(this, CurrentPlayer, ((GameFinishedMessage)message).Score)); break; } }
public async Task <IActionResult> Create([Bind("HighScoreID,Username,Score,Date")] HighScores highScores) { if (ModelState.IsValid) { _context.Add(highScores); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(highScores)); }
// This method checks the GameScreen.IsActive property, so the game will // stop updating when the pause menu is active, or if you tab away to a different application. public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, false); // Gradually fade in or out depending on whether we are covered by the pause screen. if (coveredByOtherScreen) { _pauseAlpha = Math.Min(_pauseAlpha + 1f / 32, 1); } else { _pauseAlpha = Math.Max(_pauseAlpha - 1f / 32, 0); } if (IsActive) { _playerSprite.Update(gameTime); foreach (var obstacle in _obstacles) { obstacle.Update(gameTime); if (obstacle.Bounds.CollidesWith(_playerSprite.Bounds)) { ScreenManager.ToggleSparks(); score = _timer.Elapsed.TotalSeconds; if (_highScore < score) { _highScore = score; HighScores.WriteFile(_highScore); } _timer.Reset(); for (int i = _obstacleCount + 2; i > 2; i--) { ScreenManager.Game.Components.RemoveAt(i); } ScreenManager.RemoveScreen(this); ScreenManager.AddScreen(new BackgroundScreen(), null); if (!_newHighScore) { ScreenManager.AddScreen(new DeathMenuScreen("Time survived: " + Math.Round(score, 2).ToString()), null); } else { ScreenManager.AddScreen(new DeathMenuScreen("New High Score: " + Math.Round(score, 2).ToString()), null); } ScreenManager.Flash(_playerSprite.Position); ScreenManager.Flash(_playerSprite.Position); ScreenManager.Flash(_playerSprite.Position); _deathSound.Play(); MediaPlayer.Pause(); break; } } } }
public void Latest_score_should_not_change_after_calling_personal_top_three() { var sut = new HighScores(new List <int> { 20, 100, 30, 90, 2, 70 }); Assert.Equal(new List <int> { 100, 90, 70 }, sut.PersonalTopThree()); Assert.Equal(70, sut.Latest()); }
public void InsertScore(string username, string score) { HighScores newScore = new HighScores(); newScore.Username = username; newScore.Score = int.Parse(score); newScore.Date = DateTime.Now; _context.Add(newScore); _context.SaveChanges(); }
public void highscore_cleared_highscore_is_empty() { var highScores = new HighScores(); for (int i = 0; i < 20; i++) { highScores.Add(new Score(i.ToString(CultureInfo.InvariantCulture), i)); } highScores.Clear(); CollectionAssert.IsEmpty(highScores); }
/// <summary> /// Initializes the ScreenManager /// </summary> public override void Initialize() { base.Initialize(); HighScores.ReadFile(); HighScores.Difficulty = 1; _isInitialized = true; _sparks = new SparkParticleSystem(Game, new Rectangle(-100, 500, 1000, 10)); Game.Components.Add(_sparks); _flash = new FlashParticleSystem(Game, 20); Game.Components.Add(_flash); }
public float GetAverageScores() { highScores = GetHighScores(); int combined = 0; foreach (HighScoreEntry entry in highScores.highScoreEntryList) { combined += entry.score; } return((float)combined / (float)highScores.highScoreEntryList.Count); }
public void only_highest_scores_are_stored_in_highscores() { var highScores = new HighScores(); var randomGenerator = new Random(); var generatedNumbers = new List<int>(); for (int i = 0; i < 20; i++) { var number = randomGenerator.Next(); highScores.Add(new Score(number)); generatedNumbers.Add(number); } Assert.AreEqual(generatedNumbers.OrderByDescending(x => x).Take(10).Min(), highScores.Min().Points); }
public void GameOver() { gameOver = true; HighScores highScores = new HighScores(); if (highScores.IsHighScore(score)) { gameOverText.text = "New high score!"; highScores.AddHighScore("You", score); highScores.SaveHighScores(); StartCoroutine(SwitchToLevelAfterPause("HighScores", 4.0f)); } else { gameOverText.text = "Game Over"; } }
static void Main(string[] args) { MyScores = LoadScores(); Program p = new Program(); tcpListener = new TcpListener(IPAddress.Any, 2593); tcpListener.Start(); tcpListener.BeginAcceptTcpClient(new AsyncCallback(p.AcceptClientConnection), tcpListener); while (true) { Thread.Sleep(5000); SaveScores(); } }
static Options() { //Default map mapName = "CloseQuarters"; Testing = false; play = false; mapEditing = false; if(File.Exists(HighScoresDirectory +"/"+ HighScores.HighScoresFileName)) { highScores = HighScores.load (File.ReadAllText(HighScoresDirectory +"/"+ HighScores.HighScoresFileName)); } else { highScores = new HighScores(); Directory.CreateDirectory(HighScoresDirectory); } playMusic = true; }
public void insertHighScore(int ScorePlayerID, Score score) { using (var context = new CheckersDatabaseContainer()) { var query = from Player in context.Players where Player.PlayerID == ScorePlayerID select Player; foreach (var result in query) { var player = result; var highScore = new HighScores() { Player = player, PlayerID = ScorePlayerID, PlayerMoves = score.GetPlayerMoves(), PlayerScoreDate = score.GetPlayerScoreDate() }; context.HighScores.Add(highScore); } context.SaveChanges(); } }
private void StartState() { switch (_state) { case "MainMenu": _menu = new MainMenu(this); AddChild(_menu); break; case "HighScores": _scores = new HighScores(this); AddChild(_scores); break; case "Credits": _credits = new Credits(this); AddChild(_credits); break; case "Level1": _level1 = new Level1(this); AddChild(_level1); break; case "Level2": _level2 = new Level2(this, 5); //Would have _lives instead of 5 if pickups were implemented AddChild(_level2); break; case "Level3": _level3 = new Level3(this, 5); //Idem ditto AddChild(_level3); break; case "WonGame": _wonGame = new WonGame(this); AddChild(_wonGame); break; case "Exit": Environment.Exit(0); break; default: throw new Exception("You tried to load a non-existant state"); } }
public override void Activate(bool preservedInstance) { if (!preservedInstance) { ContentManager content = ScreenManager.Game.Content; RenderTarget = new RenderTarget2D(ScreenManager.GraphicsDevice, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height, false, SurfaceFormat.Vector4, DepthFormat.None); _font = content.Load<SpriteFont>("gamePauseTitleFont"); _optionsFont = content.Load<SpriteFont>("gamePauseOptionsFont"); _backgroundTexture = content.Load<Texture2D>("postIt"); _backgroundRectangle = new Rectangle(135, 70, 554, 380); highScores = new HighScores(); highScores.InitializeTable("Normal", 5); highScores.LoadScores(); foreach (MenuEntry menuEntry in _menuEntries) { menuEntry.Font = _optionsFont; menuEntry.Padding = 5; #if DEBUG menuEntry.DrawHitBox = true; #endif } } }
void Start() { highScores = new HighScores(); UpdateHighScoreTable(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { g.state = GameState.init; String path = "Content/tilt_1.txt"; path = Path.Combine(StorageContainer.TitleLocation, path); MapParser newMap; if (File.Exists(path)) { newMap = new MapParser(path); } else { throw new Exception("No levels found."); } path = "Content/" + newMap.backgroundName + "_key.key"; path = Path.Combine(StorageContainer.TitleLocation, path); if (File.Exists(path)) { newMap.parseTilesetData(path); } else { throw new Exception("Tileset not found."); } g.map = new Map(StorageContainer.TitleLocation, newMap,g); path = "Content/"; path = Path.Combine(StorageContainer.TitleLocation, path); /*if (File.Exists(path)) { g.player = new Player(path, g); } else { throw new Exception("Player Tileset missing."); }*/ g.player = new Player(path, g); g.highScores = new List<uint>(); g.map.selectRoom(0); paws = new PauseMenu(g); mainMenu = new MainMenu(g); endMenu = new EndMenu(g); highScores = new HighScores(g); instructions = new InstructionsMenu(g); g.state = GameState.mainMenu; saveData = new SaveData(); xmlSerializer = new XmlSerializer(typeof(SaveData)); base.Initialize(); }
void Awake() { S = this; }
static void HangMan() { Console.WriteLine("What is your name?"); string username = Console.ReadLine(); Console.WriteLine("Welcome, " + username); Console.WriteLine("You will be guessing letters or the word until you get it correct"); // Declare variables List<string> letters = new List<string>(); //list of wrong letters List<string> wrongWords = new List<string>(); //list of wrong words int guesses = 7; // number of guesses string message = ""; string word = string.Empty; string hiddenWord = string.Empty; string [] words = new string[] {"banana", "apple", "orange","grape","pear","grapefruit","peach","watermelon", "plum","pineapple", "apricot","lemon","lime","mango", "papaya","kiwi","cantaloupe", "nectarine","avocado","breadfruit","bilberry","blackberry","blueberry","boysenberry", "currant","cherry","cherimoya","cloudberry","coconut","cranberry","cucumber","damson", "date","dragonfruit","durian","eggplant","elderberry","feijoa","fig","gooseberry", "guava","huckleberry","jackfruit","lychee","honeydew","nut","olive","clementine", "mandarine", "tangarine","passionfruit","pomegranate","rasberry","tomato"}; //word Bank Random rnd = new Random(); hiddenWord = words[rnd.Next(1,words.Length+1)-1]; // construct the our word with underscores - to this word we gonna add right letters for (int i = 0; i < hiddenWord.Length; i++) { word += "_"; } // printDeadMan(7); while (hiddenWord!=word && guesses>0) //until we guess the word or use all guesses { Console.Clear(); printDeadMan(guesses); Console.WriteLine(message); PrintLettersAndWords(letters, wrongWords, word); // print our word, print lists of wrong letters and words Console.WriteLine("Enter word or letter"); string input = Console.ReadLine().ToLower(); //Take input from user if (input.Length > 1) // Check if input is word { if (input == hiddenWord) // check if we guess the word { word = hiddenWord; } else { wrongWords.Add(input); // if word is wrong - add it to wrongwords list guesses--; message = "Word is wrong, you have " + guesses + " guesses left, try to guess letters first"; } } else //or input is letter { if (hiddenWord.Contains(input)) { word = ChangeWord(input, word, hiddenWord); // if we got the rigth letter - add it to our word message = "Correct! Keep going. You still have " + guesses + " guesses left"; letters.Add(input); } else { bool isExist = false; foreach (var item in letters) { if (item == input) isExist = true; } if (isExist) { message = "You already guessed letter \"" + input + "\""; } else { letters.Add(input); // if word is wrong - add it to wrongletters list guesses--; message = "Letter is wrong, you have " + guesses + " guesses left"; } } } } // In the end of while loop we check the reason why we left the loop if (hiddenWord == word) { Console.Clear(); Console.WriteLine("YOU WIN! The word is " + word); printHappyMan(); KonstantinEntities db = new KonstantinEntities(); HighScores hs = new HighScores(); hs.Date = DateTime.Now; hs.Score = 7 - guesses + hiddenWord.Length; hs.Game = "HangMan"; if (username == "") username = "******"; hs.Name = username; db.HighScores.Add(hs); db.SaveChanges(); var list = db.HighScores.Where(x => x.Game == "HangMan"); Console.WriteLine("********** High Scores *************"); foreach (var item in list) { Console.WriteLine(item.Name + " - " + item.Score); } } else // we have no guesses left { Console.Clear(); Console.WriteLine("YOU LOSE! The word was " + hiddenWord); printDeadMan(0); } // Final code, ask user if userr wanna play again Console.WriteLine("Do you want to play again? Y/N:"); string answer = Console.ReadLine(); if (answer.ToLower() == "yes" || answer.ToLower() == "y") { Console.Clear(); HangMan(); } }
public void new_highscores_is_empty() { var highScores = new HighScores(); CollectionAssert.IsEmpty(highScores); }
public MainMenu(HopnetGame hopnetGame) { highScores = new HighScores(); highScores.Load(); buttonTimeoutStopwatch = new Stopwatch(); buttonTimeoutStopwatch.Reset(); hopNetGame = hopnetGame; handTextureType = new int[2]; handTextureType[(int)GameConstants.Hand.Left] = (int)GameConstants.TextureType.Normal; handTextureType[(int)GameConstants.Hand.Right] = (int)GameConstants.TextureType.Normal; cursorOnButtonState = new bool[2]; kinectHandPosition = new Vector2[2]; kinectHandPosition[(int)GameConstants.Hand.Left] = Vector2.Zero; kinectHandPosition[(int)GameConstants.Hand.Right] = Vector2.Zero; timerStepSizePerSecond = GameConstants.HorizontalGameResolution / GameConstants.ButtonTimeDelayInSeconds; hScale = (GameConstants.HorizontalGameResolution/ GameConstants.DefaultHorizontalResolutionToScaleInto); vScale = (GameConstants.VerticalGameResolution / GameConstants.DefaultVerticalResolutionToScaleInto); backgroundSprite = new Sprite(); gameLostSprite = new Sprite(); timeoutProgressBar = new Sprite { rectangle = new Rectangle(0, 0, 0, GameConstants.VerticalGameResolution/80) }; newGameSprite = new Sprite[GameConstants.MenuTextureNumber]; scoresSprite = new Sprite[GameConstants.MenuTextureNumber]; goBackSprite = new Sprite[GameConstants.MenuTextureNumber]; exitSprite = new Sprite[GameConstants.MenuTextureNumber]; easyDifficulty = new Sprite[GameConstants.MenuTextureNumber]; mediumDifficulty = new Sprite[GameConstants.MenuTextureNumber]; hardDifficulty = new Sprite[GameConstants.MenuTextureNumber]; confirmExit = new Sprite[GameConstants.MenuTextureNumber]; handSprite = new Sprite[2, GameConstants.MenuTextureNumber]; tryAgainSprite = new Sprite[GameConstants.MenuTextureNumber]; #region initialization of every sprite's properties for (int i = 0; i < GameConstants.MenuTextureNumber; i++) { confirmExit[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution / 2 - GameConstants.DefaultMenuBtnWidth * hScale / 2), (int)(GameConstants.VerticalGameResolution / 2 - GameConstants.DefaultMenuBtnHeight * vScale / 2), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; tryAgainSprite[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution/2 -GameConstants.DefaultMenuBtnWidth*hScale/2), (int)(GameConstants.VerticalGameResolution/2 -GameConstants.DefaultMenuBtnHeight*vScale/2), (int) (GameConstants.DefaultMenuBtnWidth*hScale), (int) (GameConstants.DefaultMenuBtnHeight*vScale)) }; goBackSprite[i] = new Sprite { Rectangle = new Rectangle((int)(GameConstants.HorizontalGameResolution * 0.15f - GameConstants.DefaultMenuBtnWidth * hScale / 2), (int)(7 * GameConstants.VerticalGameResolution / 8 - GameConstants.DefaultMenuBtnHeight * vScale / 2), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; easyDifficulty[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution * 0.5f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)), (int)(GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; mediumDifficulty[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution * 0.5f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)), (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; hardDifficulty[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution * 0.5f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)), (int)(7*GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; handSprite[(int)GameConstants.Hand.Left, i] = new Sprite(); handSprite[(int)GameConstants.Hand.Right, i] = new Sprite(); handSprite[(int)GameConstants.Hand.Left, i].Position = new Vector2(GameConstants.HorizontalGameResolution / 2, GameConstants.VerticalGameResolution / 2); handSprite[(int)GameConstants.Hand.Right, i].Position = new Vector2(GameConstants.HorizontalGameResolution / 2, GameConstants.VerticalGameResolution / 2); handSprite[(int)GameConstants.Hand.Left, i].Rectangle = new Rectangle((int)(GameConstants.HorizontalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * hScale), (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * vScale), (int)(GameConstants.HandCursorRadius * hScale), (int)(GameConstants.HandCursorRadius * vScale)); handSprite[(int)GameConstants.Hand.Right, i].Rectangle = new Rectangle((int)(GameConstants.HorizontalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * hScale), (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * vScale), (int)(GameConstants.HandCursorRadius * hScale), (int)(GameConstants.HandCursorRadius * vScale)); newGameSprite[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution * 0.15f - (GameConstants.DefaultMenuBtnWidth * hScale/2)), (int)(2*GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; scoresSprite[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution * 0.15f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)), (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; exitSprite[i] = new Sprite { Rectangle = new Rectangle( (int)(GameConstants.HorizontalGameResolution * 0.15f- (GameConstants.DefaultMenuBtnWidth * hScale/2)), (int)(6 * GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)), (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale)) }; } backgroundSprite.Rectangle = new Rectangle(0, 0, GameConstants.HorizontalGameResolution, GameConstants.VerticalGameResolution); gameLostSprite.Rectangle = new Rectangle(GameConstants.HorizontalGameResolution/2- (int)(1.5f*hScale* GameConstants.DefaultMenuBtnWidth/2), 2*GameConstants.VerticalGameResolution/8 - (int)(vScale* GameConstants.DefaultMenuBtnHeight/2), (int)(GameConstants.DefaultMenuBtnWidth*hScale*1.5f), (int)(vScale* GameConstants.DefaultMenuBtnHeight)); #endregion }
void Awake() { Instance = this; HighScoresList = new List<KeyValuePair<int, string>>(); Read(); }
// Use this for initialization void Start() { singleton = this; //Save.GetHighScores(out turnsBoard,out coinsBoard); }
public void when_score_added_is_null_then_highscore_throws_argument_exception() { var highScores = new HighScores(); Score score = null; Assert.Throws<ArgumentNullException>(() => highScores.Add(score)); }
public void when_score_added_is_lower_than_zero_throws_argument_exception() { var highScores = new HighScores(); var score = new Score(-1); Assert.Throws<ArgumentException>(() => highScores.Add(score)); }
// Try to get a score from the cache. public void GetScore(string levelname, HighScores.ScoreType type) { // If we are currently loading scores, wait for that one to finish first. if (loadingScores) { return; } Dictionary<string, CacheEntry> lookup = null; if (type == HighScores.ScoreType.Speed) { lookup = speedCache; } else { lookup = timeCache; } if (!lookup.ContainsKey(levelname)) { loadingLevelName = levelname; loadingScoreType = type; Networking.GetScores(LoadedScores, levelname, type == HighScores.ScoreType.Speed ? Networking.Metric.SPEED : Networking.Metric.TIME, 0, 10); loadingScores = true; } else { RetrievedCallback(lookup[levelname].scores, levelname); } }
private void HandleClientCom(object obj) { TcpClient client = (TcpClient)obj; NetworkStream ClientStream = client.GetStream(); System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch(); Console.WriteLine("Client Connected, Awaiting Data"); while (client.Connected) { Thread.Sleep(100); if(client.Available > 0) { var score = Serializer.DeserializeWithLengthPrefix<SubmitScore>(client.GetStream(),PrefixStyle.Base128); Console.WriteLine(score.Name + " Submitted " + score.Score); MyScores.TopTen.Add(score); HighScores hs = new HighScores(); hs.TopTen.AddRange(GetTopTen(score.LevelHashCode)); Serializer.SerializeWithLengthPrefix<HighScores>(client.GetStream(), hs, PrefixStyle.Base128); } if (st.ElapsedMilliseconds > 25000) break; } }
void Awake() { instance = this; highscoreDisplay = GetComponent<DisplayHighScores>(); }
public override void Activate(bool instancePreserved) { if (!instancePreserved) { if (_content == null) { _content = new ContentManager(ScreenManager.Game.Services, "Content"); } RenderTarget = new RenderTarget2D(ScreenManager.GraphicsDevice, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height, false, SurfaceFormat.Vector4, DepthFormat.None); _marquee = _content.Load<Texture2D>("square"); _gameFont = _content.Load<SpriteFont>("Gameplay/tripaFont"); Score = 0; highScores = new HighScores(); highScores.InitializeTable("Normal", 20); highScores.LoadScores(); _cameraPosition = new Vector3(0.0f, 0.0f, 1.0f); _target = Vector3.Forward; _viewMatrix = Matrix.CreateLookAt(_cameraPosition, _target, Vector3.Up); _projectionMatrix = Matrix.CreateOrthographicOffCenter(0, (float)ScreenManager.GraphicsDevice.Viewport.Width, (float)ScreenManager.GraphicsDevice.Viewport.Height, 0, 0.1f, 1000.0f); _effect = new BasicEffect(ScreenManager.GraphicsDevice); _effect.World = Matrix.Identity; _effect.View = _viewMatrix; _effect.Projection = _projectionMatrix; _effect.EnableDefaultLighting(); _effect.DiffuseColor = Color.Black.ToVector3(); if (Microsoft.Phone.Shell.PhoneApplicationService.Current.StartupMode == Microsoft.Phone.Shell.StartupMode.Launch) { InitializeTripas(); foreach (Tripa tripa in _tripas) { tripa.SetMarqueeTexture(_marquee); tripa.SetFont(_gameFont); tripa.SetSpriteBatch(ScreenManager.SpriteBatch); tripa.SetGraphicsDevice(ScreenManager.GraphicsDevice); tripa.LoadContent(); } Thread.Sleep(1000); } } if (Microsoft.Phone.Shell.PhoneApplicationService.Current.State.ContainsKey("Tripas")) { _tripas = (List<Tripa>)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["Tripas"]; for (int i = 0; i < _tripas.Count - 1; i += 2) { _tripas[i].MatchingPair = _tripas[i + 1]; _tripas[i].SetMarqueeTexture(_marquee); _tripas[i].SetFont(_gameFont); _tripas[i].SetSpriteBatch(ScreenManager.SpriteBatch); _tripas[i].SetGraphicsDevice(ScreenManager.GraphicsDevice); _tripas[i + 1].MatchingPair = _tripas[i]; _tripas[i + 1].SetMarqueeTexture(_marquee); _tripas[i + 1].SetFont(_gameFont); _tripas[i + 1].SetSpriteBatch(ScreenManager.SpriteBatch); _tripas[i + 1].SetGraphicsDevice(ScreenManager.GraphicsDevice); } _donePairs = (Dictionary<string, Path>)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["DonePairs"]; } ScreenManager.Game.ResetElapsedTime(); }
// Use this for initialization void Start() { p = player.GetComponent<PlayerInventory> (); h = player.GetComponent<HighScores> (); }
void OnDestroy() { Instance = null; }
public void add_one_score_results_one_score_in_highscores() { var highScores = new HighScores(); highScores.Add(new Score(777)); Assert.AreEqual(1, highScores.Count()); }