private void addToScore(ScoreEvent.OnScoring evendData) { if (canScore){ totalScore += evendData.destroyedTiles*baseTileScore; modifyScoreText(); } }
/// <summary>Handles the ScoreEvent event.</summary> /// <param name="message">The message.</param> public void Handle(ScoreEvent message) { gameScore = message.Get().ToString(); }
// ScoreManager handles all of the scoring void ScoreManager(ScoreEvent sEvt) { List <Vector3> fsPts; switch (sEvt) { case ScoreEvent.draw: // Add the chained score into the total one and reset it to zero; score += chainScore * Mathf.RoundToInt(Mathf.Pow(2, chainGoldNum)); chainScore = 0; chainNum = 0; chainGoldNum = 0; break; case ScoreEvent.mine: // +1 on the chainNum chainNum++; // Add score on the chainScore chainScore += chainNum; break; case ScoreEvent.mineGold: // raise the multiplier based on the gold card encountered in this chain chainGoldNum++; chainNum++; break; case ScoreEvent.gameWin: // Clear the total score of this round, add the score to PREV_ROUND for next round SCORE_FROM_PREV_ROUND = score; break; case ScoreEvent.gameLoss: // Clear the other ones, add all to the total score score += chainScore; break; } // Handle the statements of game win and loss switch (sEvt) { case ScoreEvent.gameWin: // if it is a win, add the score to the next round // static fields are NOT reset by Application.LoadLevel() print("You Won this round! Round score: " + score); gameOverUI.text = "Round Over"; roundResultUI.text = "You have won this round!\n Round Score: " + score; ShowResultUI(true); break; case ScoreEvent.gameLoss: // If it is a loss, check against the high score gameOverUI.text = "Game Over"; if (Prospector.HIGH_SCORE <= score) { print("You got the new high score! High score: " + score); PlayerPrefs.SetInt("ProspectorHighScore", score); roundResultUI.text = "You got the high score!\n High Score: " + score; } else { print("Your final score is: " + score); roundResultUI.text = "Your final score was: " + score; ShowResultUI(true); } break; default: print("score:" + score + " chainNum:" + chainNum + " chainScore:" + chainScore); break; } // Handle the scoring show to player switch (sEvt) { case ScoreEvent.draw: case ScoreEvent.gameWin: case ScoreEvent.gameLoss: // adding the chain score to the scoreboard if (fsRun != null) { // Check if there is a started run. // If there is, make the bezier list for score moving fsPts = new List <Vector3>(); fsPts.Add(fsPosRun); fsPts.Add(fsPosMid2); fsPts.Add(fsPosEnd); fsRun.reportFinishTo = Scoreboard.S.gameObject; fsRun.Init(fsPts, 0, 1); // Change the font too. fsRun.fontSize = new List <float>(new float[] { 28, 36, 4 }); fsRun = null; // Clear fsRun so it is created again } break; case ScoreEvent.mine: case ScoreEvent.mineGold: // When mining, adding up the score in fsRun FloatingScore fs; // Moving it from the mousePosition to fsPosRun fsPts = new List <Vector3>(); Vector3 p0 = Input.mousePosition; //p0.x /= Screen.width; //p0.y /= Screen.height; fsPts.Add(p0); fsPts.Add(fsPosMid); fsPts.Add(fsPosRun); fs = Scoreboard.S.CreateFloatingScore(chainNum, fsPts); fs.fontSize = new List <float>(new float[] { 4, 50, 28 }); if (fsRun == null) { fsRun = fs; fsRun.reportFinishTo = null; } else { fs.reportFinishTo = fsRun.gameObject; } break; } }
public static void WriteScoreEvent(this PacketWriter writer, ScoreEvent data) { writer.WriteByte((byte)data); }
void onScore(ScoreEvent e) { score += e.addToScore; scoreText.text = "Score: " + score.ToString(); }
void ScoreManager(ScoreEvent sEvt) { List<Vector3> fsPts; switch (sEvt) { case ScoreEvent.draw: case ScoreEvent.gameWin: case ScoreEvent.gameLoss: chain = 0; score += scoreRun; scoreRun = 0; if (fsRun != null) { fsPts = new List<Vector3>(); fsPts.Add (fsPosRun); fsPts.Add (fsPosMid2); fsPts.Add (fsPosEnd); fsRun.reportFinishTo = Scoreboard.S.gameObject; fsRun.Init (fsPts,0,1); fsRun.fontSizes = new List<float>(new float[] {28,36,4}); fsRun = null; } break; case ScoreEvent.mine: chain++; scoreRun += chain; FloatingScore fs; Vector3 p0 = Input.mousePosition; p0.x /= Screen.width; p0.y /= Screen.height; fsPts = new List<Vector3>(); fsPts.Add (p0); fsPts.Add (fsPosMid); fsPts.Add (fsPosRun); fs = Scoreboard.S.CreateFloatingScore (chain,fsPts); fs.fontSizes = new List<float>(new float[] {4,50,28}); if(fsRun == null) { fsRun = fs; fsRun.reportFinishTo = null; } else { fs.reportFinishTo = fsRun.gameObject; } break; } switch (sEvt) { case ScoreEvent.gameWin: GTGameOver.text = "Round Over"; Prospector.SCORE_FROM_PREV_ROUND = score; print ("You won this round! Round score: "+score); GTRoundResult.text = "You won this Round!\nRound Score: "+score; ShowResultGTs(true); break; case ScoreEvent.gameLoss: GTGameOver.text = "Game Over"; if (Prospector.HIGH_SCORE <= score) { print ("You got the high score! High score: "+score); string sRR = "You got the high score!\nHigh score: "+score; GTRoundResult.text = sRR; Prospector.HIGH_SCORE = score; PlayerPrefs.SetInt("ProspectorHighScore", score); } else { print ("Your final score for the game was: "+score); GTRoundResult.text = "Your final score was: "+score; } ShowResultGTs(true); break; default: print ("score: "+score+" scoreRun:"+scoreRun+" chain:"+chain); break; } }
// ScoreManager handles all of the scoring void ScoreManager(ScoreEvent sEvt) { switch (sEvt) { // Same things need to happen whether it's a draw, a win, or a loss case ScoreEvent.draw: // Drawing a card case ScoreEvent.gameWin: // Won the round case ScoreEvent.gameLoss: // Lost the round chain = 0; // resets the score chain score += scoreRun; // add scoreRun to total score scoreRun = 0; // reset scoreRun break; case ScoreEvent.mine: // Remove a mine card chain++; // increase the score chain scoreRun += chain; // add score for this card to run break; } // This second switch statement handles round wins and losses switch (sEvt) { case ScoreEvent.gameWin: // If it's a win, add the score to the next round // static fields are NOT reset by Application.LoadLevel() Prospector.SCORE_FROM_PREV_ROUND = score; print ("You won this round! Round score: "+score); break; case ScoreEvent.gameLoss: // If it's a loss, check against the high score if (Prospector.HIGH_SCORE <= score) { print("You got the high score! High score: "+score); Prospector.HIGH_SCORE = score; PlayerPrefs.SetInt("ProspectorHighScore", score); } else { print ("Your final score for the game was: "+score); } break; default: print ("score: "+score+" scoreRun:"+scoreRun+" chain:"+chain); break; } }
void ScoreManager(ScoreEvent sEvt) { List <Vector3> fsPts; switch (sEvt) { case ScoreEvent.draw: case ScoreEvent.gameWin: case ScoreEvent.gameLoss: GTGameOver.text = "Game Over"; chain = 0; score += scoreRun; scoreRun = 0; if (fsRun != null) { fsPts = new List <Vector3>(); fsPts.Add(fsPosRun); fsPts.Add(fsPosMid2); fsPts.Add(fsPosEnd); fsRun.reportFinishTo = ScoreBoard.S.gameObject; fsRun.Init(fsPts, 0, 1); fsRun.fontSizes = new List <float>(new float[] { 28, 36, 4 }); fsRun = null; } break; case ScoreEvent.mine: chain++; scoreRun += chain; FloatingScore fs; Vector3 pO = Input.mousePosition; pO.x /= Screen.width; pO.y /= Screen.height; fsPts = new List <Vector3>(); fsPts.Add(pO); fsPts.Add(fsPosMid); fsPts.Add(fsPosRun); fs = ScoreBoard.S.CreateFloatingScore(chain, fsPts); fs.fontSizes = new List <float>(new float[] { 4, 50, 28 }); if (fsRun == null) { fsRun = fs; fsRun.reportFinishTo = null; } else { fs.reportFinishTo = fsRun.gameObject; } break; } switch (sEvt) { case ScoreEvent.gameWin: Prospector.SCORE_FROM_PREV_ROUND = score; GTGameOver.text = "Round Over"; Prospector.SCORE_FROM_PREV_ROUND = score; GTroundResults.text = "You win this round!\nRound Score: " + score; ShowResultsGTs(true); break; case ScoreEvent.gameLoss: GTGameOver.text = "Game Over"; if (Prospector.HIGH_SCORE <= score) { print("New High Score"); Prospector.HIGH_SCORE = score; string sRR = "You got the high score!\nHigh score: " + score; GTroundResults.text = sRR; PlayerPrefs.SetInt("ProspectorHighScore", score); } else { print("Your final score was" + score); GTroundResults.text = "Your final score was: " + score; } ShowResultsGTs(true); break; default: print("score" + score + " scoreRun" + scoreRun + " chain" + chain); break; } }
private void ScoreChanged(ScoreEvent evt) { view.Score = evt.Score; }
void _OnScoreUpdated(ScoreEvent e) { GetComponent <Text>().text = "Score : " + e.new_score; }
void Start() { scoreEvent = EventManager.Instance.GetOrAddEventWithPayload(new ScoreEvent()); puckResetEvent = EventManager.Instance.GetOrAddEventWithPayload(new PuckResetEvent()); }
private void ScoreManager(ScoreEvent scoreEvent) { List <Vector3> fsPts; switch (scoreEvent) { case ScoreEvent.Draw: case ScoreEvent.GameWin: case ScoreEvent.GameLoss: this.Chain = 0; this.Score += this.ScoreRun; this.ScoreRun = 0; if (this.FsRun != null) { fsPts = new List <Vector3>(); fsPts.Add(this.FsPosRun); fsPts.Add(this.FsPosMid2); fsPts.Add(this.FsPosEnd); this.FsRun.ReportFinishTo = Scoreboard.S.gameObject; this.FsRun.Init(fsPts, 0, 1); this.FsRun.FontSizes = new List <float>(new float[] { 28, 36, 4 }); this.FsRun = null; } break; case ScoreEvent.Mine: this.Chain++; this.ScoreRun += this.Chain; FloatingScore fs; Vector3 p0 = Input.mousePosition; p0.x /= Screen.width; p0.y /= Screen.height; fsPts = new List <Vector3>(); fsPts.Add(p0); fsPts.Add(this.FsPosMid); fsPts.Add(this.FsPosRun); fs = Scoreboard.S.CreateFloatingScore(this.Chain, fsPts); fs.FontSizes = new List <float>(new float[] { 4, 50, 28 }); if (this.FsRun == null) { this.FsRun = fs; this.FsRun.ReportFinishTo = null; } else { fs.ReportFinishTo = this.FsRun.gameObject; } break; } switch (scoreEvent) { case ScoreEvent.GameWin: Prospector.ScoreFromPrevRound = this.Score; print("You won this round!Round score:" + this.Score); break; case ScoreEvent.GameLoss: if (Prospector.HighScore <= this.Score) { print("You got the high score! High score:" + this.Score); Prospector.HighScore = this.Score; PlayerPrefs.SetInt("ProspectorHighScore", this.Score); } else { print("Your final score for the game was:" + this.Score); } break; default: print("score:" + this.Score + " scoreRun:" + this.ScoreRun + " chain:" + this.Chain); break; } }
public void RemoveOnScoreEvent(ScoreEvent func) { OnScoreEvent -= func; }
public void AddOnScoreEvent(ScoreEvent func) { OnScoreEvent += func; }
public void InitializeObject(bool turn, ScoreEvent se) { this.turn = turn; scoreUpdate = se; }
void Start() { scoreEvent = HeistService.Instance.FindCurrentHeist().AddToScore; }
// ScoreManager handles all of the scoring void ScoreManager(ScoreEvent sEvt) { List<Vector3> fsPts; switch (sEvt) { case ScoreEvent.draw: // Drawing a card case ScoreEvent.gameWin: // Won the round case ScoreEvent.gameLoss: // Lost the round // The same things need to happen whether it's a draw, win, or loss chain = 0; // resets the score chain score += scoreRun; // add scoreRun to total score scoreRun = 0; // reset scoreRun // Add fsRun to the _Scoreboard score if (fsRun != null) { // Create points for the Bezier curve fsPts = new List<Vector3>(); fsPts.Add(fsPosRun); fsPts.Add(fsPosMid2); fsPts.Add(fsPosEnd); fsRun.reportFinishTo = Scoreboard.S.gameObject; fsRun.Init(fsPts, 0, 1); // Also adjust the fontSize fsRun.fontSizes = new List<float>(new float[] { 28, 36, 4 }); fsRun = null; // Clear fsRun so it's created again } break; case ScoreEvent.mine: // Remove a mine card chain++; // increase the score chain scoreRun += chain; // add score for this card to run // Create a FloatingScore for this score FloatingScore fs; // Move it from the mousePosition to fsPosRun Vector3 p0 = Input.mousePosition; p0.x /= Screen.width; p0.y /= Screen.height; fsPts = new List<Vector3>(); fsPts.Add(p0); fsPts.Add(fsPosMid); fsPts.Add(fsPosRun); fs = Scoreboard.S.CreateFloatingScore(chain, fsPts); fs.fontSizes = new List<float>(new float[] { 4, 50, 28 }); if (fsRun == null) { fsRun = fs; fsRun.reportFinishTo = null; } else { fs.reportFinishTo = fsRun.gameObject; } break; } switch (sEvt) { // Same things need to happen whether it's a draw, a win, or a loss case ScoreEvent.draw: // Drawing a card case ScoreEvent.gameWin: // Won the round case ScoreEvent.gameLoss: // Lost the round chain = 0; // resets the score chain score += scoreRun; // add scoreRun to total score scoreRun = 0; // reset scoreRun break; case ScoreEvent.mine: // Remove a mine card chain++; // increase the score chain scoreRun += chain; // add score for this card to run break; } // This second switch statement handles round wins and losses switch (sEvt) { case ScoreEvent.gameWin: // If it's a win, add the score to the next round // static fields are NOT reset by Application.LoadLevel() Prospector.SCORE_FROM_PREV_ROUND = score; print("You won this round! Round score: " + score); break; case ScoreEvent.gameLoss: // If it's a loss, check against the high score if (Prospector.HIGH_SCORE <= score) { print("You got the high score! High score: " + score); Prospector.HIGH_SCORE = score; PlayerPrefs.SetInt("ProspectorHighScore", score); } else { print("Your final score for the game was: " + score); } break; default: print("score: " + score + " scoreRun:" + scoreRun + " chain:" + chain); break; } }
//ScoreManager处理所有得分 void ScoreManager(ScoreEvent sEvt) { List <Vector3> fsPts; switch (sEvt) { //无论是抽牌、赢或输,需要有对应的动作 case ScoreEvent.draw: //抽一张牌 case ScoreEvent.gameWin: //赢得本轮 case ScoreEvent.gameLoss: //本轮输了 chain = 0; //重置分数变量chain score += scoreRun; //将scoreRun加入总得分 scoreRun = 0; //重置scoreRun //将fsRun添加到_Scoreboard分数 if (fsRun != null) { //创建贝塞尔曲线的坐标点 fsPts = new List <Vector3>(); fsPts.Add(fsPosRun); fsPts.Add(fsPosMid2); fsPts.Add(fsPosEnd); fsRun.reportFinishTo = Scoreboard.Instance.gameObject; fsRun.Init(fsPts, 0, 1); //同时调整fontSize fsRun.fontSizes = new List <float>(new float[] { 28, 36, 4 }); fsRun = null;//清除fsRun以再次创建 } break; case ScoreEvent.mine: //删除一张矿井纸牌 chain++; //分数变量chain自加 scoreRun += chain; //添加当前纸牌的分数到这回合 //为当前分数创建FloatingScore FloatingScore fs; //从mousePosition移动到fsPosRun Vector3 p0 = Input.mousePosition; p0.x /= Screen.width; p0.y /= Screen.height; fsPts = new List <Vector3>(); fsPts.Add(p0); fsPts.Add(fsPosMid); fsPts.Add(fsPosRun); fs = Scoreboard.Instance.CreateFloatingScore(chain, fsPts); fs.fontSizes = new List <float>(new float[] { 4, 50, 28 }); if (fsRun == null) { fsRun = fs; fsRun.reportFinishTo = null; } else { fs.reportFinishTo = fsRun.gameObject; } break; } //第二个switch语句处理本轮的输赢 switch (sEvt) { case ScoreEvent.gameWin: GTGameOver.text = "Round Over"; //赢的话,将分数添加到下一轮 Prospector.SCORE_FROM_PREV_ROUND = score; GTRoundResult.text = "You won this round!\nRound Score:" + score; ShowResultGTs(true); break; case ScoreEvent.gameLoss: GTGameOver.text = "Game Over"; //输的话,与最高分进行比较 if (Prospector.HIGH_SCORE <= score) { string sRR = "You got the hihg score!\nHigh score:" + score; GTRoundResult.text = sRR; Prospector.HIGH_SCORE = score; PlayerPrefs.SetInt("ProspectorHighScore", score); } else { GTRoundResult.text = "Your final score was:" + score; } ShowResultGTs(true); break; default: break; } }
//Events private void OnScoreEvent(ScoreEvent evt) { var playerId = (int)evt.playerId; _playerScores[playerId].text = $"Player {playerId + 1}: {evt.scoreData.GetScore()}"; }
//Events private void OnScoreEvent(ScoreEvent evt) { _ball.GetComponent <Rigidbody>().velocity = Vector3.zero; _ball.transform.position = evt.playerPosition; }
// ScoreManager handles all of the scoring void ScoreManager(ScoreEvent sEvt) { List<Vector3> fsPts; switch (sEvt) { // Same things need to happen whether it's a draw, a win, or a loss case ScoreEvent.draw: // Drawing a card case ScoreEvent.gameWin: // Won the round case ScoreEvent.gameLoss: // Lost the round chain = 0; // resets the score chain score += scoreRun; // add scoreRun to total score scoreRun = 0; // reset scoreRun // Add fsRun to the _Scoreboard score if (fsRun != null) { // Create points for the Bezier curve fsPts = new List<Vector3>(); fsPts.Add( fsPosRun ); fsPts.Add( fsPosMid2 ); fsPts.Add( fsPosEnd ); fsRun.reportFinishTo = Scoreboard.S.gameObject; fsRun.Init(fsPts, 0, 1); // Also adjust the fontSize fsRun.fontSizes = new List<float>(new float[] {28,36,4}); fsRun = null; // Clear fsRun so it's created again } break; case ScoreEvent.mine: // Remove a mine card chain++; // increase the score chain scoreRun += chain; // add score for this card to run // Create a FloatingScore for this score FloatingScore fs; // Move it from the mousePosition to fsPosRun Vector3 p0 = Input.mousePosition; p0.x /= Screen.width; p0.y /= Screen.height; fsPts = new List<Vector3>(); fsPts.Add( p0 ); fsPts.Add( fsPosMid ); fsPts.Add( fsPosRun ); fs = Scoreboard.S.CreateFloatingScore(chain,fsPts); fs.fontSizes = new List<float>(new float[] {4,50,28}); if (fsRun == null) { fsRun = fs; fsRun.reportFinishTo = null; } else { fs.reportFinishTo = fsRun.gameObject; } break; } // This second switch statement handles round wins and losses switch (sEvt) { case ScoreEvent.gameWin: // If it's a win, add the score to the next round // static fields are NOT reset by Application.LoadLevel() Prospector.SCORE_FROM_PREV_ROUND = score; print ("You won this round! Round score: "+score); break; case ScoreEvent.gameLoss: // If it's a loss, check against the high score if (Prospector.HIGH_SCORE <= score) { print("You got the high score! High score: "+score); Prospector.HIGH_SCORE = score; PlayerPrefs.SetInt("ProspectorHighScore", score); } else { print ("Your final score for the game was: "+score); } break; default: print ("score: "+score+" scoreRun:"+scoreRun+" chain:"+chain); break; } }
/************** * CUSTOM METHODS ***************/ private void OnScoreEvent(ScoreEvent e) { GUIManager.Instance.UpdateScore(e.scoreAmount, e.eventType.ToString()); }