// Use this for initialization void Start () { //checks for camera and assigns main camera if no camera assigned earlier. if(cam==null) cam=Camera.main; //acess TimeCounter script. timecounter = gameObject.GetComponent<TimeCounter>(); //acess HighScore Script. highscore = gameObject.GetComponent<HighScore>(); //stores the screen limits in a vector. Vector3 screenlimit = new Vector3(Screen.width,Screen.height,0f); //converts screen limits to world limits and stores it in a vector. Vector3 worldlimit = cam.ScreenToWorldPoint(screenlimit); //(-0.9f),so that candies are spawned inside the screenlimit. maxwidth = worldlimit.x - 0.9f; //display instructions before game starts. instruction.enabled=true; //begin spawning candies and other GOs. StartCoroutine("spawn"); }
private HighScore GetHighScoreFromField() { var scoreFromInput = int.Parse(this.InputField.text); var highScore = new HighScore(); highScore.score = scoreFromInput; return highScore; }
public IHttpActionResult PutHighScore(int id, HighScore highScore) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != highScore.ID) { return BadRequest(); } db.Entry(highScore).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HighScoreExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public HighScoreManager() { _scores = new List<HighScore>(); _isHighScore = false; hs = null; _pos = -1; }
// Use this for initialization void Start () { //assigns to main camera if no other camera is assigned before hand. if(cam==null) cam=Camera.main; //access scorecounter script. scorecount = GameObject.Find("GameController").GetComponent<Scorecount>(); //access timecounter script. timecounter = GameObject.Find("GameController").GetComponent<TimeCounter>(); //access highscore script. highscore = GameObject.Find("GameController").GetComponent<HighScore>(); //stores the screenlimits in the form of a vector. Vector3 screenlimit = new Vector3(Screen.width,Screen.height,0f); //converts screen limits into world limits and stores it in the form of a vector. Vector3 worldlimit = cam.ScreenToWorldPoint(screenlimit); //(-1.1f) so that the entire pumpkin lies inside the screen. maxwidth = worldlimit.x - 1.1f; }
public void SetScoreAt(int i, HighScore score) { if (scores.Count <= i + 1) { scores[i] = score; } }
public HighScoreState(Vector2 screenSize) : base(screenSize) { highScore = new HighScore(); dataDictionary = highScore.Read(); elements.Add(new GUIelements("HSBG", new Vector2(0, 0), 1366, 768)); elements.Add(new GUIelements("HS",new Vector2(433,30),500,175)); }
public static HighScore getInstance() { if (instance == null) { instance = new HighScore(); } return instance; }
private void Start() { hs = GameObject.FindObjectOfType<HighScore>(); dir = Directory.GetCurrentDirectory() + "\\"; hs.HScore = LoadScoreFromFile(dir + filename); DontDestroyOnLoad(this); }
public void loadScores() { _scores.Clear(); for(int k = 0; k<MAX_ENTRIES; k++){ HighScore hs = new HighScore(PlayerPrefs.GetInt("Player H" + k,_players_score[k]), PlayerPrefs.GetString("Player " + k,_players[k]) ); _scores.Add(hs); } }
void InitScores() { topScores=new HighScore[10]; for(int it1=0;it1<10;it1++){ topScores[it1].name=""; topScores[it1].val=0; } roundScore = new HighScore(); roundScore.name=""; roundScore.val=0; }
public HighScore GetScoreAt(int i) { if (scores.Count <= i + 1) { return scores[i]; } else { HighScore highScore = new HighScore(0, "N/A"); return highScore; } }
public void StoreHighscore(int newHighscore) { if(newHighscore > _oldHighscore) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/HighScoreData.kappa"); HighScore saveScore = new HighScore(); saveScore.highScore = newHighscore; bf.Serialize(file, saveScore); file.Close(); } }
//takes care of reading from the xml public void LoadScores() { XmlReader xmlReader = XmlReader.Create (Application.dataPath + "/highScores.xml"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load (xmlReader); foreach(XmlNode xmlNode in xmlDoc.DocumentElement.ChildNodes) { HighScore tempHS = new HighScore(); tempHS.s_Player = xmlNode.Attributes["player"].Value; tempHS.s_Score = int.Parse(xmlNode.Attributes["score"].Value); m_TopTen.Add(tempHS); } xmlReader.Close(); }
public void addScore(int myscore) { hs = new HighScore(myscore,""); _scores.Add(hs); HighScore lowest = null; foreach(HighScore score in _scores){ if(lowest==null) lowest = score; else if(score.get_score() < lowest.get_score()) lowest = score; } _scores.Remove(lowest); if(_scores.Contains(hs)){ _isHighScore = true; } else _isHighScore = false; }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } HighScore = await _context.HighScore.FindAsync(id); if (HighScore != null) { _context.HighScore.Remove(HighScore); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public static HighScore LoadHighScore() { FileStream file; file = File.OpenRead(Application.persistentDataPath + "/high score.dat"); DataContractSerializer ds = new DataContractSerializer(Type.GetType("HighScore")); MemoryStream streamer = new MemoryStream(); byte[] bytes = new byte[file.Length]; file.Read(bytes, 0, (int)file.Length); streamer.Write(bytes, 0, (int)file.Length); streamer.Seek(0, SeekOrigin.Begin); HighScore temp = (HighScore)ds.ReadObject(streamer); file.Close(); return(temp); }
private void ShowScores() { ReadScores(); for (int i = 0; i < topRanks; i++) { if (i <= highScores.Count - 1) { GameObject scoreView = Instantiate(scorePrefab); HighScore currentScore = highScores[i]; scoreView.GetComponent <HighScoreManager>().SetScore(currentScore.Name, currentScore.Score.ToString(), "#" + (i + 1).ToString()); scoreView.transform.SetParent(scoreParent); } } }
void Awake() { //unload any assets not being used Resources.UnloadUnusedAssets(); //initialize reference to score ScoreScript = ScoreText.GetComponent<HighScore>(); //initialize door room array doorRoom = Resources.LoadAll<Transform>("DoorRooms"); if (doorRoom.Length < ROOMS_PER_FLOOR) { Debug.Log("Please make sure there are at least 4 door rooms"); return; } canGenerate = false; initializeRooms (); }
private static void listHighScores() { Console.WriteLine("++ Listing high scores ++++++++++++++++++++++++++++++++"); Console.WriteLine("Lets examine default behaviour"); using (var session = _sessionFactory.OpenSession()) { var highScores = session.Query <HighScore>() .Fetch(x => x.Game) .Fetch(x => x.Player) .ToList(); foreach (var hs in highScores) { Console.WriteLine($"High Score Id: {hs.Id}, Player: {hs.Player.Initials}, Game: {hs.Game.Name}, Score: {hs.Score}"); } Console.WriteLine("now lets be more specific with what we want back"); var highScoreResults = session.Query <HighScore>() .Fetch(x => x.Game) .Fetch(x => x.Player) .Select(x => new { HighScoreId = x.Id, PlayerInitials = x.Player.Initials, GameName = x.Game.Name, Score = x.Score }) .ToList(); foreach (var hs in highScoreResults) { Console.WriteLine($"High Score Id: {hs.HighScoreId}, Player: {hs.PlayerInitials}, Game: {hs.GameName}, Score: {hs.Score}"); } Console.WriteLine("What about an explicit left join? We must use QueryOver() style queries for that."); Game gameAlias = null; HighScore hsAlias = null; var gamesAndHighScores = session.QueryOver <Game>(() => gameAlias) .JoinAlias(() => gameAlias.HighScores, () => hsAlias, JoinType.LeftOuterJoin) // .Where(() => hsAlias == null || hsAlias.Player.Id <= 9) .SelectList(list => list .Select(() => gameAlias.Name) .SelectCount(() => hsAlias.Id) ).List <object[]>(); foreach (var ghs in gamesAndHighScores) { Console.WriteLine($"{ghs[0]} has {ghs[1]} high scores"); } } }
public void SaveScore() { string name = InputName.text.Replace("\"", ""); name = name.Length > 15 ? name.Substring(0, 15) : name; HighScore newScore = new HighScore() { Player = name, Score = score }; StartCoroutine(WaitForRequest(HighscoreAPI.SaveScore(newScore))); btnSaveScore.gameObject.SetActive(false); InputName.gameObject.SetActive(false); }
public void LoadHightScore() { if (File.Exists(Application.persistentDataPath + "/HighScore.save")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/HighScore.save", FileMode.Open); HighScore hs = (HighScore)bf.Deserialize(file); hightScore = hs.highScore; file.Close(); Debug.Log("Loaded"); } else { hightScore = 0; Debug.Log("save not found"); } }
public void Start() { TouchArea = new Rect(0, 0, Screen.width, Screen.height - 125f); rb = GetComponent <Rigidbody2D>(); cs = GetComponent <CanvasScript>(); ss = GameObject.Find("Main Camera").GetComponent <SqaureSpawner>(); Gm = GameObject.Find("GameManager").GetComponent <GameManager> (); shake = GameObject.FindGameObjectWithTag("screenShake").GetComponent <CameraShake> (); camRipple = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <RipplePostProcessor> (); highscore = GameObject.Find("GameManager").GetComponent <HighScore> (); cs.enabled = false; ss.enabled = false; playerVelocity = new Vector2(0f, 12f); }
/// <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() { StartScene startScene = new StartScene(this); this.Components.Add(startScene); Services.AddService <StartScene>(startScene); ActionScene actionScene = new ActionScene(this); this.Components.Add(actionScene); Services.AddService <ActionScene>(actionScene); HelpScene helpScene = new HelpScene(this); this.Components.Add(helpScene); Services.AddService <HelpScene>(helpScene); CreditScene creditScene = new CreditScene(this); this.Components.Add(creditScene); Services.AddService <CreditScene>(creditScene); GameOver gameOver = new GameOver(this); this.Components.Add(gameOver); Services.AddService <GameOver>(gameOver); HighScore highScore = new HighScore(this); this.Components.Add(highScore); Services.AddService <HighScore>(highScore); backRoundSong = Content.Load <Song>("game music"); MediaPlayer.IsRepeating = true; MediaPlayer.Volume = 0.1f; MediaPlayer.Play(backRoundSong); base.Initialize(); // hide all then show our first scene // this has to be done after the initialize methods are called // on all our components HideAllScenes(); startScene.Show(); }
public static void Main() { string pressedInitialKey = MenuForTheGame.PressingKey(); if (pressedInitialKey == "Start") { MainLogicOfTheGame.MainLogic(); } else if (pressedInitialKey == "High") { HighScore.HighestScore(InitialisationOfTheGame.scores); } else if (pressedInitialKey == "Exit") { return; } }
void OnCollisionEnter2D(Collision2D other) { if (PlayerPrefs.GetInt("HighScore") < score) { PlayerPrefs.SetInt("HighScore", score); } GetComponent <PolygonCollider2D>().enabled = false; GetComponent <Rigidbody2D>().gravityScale = 0; ObstacleGenerator.transform.position = new Vector2(-5, 0); HighScore.GetComponent <Text>().text = "High Score: " + PlayerPrefs.GetInt("HighScore"); MenuCanvas.GetComponent <Canvas>().enabled = true; GameplayCanvas.GetComponent <Canvas>().enabled = false; transform.position = new Vector3(transform.position.x, transform.position.y, 10); GameObject exp = Instantiate(Explosion, new Vector2(transform.position.x, transform.position.y), Quaternion.identity) as GameObject; Destroy(exp, 0.58f); }
public void HighScore_ToString() { HighScore h = new HighScore(); h.Name = "ha"; Assert.IsTrue(h.ToString() == " ha Level 1 Easy 0"); h = new HighScore("Jojo", Level.Level_2, Difficulty.Hard, 90, "nothing.jpg"); Assert.IsTrue(h.ToString() == " Jojo Level 2 Hard 90"); h.Diff = Difficulty.Medium; h.Level = Level.Boss; Assert.IsTrue(h.ToString() == " Jojo Boss Medium 90"); h = new HighScore("", Level.Level_2, Difficulty.Hard, 90, "nothing.jpg"); Assert.IsTrue(h.Name == "Unknown"); }
/// <summary> /// Log出力用メソッド /// 入力値を取得してLogに出力し、初期化 /// </summary> public void InputLogger() { string inputValue = inputField.text; Debug.Log(inputValue); PlayerPrefs.SetString("playerName", inputValue); if (PlayerPrefs.HasKey("hiScore")) { HighScore highScore = new HighScore(); highScore.name = PlayerPrefs.GetString("playerName"); highScore.score = PlayerPrefs.GetInt("hiScore"); highScore.SendData(); } Destroy(this.gameObject); }
public int CompareTo(object obj) { if (obj == null) { return(1); } HighScore otherHighScore = obj as HighScore; if (otherHighScore != null) { return(this.score.CompareTo(otherHighScore.getScore())); } else { throw new ArgumentException("Object is not a HighScore"); } }
public void Load_FromFile_Pass() { HighScoreManager Test = new HighScoreManager(); HighScore BobTest = new HighScore("Bob", Level.Level_1, Difficulty.Easy, 9001, "ship.png"); Test.highScores.Add(BobTest); Test.Save(); Test.highScores.Clear(); Test.Load(); Assert.IsTrue(Test.highScores[Test.highScores.Count - 1].Name == "Bob"); Assert.IsTrue(Test.highScores[Test.highScores.Count - 1].Level == Level.Level_1); Assert.IsTrue(Test.highScores[Test.highScores.Count - 1].Diff == Difficulty.Easy); Assert.IsTrue(Test.highScores[Test.highScores.Count - 1].Score == 9001); Assert.IsTrue(Test.highScores[Test.highScores.Count - 1].ShipImage == "ship.png"); //Delete File File.Delete(Environment.CurrentDirectory + @"/JSON.txt"); }
public void LoadScore() { if (!File.Exists(Application.persistentDataPath + "/HighScore.sav")) { highScore = 0; SaveScore(); } else { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/HighScore.sav", FileMode.Open); HighScore hs = (HighScore)bf.Deserialize(file); file.Close(); highScore = hs.highScore; } }
public static bool SaveScore(int sitesDestroyed, int tanksDestroyed, int numberOfDeaths) { HighScore newHighScore = new HighScore(sitesDestroyed, tanksDestroyed, numberOfDeaths); HighScore[] scores = LoadScores(); if (scores.Any() && scores.Last().Score() > newHighScore.Score()) { return(false); } scores = Reorder(scores, newHighScore); FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, scores); stream.Close(); return(true); }
public void Save() { if (GameManager.instance.highScore == 0) { //Debug.Log("Sparar"); Load(); } print(GameManager.instance.highScore); currentHighScore = new HighScore { hScore = GameManager.instance.highScore }; string json = JsonUtility.ToJson(currentHighScore); StreamWriter writer = new StreamWriter(path + "/" + scores); writer.WriteLine(json); writer.Close(); //Debug.Log("Save"); }
private int SaveScores() { string s = "ass".ToUpper(); HighScore hs = new HighScore(s, currentScore); highScores.Add(hs); highScores = highScores.OrderByDescending(x => x.score).ToList(); if (highScores.Count > maxHighScores) { highScores.RemoveRange(maxHighScores, highScores.Count - maxHighScores); } Serializer.SerializeXML(highScores, "HighScore", @"..\"); return(0); }
public void ShowScores() { GetScores(); foreach (GameObject scorePrefab in GameObject.FindGameObjectsWithTag("Score")) { Destroy(scorePrefab); } for (int i = 0; i < TopRanks; i++) { if (i <= highscores.Count - 1) { GameObject tmpObj = Instantiate(scorePrefab); HighScore tmpScor = highscores[i]; tmpObj.GetComponent <HighScoreScript>().SetScore(tmpScor.Username, tmpScor.Score.ToString(), "#" + (i + 1).ToString()); tmpObj.transform.SetParent(Parent); } } }
void sort() { for (int j = 0; j < scores.Count; j++) { int maxScore = j; for (int i = j; i < scores.Count; i++) { if (scores [i].value > scores [maxScore].value) { maxScore = i; } } HighScore a = scores [maxScore]; scores.RemoveAt(maxScore); scores.Insert(j, a); } //scores.Sort (); }
/// <summary> /// Adds a name and a score to the list of high scores. /// </summary> /// <param name="name">The name for the high score.</param> /// <param name="score">The score.</param> public void AddHighScore(string name, UInt64 score) { for (int i = 0; i < MaxHighScores; i++) { if (score > this.highScores[i].score) { HighScore highScore = new HighScore(); highScore.name = name; highScore.score = score; this.highScores.Insert(i, highScore); this.highScores.RemoveAt(MaxHighScores); break; } } }
public void CalculateScore() { if (Score > LastScore) { PlayerPrefs.SetInt("Score", Score); } EndUI.SetActive(true); //只有物体显示后才能获取到对象,否则为抛出空指针异常 NowScore = GameObject.Find("NowScore"); HighScore = GameObject.Find("HighScore"); NowScore.GetComponent <Text>().text = Score.ToString(); HighScore.GetComponent <Text>().text = LastScore.ToString(); if (Input.GetKey(KeyCode.Mouse0)) { SceneManager.LoadScene("UI"); } }
public static HighScore LoadData() { string path = Application.persistentDataPath + DataLoader.path; if (File.Exists(path)) { // File.Delete(path); BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); HighScore data = formatter.Deserialize(stream) as HighScore; stream.Close(); return(data); } Debug.Log("Load - LOADED PLAYER COMPLETED"); return(new HighScore()); }
// Start is called before the first frame update void Start() { InitAudio(); gameManager = GetComponent <GameManager>(); gameManager.LoadHighScores(); string highScoreInfo = ""; for (int i = 0; i < 10; i++) { HighScore score = gameManager.HighScores[i]; highScoreInfo += score.name + " - " + score.score + "\n"; } highScoreText.text = highScoreInfo; bool showEnemyHealth = PlayerPrefs.GetInt("ShowEnemyHealth", 0) == 1; enemyHealthToggle.isOn = showEnemyHealth; }
public void TestSorting() { HighScore highScore = new HighScore(); highScore.EmptyList(); highScore.NewHighscore("bob", "SpacePlace", 234, 2, 3); highScore.NewHighscore("jenifer", "spa", 521, 4, 6); highScore.NewHighscore("john", "HisHouse", 437, 3, 8); List <HighScoreInfo> NewList = highScore.GetHighScoreList(); Assert.AreEqual("jenifer", NewList[0].Name); Assert.AreEqual("john", NewList[1].Name); Assert.AreEqual("bob", NewList[2].Name); highScore.EmptyList(); }
public void TestComparingTopTen() { HighScore HighScore = new HighScore(); HighScore.EmptyList(); List <HighScoreInfo> scores = HighScore.GetHighScoreList(); Assert.AreEqual(0, scores.Count); for (int i = 0; i <= 12; i++) { HighScore.NewHighscore($"bob{i}", "Outer Space", 69, 76, 420); } scores = HighScore.GetHighScoreList(); Assert.AreEqual(10, scores.Count); HighScore.EmptyList(); }
void ShowScores() { GetScores(); for (int i = 0; i < topRanks; i++) { if (i <= highScores.Count - 1) { GameObject tmpGameobject = Instantiate(scorePrefab); HighScore tmpHighScore = highScores[i]; tmpGameobject.GetComponent <HighScoreScript>().SetScore(tmpHighScore.Name, (i + 1) + "#", tmpHighScore.Seconds, tmpHighScore.Points); tmpGameobject.transform.SetParent(scoreParent); } } }
IEnumerator DownloadHighscores() { WWW www = new WWW(webUrl + pubCode + "/pipe/"); yield return(www); if (string.IsNullOrEmpty(www.error)) { print("Leaderboard Downloaded"); // Store the data in www.text // store only get top 5 string data = www.text; string[] entries = data.Split(new char[] { '\n' }); if (entries.Length >= highscores.Length) { for (int i = 0; i < highscores.Length; i++) { string[] entryData = entries[i].Split(new char[] { '|' }); string username = entryData[0]; int score = int.Parse(entryData[1]); highscores[i] = new HighScore(username, score); } } else { for (int i = 0; i < entries.Length; i++) { string[] entryData = entries[i].Split(new char[] { '|' }); string username = entryData[0]; int score = int.Parse(entryData[1]); highscores[i] = new HighScore(username, score); } } UpdateLeaderbaordUI(); } else { print("Error Downloading Leaderboard : " + www.error); } }
/********************************************************************************************/ /**************************************** BEHAVIOURS ****************************************/ /********************************************************************************************/ /// <summary> /// Adds a high score to the list. Will not add if it is not higher than the lowest high score. /// </summary> /// <param name="highScore">The score to add to the list.</param> public static void AddHighScore(HighScore highScore) { if (highScores.Count == 0) //Any score can be added if no high scores exist. { highScores.Insert(0, highScore); NewHighScoreArgs args = new NewHighScoreArgs() { newScore = highScore.score }; OnNewHighScore(args); } else { for (int i = 0; i < highScores.Count; i++) //Find the appropriate ordered position for the new score. { if (highScore.score > highScores[i].score) { highScores.Insert(i, highScore); if (highScores.Count > _maxNumOfHighScores) //cull high scores that exist beyond the limit. { for (int c = highScores.Count - 1; c >= _maxNumOfHighScores; c--) { highScores.RemoveAt(c); } } NewHighScoreArgs args = new NewHighScoreArgs() { newScore = highScore.score }; OnNewHighScore(args); return; } } if (highScores.Count < _maxNumOfHighScores)//Any high score can be added if the list is not full. { highScores.Add(highScore); NewHighScoreArgs args = new NewHighScoreArgs() { newScore = highScore.score }; OnNewHighScore(args); } } }
/// <summary> /// Called when the panel first opens /// Sets up the UI thats on the panel /// </summary> public override void OnShow() { List <HighScore> highScores = HighScoreManager.instance.GetSortedScores(); if (highScores.Count > 0) { HighScore highScore = highScores[0]; highScoreText.text = "High Score (" + highScore.name + "): " + highScore.score.ToString(); highScoreText.gameObject.SetActive(true); } else { highScoreText.gameObject.SetActive(false); } int score = GameLogic.instance.score; scoreText.text = "Score: " + score; }
public void Initialize() { int rows = tableLayoutPanel1.RowCount; int columns = tableLayoutPanel1.ColumnCount; HighScore con = new HighScore(@"Resources\Nordwind"); con.Open(); List<string[]> highscores = con.GetHighScores(); con.Close(); for (int count = 0; count < rows; count++) { for (int i = 0; i < columns; i++) { Panel textPanel = new Panel(); Label label = new Label(); if (i == 0) { label.Text = highscores[count][i]; } else if (i == 1) { label.Text = highscores[count][i]; } else { label.Text = highscores[count][i]; } int labelHeight = (int)label.Font.GetHeight(); FontFamily ff = new FontFamily("Haettenschweiler"); label.Font = new Font(ff, 16, FontStyle.Regular); textPanel.Controls.Add(label); textPanel.Size = label.Size; label.ForeColor = Color.White; tableLayoutPanel1.Controls.Add(textPanel, i, count); } } }
private void Start() { // find high score hs = GameObject.FindObjectOfType<HighScore>(); dm = GameObject.FindObjectOfType<DoorManager>(); pa = GameObject.FindObjectOfType<PlayerAnim>(); // setup buttons rawInput = new BitArray(6); playerValue = ToInt (rawInput); playerScore = 0; // scale ui to screen uiUnit = Screen.height / 5.0f; uiStart = (Screen.width / 2.0f) - (uiUnit * 3.0f); // setup style for button text buttonStyle = new GUIStyle(); buttonStyle.font = font; buttonStyle.fontSize = (int)(0.11f * Screen.height); buttonStyle.alignment = TextAnchor.MiddleCenter; scoreStyle = new GUIStyle(); scoreStyle.font = font; scoreStyle.fontSize = (int)(0.06f * Screen.height); scoreStyle.alignment = TextAnchor.UpperLeft; scoreStyle.normal.textColor = Color.white; //Color.cyan; scoreStyle.fontStyle = FontStyle.Bold; hScoreStyle = new GUIStyle(); hScoreStyle.font = font; hScoreStyle.fontSize = (int)(0.06f * Screen.height); hScoreStyle.alignment = TextAnchor.UpperRight; hScoreStyle.normal.textColor = Color.white; hScoreStyle.fontStyle = FontStyle.Bold; }
//Adds the new score to the list. public int NewScore(string name, int score) { HighScore nHS = new HighScore(); nHS.s_Player = name; nHS.s_Score = score; if (m_TopTen.Count < 10) { for(int i = 0; i < m_TopTen.Count; ++i) { if(nHS.s_Score > m_TopTen[i].s_Score) { m_TopTen.Insert(i, nHS); return i+1; } else if( i+1 >= m_TopTen.Count) { m_TopTen.Add(nHS); return i+1; } } } else { for(int i = 0; i < m_TopTen.Count; ++i) { if(nHS.s_Score > m_TopTen[i].s_Score) { m_TopTen.Insert(i, nHS); m_TopTen.Remove(m_TopTen[m_TopTen.Count-1]); return i+1; } } } return -1; }
public void AddHighScore(HighScore score) { if (score.score < 1) { return; } bool hasInserted = false; List<HighScore> scores = GetHighScores(); for (int i = 0; i < scores.Count; ++i) { if (score.score >= scores[i].score) { scores.Insert(i, score); hasInserted = true; break; } } if (!hasInserted) { scores.Add(score); } // Trim the list length to the max number of entries in the list. while (scores.Count > maxHighScores) { scores.RemoveAt(scores.Count - 1); } ES2.Save(scores, ScoreManager.highScorePath); }
// Use this for initialization void Start () { Application.targetFrameRate = 60; highScoreScript = GetComponent<HighScore> (); spawnerScript = GetComponent<PuzzleSpawner> (); }
public void NewScore(HighScore newScore) { topScores[9]=newScore; SortScores(); SaveScoresToPrefs(); }
public void AddScore(HighScore score) { bool scoreSet = false; for (int i = 0; i < scores.Count; i++) { if (!scoreSet) { if (scores[i].Score < score.Score) { scoreSet = true; scores.Insert(i, score); if (scores.Count == 11) { //We have gone over the top ten scores.RemoveAt(10); } } } } if (!scoreSet) { //Score was not set so list must not have a full ten scores in it so add score to end of list if (scores.Count < 10) { scores.Add(score); } } }
/// <summary> /// Use for initialization. /// </summary> private void Start() { HighScore.Instance = this; this.highScoreInput = GameObject.Find("HighScoreInput"); this.highScoreInput.SetActive(false); var namesList = GameObject.Find("NamesList"); if (namesList == null) throw new InvalidOperationException("Names list must not be null."); this.nameList = namesList.GetComponent<UILabel>(); var scoresList = GameObject.Find("ScoresList"); if (scoresList == null) throw new InvalidOperationException("Scores list must not be null."); this.scoreList = scoresList.GetComponent<UILabel>(); }
/** \brief Fonction Awake pour Unity3D, gère le singleton */ void Awake() { if (Instance != null) { // Si l'instance existe déjà, erreur Debug.LogError("There is multiple instance of singleton HighScore"); return; } Instance = this; }
public IHttpActionResult PostHighScore(HighScore highScore) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Scores.Add(highScore); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = highScore.ID }, highScore); }
void Save() { BinaryFormatter bf = new BinaryFormatter (); FileStream file = File.Create (Application.persistentDataPath + "/highscoreInfo.dat"); HighScore score = new HighScore (); score.highscore = highscore; score.time = hightime; bf.Serialize (file, score); file.Close (); }
public override object Read(ES2Reader reader) { HighScore data = new HighScore(); Read(reader, data); return data; }
/// <summary> /// Add a score to the currently loaded scores. /// </summary> /// <param name="name"></param> /// <param name="score"></param> public void addHighScore(string name, int score) { var entry = new HighScore(); entry.name = name; entry.score = score; scores.scores.Add(entry); }
public void AddHighScore(int a_distanceScore) { if (HighScores.Count < 10) { HighScore temp = new HighScore(); temp.distance = a_distanceScore; temp.date = System.DateTime.Now.Date.ToString("dd\\/MM\\/yyyy"); temp.name = "Default"; HighScores.Add(temp); HighScores.Sort((s1, s2) => s2.distance.CompareTo(s1.distance)); HighScores.Reverse(); } else { HighScores.Sort((s1, s2) => s2.distance.CompareTo(s1.distance)); HighScores.Reverse(); for (int i = 0; i < HighScores.Count; ++i) { if (HighScores[i].distance > a_distanceScore) { HighScore temp = new HighScore(); temp.distance = a_distanceScore; temp.date = System.DateTime.Now.Date.ToString("dd\\/MM\\/yyyy"); temp.name = "Default"; HighScores[i] = temp; return; } } } }