Skip to content

Commit

Permalink
commented my code and fixed some last minute visual bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonHoangTran committed Apr 22, 2024
1 parent 407799f commit aef661a
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Assets/Scenes/RC1 Levels/Jason's Level.unity
Original file line number Diff line number Diff line change
Expand Up @@ -8744,7 +8744,7 @@ BoxCollider2D:
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.016304016, y: -0.040762305}
m_Offset: {x: -0.0043821335, y: -0.026972413}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
Expand All @@ -8755,7 +8755,7 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1.2771835, y: 1.1467445}
m_Size: {x: 1.5667706, y: 1.4914901}
m_EdgeRadius: 0
--- !u!212 &1056180411
SpriteRenderer:
Expand Down Expand Up @@ -37359,7 +37359,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!95 &1426395666
Animator:
serializedVersion: 5
Expand Down Expand Up @@ -68655,7 +68655,7 @@ BoxCollider2D:
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Offset: {x: -0.0034475327, y: -0.027579784}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
Expand All @@ -68666,7 +68666,7 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_Size: {x: 1.5860691, y: 1.4964337}
m_EdgeRadius: 0
--- !u!114 &2114044730
MonoBehaviour:
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scenes/RC1 Levels/JasonLevel2.unity
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ BoxCollider2D:
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.016304016, y: -0.040762305}
m_Offset: {x: -0.014526367, y: -0.021143436}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
Expand All @@ -764,7 +764,7 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1.2771835, y: 1.1467445}
m_Size: {x: 1.6975899, y: 1.4998856}
m_EdgeRadius: 0
--- !u!212 &77452158
SpriteRenderer:
Expand Down Expand Up @@ -58137,7 +58137,7 @@ BoxCollider2D:
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Offset: {x: -0.042040348, y: -0.0028026104}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
Expand All @@ -58148,7 +58148,7 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_Size: {x: 1.622201, y: 1.4428277}
m_EdgeRadius: 0
--- !u!212 &889575791
SpriteRenderer:
Expand Down
12 changes: 12 additions & 0 deletions Assets/Scripts/BossEnemyStageOne.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public class BossEnemyStageOne : MonoBehaviour
{
// Variable Declarations
private float directionX;
public float moveSpeed;
private Rigidbody2D myRigidBody;
Expand All @@ -13,6 +14,10 @@ public class BossEnemyStageOne : MonoBehaviour
public BossHealthStageOne bossHealth;

// Start is called before the first frame update
// Gets access to player's health script
// Gets access to the boss' health script
// Sets the boss' direction when starting level
// Gets the boss' rigidbody
void Start()
{
localScale = transform.localScale;
Expand All @@ -22,6 +27,9 @@ void Start()
bossHealth = GameObject.FindGameObjectWithTag("Enemy").GetComponent<BossHealthStageOne>();
}

// Allows the boss to take damage from metal crates
// Hurts the player if the boss and the player touch
// Changes the boss' direction when they touch a wall
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.transform.CompareTag("Wall"))
Expand All @@ -38,11 +46,13 @@ private void OnTriggerEnter2D(Collider2D collision)
}
}

// actually moves the boss
private void FixedUpdate()
{
myRigidBody.velocity = new Vector2(directionX * moveSpeed, myRigidBody.velocity.y);
}

// Flips the boss sprite when they switch directions
void LateUpdate()
{
if (directionX > 0)
Expand All @@ -63,6 +73,8 @@ void LateUpdate()

FlipY();
}

// Flips the enemy sprite when gravity is changed
public void FlipY()
{
Vector3 scale = transform.localScale;
Expand Down
12 changes: 12 additions & 0 deletions Assets/Scripts/BossEnemyStageThree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public class BossEnemyStageThree : MonoBehaviour
{
// Variable Declarations
private float directionX;
public float moveSpeed;
private Rigidbody2D myRigidBody;
Expand All @@ -13,6 +14,10 @@ public class BossEnemyStageThree : MonoBehaviour
public BossHealthStageThree bossHealth;

// Start is called before the first frame update
// Gets access to player's health script
// Gets access to the boss' health script
// Sets the boss' direction when starting level
// Gets the boss' rigidbody
void Start()
{
localScale = transform.localScale;
Expand All @@ -22,6 +27,9 @@ void Start()
bossHealth = GameObject.FindGameObjectWithTag("Enemy").GetComponent<BossHealthStageThree>();
}

// Allows the boss to take damage from metal crates
// Hurts the player if the boss and the player touch
// Changes the boss' direction when they touch a wall
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.transform.CompareTag("Wall"))
Expand All @@ -38,11 +46,13 @@ private void OnTriggerEnter2D(Collider2D collision)
}
}

// actually moves the boss
private void FixedUpdate()
{
myRigidBody.velocity = new Vector2(directionX * moveSpeed, myRigidBody.velocity.y);
}

// Flips the boss sprite when they switch directions
void LateUpdate()
{
if (directionX > 0)
Expand All @@ -63,6 +73,8 @@ void LateUpdate()

FlipY();
}

