Skip to content

Commit

Permalink
EndGame structure
Browse files Browse the repository at this point in the history
  • Loading branch information
XxDarkTheMaxPanicdu69xX committed Dec 5, 2019
1 parent 37d774d commit d6968b2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ Camera:
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0.74759704, g: 0.9056604, b: 0.8131712, a: 0}
m_BackGroundColor: {r: 0.8568872, g: 0.9056604, b: 0.48273405, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
Expand Down Expand Up @@ -1488,6 +1488,9 @@ MonoBehaviour:
- {fileID: 2011355447}
winner: {fileID: 0}
isWon: 0
victoryJapColor: {r: 0.8301887, g: 0, b: 0, a: 0.49019608}
victoryUsColor: {r: 0, g: 0.19432807, b: 1, a: 0.49019608}
baseColor: {r: 0.7754474, g: 0.9056604, b: 0.38020647, a: 0.46666667}
--- !u!1 &1247210510
GameObject:
m_ObjectHideFlags: 0
Expand Down
29 changes: 27 additions & 2 deletions Assets/Scripts/MatchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ public class MatchManager : MonoBehaviour, OnBeatElement
private bool gameIsPaused = false;
private bool roundIsEnd = false;
private bool matchIsEnd = false;

public Color victoryJapColor;
public Color victoryUsColor;
public Color baseColor;


void Start()
{
Camera.main.backgroundColor = baseColor;

BeatManager.RegisterOnBeatElement(this);

for (int i = 0; i<winSliders.Length; i++)
Expand Down Expand Up @@ -73,7 +76,6 @@ void Update()

if (winner != null && winner.wins == roundToWin)
{

onMatchEnd(winner);
}
else
Expand All @@ -95,6 +97,12 @@ void Update()
winnerID = 0;
isWon = true;
}

if (matchIsEnd)
if(Input.GetKeyDown(KeyCode.R))
{
resetGame();
}
}

public void onRoundEnd()
Expand All @@ -109,17 +117,23 @@ public void resetRound()
{
players[i].currentLife = players[i].maxLife;
players[i].health.value = players[i].currentLife;
players[i].BufferReset();
}
winner = null;
isWon = false;
}

public void onMatchEnd(Player winner)
{
matchIsEnd = true;

if (winner == players[0])
Camera.main.backgroundColor = victoryUsColor;
else if (winner == players[1])
Camera.main.backgroundColor = victoryJapColor;
pause();
gameIsPaused = false;
matchIsEnd = true;
//anim/son de fin de partie
}

Expand All @@ -139,4 +153,15 @@ public void pause()
InputTranslator.sequence = Sequence.IDLE;
}

public void resetGame()
{
Camera.main.backgroundColor = baseColor;
for (int i = 0; i < players.Length; i++)
{
players[i].wins = 0;
winSliders[i].value = players[i].wins;
}
resetRound();
resume();
}
}

0 comments on commit d6968b2

Please sign in to comment.