public Score(ScoreEntry scoreEntry) { Name = scoreEntry.Name; Frags = scoreEntry.Frags; Kills = scoreEntry.Kills; Deaths = scoreEntry.Deaths; }
private void Start() { entries = transform.Find("Entries"); entry = entries.Find("Entry"); entry.gameObject.SetActive(false); Scores scores = AddScoreEntry(scoreCounter.points, playernamestr); for (int i = 0; i < scores.scoreEntries.Count; i++) { for (int j = i + 1; j < scores.scoreEntries.Count; j++) { if (scores.scoreEntries[j].score > scores.scoreEntries[i].score) { ScoreEntry tmp = scores.scoreEntries[i]; scores.scoreEntries[i] = scores.scoreEntries[j]; scores.scoreEntries[j] = tmp; } } } scoreEntriesTransforms = new List <Transform>(); for (int i = 0; i < 5; i++) { ScoreEntry scoreEntry = scores.scoreEntries[i]; CreateScoreEntryTransform(scoreEntry, entries, scoreEntriesTransforms); } }
private void Awake() { Instance = this; entries = new Dictionary <Player, ScoreEntry>(); entryTemplate.gameObject.SetActive(false); int i = 0; float templateHeight = 33f; foreach (Player player in PlayerManager.Instance.players) { GameObject entry = Instantiate(entryTemplate, entryContainer.transform); ScoreEntry scoreEntry = new ScoreEntry(entry); if (anchorPosition == null) { float x = scoreEntry.rectTransform.anchoredPosition.x; float y = scoreEntry.rectTransform.anchoredPosition.y; anchorPosition = new Vector2(x, y); } scoreEntry.rectTransform.anchoredPosition = new Vector2(anchorPosition.x, anchorPosition.y - templateHeight * i); scoreEntry.gameObject.SetActive(true); scoreEntry.nick.text = player.nick; scoreEntry.nick.color = player.color; scoreEntry.score.text = player.score.ToString(); scoreEntry.score.color = player.color; entries.Add(player, scoreEntry); i += 1; } }
private void CopyFields(ScoreEntry scoreEntry) { foreach (PropertyInfo prop in scoreEntry.GetType().GetProperties()) { GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(scoreEntry, null), null); } }
public void LoadScores() // Load scores when coming straight from main menu { if (File.Exists(Application.dataPath + "/highscores.json")) { string[] entryStrings = File.ReadAllLines(Application.dataPath + "/highscores.json"); List <ScoreEntry> entryObjects = new List <ScoreEntry>(); for (int i = 0; i < entryStrings.Length; i++) { entryObjects.Add(JsonUtility.FromJson <ScoreEntry>(entryStrings[i])); } entryObjects = entryObjects.OrderByDescending(o => o.score).ToList(); // Order by descending score for (int i = 0; i < 9; i++) // Display first 9 scores { Transform entryObject = transform.Find("ScoreList").Find("ScoreEntry" + (i + 1)); ScoreEntry result = entryObjects[i]; entryObject.Find("EntryRank").GetComponent <Text>().text = ConvertToRank(i + 1); entryObject.Find("EntryScore").GetComponent <Text>().text = result.score.ToString(); entryObject.Find("EntryWaves").GetComponent <Text>().text = result.waves.ToString(); entryObject.Find("EntryName").GetComponent <Text>().text = result.name; } } }
public void LoadScores() { //Pega os scores string data = PlayerPrefs.GetString("HighScores"); //carrega se não for nulo if (!string.IsNullOrEmpty(data)) { //Binary formatter BinaryFormatter b = new BinaryFormatter(); //Cria a memorystream MemoryStream m = new MemoryStream(Convert.FromBase64String(data)); //Salva no atributo highScores = (List <ScoreEntry>)b.Deserialize(m); } else { for (int i = 0; i < 10; i++) { highScores = new List <ScoreEntry>(); ScoreEntry scoreEntry = new ScoreEntry(); scoreEntry.name = "aaa"; scoreEntry.score = 700; highScores.Add(scoreEntry); } } }
public async Task <IActionResult> Edit(int id, [Bind("ScoreEntryId,DateCreated,DateModified,ScoreType,Total,UserProfileId,WeekEnding")] ScoreEntry scoreEntry) { if (id != scoreEntry.ScoreEntryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(scoreEntry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScoreEntryExists(scoreEntry.ScoreEntryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["UserProfileId"] = new SelectList(_context.UserProfile, "UserProfileId", "UserProfileId", scoreEntry.UserProfileId); return(View(scoreEntry)); }
public async Task <IActionResult> Create([Bind("ScoreEntryId,DateCreated,DateModified,ScoreType,Total,UserProfileId,WeekEnding")] ScoreEntry scoreEntry) { if (ModelState.IsValid) { _context.Add(scoreEntry); //Update the total Score var up = await _context.UserProfile.Where(u => u.UserProfileId == scoreEntry.UserProfileId).FirstOrDefaultAsync(); // TODO: Create function for this // Update column based on presentation type switch (scoreEntry.ScoreType) { case ScoreEntryType.Presentation: up.TotalPresentations += scoreEntry.Total; break; case ScoreEntryType.Ascend: up.TotalAscend += scoreEntry.Total; break; default: break; } await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["UserProfileId"] = new SelectList(_context.UserProfile, "UserProfileId", "UserProfileId", scoreEntry.UserProfileId); return(View(scoreEntry)); }
// Use this for initialization void Start() { bestBlockadeScore = new ScoreEntry(); bestBlockadeScore.type = 0; bestBlockadeScore.score = 0; if (!PlayerPrefs.HasKey("blockade1")) { for (int x = 1; x < 4; x++) { PlayerPrefs.SetInt("blockade" + x.ToString(), 0); } } if (!PlayerPrefs.HasKey("arcade1")) { for (int x = 1; x < 4; x++) { PlayerPrefs.SetInt("arcade" + x.ToString(), 0); } } bestArcadeScore = new ScoreEntry(); bestArcadeScore.type = 1; bestArcadeScore.score = 0; ReadHeader(); }
public IList <ScoreEntry> Get(DateTime entryDate) { try { Logger.LogInfo("Get: ScoreEntry process start"); IList <ScoreEntry> lstScoreEntry = new List <ScoreEntry>(); DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_BY_DATE, entryDate)); foreach (DataRow dr in dtAppConfig.Rows) { ScoreEntry ScoreEntry = convertToScoreEntryObject(dr); lstScoreEntry.Add(ScoreEntry); } Logger.LogInfo("Get: ScoreEntry process completed."); return(lstScoreEntry); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
void InitDefaultScores() { string[] defaultNames; uint[] defaultScores; ushort[] defaultBestCombos; defaultNames = defaultHardNames; defaultScores = defaultHardScores; defaultBestCombos = defaultHardBestCombos; if (tableName == "normal") { defaultNames = defaultNormalNames; defaultScores = defaultNormalScores; defaultBestCombos = defaultNormalBestCombos; } else if (tableName == "easy") { defaultNames = defaultEasyNames; defaultScores = defaultEasyScores; defaultBestCombos = defaultEasyBestCombos; } for (int i = 0; i < 10; i++) { ScoreEntry entry = new ScoreEntry(defaultNames[i], defaultScores[i], defaultBestCombos[i]); scoresTable.Add(entry); } scoresTable.Sort((a, b) => a.score.CompareTo(b.score)); scoresTable.Reverse(); }
public void showGameOver(string message) { GameOver = true; Pause = true; MainTimer.Stop(); xScoreEntry = new ScoreEntry(this); if (Int32.Parse(Pointslbl.Text) > lowest) { ScoreView.Clear(); } pauseLabel.Text = message; if (pauseLabel.Text == "You win") { pauseLabel.Location = new Point((System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2) - 210, 100); } else { pauseLabel.Location = new Point((System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2) - 285, 100); } pauseLabel.Visible = true; p.MoveRightStop(); p.MoveLeftStop(); p.MoveUpStop(); p.MoveDownStop(); p.CloseGunLock(); }
public void AddScoreIntoHighScore(ScoreEntry entry){ highScores.Add (entry); if (highScores.Count > 1) { SortHighScore (); } if (highScores.Count > NUMBER_OF_HIGHSCORE) { highScores.RemoveAt(highScores.Count - 1); } if (GameManager.Instance.Authenticated) { Social.ReportScore((int)entry.score, "CgkI3OiBg-AbEAIQAg", (bool success) => { // handle success or failure }); if ((int)entry.score >= 100) { Social.ReportProgress("CgkI3OiBg-AbEAIQBQ", 100.0f, (bool success) => { Debug.Log("Successfully sent Achievement!"); }); } if ((int)entry.score > 10000) { Social.ReportProgress("CgkI3OiBg-AbEAIQBg", 100.0f, (bool success) => { Debug.Log("Successfully sent Achievement!"); }); } } SaveScores (); }
public async Task <ActionResult <ScoreEntry> > PostScoreEntry(ScoreEntry scoreEntry) { dbContext.ScoreEntries.Add(scoreEntry); await dbContext.SaveChangesAsync(); return(CreatedAtAction("GetScoreEntry", new { id = scoreEntry.Id }, scoreEntry)); }
void Start() { playerScore = new ScoringSystem.ScoreEntry(); playerScore.name = "Player 1"; playerScore.score = 0; InitializeHighScore(); }
private GameObject InstantiateEntry(ScoreEntry entry, int index) { GameObject go = Instantiate(highscoreEntryPrefab, highscoresArea); go.GetComponent <HighscoreEntry>().Initialize(entry, index + 1); return(go); }
/// <summary> /// Registers the player's score /// </summary> /// <param name="playerName"></param> /// <param name="score"></param> public static void RegisterScore(string playerName, int score) { List <ScoreEntry> scores = GetScores(); // find entry ScoreEntry entry = FindEntry(scores, playerName); // make a new entry if none if (entry == null) { entry = new ScoreEntry(); entry.name = playerName; scores.Add(entry); } // set score entry.score = score; // sort by score scores.Sort(delegate(ScoreEntry e1, ScoreEntry e2) { return(e2.score.CompareTo(e1.score)); }); SaveScore(scores); }
public void AddScoreIntoHighScore(ScoreEntry entry) { highScores.Add(entry); if (highScores.Count > 1) { SortHighScore(); } if (highScores.Count > NUMBER_OF_HIGHSCORE) { highScores.RemoveAt(highScores.Count - 1); } if (GameManager.Instance.Authenticated) { Social.ReportScore((int)entry.score, "CgkI3OiBg-AbEAIQAg", (bool success) => { // handle success or failure }); if ((int)entry.score >= 100) { Social.ReportProgress("CgkI3OiBg-AbEAIQBQ", 100.0f, (bool success) => { Debug.Log("Successfully sent Achievement!"); }); } if ((int)entry.score > 10000) { Social.ReportProgress("CgkI3OiBg-AbEAIQBg", 100.0f, (bool success) => { Debug.Log("Successfully sent Achievement!"); }); } } SaveScores(); }
IEnumerator UploadScoreForAdmin() { var q = new UnityWebRequest(ServerURL); q.method = UnityWebRequest.kHttpVerbPOST; var stub_entry = new ScoreEntry { username = UserStore.AdminName, value = StaticVars.LocalAdminScore, user_type = "admin" }; var qs = JsonConvert.SerializeObject(stub_entry); var uh = new UploadHandlerRaw(Encoding.ASCII.GetBytes(qs)); uh.contentType = "application/json"; q.uploadHandler = uh; yield return(q.SendWebRequest()); if (q.isNetworkError || q.isHttpError) { Debug.LogError(q.error); AdminNameTexts[0].text = "通信エラー発生(送信)"; } else { // Debug.Log(q.responseCode); upload_status++; } }
/// <summary> /// Handle moves in this menu /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { frameCount += 1; if (Actions.GetInstance()[Inputs.Action.Left].IsPressed()) { selectedIndexCharCursor = TetrisMath.mod(selectedIndexCharCursor - 1, selectedIndexChar.Length); } if (Actions.GetInstance()[Inputs.Action.Right].IsPressed()) { selectedIndexCharCursor = TetrisMath.mod(selectedIndexCharCursor + 1, selectedIndexChar.Length); } if (Actions.GetInstance()[Inputs.Action.Up].IsPressed()) { selectedIndexChar[selectedIndexCharCursor] = TetrisMath.mod(selectedIndexChar[selectedIndexCharCursor] + 1, POSSIBLE_CHARS.Length); } if (Actions.GetInstance()[Inputs.Action.Down].IsPressed()) { selectedIndexChar[selectedIndexCharCursor] = TetrisMath.mod(selectedIndexChar[selectedIndexCharCursor] - 1, POSSIBLE_CHARS.Length); } if (Actions.GetInstance()[Inputs.Action.Start].IsPressed()) { ScoreEntry scoreEntry = new ScoreEntry(IndicesToString(), score, level); Scores.Instance.AddScore(scoreEntry); tetris.ChangeMenu(nextMenu); } }
void AddEntryToTable(ScoreEntry entry) { scoresTable.Add(entry); scoresTable.Sort((a, b) => a.score.CompareTo(b.score)); scoresTable.Reverse(); scoresTable.RemoveAt(scoresTable.Count - 1); }
public async Task <EntryResult> AddNewEntry(NewEntry newEntry) { await _repository.AddNewPlayerIfNecessary(newEntry.Name); bool banned = await _repository.IsPlayerBanned(newEntry.Name); if (banned) { EntryResult result = new EntryResult(); result.Name = newEntry.Name; result.Banned = true; result.BestRanking = 0; result.BestScore = 0; result.Score = 0; result.Ranking = 0; return(result); } else { ScoreEntry entry = new ScoreEntry(); entry.Date = DateTime.UtcNow; entry.Name = newEntry.Name; entry.Score = newEntry.Score; entry._id = Guid.NewGuid(); return(await _repository.AddNewEntry(entry)); } }
/// <summary> /// This downloads the scores and loads it into the scores List<> /// </summary> public void DownloadScores() { // Create a Web Request to the Web API HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(ServerAPIAddress); // Obtain the Result Handle from the API WebResponse getResult; try { getResult = webReq.GetResponse(); } catch (WebException) { Debug.Log("Unable to connect to server!"); return; } // Obtain the Stream from the Result Handle Stream receiveStream = getResult.GetResponseStream(); // Pipe the stream to a higher level stream reader with the required encoding format. StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); string results = readStream.ReadToEnd(); // Close the StreamReader readStream.Close(); // Close the Result Handle getResult.Close(); // Clear the current list of scores to prepare to load new ones scores.Clear(); // Process the results by tokenizing string entry = ""; foreach (var c in results) { // Check for entry delimiter if (c == ',') { // Process the score entry string ScoreEntry e = processString(entry); // Check if the processed value is valid if (e.IsValid) { scores.Add(e); } // Clear the entry for the next item to process entry = ""; } else { entry += c; } } }
/** * @pre Game has ended * @post Add current game's score data to the 'savedGames.gd' file * @param int score of the winner, string name of player who won * @return None. */ private void WriteScoreToFile(int score, string playerName) { ScoreData scoreData = new ScoreData(); BinaryFormatter bf = new BinaryFormatter(); if (File.Exists(Application.persistentDataPath + "/savedGames.gd")) { FileStream readFile = File.Open(Application.persistentDataPath + "/savedGames.gd", FileMode.Open); scoreData = (ScoreData)bf.Deserialize(readFile); readFile.Close(); } ScoreEntry currentScoreEntry = new ScoreEntry(); currentScoreEntry.score = score; currentScoreEntry.name = playerName; scoreData.AddScoreByNumShips(Team1.numberOfShips, currentScoreEntry); FileStream writeFile = File.Create(Application.persistentDataPath + "/savedGames.gd"); bf.Serialize(writeFile, scoreData); writeFile.Close(); foreach (ScoreEntry a in scoreData.GetScoresByNumShips(1)) { Debug.Log("1 Ship: " + a.name + ": " + a.score); } }
public void AddIncome(Resources.Type type, int amount) { int current = Resources.instance.GetValue(type, false); int max = Resources.instance.GetValue(type, true); if (current + amount > max) { AddLoss(type, max - current - amount); amount = max - current; } for (int i = 0; i < income.Count; ++i) { if (income[i].type == type) { // if it exists increase it's value: ScoreEntry entry = income[i]; entry.amount += amount; income[i] = entry; return; } } // otherwise add it: ScoreEntry e; e.type = type; e.amount = amount; income.Add(e); }
public void RemoveExpenses(Resources.Type type, int amount) { int current = Resources.instance.GetValue(type, false); int max = Resources.instance.GetValue(type, true); if (current + amount > max) { AddLoss(type, max - current - amount); amount = max - current; } for (int i = 0; i < expenses.Count; ++i) { if (expenses[i].type == type) { // if it exists increase it's (negative) magnitude: ScoreEntry entry = expenses[i]; entry.amount += amount; expenses[i] = entry; return; } } // otherwise add it: ScoreEntry e; e.type = type; e.amount = amount; expenses.Add(e); }
public static HighScores AddHighScore(HighScores highScores, ScoreEntry scoreEntry) { highScores.entryList.Add(scoreEntry); while (highScores.entryList.Count > entryListSize && highScores.entryList.Count > 0) { int minScore = int.MaxValue; ScoreEntry minScoreEntry = null; foreach (ScoreEntry se in highScores.entryList) { if (minScore > se.score) { minScore = se.score; minScoreEntry = se; } } highScores.entryList.Remove(minScoreEntry); } highScores.SortList(); return(highScores); }
/// <summary> /// Resets the player's stats /// </summary> public void Reset() { InternalScore = new ScoreEntry { ArrowsRemaining = 3 }; }
public void AddNewHighscore(ScoreEntry scoreEntry) { string key = FirebaseDatabase.DefaultInstance.GetReference(DATABASE_REFERENCE_SCORES).Push().Key; DateTime utcTime = DateTime.UtcNow; if (scoreEntry.date == 0) { scoreEntry.date = utcTime.ToOADate(); } Dictionary <string, object> entryValues = scoreEntry.ToDictionary(); Dictionary <string, object> childUpdates = new Dictionary <string, object>(); childUpdates[key] = entryValues; FirebaseDatabase.DefaultInstance.GetReference(DATABASE_REFERENCE_SCORES).UpdateChildrenAsync(childUpdates).ContinueWith(task => { if (task.Exception != null) { Debug.Log("Error al insertar Score: " + task.Exception.ToString()); } else if (task.IsCompleted) { Debug.Log("Añadido: " + key + ": " + scoreEntry.ToContatString()); } }); }
/// <summary>Adds a new entry to the <see cref="Games.Concrete.PacManGame"/> scoreboard.</summary> public void AddScore(ScoreEntry entry) { logger.Log(LogSeverity.Info, LogSource.Storage, $"New scoreboard entry: {entry}"); Db.PacManScores.Add(entry); Db.SaveChanges(); }
public IActionResult Entry(int id) { // Retrieve the score entry using the ID (via LINQ lambda syntax) ScoreEntry score = database.Entries.SingleOrDefault(x => id == x.Id); return(View(score)); }
public void Score7CompareToScore7() { ScoreEntry bunny = new ScoreEntry(7, "Bunny"); ScoreEntry satan = new ScoreEntry(7, "Satan"); int actualResult = bunny.CompareTo(satan); Assert.AreEqual(0, actualResult); }
public void Score11CompareToScore15() { ScoreEntry bunny = new ScoreEntry(11, "Bunny"); ScoreEntry satan = new ScoreEntry(15, "Satan"); int actualResult = bunny.CompareTo(satan); Assert.AreEqual(-1, actualResult); }
/// <summary> /// Use this function to send a score to the server. /// </summary> /// <param name="score">The ScoreEntry you wish to send.</param> public void SendScore(ScoreEntry score) { // Store the form data WWWForm form = new WWWForm(); form.AddField("Name", score.Name); form.AddField("Score", score.Score); // Send the form data to the ServerAPIAddress WWW sender = new WWW(ServerAPIAddress, form); }
public ScoreEntry (ScoreEntry entry) { Name = entry.Name; Score = entry.Score; }
private List<ScoreEntry> AllocateList(int scoreIndex, TimeSpan durationIndex, Difficulty difficulty, ref int name, int step) { List<ScoreEntry> rtnList = GetList(difficulty); for (int i = 0; i < 10; i++) { ScoreEntry score = new ScoreEntry(); score.GamerTag = Names[name]; score.Score = scoreIndex; score.Duration = durationIndex; score.Difficulty = difficulty; rtnList.Add(score); scoreIndex -= step; durationIndex -= TimeSpan.FromSeconds(10); name++; } return rtnList; }
private ScoreEntry GetEntryFor( Mobile from ) { if ( m_Entries == null ) m_Entries = new Hashtable(); ScoreEntry e = (ScoreEntry)m_Entries[from]; if ( e == null ) m_Entries[from] = e = new ScoreEntry(); return e; }
public void GameOver(GameTime gameTime, object nothing) { isGameOver = true; Shorewood.gameState = GameState.GameOver; int score = gridRenderer.grid.currentScore; TimeSpan duration = Shorewood.gameplayTimer.ElapsedTime; ScoreEntry highScore = new ScoreEntry(); highScore.Difficulty = Shorewood.Difficulty; highScore.Duration = duration; highScore.Score = Shorewood.scoreBox.CurrentScore; #if XBOX if ((Gamer.SignedInGamers.Count > 0) && Gamer.SignedInGamers[Shorewood.mainPlayer] != null) { highScore.GamerTag = Gamer.SignedInGamers[Shorewood.mainPlayer].Gamertag; GamerEntry gamer = new GamerEntry(); gamer.GamerPicture = Gamer.SignedInGamers[Shorewood.mainPlayer].GetProfile().GamerPicture; gamer.gamerTag = highScore.GamerTag; if (!Shorewood.storage.HighScores.Gamers.Contains(gamer)) { Shorewood.storage.HighScores.Gamers.Add(gamer); } } #else highScore.GamerTag = "Zikomo"; #endif List<ScoreEntry> scores = Shorewood.storage.HighScores.GetList(Shorewood.Difficulty); scores.Add(highScore); scores.Sort(); if (scores.Count > 10) { scores.RemoveRange(10, scores.Count - 10); } Shorewood.storage.SaveHighScoresToDevice(); gameplayState = NormalGameplayState.GameOver; }
void Start(){ playerScore = new ScoringSystem.ScoreEntry (); playerScore.name = "Player 1"; playerScore.score = 0; InitializeHighScore (); }
public ScoreEntry AddScore(string name, int score) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); if (score <= scores[scores.Count - 1].Score) return null; ScoreEntry newScore = new ScoreEntry() { PlayerName = name, Score = score }; scores.Add(newScore); scores.Sort(); scores = scores.Take(5).ToList(); return newScore; }
public void AddScore(ScoreEntry score) { HighScores.Add(score); SaveScores(); }
public int IndexOf(ScoreEntry score) { return scores.IndexOf(score); }