// Flips the enemy sprite when gravity is changed
public void FlipY()
{
Vector3 scale = transform.localScale;
Expand Down
12 changes: 12 additions & 0 deletions Assets/Scripts/BossEnemyStageTwo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public class BossEnemyStageTwo : MonoBehaviour
{
// Variable Declarations
private float directionX;
public float moveSpeed;
private Rigidbody2D myRigidBody;
Expand All @@ -13,6 +14,10 @@ public class BossEnemyStageTwo : MonoBehaviour
public BossHealthStageTwo bossHealth;

// Start is called before the first frame update
// Gets access to player's health script
// Gets access to the boss' health script
// Sets the boss' direction when starting level
// Gets the boss' rigidbody
void Start()
{
localScale = transform.localScale;
Expand All @@ -22,6 +27,9 @@ void Start()
bossHealth = GameObject.FindGameObjectWithTag("Enemy").GetComponent<BossHealthStageTwo>();
}

// Allows the boss to take damage from metal crates
// Hurts the player if the boss and the player touch
// Changes the boss' direction when they touch a wall
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.transform.CompareTag("Wall"))
Expand All @@ -38,11 +46,13 @@ private void OnTriggerEnter2D(Collider2D collision)
}
}

// actually moves the boss
private void FixedUpdate()
{
myRigidBody.velocity = new Vector2(directionX * moveSpeed, myRigidBody.velocity.y);
}

// Flips the boss sprite when they switch directions
void LateUpdate()
{
if (directionX > 0)
Expand All @@ -63,6 +73,8 @@ void LateUpdate()

FlipY();
}

// Flips the enemy sprite when gravity is changed
public void FlipY()
{
Vector3 scale = transform.localScale;
Expand Down
10 changes: 10 additions & 0 deletions Assets/Scripts/BossHealthStageOne.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

public class BossHealthStageOne : MonoBehaviour
{
// Variable Declarations
public int maxHealth = 15;
public int currentHealth;
// Array of boss health
public Image[] Health;
public Sprite fullHeart;
public Sprite emptyHeart;
Expand All @@ -16,13 +18,16 @@ public class BossHealthStageOne : MonoBehaviour


// Start is called before the first frame update
// Sets current health to max health
// Gets access to exit level script
void Start()
{
exitLevel = GameObject.FindGameObjectWithTag("Exit").GetComponent<ExitLevelScriptV2>();
currentHealth = maxHealth;
}

// Update is called once per frame
// Keeps track of boss health
void Update()
{
for (int index = 0; index < Health.Length; index++)
Expand All @@ -47,6 +52,10 @@ void Update()
}
}

// Makes the boss take damage
// plays the hurt sound effect
// plays boss hurt animation
// Goes to the next level if boss reaches certain health
public void TakeDamage(int amount)
{
currentHealth -= amount;
Expand All @@ -60,6 +69,7 @@ public void TakeDamage(int amount)
}
}

// plays boss animations after a certain time
public IEnumerator GoBackToNormalAnimation()
{
yield return new WaitForSeconds(1);
Expand Down
11 changes: 11 additions & 0 deletions Assets/Scripts/BossHealthStageThree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

public class BossHealthStageThree : MonoBehaviour
{
// Variable Declarations
public int maxHealth = 15;
public int currentHealth;
// Array of boss health
public Image[] Health;
public Sprite fullHeart;
public Sprite emptyHeart;
Expand All @@ -16,13 +18,17 @@ public class BossHealthStageThree : MonoBehaviour


// Start is called before the first frame update
// Start is called before the first frame update
// Sets current health to max health
// Gets access to exit level script
void Start()
{
exitLevel = GameObject.FindGameObjectWithTag("Exit").GetComponent<ExitLevelScriptV2>();
currentHealth = 5;
}

// Update is called once per frame
// Keeps track of boss health
void Update()
{
for (int index = 0; index < Health.Length; index++)
Expand All @@ -47,6 +53,10 @@ void Update()
}
}

// Makes the boss take damage
// plays the hurt sound effect
// plays boss hurt animation
// Goes to the next level if boss reaches certain health
public void TakeDamage(int amount)
{
currentHealth -= amount;
Expand All @@ -60,6 +70,7 @@ public void TakeDamage(int amount)
}
}

// plays boss animations after a certain time
public IEnumerator GoBackToNormalAnimation()
{
yield return new WaitForSeconds(1);
Expand Down
12 changes: 12 additions & 0 deletions Assets/Scripts/BossHealthStageTwo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

public class BossHealthStageTwo : MonoBehaviour
{
// Variable Declarations
public int maxHealth = 15;
public int currentHealth;
// Array of boss health
public Image[] Health;
public Sprite fullHeart;
public Sprite emptyHeart;
Expand All @@ -16,13 +18,18 @@ public class BossHealthStageTwo : MonoBehaviour


// Start is called before the first frame update
// Start is called before the first frame update
// Start is called before the first frame update
// Sets current health to max health
// Gets access to exit level script
void Start()
{
exitLevel = GameObject.FindGameObjectWithTag("Exit").GetComponent<ExitLevelScriptV2>();
currentHealth = 10;
}

// Update is called once per frame
// Keeps track of boss health
void Update()
{
for (int index = 0; index < Health.Length; index++)
Expand All @@ -47,6 +54,10 @@ void Update()
}
}

// Makes the boss take damage
// plays the hurt sound effect
// plays boss hurt animation
// Goes to the next level if boss reaches certain health
public void TakeDamage(int amount)
{
currentHealth -= amount;
Expand All @@ -60,6 +71,7 @@ public void TakeDamage(int amount)
}
}

// plays boss animations after a certain time
public IEnumerator GoBackToNormalAnimation()
{
yield return new WaitForSeconds(1);
Expand Down
Loading

0 comments on commit aef661a

Please sign in to comment.