public void SaveHighscoresTable() { var localScores = ScoresManager.Instance.Scores; var globalScores = _scoresTable.FindAll(); var scoresTable = new ScoreTable(); foreach (var score in globalScores) { scoresTable.AddNew(score.Element); } for (int i = 0; i < localScores.Count; i++) { scoresTable.AddNew(localScores[i]); } for (int i = 0; i < scoresTable.Scores.Count; i++) { if (i >= globalScores.Count) { _scoresTable.Add(scoresTable.Scores[i]); continue; } if (globalScores[i].Element.Score < scoresTable.Scores[i].Score) { globalScores[i].Element = scoresTable.Scores[i]; globalScores[i].Update(); } } }
public void WriteScores(ScoreTable table) { using (var stream = new FileStream(Application.dataPath + FilePath, FileMode.Create, FileAccess.Write, FileShare.Write)) { _serializer.Serialize(stream, table); stream.Close(); } }
private ScoresManager() { _serializer = new ScoreSerializer(); _scoreTable = _serializer.ReadScores(); if (_scoreTable == null) { _scoreTable = new ScoreTable(); } }
// Use this for initialization void Start() { if(networkView.isMine == true) { multiplayerManager = GameObject.Find ("MultiplayerManager"); myScript = multiplayerManager.GetComponent<MultiplayerScript>(); gameManager = GameObject.Find ("GameManager"); commScript = gameManager.GetComponent<CommunicationWindow>(); scoreScript = gameManager.GetComponent<ScoreTable>(); } else {enabled = false;} }
public void OpenHighScore() { if (ScoreTable.playerScores == null) { Debug.Log("No scoreTable"); return; } ScoreTable.LoadAllScores(); string[] players = ScoreTable.GetPlayers(); foreach (string name in players) { GameObject obj = Instantiate(playerScorePrefab); obj.transform.SetParent(this.transform); obj.transform.Find("Name").GetComponent <Text>().text = name; obj.transform.Find("Value1").GetComponent <Text>().text = ScoreTable.GetScore(name, "level").ToString(); obj.transform.Find("Value2").GetComponent <Text>().text = ScoreTable.GetScore(name, "score").ToString(); } }
private void ReadyPlayer(Mobile m) { if (!ScoreTable.ContainsKey(m.Serial)) { ScoreTable.Add(m.Serial, new ScoreKeeper(m)); } if (EventSupplier != null) { EventSupplier.OnMoveOver(m); } Contestants.Add(m); m.MoveToWorld(JoinLocation, JoinMap); m.Blessed = true; if (m.NetState != null) { m.SendMessage(38, "You have joined a tournament"); } }
private void Listen() { string message = ""; try { while (!message.ToLower().StartsWith("the")) { NetworkStream n = client.GetStream(); message = new BinaryReader(n).ReadString(); if (!message.ToLower().StartsWith("the")) { try { object o = JsonConvert.DeserializeObject <ScoreTable>(message); if (o is ScoreTable) { ScoreTable temp = o as ScoreTable; UpdateList(temp); EnablePanelContents(gameBoard); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show(message); } } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
private static StaticCourse LoadCourse(TemplateLoader templateLoader, XElement courseElement, string parentScoreTemplate, string parentLevelTemplates, string parentCreditsStr) { string courseName = XmlHelper.GetAttributeValue(courseElement, "name"); string scoreTemplate = XmlHelper.GetAttributeValue(courseElement, "scores") ?? parentScoreTemplate; if (scoreTemplate == null) { throw XmlHelper.CreateException(courseElement, "Unspecified score template"); } string courseTemplates = XmlHelper.GetAttributeValue(courseElement, "levels") ?? parentLevelTemplates; if (courseTemplates == null) { throw XmlHelper.CreateException(courseElement, "Unspecified level template"); } string creditsStr = XmlHelper.GetAttributeValue(courseElement, "credits") ?? parentCreditsStr; if (creditsStr == null) { throw XmlHelper.CreateException(courseElement, "Unspecified credits value"); } double credits; if (!StringParser.TryParseDoubleStrict(creditsStr, out credits) || credits < 0) { throw XmlHelper.CreateException(courseElement, "Invalid credits value: " + creditsStr); } LevelGroup[] groups = templateLoader.BuildLevels(courseTemplates); ScoreTable scoreTable = templateLoader.BuildScoreTable(scoreTemplate); return(new StaticCourse(courseName, credits, groups, scoreTable)); }
private void Update() { //Debug.Log("CurrentLevel: " + currentLevel); if (Input.GetKey(KeyCode.Escape)) { if (inLevel) { ScoreTable.SaveScores(); Save(); } SceneManager.LoadScene("MainMenu"); } if (!theGameIsOn) { Time.timeScale = 0; } else { Time.timeScale = 1; } }
private void UpdateCorrectScore() { int totalLines = 0; int realScore = 0; int adjScore = 0; List <int> lines = lastGameState.lineHistory; foreach (int line in lines) { if (totalLines > 100) { break; } totalLines += line; realScore += ScoreTable.getScore(line, 19); adjScore += ScoreTable.getScore(line, 19 + (totalLines / 10)); } realScore += lastGameState.softDropTotal; adjScore += lastGameState.softDropTotal; realScoreUI.text = realScore.ToString("000000"); adjScoreUI.text = adjScore.ToString("000000"); }
public void StartGame() { if (textField.text.Length > 0 && !PlayerPrefs.HasKey(textField.text)) { GameStatus.gameBegin = true; PlayerPrefs.SetString(textField.text, textField.text); PlayerPrefs.SetInt(textField.text + "levels", 1); PlayerPrefs.SetInt(textField.text + "scores", 0); //testing ways to do highscore ScoreTable.SetScore(textField.text, "level", 1); ScoreTable.SetScore(textField.text, "score", 0); ScoreTable.currentPlayer = textField.text; ScoreTable.SaveScores(); Debug.Log("New Challenger! Name: " + textField.text + " Level: " + ScoreTable.GetScore(textField.text, "level") + ", Score: " + ScoreTable.GetScore(textField.text, "score")); SceneManager.LoadScene("Map"); } else if (PlayerPrefs.HasKey(textField.text)) { ScoreTable.currentPlayer = textField.text; Debug.Log(PlayerPrefs.GetString(textField.text)); ScoreTable.LoadScores(); SceneManager.LoadScene("Map"); } }
public void insertScore(ValueObject inputData) { //DB연결 및 연결체크. *필수코드 if (DBConnectionFnc()) { Debug.Print("insertScore - DBConnection Error"); return; } string winTeam = "draw"; if (inputData.getInt("") > inputData.getInt("")) { winTeam = "red"; } else if (inputData.getInt("") < inputData.getInt("")) { winTeam = "blue"; } else { winTeam = "draw"; } //db.DropTable<ScoreTable>(); db.CreateTable <ScoreTable>(); int seq = 1; var Maxtable = db.Query <ScoreTable>("SELECT * FROM ScoreTable where seq = (select max(seq) from ScoreTable) "); if (Maxtable.Count != 0) { var test = Maxtable.GetEnumerator(); foreach (var s in Maxtable) { seq = s.seq + 1; } } for (int i = 1; i <= inputData.getInt("setIndex"); i++) { var insSTrow = new ScoreTable(); insSTrow.seq = seq; insSTrow.insDate = DateTime.Now; insSTrow.redTeamScore = inputData.getInt(string.Format("redTeamScore{0}", i)); // 적팀 한 세트 스코어 insSTrow.blueTeamScore = inputData.getInt(string.Format("blueTeamScore{0}", i)); // 청팀 한 세트 스코어 insSTrow.redTeamSetScore = inputData.getInt("redTeamSetScore"); // 적팀 세트 스코어 insSTrow.blueTeamSetScore = inputData.getInt("blueTeamSetScore"); // 청팀 세트 스코어 insSTrow.winTeam = winTeam; insSTrow.delYn = "N"; db.Insert(insSTrow); } //Debug.Print("Test ::Data Count " + (db.Table<ScoreTable>().Count())); //Debug.Print("Reading data"); var table = db.Table <ScoreTable>(); foreach (var s in table) { Debug.Print(s.Id + ":Seq" + s.seq); } db.Close(); }
void Awake() { highscoreDisplay = GetComponent <ScoreTable>(); }
// Use this for initialization void Start() { scoreScript = GetComponent <ScoreTable>(); }
public void PostNew([FromBody] ScoreTable item) { _scoreService.Post(item); }
/// <summary> /// Constructs a new course object. /// </summary> /// <param name="name">The name of the course.</param> /// <param name="credits">The credit value of the course.</param> /// <param name="groups">An array containing the level groups of the course.</param> /// <param name="scoreTable">The table that maps scores to GPA values.</param> public StaticCourse(string name, double credits, LevelGroup[] groups, ScoreTable scoreTable) { if (name == null) throw new ArgumentNullException("name"); if (credits <= 0) throw new ArgumentOutOfRangeException("credits"); if (groups == null) throw new ArgumentNullException("groups"); if (groups.Length == 0) throw new ArgumentException("Must provide at least one level group"); if (scoreTable == null) throw new ArgumentNullException("scoreTable"); _name = name; _credits = credits; _groups = groups; _scoreTable = scoreTable; LevelGroup group = groups[0]; _selectedLevelGroup = group; _selectedLevel = group.LevelCount > 0 ? group[0] : null; NameTranslator = x => x; }
public IActionResult KontrolEt(string answerUser, FourWord fourWord , FifthWord fifthWord, SixthWord sixthWord, SevenWord sevenWord, EightWord eightWord, NineWord nineWord, TenWord tenWord, ScoreTable scoreTable, int questionCount, string lastScore) { var gamevariant = _unitOfWorkGameVariant.RepositoryGameVariant.GetAll(); foreach (var gameVariant in gamevariant) { if (gameVariant.GameIsCompleted == false) { if (gameVariant.GameIsOver == false) { if (fourWord.FourWordAnswer == answerUser) { gameVariant.GameScoreCount = gameVariant.GameScoreCount + fourWord.FourWordScore; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 1; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); TempData["Message"] = "Cevabınız Doğru !!"; TempData["JS"] = "showSuccess();"; } else if (fifthWord.FifthWordAnswer == answerUser) { gameVariant.GameScoreCount = gameVariant.GameScoreCount + fifthWord.FifthWordScore; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 1; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); TempData["Message"] = "Cevabınız Doğru !!"; TempData["JS"] = "showSuccess();"; } else if (sixthWord.SixthWordAnswer == answerUser) { gameVariant.GameScoreCount = gameVariant.GameScoreCount + sixthWord.SixthWordScore; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 1; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); TempData["Message"] = "Cevabınız Doğru !!"; TempData["JS"] = "showSuccess();"; } else if (sevenWord.SevenWordAnswer == answerUser) { gameVariant.GameScoreCount = gameVariant.GameScoreCount + sevenWord.SevenWordScore; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 1; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); TempData["Message"] = "Cevabınız Doğru !!"; TempData["JS"] = "showSuccess();"; } else if (eightWord.EightWordAnswer == answerUser) { gameVariant.GameScoreCount = gameVariant.GameScoreCount + eightWord.EightWordScore; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 1; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); TempData["Message"] = "Cevabınız Doğru !!"; TempData["JS"] = "showSuccess();"; } else if (nineWord.NineWordAnswer == answerUser) { gameVariant.GameScoreCount = gameVariant.GameScoreCount + nineWord.NineWordScore; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 1; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); TempData["Message"] = "Cevabınız Doğru !!"; TempData["JS"] = "showSuccess();"; } else if (tenWord.TenWordAnswer == answerUser) { gameVariant.GameScoreCount = gameVariant.GameScoreCount + tenWord.TenWordScore; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 1; gameVariant.GameIsCompleted = true; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); if (gameVariant.GameQuestionCount == 14) { scoreTable.UserID = 1; scoreTable.ScoreData = gameVariant.GameScoreCount; _unitOfWorkScoreTable.RepositoryScoreTable.Create(scoreTable); _unitOfWorkScoreTable.Complete(); TempData["Message"] = "Tebrikler !! Oyunu " + scoreTable.ScoreData + " puan ile bitirdiniz!!"; TempData["JS"] = "showSuccess();"; var currentUser = _unitOfWorkUser.RepositoryUser.GetByIDForUpdate(getCurrentUser()); foreach (var userUpdate in currentUser) { userUpdate.UserLastScore = (gameVariant.GameScoreCount).ToString(); userUpdate.CreatedDate = DateTime.Now; userUpdate.ModifiedDate = DateTime.Now; _unitOfWorkUser.RepositoryUser.Update(userUpdate); int request = HttpContext.Response.StatusCode; if (request == 200) { _unitOfWorkUser.Complete(); } } gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = true; gameVariant.GameQuestionCount = 0; gameVariant.GameScoreCount = 0; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); int secondRequest = HttpContext.Response.StatusCode; if (secondRequest == 200) { _unitOfWorkGameVariant.Complete(); } } else { TempData["Message"] = "Cevabınız Doğru !!"; TempData["JS"] = "showSuccess();"; return(RedirectToAction("GameArena")); } } else { gameVariant.GameScoreCount = gameVariant.GameScoreCount - questionCount; gameVariant.GameQuestionCount = gameVariant.GameQuestionCount + 0; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); _unitOfWorkGameVariant.Complete(); TempData["Message"] = "Cevabınız Yanlış !!"; TempData["JS"] = "showError();"; return(RedirectToAction("GameArena")); } } else { var currentUser = _unitOfWorkUser.RepositoryUser.GetByIDForUpdate(getCurrentUser()); gameVariant.GameIsCompleted = true; gameVariant.GameIsOver = true; gameVariant.GameQuestionCount = 0; gameVariant.GameScoreCount = 0; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); int secondRequest = HttpContext.Response.StatusCode; if (secondRequest == 200) { _unitOfWorkGameVariant.Complete(); } foreach (var x in currentUser) { TempData["Message"] = "Tebrikler !! Oyunu " + x.UserLastScore + " puan ile bitirdiniz!!"; TempData["JS"] = "showSuccess();"; return(RedirectToAction("GameArena")); } } } else { gameVariant.GameScoreCount = 0; gameVariant.GameQuestionCount = 0; gameVariant.GameIsCompleted = false; gameVariant.GameIsOver = false; gameVariant.GameVariantID = 1; _unitOfWorkGameVariant.RepositoryGameVariant.Update(gameVariant); int request = HttpContext.Response.StatusCode; if (request == 200) { TempData["Message"] = "Önceki oyunu başarıyla tamamladınız. Skorunuz:" + lastScore + " Yeni oyuna başlayabilirsiniz."; TempData["JS"] = "showSuccess();"; _unitOfWorkGameVariant.Complete(); return(RedirectToAction("GameArena")); } else { TempData["Message"] = "Bir sorun oluştu,tekrar deneyiniz"; TempData["JS"] = "showError();"; return(RedirectToAction("GameArena")); } } } return(RedirectToAction("GameArena")); }
private IEnumerator Send() { string data = ""; string name = DataHolder.nickname; string score = DataHolder.points.ToString(); string url = "http://seventh.touchit.space/addPlayer.php"; // Database server URL List <IMultipartFormSection> wwwForm = new List <IMultipartFormSection>(); if (name != "" || name != null) { wwwForm.Add(new MultipartFormDataSection("name", name)); wwwForm.Add(new MultipartFormDataSection("score", score)); UnityWebRequest www_add = UnityWebRequest.Post(url, wwwForm); yield return(www_add.SendWebRequest()); } url = "http://seventh.touchit.space/"; // Database server URL wwwForm = new List <IMultipartFormSection>(); UnityWebRequest www = UnityWebRequest.Post(url, wwwForm); www = UnityWebRequest.Post(url, wwwForm); yield return(www.SendWebRequest()); data = www.downloadHandler.text; ScoreTable GlobalScoreTable = new ScoreTable(); // <ScoreTable> Class declaration: Assets/Classes/ScoreTable.cs Debug.Log(data); GlobalScoreTable = JsonUtility.FromJson <ScoreTable>(data); Debug.Log(GlobalScoreTable); if (GlobalScoreTable != null) { foreach (Player player in GlobalScoreTable.Players) { scoreTableItem.transform.Find("Id").GetComponent <Text>().text = player.id.ToString(); scoreTableItem.transform.Find("Name").GetComponent <Text>().text = player.name; scoreTableItem.transform.Find("Score").GetComponent <Text>().text = player.score.ToString(); Instantiate(scoreTableItem.transform, scoreTableContent.transform); } } else { ScoreTable LocalScoreTable = new ScoreTable(); // <ScoreTable> Class declaration: Assets/Classes/ScoreTable.cs Player player = new Player(); string scoreTable = JsonDatabaseConnection.load("ScoreTable"); if (scoreTable != "") { LocalScoreTable = JsonUtility.FromJson <ScoreTable>(scoreTable); Debug.Log(LocalScoreTable.Players); } long currentUnixTime = System.DateTimeOffset.Now.ToUnixTimeSeconds(); // unix-time player.name = DataHolder.nickname; player.score = DataHolder.points; player.id = currentUnixTime * player.name.Length; LocalScoreTable.Players.Add(player); LocalScoreTable.save(); scoreTableContent.SetActive(false); scoreTableItemError.SetActive(true); } scoreTableItem.SetActive(false); }
private void Start() { scoreText = gameObject.GetComponent <Text>(); scoreText.text = ScoreTable.GetScore(ScoreTable.currentPlayer, "score").ToString(); }
void Update() { scoreText.text = ScoreTable.GetScore(ScoreTable.currentPlayer, "score").ToString(); }
// Use this for initialization void Start() { m_Player = FindObjectOfType<SpaceShip_Controller>(); m_HUD = FindObjectOfType<Player_HUD>(); m_Spawners = FindObjectsOfType<Spawn_Controller>(); m_Values = FindObjectOfType<ValueHolder> (); m_HighScores = new ScoreTable(); m_HighScores.LoadScores (); m_Timer = m_Respawn; }
void CollectMatches(TestDatabase database, IEnumerable <TestPair> pairSource, ScoreTable table, Stopwatch timer) { var pairs = pairSource.ToList(); var templates = from pair in pairs select database[pair.Candidate].Template; var scores = RunMatch(templates.ToList(), timer); foreach (int i in Enumerable.Range(0, scores.Length)) { table[pairs[i]] = scores[i]; } }