Skip to content

Commit

Permalink
Trying to fix game
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahRobichaux committed Nov 28, 2023
1 parent 223af7a commit 04e47b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 66 deletions.
57 changes: 4 additions & 53 deletions Assets/Scenes/LevelOne.unity
Original file line number Diff line number Diff line change
Expand Up @@ -3037,7 +3037,6 @@ MonoBehaviour:
barsBroken: 0
isPuckOnWinWall: 0
nextLevel: LevelTwo
mainMenuScene: MainMenu
loadLevelDelay: 5
loadMainMenuDelay: 3
isPlayerDead: 0
Expand All @@ -3058,14 +3057,6 @@ MonoBehaviour:
barContent: {fileID: 1520401634}
playerBar: {fileID: 1209673245}
gameManagerObject: {fileID: 725003279}
LevelOne:
m_Handle: 0
LevelTwo:
m_Handle: 0
MainMenu:
m_Handle: 0
LevelSelect:
m_Handle: 0
--- !u!4 &725003281
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3094,8 +3085,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
gameManagerScript: {fileID: 725003280}
mainMenu:
m_Handle: 0
highScoreText: {fileID: 0}
highScoreObject: {fileID: 0}
playButton: {fileID: 0}
Expand Down Expand Up @@ -3971,7 +3960,6 @@ MonoBehaviour:
barsBroken: 0
isPuckOnWinWall: 0
nextLevel:
mainMenuScene:
loadLevelDelay: 5
loadMainMenuDelay: 3
isPlayerDead: 0
Expand All @@ -3992,14 +3980,6 @@ MonoBehaviour:
barContent: {fileID: 1520401634}
playerBar: {fileID: 1209673245}
gameManagerObject: {fileID: 725003279}
LevelOne:
m_Handle: 0
LevelTwo:
m_Handle: 0
MainMenu:
m_Handle: 0
LevelSelect:
m_Handle: 0
--- !u!1001 &839745574
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -4212,8 +4192,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
gameManagerScript: {fileID: 725003280}
mainMenu:
m_Handle: 0
highScoreText: {fileID: 0}
highScoreObject: {fileID: 0}
playButton: {fileID: 0}
Expand Down Expand Up @@ -4463,7 +4441,6 @@ MonoBehaviour:
barsBroken: 0
isPuckOnWinWall: 0
nextLevel:
mainMenuScene:
loadLevelDelay: 5
loadMainMenuDelay: 3
isPlayerDead: 0
Expand All @@ -4484,14 +4461,6 @@ MonoBehaviour:
barContent: {fileID: 1520401634}
playerBar: {fileID: 1209673245}
gameManagerObject: {fileID: 725003279}
LevelOne:
m_Handle: 0
LevelTwo:
m_Handle: 0
MainMenu:
m_Handle: 0
LevelSelect:
m_Handle: 0
--- !u!1001 &940974903
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5866,7 +5835,7 @@ Rigidbody2D:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1201304498}
m_BodyType: 0
m_BodyType: 2
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 1
Expand Down Expand Up @@ -5999,7 +5968,7 @@ Rigidbody2D:
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_Mass: 0.65
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 0
Expand Down Expand Up @@ -6516,7 +6485,6 @@ MonoBehaviour:
barsBroken: 0
isPuckOnWinWall: 0
nextLevel:
mainMenuScene:
loadLevelDelay: 5
loadMainMenuDelay: 3
isPlayerDead: 0
Expand All @@ -6537,14 +6505,6 @@ MonoBehaviour:
barContent: {fileID: 1520401634}
playerBar: {fileID: 1209673245}
gameManagerObject: {fileID: 725003279}
LevelOne:
m_Handle: 0
LevelTwo:
m_Handle: 0
MainMenu:
m_Handle: 0
LevelSelect:
m_Handle: 0
--- !u!1001 &1260141530
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -9397,7 +9357,7 @@ Rigidbody2D:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1930818757}
m_BodyType: 0
m_BodyType: 2
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 1
Expand Down Expand Up @@ -10419,7 +10379,6 @@ MonoBehaviour:
barsBroken: 0
isPuckOnWinWall: 0
nextLevel:
mainMenuScene:
loadLevelDelay: 5
loadMainMenuDelay: 3
isPlayerDead: 0
Expand All @@ -10440,14 +10399,6 @@ MonoBehaviour:
barContent: {fileID: 1520401634}
playerBar: {fileID: 1209673245}
gameManagerObject: {fileID: 725003279}
LevelOne:
m_Handle: 0
LevelTwo:
m_Handle: 0
MainMenu:
m_Handle: 0
LevelSelect:
m_Handle: 0
--- !u!1001 &2129924763
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -10616,7 +10567,6 @@ SceneRoots:
- {fileID: 753431602}
- {fileID: 2098512381}
- {fileID: 1571914467}
- {fileID: 745561497}
- {fileID: 725003281}
- {fileID: 300890633}
- {fileID: 909189617}
Expand All @@ -10626,3 +10576,4 @@ SceneRoots:
- {fileID: 1656308818}
- {fileID: 1955446657}
- {fileID: 1621935935}
- {fileID: 745561497}
2 changes: 1 addition & 1 deletion Assets/Scripts/DeathBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void OnTriggerEnter2D(Collider2D collision)
{
gameManagerScript.isPlayerDead = true;
gameManagerScript.lostLifeObject.SetActive(true);
collision.gameObject.GetComponent<Transform>().localPosition = new Vector2(0f, -4.2f);
collision.gameObject.GetComponent<Transform>().localPosition = Puck.puckInitPos;
collision.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePosition;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void Update()
}
if (isPlayerDead && lives == 3)
{
lives = 0;
lives = 2;
livesText.SetText("Lives: 2");
lostLifeObject.SetActive(true);
startText.SetActive(true);
Expand Down
26 changes: 15 additions & 11 deletions Assets/Scripts/Puck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ public class Puck : MonoBehaviour

public float speed;

public static Vector2 puckInitPos;
public static Vector2 playerInitPos;

void Start()
{
puckRB = GetComponent<Rigidbody2D>();
speed = 0.5f;
puck.GetComponent<Transform>().localPosition = new Vector2(0f, -4.2f);
puckInitPos = puck.GetComponent<Transform>().localPosition;
playerInitPos = gameManagerScript.playerBar.GetComponent<Transform>().position;
puck.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePosition;
redBars = GameObject.FindGameObjectsWithTag("RedBars");
orangeBars = GameObject.FindGameObjectsWithTag("OrangeBars");
Expand Down Expand Up @@ -73,9 +77,9 @@ void Update()
}
if (gameManagerScript.lives < 3 && gameManagerScript.lives > 0)
{
puck.GetComponent<Transform>().localPosition = new Vector2(0f, -4.2f);
puck.GetComponent<Transform>().localPosition = puckInitPos;
puck.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePosition;
gameManagerScript.playerBar.GetComponent<Transform>().localPosition = new Vector2(0, -4.5f);
gameManagerScript.playerBar.GetComponent<Transform>().localPosition = playerInitPos;
if (Input.GetKeyDown(KeyCode.Space) && puck.GetComponent<Rigidbody2D>().constraints == RigidbodyConstraints2D.FreezePosition)
{
puck.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
Expand All @@ -84,7 +88,6 @@ void Update()
float y = 10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);

}
}
}
Expand Down Expand Up @@ -116,15 +119,15 @@ private void OnCollisionEnter2D(Collision2D collision)
{
if (isPuckGoingUp == true)
{
float x = Random.Range(-10f, 10f);
float x = Random.Range(5f, 10f);
float y = 10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);
gameManagerScript.barBreakObject.SetActive(true);
}
if (isPuckGoingUp == false)
{
float x = Random.Range(-10f, 10f);
float x = Random.Range(5f, 10f);
float y = -10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);
Expand All @@ -133,11 +136,12 @@ private void OnCollisionEnter2D(Collision2D collision)
}
if (collision.gameObject.name == "Player_Bar")
{
float x = Random.Range(-10f, 10f);
float x = Random.Range(5f, 10f);
float y = 10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);
gameManagerScript.barBreakObject.SetActive(true);
isPuckGoingUp = true;
}
}
private void OnTriggerEnter2D(Collider2D collision)
Expand All @@ -150,7 +154,7 @@ private void OnTriggerEnter2D(Collider2D collision)
gameManagerScript.barBreakObject.SetActive(true);
hasBrokenRed = true;
isPuckGoingUp = false;
float x = Random.Range(-10f, 10f);
float x = Random.Range(5f, 10f);
float y = -10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);
Expand All @@ -164,7 +168,7 @@ private void OnTriggerEnter2D(Collider2D collision)
gameManagerScript.barBreakObject.SetActive(true);
hasBrokenOrange = true;
isPuckGoingUp = false;
float x = Random.Range(-10f, 10f);
float x = Random.Range(5f, 10f);
float y = -10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);
Expand All @@ -177,7 +181,7 @@ private void OnTriggerEnter2D(Collider2D collision)
gameManagerScript.barsBroken = gameManagerScript.barsBroken + 1;
gameManagerScript.barBreakObject.SetActive(true);
isPuckGoingUp = false;
float x = Random.Range(-10f, 10f);
float x = Random.Range(5f, 10f);
float y = -10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);
Expand All @@ -190,7 +194,7 @@ private void OnTriggerEnter2D(Collider2D collision)
gameManagerScript.barsBroken = gameManagerScript.barsBroken + 1;
gameManagerScript.barBreakObject.SetActive(true);
isPuckGoingUp = false;
float x = Random.Range(-10f, 10f);
float x = Random.Range(5f, 10f);
float y = -10f;
puckDirection = new Vector2(x, y);
puckRB.AddForce(puckDirection, ForceMode2D.Force);
Expand Down

0 comments on commit 04e47b6

Please sign in to comment.