/********************************** * * Triggered Events * * ********************************/ public void increaseProgress(int unit, ScoreType type) { if (progressCount [level] < 0) { return; } ScoreAmount scoreAmount = 0; ProgressAmount progressAmount = 0; switch (type) { case ScoreType.Building: fallenPiecesCount++; if (fallenPiecesCount == num_of_pieces) { if (pA) { pA.level2On = true; //StartCoroutine (pA.startShakeCountDown ()); GetComponent <SpriteControl> ().activateColor(); } } progressAmount = ProgressAmount.Building; scoreAmount = ScoreAmount.Building; break; case ScoreType.Blocks: progressAmount = ProgressAmount.Block; scoreAmount = ScoreAmount.Block; break; case ScoreType.Human: progressAmount = ProgressAmount.Human; scoreAmount = ScoreAmount.Human; break; default: break; } progressCount [level] -= unit * (int)progressAmount; increaseScore(scoreBase * unit * (int)scoreAmount); if (progressCount[level] == 0) { //structures[level].GetComponent<PolygonCollider2D>().enabled = true; progressCount[level]--; buildingDestroyedCount++; } //Debug.Log (progressCount [level]); }
protected override ReadonlyEvent GatherData() { if (ScoreCanIncrease(currentPlayer)) { Result.Deltas.Add(new Delta { Actor = currentPlayer, Key = "Score", Value = ScoreAmount.ToString(), Targets = repo.Get(Result) }); Result.Actor = currentPlayer; Result.Targets = ValidScoreTargets; Result.Resolution = EventResolutionType.Commit; } return(this); }
public ScoreAmountRepresentation(ScoreAmount scoreAmount) { ScoreAmount = scoreAmount; AmountString = scoreAmount.ToString(); if (scoreAmount.IsGeneral) { AmountString = scoreAmount.Amount.ToString(); } else if (scoreAmount.IsMatch) { AmountString = scoreAmount.Amount.ToString(); } AmountColor = scoreAmount.IsGeneral ? "DarkRed" : scoreAmount.IsMatch ? "Orange" : "Black"; }
//--------------------------------------------------------------------------------------------------------------------- // Method: KillEntity, overload III // Desc: Kills the entity and applies a force to a specific collider in the ragdolls heirarchy, like an arm or leg // Also updates the score. This is the main killEntity method called by player scripts. previous methods maintained to // maintain functionality //--------------------------------------------------------------------------------------------------------------------- public void KillEntity(Vector3 direction, float force, Collider hitCol, ScoreAmount scoreAmount) { _beastScream.PlayOneShot(_beastScream.clip); GetComponent <RagdollManager>().EnableRagdoll(direction, force, hitCol); switch (scoreAmount) { case ScoreAmount.bodyShotScore: break; case ScoreAmount.HeadShotScore: break; case ScoreAmount.KillMeleeEnemy: PlayerStats.Score += _killScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); PlayerStats.EnemiesKilled++; PlayerStats.ActiveEnemies--; break; case ScoreAmount.KillArmouredEnemy: PlayerStats.Score += _armouredEnemyScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); PlayerStats.EnemiesKilled++; PlayerStats.ActiveEnemies--; PlayerStats.ActiveArmouredEnemies--; break; case ScoreAmount.KillFlamerEnemy: PlayerStats.Score += _flamerEnemyScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); PlayerStats.EnemiesKilled++; PlayerStats.ActiveEnemies--; PlayerStats.ActiveFlamerEnemies--; break; default: break; } Invoke("SpawnGoodies", 0.15f); }
public PlayResult GetPlayResult() { var isOver = StickRoundList.Count == 9 && CurrentStickRound.StickResult != null; if (!isOver) { return(null); } var playerResultDictionary = PlayerGroupInfo .GetPlayerList() .ToDictionary(p => p, p => { var wonCards = StickRoundList .Select(r => r.StickResult) .Where(r => r.Winner == p) .SelectMany(r => r.StickPile) .ToList(); return(wonCards); }); var playersWithSticks = playerResultDictionary .Where(p => p.Value.Any()) .Select(p => p.Key) .ToList(); var generalPlayer = playersWithSticks.Count == 1 ? playersWithSticks.Single() : null; if (generalPlayer != null) { //Case General var generalAmount = new ScoreAmount(isMatch: true, isGeneral: true); var zeroAmount = new ScoreAmount(); return(new PlayResult { PlayerGroupInfo = PlayerGroupInfo, Team1Score = PlayerGroupInfo.GetTeamOfPlayer(generalPlayer.PlayerId) == PlayerGroupInfo.Team1 ? generalAmount : zeroAmount, Team2Score = PlayerGroupInfo.GetTeamOfPlayer(generalPlayer.PlayerId) == PlayerGroupInfo.Team2 ? generalAmount : zeroAmount }); } var teamResultDictionary = playerResultDictionary .GroupBy(p => PlayerGroupInfo.GetTeamOfPlayer(p.Key.PlayerId)) .ToDictionary(g => g.Key, g => g.ToList().SelectMany(p => p.Value).ToList()); var teamsWithSticks = teamResultDictionary .Where(p => p.Value.Any()) .Select(p => p.Key) .ToList(); var matchTeam = teamsWithSticks.Count == 1 ? teamsWithSticks.Single() : null; if (matchTeam != null) { //Case Match var matchAmount = new ScoreAmount(isMatch: true); var zeroAmount = new ScoreAmount(); return(new PlayResult { PlayerGroupInfo = PlayerGroupInfo, Team1Score = PlayerGroupInfo.GetTeamOfPlayer(generalPlayer.PlayerId) == PlayerGroupInfo.Team1 ? matchAmount : zeroAmount, Team2Score = PlayerGroupInfo.GetTeamOfPlayer(generalPlayer.PlayerId) == PlayerGroupInfo.Team2 ? matchAmount : zeroAmount }); } //Case no General/Match var team1Amount = teamResultDictionary[PlayerGroupInfo.Team1] .Select(c => c.GetValue(PlayType)) .Sum(); var team2Amount = teamResultDictionary[PlayerGroupInfo.Team2] .Select(c => c.GetValue(PlayType)) .Sum(); var lastStickTeam = PlayerGroupInfo.GetTeamOfPlayer(StickRoundList.Last().StickResult.Winner.PlayerId); if (lastStickTeam == PlayerGroupInfo.Team1) { team1Amount += 5; } if (lastStickTeam == PlayerGroupInfo.Team2) { team2Amount += 5; } return(new PlayResult { PlayerGroupInfo = PlayerGroupInfo, Team1Score = new ScoreAmount(team1Amount), Team2Score = new ScoreAmount(team2Amount) }); }
//-------------------------------------------------------------------------------------------------------- // Method: TakeDamage, overload III // Desc: takes damage, also can apply rigidbody force to a specific collider, which is used for // a more precise ragdolling effect. This method enables scoring to occur //-------------------------------------------------------------------------------------------------------- public void TakeDamage(float damage, Vector3 direction, float force, Collider hitCol, ScoreAmount scoreAmount) { EnemyHealth -= damage; if (transform.CompareTag(TagsHashIDs.MeleeEnemy) || transform.CompareTag(TagsHashIDs.EnemyHead) || transform.CompareTag(TagsHashIDs.EnergyPack)) { _animator.SetTrigger(_hitTrigger); } // Added a switch statement to update the player score and emit score particles: // Score particles referring to how the score increment pops up and out of the bottom right of the in game HUD switch (scoreAmount) { case ScoreAmount.punchScore: PlayerStats.Score += _punchScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); break; case ScoreAmount.bodyShotScore: PlayerStats.Score += _bodyShotScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); break; case ScoreAmount.HeadShotScore: PlayerStats.Score += _headShotScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); break; case ScoreAmount.KillMeleeEnemy: PlayerStats.Score += _killScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); break; case ScoreAmount.KillArmouredEnemy: PlayerStats.Score += _armouredEnemyScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); break; case ScoreAmount.KillFlamerEnemy: PlayerStats.Score += _flamerEnemyScore; ScoreText.SetText("Score: " + PlayerStats.Score); _scoreParticles[(int)scoreAmount].Emit(1); break; default: break; } // Use a conditional and switch statement to determine the kill score of this enemy, by comparing the hitcol's tag: if (EnemyHealth <= 0) { switch (hitCol.tag) { case TagsHashIDs.MeleeEnemy: KillEntity(direction, force, hitCol, ScoreAmount.KillMeleeEnemy); break; case TagsHashIDs.ArmouredEnemy: KillEntity(direction, force, hitCol, ScoreAmount.KillArmouredEnemy); break; case TagsHashIDs.FlamerEnemy: KillEntity(direction, force, hitCol, ScoreAmount.KillFlamerEnemy); break; case TagsHashIDs.EnemyHead: KillEntity(direction, force, hitCol, ScoreAmount.KillMeleeEnemy); // The melee enemy is the only one we can headshot break; case TagsHashIDs.EnergyPack: KillEntity(direction, force, hitCol, ScoreAmount.KillFlamerEnemy); // The flamer enemy is the only one with an energy pack break; default: KillEntity(direction, force, hitCol, scoreAmount); // Default to this if the other tag comparison's fail break; } } }