/// <summary> /// Takes the players current name and current score and sets a new High score if the got one. /// </summary> /// <param name="newHighScore">New high score.</param> /// <param name="playerName">Player name.</param> void StoreNewHighScore(int newHighScore, string playerName) { PlayerScore a = new PlayerScore(); a.name = playerName; a.score = newHighScore; //LoadList(); scoreIndex.Add(a); scoreIndex.Sort(); scoreIndex.Reverse(); PlayerPrefs.SetString("name0", scoreIndex[0].name); PlayerPrefs.SetInt("score0", scoreIndex[0].score); PlayerPrefs.SetString("name1", scoreIndex[1].name); PlayerPrefs.SetInt("score1", scoreIndex[1].score); PlayerPrefs.SetString("name2", scoreIndex[2].name); PlayerPrefs.SetInt("score2", scoreIndex[2].score); PlayerPrefs.SetString("name3", scoreIndex[3].name); PlayerPrefs.SetInt("score3", scoreIndex[3].score); PlayerPrefs.SetString("name4", scoreIndex[4].name); PlayerPrefs.SetInt("score4", scoreIndex[4].score); PlayerPrefs.Save(); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Head") { GameObject gameController = GameObject.Find("GameController"); PlayerScore score = gameController.GetComponent <PlayerScore>(); int tmpMultiplier = score.getMuliplier(); Destroy(this.gameObject); other.rigidbody2D.velocity = Vector3.zero; other.rigidbody2D.gravityScale = 0.0f; Head head = other.GetComponent <Head>(); head.controlLock = true; head.destroyAllSegments(); Animator anim = other.gameObject.GetComponent <Animator>(); anim.SetBool("ReachedEndOfLevel", true); Camera.main.orthographicSize = 3.0f; smooth2Dfollow sm2Df = Camera.main.GetComponent <smooth2Dfollow>(); sm2Df.targetPosOnScreenX = 0.5f; sm2Df.targetPosOnScreenY = 0.5f; score.setMultiplier(tmpMultiplier); } }
public void AddingPlayerToHighscoreTableShouldWorkCorrectly() { HighscoreTable table = new HighscoreTable(); PlayerScore somePlayer = new PlayerScore("Pesho", 10, DateTime.Now); table.AddPlayer(somePlayer); Assert.AreEqual(1, table.Table.Count); }
private static void FriendsScoresLoop(List <object> playerids, int points, Action finished) { Thread.Sleep(500); points += 1000; var playerid = playerids [0].ToString(); playerids.RemoveAt(0); var score = new PlayerScore { playername = "playerid" + playerid, playerid = playerid, table = "friends" + rnd, points = points, highest = true, fields = { { "rnd", rnd } } }; Playtomic.Leaderboards.Save(score, r => { if (playerids.Count > 0) { FriendsScoresLoop(playerids, points, finished); return; } finished(); }); }
// Update is called once per frame void Update() { if (!PhotonNetwork.inRoom || PhotonNetwork.room.PlayerCount != 2) { return; } currentTime -= Time.deltaTime; // float minutef = Mathf.FloorToInt(currentTime / 60); float secondf = Mathf.FloorToInt(currentTime % 60); minuteText.text = minutef.ToString("0"); secondText.text = secondf.ToString("0"); if (currentTime <= 0) { currentTime = 0; PlayerScore playerScore = GameObject.Find("CanvasGlobal").GetComponent <PlayerScore>(); playerScore.EndGame(); Debug.Log("Time ends!"); } }
public void TestIfToStringListsCorrectlyReturnsAHighscoreTableAsStringLists() { var table = new HighscoreTable(); var sampleStringTable = new List<List<string>>() { new List<string>() { "tosho", "8" }, new List<string>() { "gosho", "28" }, new List<string>() { "pesho", "30" } }; foreach (var record in sampleStringTable) { var score = new PlayerScore(record[0], int.Parse(record[1]), DateTime.Now); } var asStringLists = table.ToStringLists(); for (int i = 0, length = asStringLists.Count; i < length; i++) { for (int j = 0, length2 = asStringLists[i].Count; j < length2; j++) { Assert.AreEqual(sampleStringTable[i][j], asStringLists[i][j]); } } }
//For every enemy killed -> player gets the bonus of 10 points static void IncreamentPlayerScoreBonus() { GameObject playerSc = GameObject.Find("ScoreTxt"); PlayerScore score2 = playerSc.GetComponent <PlayerScore> (); score2.bonusScore(EXTRA_POINTS); }
void Start () { // initialize player's attributes player = GameObject.FindGameObjectWithTag("Player"); // find player's gamobject in the scene playerAttribute = player.GetComponent<Player> (); playerScore = player.GetComponent<PlayerScore> (); playerAttack = player.GetComponent<PlayerAttack> (); }
private void HandleDeath() { if (m_IsDead) { return; } // call OnDie action if (currentHealth <= 0f) { if (onDie != null) { if (gameObject.CompareTag("Enemy")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.AddPoints(30); //print("Enemy killed " + player.currentPoints); } if (gameObject.CompareTag("Player")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.DecreasePoints(30); // print("Player died" + player.currentPoints); player.UpdateHighScore(); } m_IsDead = true; onDie.Invoke(); } } }
public IActionResult ChangePlayerScore([FromBody] PlayerScoreVM model) { if (model == null || model.IdPlayerScore <= 0) { return(Ok(0)); } PlayerScore player = _context.Scores.SingleOrDefault(p => p.IdPlayerScore == model.IdPlayerScore); if (player == null) { return(CreatePlayerScore(model)); } else { try { player.IdPlayerScore = model.IdPlayerScore; player.CorrectAnswers = model.CorrectAnswers; player.IncorrectAnswers = model.IncorrectAnswers; player.SkippedAnswers = model.SkippedAnswers; player.TotalScore = model.TotalScore; player.TimeGameInSeconds = model.TimeGameInSeconds; player.ProgressInGame = model.ProgressInGame; player.CurrentQuestionNoAnswer = model.CurrentQuestionNoAnswer; player.AnswersSkipped = model.AnswersSkipped; player.AnswersWrong = model.AnswersWrong; _context.SaveChanges(); } catch (Exception) { return(Ok(0)); } return(Ok(player.IdPlayerScore)); } }
/// <summary> /// Loads the high scores and names stored locally and adds them into the l /// </summary> void LoadList() { PlayerScore a = new PlayerScore(); a.name = PlayerPrefs.GetString("name0"); a.score = PlayerPrefs.GetInt("score0"); scoreIndex.Add(a); PlayerScore b = new PlayerScore(); b.name = PlayerPrefs.GetString("name1"); b.score = PlayerPrefs.GetInt("score1"); scoreIndex.Add(b); PlayerScore c = new PlayerScore(); c.name = PlayerPrefs.GetString("name2"); c.score = PlayerPrefs.GetInt("score2"); scoreIndex.Add(c); PlayerScore d = new PlayerScore(); d.name = PlayerPrefs.GetString("name3"); d.score = PlayerPrefs.GetInt("score3"); scoreIndex.Add(d); PlayerScore e = new PlayerScore(); e.name = PlayerPrefs.GetString("name4"); e.score = PlayerPrefs.GetInt("score4"); scoreIndex.Add(e); }
public void ScoreBoard_TryToAddMoreThanMaxAllowedTopScores() { const int NUMBER_OF_SCORES_TO_ADD = 10; const int NUMBER_OF_SCORES_TO_EXPECT = 5; const int TEST_MOVES = 9; const string TEST_NAME = "Ivan"; for (int i = 0; i < NUMBER_OF_SCORES_TO_ADD; i++) { PlayerScore score = new PlayerScore(); score.Name = TEST_NAME; score.Moves = TEST_MOVES; this.scoreBoard.AddScore(score); } StringWriter writer = new StringWriter(); Console.SetOut(writer); ConsoleRenderer renderer = new ConsoleRenderer(); this.scoreBoard.Render(renderer); string expected = "Top 5: \n"; for (int i = 0; i < NUMBER_OF_SCORES_TO_EXPECT; i++) { expected += string.Format("{0}. {1} ---> {2} moves \n", i + 1, TEST_NAME, TEST_MOVES); } Assert.AreEqual(expected, writer.ToString()); }
public void ScoreBoard_AddScorePassWrongValueInPosition() { PlayerScore wrongTypeOfScore = new PlayerScore(); wrongTypeOfScore.Position = -4; this.scoreBoard.AddScore(wrongTypeOfScore); }
public void ScoreBoard_AddScorePassWrongValueInName() { PlayerScore wrongTypeOfScore = new PlayerScore(); wrongTypeOfScore.Name = string.Empty; this.scoreBoard.AddScore(wrongTypeOfScore); }
private void Update() { { Text temp = GameUIScreen.transform.GetChild(0).GetComponent <Text>(); temp.text = "Score: " + PlayerScore; Text GameOverScreenScore = GameOverScreen.transform.GetChild(4).GetComponent <Text>(); GameOverScreenScore.text = PlayerScore.ToString() + " points"; } if (GameOverFlag) { GameOver(); } if (Input.GetKeyDown(KeyCode.Escape)) { if (PauseFlag) { ResumeGame(); } else { PauseGame(); } } }
// Use this for initialization void Start() { enemyRen = GetComponent <SpriteRenderer>(); anim = GetComponent <Animator>(); if (rigidbodyComponent == null) { rigidbodyComponent = GetComponent <Rigidbody2D>(); } if (canShoot == true) { InvokeRepeating("EnemyShotAttack", 0, 2f); } enemyPosx = transform.position.x; dirRight = false; Patrol = true; MainPlayer = GameObject.FindGameObjectWithTag("Player"); Gary = MainPlayer.GetComponent <Player>(); PScore = GameObject.FindGameObjectWithTag("Score"); Score = PScore.GetComponent <PlayerScore>(); }
private void AddRecordOfExistedPlayer(string playerName, string diff, int sec, int min, int h) { using (var ctx = new MyDbContext()) { var player_id = ctx.Player.Select(s => s) .Where(i => i.name == playerName) .First(); var score = new Score { difficulty = diff, seconds = sec, minutes = min, hours = h }; ctx.Score.Add(score); ctx.SaveChanges(); var score_id = ctx.Score .Select(s => s.id).Max(); var playerScore = new PlayerScore { id_player = player_id.id, id_score = score_id }; ctx.PlayerScore.Add(playerScore); ctx.SaveChanges(); } }
public void ScoreBoard_AddScorePassWrongValueInMoves() { PlayerScore wrongTypeOfScore = new PlayerScore(); wrongTypeOfScore.Moves = -7; this.scoreBoard.AddScore(wrongTypeOfScore); }
private void Start() { _retryBall.Activated += (sender) => { PlayerScore.Reset(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single); }; _quitBall.Activated += (sender) => { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif }; Hide(); _particles.AddRange(_retryBall.GetComponentsInChildren <ParticleSystem>()); _particles.AddRange(_quitBall.GetComponentsInChildren <ParticleSystem>()); foreach (var ps in _particles) { var main = ps.main; main.useUnscaledTime = true; } }
public void CallDropped() { Beep(); Operator.LoseLife(); PlayerScore.RecordCall(false); ChangeState <WaitForCall>(); }
public void InflictDamage(float damage, bool isExplosionDamage, GameObject damageSource) { if (health) { var totalDamage = damage; // skip the crit multiplier if it's from an explosion if (!isExplosionDamage) { if (health.gameObject.CompareTag("Player")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.DecreasePoints(3); } totalDamage *= damageMultiplier; } // potentially reduce damages if inflicted by self if (health.gameObject == damageSource) { if (health.gameObject.CompareTag("Player")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.DecreasePoints(1); } totalDamage *= sensibilityToSelfdamage; } // apply the damages health.TakeDamage(totalDamage, damageSource); } }
private void Start() { if (!isServer) { return; } // Find Network manager NetworkLobbyManager lobbyManager = FindObjectOfType <NetworkLobbyManager>(); // Find how many players were in the Lobby ExpectedPlayerCount = lobbyManager.numPlayers; // Find data collector dataCollector = FindObjectOfType <DataCollector>(); // Initialize player hand reference playerHands = new List <int> [4]; playerScores = new List <PlayerScore>(); player0Hand = new List <int>(); playerHands[0] = player0Hand; Player0Score = new PlayerScore(); playerScores.Add(Player0Score); player1Hand = new List <int>(); playerHands[1] = player1Hand; Player1Score = new PlayerScore(); playerScores.Add(Player1Score); player2Hand = new List <int>(); playerHands[2] = player2Hand; Player2Score = new PlayerScore(); playerScores.Add(Player2Score); player3Hand = new List <int>(); playerHands[3] = player3Hand; Player3Score = new PlayerScore(); playerScores.Add(Player3Score); // Initialize lists playerList = new List <Player>(); discardPile = new List <int>(); drawPile = new List <int>(); // If loading a saved game update scores if (dataCollector.LoadSavedGame) { savedPlayerNames = dataCollector.LoadNames(); savedPlayerScores = dataCollector.LoadScores(); for (int i = 0; i < savedPlayerScores.Count; i++) { playerScores[i].SetScore(savedPlayerScores[i]); } } // Set start timer startTimer = defaultStartTime; }
// other methods public void checkLevelUP(PlayerScore playerScore, PlayerEnergy playerEnergy, PlayerAttack playerAttack) { if (playerScore.getScore() >= scoreLevel) // check if the player can level up or not { levelUP(playerEnergy, playerAttack); } }
// Use this for initialization void Start() { GameObject gameController = GameObject.Find("GameController"); PlayerScore scoreKeeper = gameController.GetComponent <PlayerScore>(); if (scoreKeeper) { int fruitscore = scoreKeeper.score; int mult = scoreKeeper.getMuliplier(); int deaths = scoreKeeper.getDeaths(); int finalmult = mult - deaths < 0 ? 0 : (mult - deaths); playerScore = fruitscore * finalmult; this.guiText.text = "Multiplier: " + mult + " - " + deaths + " = " + (mult - deaths) + " = " + finalmult + "\n" + "Your Score: " + fruitscore + " X " + finalmult + " = " + playerScore; } else { Debug.Log("Score could not be found!"); } Destroy(gameController); savingDone = false; }
protected override void Effect(GameObject player) { PlayerScore playerScore = player.GetComponent <PlayerScore>(); playerScore.IncreaseLife(m_LifePoints); playerScore.IncreaseScore(m_ScorePoints); }
void Start() { jump = GetComponent<Jump> (); charge = GetComponent<Charge> (); anim = gameObject.GetComponent<Animator> (); score = GetComponent<PlayerScore>(); }
private void UpdateCharacterScore() { PlayerScore = CalcScore(MarathonGameTimerController.Instance.MarathonGameTimeInSec); string playerScoreStr = PlayerScore.ToString(); if (playerScoreStr.Length < scoreDigits) { int lack = scoreDigits - playerScoreStr.Length; for (int i = 0; i < lack; i++) { playerScoreStr = 0.ToString() + playerScoreStr; } } string playerTimeSec = MarathonGameTimerController.Instance.Second.ToString(); playerTimeSec = playerTimeSec.Length == 2 ? playerTimeSec : 0.ToString() + playerTimeSec; string playerTimeMin = MarathonGameTimerController.Instance.Minute.ToString(); playerTimeMin = playerTimeMin.Length == 2 ? playerTimeMin : 0.ToString() + playerTimeMin; RivalScore = CalcScore(rivalCostTime); UIResourceController.DisplayNumImage(minNumRoot, playerTimeMin, minColor, numImageInterval); UIResourceController.DisplayNumImage(secNumRoot, playerTimeSec, secColor, numImageInterval); UIResourceController.DisplayNumImage(scoreNumRoot, playerScoreStr, scoreColor, numImageInterval); resultTimeline.Play(); }
public static void CreateMessage(PlayerScore[] scores) { GameObject gameObj = new GameObject("scoreMessage"); DontDestroyOnLoad(gameObj); gameObj.AddComponent(typeof(PlayerScoreMessage)); gameObj.GetComponent<PlayerScoreMessage>().scores = scores; }
public IActionResult CreatePlayerScore([FromBody] PlayerScoreVM model) { if (model == null) { return(Ok(0)); } PlayerScore player; try { player = new PlayerScore() { IdPlayerScore = model.IdPlayerScore, CorrectAnswers = model.CorrectAnswers, IncorrectAnswers = model.IncorrectAnswers, SkippedAnswers = model.SkippedAnswers, TotalScore = model.TotalScore, TimeGameInSeconds = model.TimeGameInSeconds, ProgressInGame = model.ProgressInGame, CurrentQuestionNoAnswer = model.CurrentQuestionNoAnswer, AnswersSkipped = model.AnswersSkipped, AnswersWrong = model.AnswersWrong }; _context.Scores.Add(player); _context.SaveChanges(); } catch (Exception) { return(Ok(0)); } return(Ok(player.IdPlayerScore)); }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); playerMovement = gameObject.GetComponent <playerMovement>(); playerScore = gameObject.GetComponent <PlayerScore>(); dodgeRender = gameObject.GetComponent <PlayerDodgeRender>(); }
public void SaveGameData(PlayerScore PlayerScore_) { string DataJson = JsonUtility.ToJson(PlayerScore_); File.WriteAllText(FilePath, DataJson); Debug.Log("Game data saved"); }
public static void SendGameScoreToServer(string username, int score) { ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true; Debug.Log("Starting to send POST request to server..."); var httpWebRequest = (HttpWebRequest)WebRequest.Create(highscoreURL); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { PlayerScore playerScore = new PlayerScore(); playerScore.username = username; playerScore.score = score; string sendScoreJSON = JsonUtility.ToJson(playerScore); Debug.Log(sendScoreJSON); streamWriter.Write(sendScoreJSON); streamWriter.Flush(); streamWriter.Close(); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); if (result.Equals("score_set")) { Debug.Log("Score set"); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "RedEnemy") { PlayerScore playerScore = GameObject.Find("Score").GetComponent <PlayerScore>(); if (playerScore != null) { playerScore.IncremenScoreRed(); } Destroy(other.gameObject); Destroy(gameObject); } if (other.tag == "GreenEnemy") { PlayerScore playerScore = GameObject.Find("Score").GetComponent <PlayerScore>(); if (playerScore != null) { playerScore.IncremenScoreGreen(); } Destroy(other.gameObject); Destroy(gameObject); } if (other.tag == "BlueEnemy") { PlayerScore playerScore = GameObject.Find("Score").GetComponent <PlayerScore>(); if (playerScore != null) { playerScore.IncremenScoreBlue(); } Destroy(other.gameObject); Destroy(gameObject); } }
public void UpdatePlayerInfo(PlayerScore _info, int _index) { _playerScore = _info; if (_playerScore != default && _info.valid) { playerPlaceText.text = (_index + 1).ToString(); playerNameText.text = _playerScore.name; playerNameText.color = _playerScore.color; _previousScore = _currentScore; _currentScore = _playerScore.score; playerSpeakerIcon.gameObject.SetActive(InGameOnlineController.Instance.VoiceChatIsTalking(_playerScore.id)); _progress = 0; if (_info.playerFlags.rainbowName && !_rainbowName) { playerNameText.color = _info.color; _color = HSBColor.FromColor(_info.color); } else if (!_info.playerFlags.rainbowName && playerNameText.color != _info.color) { playerNameText.color = _info.color; } _rainbowName = _info.playerFlags.rainbowName; } else { playerPlaceText.text = ""; playerNameText.text = ""; playerScoreText.text = ""; playerSpeakerIcon.gameObject.SetActive(false); _rainbowName = false; } }
public void TakeDamage(float damage, GameObject damageSource) { if (invincible) { return; } if (gameObject.CompareTag("Enemy")) { PlayerScore player = FindObjectOfType <PlayerScore>(); player.AddPoints(5); print("Enemy attacked" + player.currentPoints); } float healthBefore = currentHealth; currentHealth -= damage; currentHealth = Mathf.Clamp(currentHealth, 0f, maxHealth); // call OnDamage action float trueDamageAmount = healthBefore - currentHealth; if (trueDamageAmount > 0f && onDamaged != null) { onDamaged.Invoke(trueDamageAmount, damageSource); } HandleDeath(); }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); PointPosition = player.transform.position; //startposition of the score text playerScore = player.GetComponent<PlayerScore>(); }
void Awake() { players = new PlayerScore[playerCount]; for (int i = 0; i < playerCount; ++i) { players[i] = new PlayerScore(); } }
// Use this for initialization void Awake() { playerTarget = GameObject.Find ("PlayerTarget"); playerHealth = (PlayerHealth) playerTarget.GetComponent(typeof(PlayerHealth)); playerScore = (PlayerScore) playerTarget.GetComponent (typeof (PlayerScore)); spawnSphere = GameObject.Find ("Spawner Sphere"); spawner = (SpawnParticles) spawnSphere.GetComponent(typeof(SpawnParticles)); }
private void AddPointsWhenPlayerHasNoAdvantage(PlayerScore player) { if (player.Points == Points.Forty && PlayerTwo.Points < Points.Forty || player.Points == Points.Forty && PlayerOne.Points < Points.Forty) { player.AddPoints(); } }
private void GUIRow(ref PlayerScore s) { for (int i = 0; i < s.frames.Length; ++i) { GUI.BeginGroup(new Rect(i * frameWidth, 0, frameWidth, frameHeight)); GUIFrame(ref s.frames[i]); GUI.EndGroup(); } }
public void SaveScore() { if (string.IsNullOrEmpty (playerName.text)) return; int playerScore = GameScoreManager.Instance.score; PlayerScore player = new PlayerScore (playerName.text, playerScore); LoadSaveDataList.AddData (player, "playerRanking.infos"); Application.LoadLevel ("Main menu"); }
/// <summary> /// Adds a player to a <see cref="HighscoreTable"/>. /// </summary> /// <param name="score">An instance of a class that implements the PlayerScore interface.</param> public void AddPlayer(PlayerScore score) { this.table.Add(score); this.table.Sort(); if (this.table.Count > HighscoreTable.MaxPlayers) { this.table.RemoveAt(this.table.Count - 1); } }
/// <summary> /// Awake this instance. /// </summary> void Awake() { sessionTime = 0; if (Instance != null) { Debug.LogError("Multiple instances of PlayerScore!"); } Instance = this; }
void Start() { EmptySlot = GameObject.FindGameObjectWithTag("iconHolder"); database = GameObject.FindGameObjectWithTag("gameController").GetComponent<ItemDatabase>(); scoreScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScore>(); //x = EmptySlot.transform.position.x; // x-position of the emptyslot image in screen //y = EmptySlot.transform.position.y; // y-position of the emptyslot image in screen //x = 70; //y = 265; slotRect = new Rect(x, y, 80, 80); //the position of the ItemIcon in screen }
public void UpdateScoreLists(NetworkPlayer player,string name, int score, int idxColor) { PlayerScore tempPlayer = new PlayerScore(); tempPlayer.netPlayer = player; tempPlayer.playerName = name; tempPlayer.score = score; tempPlayer.nameColor = ReturnColorBasedOnIndex(idxColor); playersScores.Add(tempPlayer); }
private void Awake() { // Setting up the references. _player = GameObject.FindGameObjectWithTag("Player").transform; _playerScore = _player.GetComponent<PlayerScore>(); _animator = GetComponent<Animator>(); _playerHealth = _player.GetComponent<PlayerHealth>(); enemySight = GetComponent<EnemySight>(); nav = GetComponent<NavMeshAgent>(); lastPlayerSighting = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<LastPlayerSighting>(); }
void Awake() { m_pn.Read(); for (int i = 0; i < m_pn.nameList.Count - 1; ++i) { PlayerScore ps = new PlayerScore(); ps.playerName = m_pn.nameList[i] as string; ps.playerScore = PlayerPrefs.GetInt(i.ToString() + ps.playerName, 0); m_playerScoreList.Add(ps); } }
void init(PlayerScore score) { Score = score; Window.TextList.Clear(); Vector2 orgpos = Window.TextAreaPosition; Vector2 mergin = WindowConfigure.createFontScaleForVector(0,1.5f); List<WindowText> texts = new List<WindowText>(); var strs = score.getScoreTextsForResult(); for (int i = 0; i < strs.Length; i++) { texts.Add(new WindowText(strs[i],orgpos+(i*mergin))); } Window.addWindowText(texts.ToArray()); }
public void AddCurrentPlayerToBestScores() { PlayerScore ps; if (Players.TryGetValue(CurrentPlayer.Name, out ps)) { if (CurrentPlayer.Score > ps.Score) { ps.Score = CurrentPlayer.Score; } } else { ps = new PlayerScore(CurrentPlayer.Name, CurrentPlayer.Score); Players.Add(CurrentPlayer.Name, ps); } }
void Start() { //setting the references MysteriousTickingNoise = GetComponent<AudioSource>(); BellRinging = GameObject.FindGameObjectWithTag("bell").GetComponent<AudioSource>(); Endscript = GameObject.FindGameObjectWithTag("gameController").GetComponent<onButtonClick>(); GameObject TimeSlider = GameObject.FindGameObjectWithTag("TimeBar"); TimeBar = TimeSlider.GetComponent<Image>(); // set the fillamount of the image to zero to start with a time of zero TimeBar.fillAmount = 0f; playerScore = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScore>(); scoreScript = GameObject.FindGameObjectWithTag("gameController").GetComponent<Score>(); }
public void CollideWithPlayer(PlayerScore otherPlayer) { if(chasing && !otherPlayer.chasing) { //we caught them! hooray! CatchPlayer(); otherPlayer.GetCaught(); } else if(!chasing && otherPlayer.chasing) { GetCaught(); otherPlayer.CatchPlayer(); } }
void InsertRecord(int score) { // для такого маленького списка бинарный поиск не даст выигрыша по скорости for (int index = 0; index < tableSize; index++) { if(scoreRecords[index].score < score) { PlayerScore record = new PlayerScore(); record.name = "You"; record.score = score; scoreRecords.Insert(index, record); scoreRecords.RemoveAt(tableSize); return; } } }
void Awake() { // intialize player's attribute playerScore = GetComponent<PlayerScore> (); playerAttack = GetComponent<PlayerAttack> (); playerEnergy = GetComponent<PlayerEnergy> (); playerLevel = GetComponent<PlayerLevel> (); // other flag status grounded = false; facingLeft = true; doubleJump = false; source = GetComponent<AudioSource> (); }
private PlayerScore PlayerScore; // for the reference of the playerscore script void Awake() { PlayerScore = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScore>(); //reference to the playerscore script <<<<<<< HEAD //enemySight = GameObject.FindGameObjectWithTag("Enemy").GetComponent<EnemySight>(); //only works, if there is just one player ======= enemySight = GameObject.FindGameObjectWithTag("Enemy").GetComponent<EnemySight>(); //only works, if there is just one player >>>>>>> dd5711ced731f99b586cb33f83b71c58174c8409 scoreCounter = GameObject.FindGameObjectWithTag("scoreCounter"); //find the scoreCounter gameObject scoreText = scoreCounter.GetComponent<Text>(); //get the Text compnent of that gameobject if (NameOfScene != "StartScreen") //this does not work as I want it to. { Reset(); }//reset it at the start of the level }
public PlayerScore GetScore(string playerName) { var playerScore = _scores.FirstOrDefault(s => s.PlayerName.ToLower() == playerName.ToLower()); if (playerScore == null) { playerScore = new PlayerScore { PlayerName = playerName }; _scores.Add(playerScore); } return playerScore; }
public static void FirstScore(Action done) { const string section = "TestLeaderboards.FirstScore"; Debug.Log (section); PlayerScore score = new PlayerScore { table = "scores" + rnd, playername = "person1", points = 10000, highest = true, fields = new PDictionary { {"rnd", rnd} } }; Playtomic.Leaderboards.Save (score, r => { AssertTrue(section + "#1", "Request succeeded", r.success); AssertEquals(section + "#1", "No errorcode", r.errorcode, 0); // duplicate score gets rejected score.points = 9000; Thread.Sleep (1000); Playtomic.Leaderboards.Save (score, r2 => { AssertTrue(section + "#2", "Request succeeded", r2.success); AssertEquals(section + "#2", "Rejected duplicate score", r2.errorcode, 209); // better score gets accepted score.points = 11000; Playtomic.Leaderboards.Save (score, r3 => { AssertTrue(section + "#3", "Request succeeded", r3.success); AssertEquals(section + "#3", "No errorcode", r3.errorcode, 0); // score gets accepted score.points = 9000; score.allowduplicates = true; Playtomic.Leaderboards.Save (score, r4 => { AssertTrue(section + "#4", "Request succeeded", r4.success); AssertEquals(section + "#4", "No errorcode", r4.errorcode, 0); done(); }); }); }); }); }
public void HandlePlayerRegistered(string playerName) { if (_scores.Any(s => s.PlayerName.ToLower() == playerName.ToLower())) { return; } var playerScore = new PlayerScore { PlayerName = playerName, Kills = 0, Deaths = 0, Assists = 0 }; _scores.Add(playerScore); }
void Start() { for (int index = 0; index < tableSize; index++) { PlayerScore record = new PlayerScore(); record.name = PlayerPrefs.GetString("name"+index, "Nobody"); record.score = PlayerPrefs.GetInt("score"+index, 0); scoreRecords.Add(record); } string tableNamesText = ""; string tableScoresText = ""; for (int index = 0; index < tableSize; index++) { tableNamesText += scoreRecords[index].name; tableNamesText += "\n"; tableScoresText += scoreRecords[index].score.ToString(); tableScoresText += "\n"; } tableNames.text = tableNamesText; tableScores.text = tableScoresText; }
public void Win(PlayerScore player) { if (Finished) return; if (IsPlayerTwoAdvantage(player)) { this.PlayerTwo.RemovePoints(); return; } if (IsPlayerOneAdvantage(player)) { this.PlayerOne.RemovePoints(); return; } AddPointsWhenPlayerHasNoAdvantage(player); AddPointsToPlayer(player); FinishGame(); }
void Start() { // iPhoneKeyboard.autorotateToPortrait = false; // iPhoneKeyboard.autorotateToPortraitUpsideDown = false; // iPhoneKeyboard.autorotateToLandscapeRight = false; // iPhoneKeyboard.autorotateToLandscapeLeft = true; players = new PlayerScore[maxPlayer]; int index = 0; string key = ""; while(index < maxPlayer) { key = "player" + index; if(PlayerPrefs.HasKey(key)) { players[index] = new PlayerScore(PlayerPrefs.GetString(key)); } else { players[index] = new PlayerScore(); } players[index].id = index; players[index].rect = new Rect(120, 70 + index * 24, 300, 24); players[index].textStyle = textStyle; index++; } if(PlayerPrefs.HasKey("player")) { PlayerScore newPlayer = new PlayerScore(PlayerPrefs.GetString("player")); newPlayerPosition = maxPlayer; for(index = maxPlayer - 1; index >= 0 ; index--) { if(players[index].getWeight() < newPlayer.getWeight()) { if((index + 1) < maxPlayer) { players[index + 1].Copy(players[index]); } players[index].Copy(newPlayer); newPlayerPosition = index; } } if(newPlayerPosition < maxPlayer) keyboard = iPhoneKeyboard.Open(players[newPlayerPosition].name, iPhoneKeyboardType.Default); MainMenu.CleanPlayerPrefs(); } GameMaster.SetGame(false); }