Skip to content

Commit 13dfff7

Browse files
committed
refactored code
1 parent e346839 commit 13dfff7

File tree

7 files changed

+801
-20
lines changed

7 files changed

+801
-20
lines changed

Assets/Scripts/AnimatedSprite.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private void Awake()
2121

2222
private void Start()
2323
{
24-
InvokeRepeating(nameof(Advance), animationTime, animationTime);
24+
InvokeRepeating(nameof(Advance), animationTime, animationTime); // to change to coroutine
2525
}
2626

2727
private void Advance()

Assets/Scripts/ChasingGhostBehavior.cs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ private void OnTriggerEnter2D(Collider2D collision)
2929
minDistance = distance;
3030
}
3131
}
32-
3332
ghost.movement.SetDirection(direction);
3433
}
3534
}

Assets/Scripts/FadeIn.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44
using UnityEngine.UI;
5-
5+
// TODO: REFACTOR
66
public class FadeIn : MonoBehaviour
77
{
88
public CanvasGroup canvasGroup { get; private set; }
@@ -19,7 +19,7 @@ private void Awake()
1919

2020
}
2121

22-
private void Update() //to refactor
22+
private void Update()
2323
{
2424
if (this.enabled == false)
2525
{
@@ -36,7 +36,6 @@ private void Update() //to refactor
3636
alpha = animationFrame / 100f;
3737
canvasGroup.alpha = alpha;
3838
}
39-
//Debug.Log("3");
4039
}
4140

4241
public void Restart()

Assets/Scripts/Fruit.cs

-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ public class Fruit : MonoBehaviour
88

99
public float weight; // in %
1010

11-
private void Start()
12-
{
13-
14-
}
15-
public void GenerateFruit()
16-
{
17-
18-
}
1911
private void Eat()
2012
{
2113
FindObjectOfType<GameManager>().FruitEaten(this);

Assets/Scripts/FruitsManager.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ private void Start()
2727

2828
private void OnEnable()
2929
{
30-
DestroyCurrentFruit();
31-
3230
StopAllCoroutines();
33-
31+
DestroyCurrentFruit();
32+
3433
if (this.gameObject.activeSelf)
3534
{
3635
StartCoroutine(GenerateFruit());

Assets/Scripts/GameManager.cs

-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ private void Start()
3333
{
3434
fadeIn = canvasGameOver.gameObject.GetComponent<FadeIn>();
3535
canvasGameOver.gameObject.SetActive(false);
36-
3736
NewGame();
3837
}
3938

@@ -73,7 +72,6 @@ private void ResetState()
7372
{
7473
ghosts[i].ResetState();
7574
}
76-
7775
pacman.ResetState();
7876
}
7977

@@ -86,7 +84,6 @@ private void GameOver()
8684

8785
fruitsManager.gameObject.SetActive(false);
8886
pacman.gameObject.SetActive(false);
89-
9087
canvasGameOver.gameObject.SetActive(true);
9188
fadeIn.Restart();
9289

@@ -167,7 +164,6 @@ private bool HasReminingPellets()
167164
return true;
168165
}
169166
}
170-
171167
return false;
172168
}
173169

0 commit comments

Comments
 (0)