Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Projeto Final de

AEDI 2022
Ovídio Farias e Bruno Sampietro
Objetivo

Tendo em mente os conteúdos aprendidos em sala de


aula, a professora propôs aos alunos a codificação de
um jogo para demonstrar o uso da Pilha de maneira
mais lúdica.
Representação de

Pilha com contagem

de vidas
Interface
Metodologia
Pesquisa bibliográfica:
Documentação da C#
Documentação da Engine
Pesquisa adicional (dúvidas)
Recursos

utilizados
Unity Engine
Visual Studio Code
Google (Imagens)
Codificação
public class GameController : MonoBehaviour
{
public GameObject heart1, heart2, heart3, gameOver;
public static Stack<int> health = new Stack<int>();
// Start is called before the first frame update
void Start()
{
health.Push(1);
health.Push(2);
health.Push(3);
heart1.gameObject.SetActive (true);
heart2.gameObject.SetActive (true);
heart3.gameObject.SetActive (true);
gameOver.gameObject.SetActive (false);

}
// Update is called once per frame
void Update() else
{ {
if(health.Count == 3) heart1.gameObject.SetActive (false);
{ heart2.gameObject.SetActive (false);
heart1.gameObject.SetActive (true); heart3.gameObject.SetActive (false);
heart2.gameObject.SetActive (true); gameOver.gameObject.SetActive

heart3.gameObject.SetActive (true); (true);


} Time.timeScale = 0;
else if(health.Count == 2) }
{ if(Time.timeScale == 0 &&

heart1.gameObject.SetActive (true); Input.GetKeyDown(KeyCode.R))


heart2.gameObject.SetActive (true); {
heart3.gameObject.SetActive (false);

} SceneManager.LoadScene(SceneManager.G

else if(health.Count == 1) etActiveScene().buildIndex);


{
Time.timeScale = 1f;
heart1.gameObject.SetActive (true);
}
heart2.gameObject.SetActive (false);
}
heart3.gameObject.SetActive (false);
}
}
public class HeartScript : MonoBehaviour
{
public class SkullScript : MonoBehaviour
void OnTriggerEnter2D(Collider2D col) {
{ void OnTriggerEnter2D (Collider2D col)
if(GameController.health.Count == 1) {
{ GameController.health.Pop();
GameController.health.Push(2); }
}

else if(GameController.health.Count == 2) }
{
GameController.health.Push(3);
}
}

}
Referências
https://www.youtube.com/watch?v=ZoZcBgRR9ns&t=250s
https://www.youtube.com/watch?v=3uyolYVsiWc&t=279s
https://www.youtube.com/watch?v=LsUiJItfzxU&t=6s

You might also like