cheer fx and post match screen
This commit is contained in:
@@ -108,11 +108,13 @@ public class GameManager : NetworkBehaviour
|
||||
[SyncVar(hook = nameof(OnScoreChanged))]
|
||||
public int blueScore=0;
|
||||
|
||||
[Header("Effects")]
|
||||
public ParticleSystem[] redGoalEffects;
|
||||
public ParticleSystem[] blueGoalEffects;
|
||||
|
||||
[Header("UI")]
|
||||
public TMP_Text redScoreText;
|
||||
public TMP_Text blueScoreText;
|
||||
public GameObject gameOverPanel;
|
||||
public GameObject blueWon,redWon;
|
||||
public CanvasGroupUtils blueTimerGroup;
|
||||
[FormerlySerializedAs("timerGroup")] public CanvasGroupUtils redTimerGroup;
|
||||
[Header("Timer Flash Settings")]
|
||||
@@ -526,9 +528,11 @@ public class GameManager : NetworkBehaviour
|
||||
if(team == Team.Blue){
|
||||
blueScore++;
|
||||
blueScoreText.text = blueScore.ToString();
|
||||
PlayGoalEffects(Team.Blue);
|
||||
}else{
|
||||
redScore++;
|
||||
redScoreText.text = redScore.ToString();
|
||||
PlayGoalEffects(Team.Red);
|
||||
}
|
||||
|
||||
SwitchTeams();
|
||||
@@ -549,6 +553,38 @@ public class GameManager : NetworkBehaviour
|
||||
hitCounter = 0;
|
||||
}
|
||||
|
||||
void PlayGoalEffects(Team team){
|
||||
if(isServer){
|
||||
m_PlayGoalEffects(team);
|
||||
RpcPlayGoalEffects(team);
|
||||
}else{
|
||||
CmdPlayGoalEffects(team);
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdPlayGoalEffects(Team team){
|
||||
m_PlayGoalEffects(team);
|
||||
RpcPlayGoalEffects(team);
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcPlayGoalEffects(Team team){
|
||||
m_PlayGoalEffects(team);
|
||||
}
|
||||
|
||||
void m_PlayGoalEffects(Team team){
|
||||
if(team == Team.Blue){
|
||||
foreach(ParticleSystem effect in blueGoalEffects){
|
||||
effect.Play();
|
||||
}
|
||||
}else{
|
||||
foreach(ParticleSystem effect in redGoalEffects){
|
||||
effect.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcPlayGoalScoredSfx()
|
||||
{
|
||||
@@ -562,14 +598,12 @@ public class GameManager : NetworkBehaviour
|
||||
}
|
||||
|
||||
void gameOver(Team team){
|
||||
gameOverPanel.SetActive(true);
|
||||
if(team == Team.Blue){
|
||||
blueWon.SetActive(true);
|
||||
redWon.SetActive(false);
|
||||
}else{
|
||||
blueWon.SetActive(false);
|
||||
redWon.SetActive(true);
|
||||
}
|
||||
StartCoroutine(CoroutineGameOver(team));
|
||||
}
|
||||
|
||||
IEnumerator CoroutineGameOver(Team team){
|
||||
yield return new WaitForSeconds(2f);
|
||||
LevelLoadManager.instance.SetupGameOver(team,redScore,blueScore);
|
||||
}
|
||||
|
||||
bool freezeInput = false;
|
||||
|
||||
@@ -21,6 +21,10 @@ public class LevelLoadManager : MonoBehaviour
|
||||
public TMP_Text p1_name, p2_name;
|
||||
public TMP_Text p1_l10, p2_l10;
|
||||
public Sprite redIcon, blueIcon;
|
||||
public TMP_Text txtMiddle;
|
||||
[Header("Game Over UI")]
|
||||
public GameObject p1_winner;
|
||||
public GameObject p2_winner;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -71,13 +75,22 @@ public class LevelLoadManager : MonoBehaviour
|
||||
canvasGroup.interactable=false;
|
||||
contentImage.fillOrigin = 1;
|
||||
canvasGroup.DOFade(0, transitionDuration).SetEase(Ease.InSine);
|
||||
contentImage.DOFillAmount(0, transitionDuration).SetEase(Ease.InSine);
|
||||
contentImage.DOFillAmount(0, transitionDuration).SetEase(Ease.InSine).OnComplete(() => {
|
||||
if(gameOver){
|
||||
gameOver = false;
|
||||
matchmadeUI.SetActive(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void SetupMatchMade(Team myTeam, string opponentName, string myName, string myL10, string opponentL10){
|
||||
Team myTeam = Team.Red;
|
||||
public void SetupMatchMade(Team myTeam_, string opponentName, string myName, string myL10, string opponentL10){
|
||||
myTeam = myTeam_;
|
||||
matchmadeUI.SetActive(true);
|
||||
p1_winner.SetActive(false);
|
||||
p2_winner.SetActive(false);
|
||||
|
||||
txtMiddle.text = "VS";
|
||||
if(myTeam == Team.Red){
|
||||
p1_red.SetActive(true);
|
||||
p1_blue.SetActive(false);
|
||||
@@ -101,4 +114,51 @@ public class LevelLoadManager : MonoBehaviour
|
||||
p1_l10.text = myL10;
|
||||
p2_l10.text = opponentL10;
|
||||
}
|
||||
|
||||
MatchmadePlayer myPlayer;
|
||||
MatchmadePlayer opponentPlayer;
|
||||
|
||||
public void SetupMatchMade(Team myTeam_, MatchmadePlayer myPlayer_, MatchmadePlayer opponentPlayer_){
|
||||
myTeam = myTeam_;
|
||||
myPlayer = myPlayer_;
|
||||
opponentPlayer = opponentPlayer_;
|
||||
|
||||
string opponentName = opponentPlayer_.Name;
|
||||
string myName = myPlayer_.Name;
|
||||
|
||||
string myL10 = $"L10 {myPlayer.l10_wins} -{myPlayer.l10_losses}";
|
||||
string opponentL10 = $"L10 {opponentPlayer.l10_wins} -{opponentPlayer.l10_losses}";
|
||||
|
||||
SetupMatchMade(myTeam, myName, opponentName, myL10, opponentL10);
|
||||
}
|
||||
bool gameOver = false;
|
||||
public void SetupGameOver(Team winningTeam, int redScore, int blueScore){
|
||||
gameOver = true;
|
||||
|
||||
txtMiddle.text = $"{(myTeam == Team.Red ? redScore : blueScore)} FINAL {(myTeam == Team.Red ? blueScore : redScore)}";
|
||||
|
||||
if(myTeam == winningTeam){
|
||||
p1_winner.SetActive(true);
|
||||
p2_winner.SetActive(false);
|
||||
|
||||
myPlayer.l10_wins++;
|
||||
myPlayer.l10_losses--;
|
||||
|
||||
opponentPlayer.l10_losses++;
|
||||
opponentPlayer.l10_wins--;
|
||||
}else{
|
||||
p1_winner.SetActive(false);
|
||||
p2_winner.SetActive(true);
|
||||
|
||||
opponentPlayer.l10_wins++;
|
||||
opponentPlayer.l10_losses--;
|
||||
|
||||
myPlayer.l10_losses++;
|
||||
myPlayer.l10_wins--;
|
||||
}
|
||||
|
||||
p1_l10.text = $"L10 {myPlayer.l10_wins}-{myPlayer.l10_losses}";
|
||||
p2_l10.text = $"L10 {opponentPlayer.l10_wins}-{opponentPlayer.l10_losses}";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user