This commit is contained in:
2025-01-17 13:10:42 +01:00
commit 4536213c91
15115 changed files with 1442174 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
using System;
using UnityEngine;
public class Black_Hole : MonoBehaviour
{
void Start()
{
}
private void OnTriggerEnter(Collider other)
{
Destroy(other.gameObject);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 90d41f84363b29e488c7c8f7c1357968

View File

@@ -0,0 +1,112 @@
using System;
using Unity.VisualScripting;
using UnityEditor.SearchService;
using UnityEngine;
using UnityEngine.Experimental.GlobalIllumination;
using UnityEngine.SceneManagement;
public class Droid : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
private bool jumpKeyWasPressed = false;
private float horizontalInput;
private Rigidbody rigidbodyComponent;
private bool isGrounded = false;
private int energy = 0;
private int rota = 0;
[SerializeField] private GameObject fusee;
private UIManager UIManager;
private int life = 1;
private int nbrfusee = 1;
void Start()
{
UIManager = FindAnyObjectByType<UIManager>();
rigidbodyComponent = GetComponent<Rigidbody>();
StartCoroutine(UIManager.LifeUp(life, nbrfusee));
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
jumpKeyWasPressed = true;
}
horizontalInput = Input.GetAxis("Horizontal");
if (Input.GetKeyDown(KeyCode.E))
{
if (nbrfusee > 0)
{
GameObject ball = Instantiate(fusee, transform.position, new Quaternion(90, 90, 0, 0));
ball.GetComponent<Rigidbody>().linearVelocity =
new Vector3(20, 0, 0);
nbrfusee--;
StartCoroutine(UIManager.LifeUp(life, nbrfusee));
}
}
}
private void FixedUpdate(){
int speed = 5;
if (energy >= 5)
speed = 10;
if (jumpKeyWasPressed && isGrounded)
{
rigidbodyComponent.AddForce(Vector3.up * speed, ForceMode.VelocityChange);
jumpKeyWasPressed = false;
}
rigidbodyComponent.linearVelocity = new Vector3(horizontalInput * speed, rigidbodyComponent.linearVelocity.y, 0);
}
private void OnCollisionStay(Collision collision){
isGrounded = true;
}
private void OnCollisionExit(Collision collision){
isGrounded = false;
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.layer == 7)
{
rota += 180;
Transform[] transforms = gameObject.GetComponentsInChildren<Transform>();
transforms[3].rotation = Quaternion.Euler(0, 0, rota);
}
if (collision.gameObject.layer == 10)
{
life -=2;
StartCoroutine(UIManager.LifeUp(life, nbrfusee));
if (life <= 0)
{
StartCoroutine(UIManager.GameOverSequence());
}
}
if (collision.gameObject.layer == 11)
{
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer == 3)
{
Destroy(other.gameObject);
energy++;
life++;
nbrfusee++;
StartCoroutine(UIManager.LifeUp(life, nbrfusee));
}
if (other.tag == "exit" ){
SceneManager.LoadScene(1);
}
if (other.tag == "GameOver")
{
StartCoroutine(UIManager.GameOverSequence());
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3c47eedd088243748927584267e681c4

View File

@@ -0,0 +1,25 @@
using UnityEngine;
public class Fusee : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.layer == 7 || other.gameObject.layer == 10)
{
Destroy(other.gameObject);
Destroy(this.gameObject);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 68e381e6071c42746a6f76f306791567

View File

@@ -0,0 +1,25 @@
using System.Collections;
using UnityEngine;
using static UnityEngine.UIElements.UxmlAttributeDescription;
public class MeteorRain : MonoBehaviour
{
[SerializeField] private GameObject Meteorite;
IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(3f);
Create();
}
}
void Create()
{
GameObject meteor = Instantiate(Meteorite, transform.position, transform.rotation);
meteor.GetComponent<Rigidbody>().linearVelocity =
new Vector3(Random.Range(-10.0f, 10.0f), Random.Range(-10.0f, 0f), 0);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fb3da3ff36aba0d4e9cbcb234770f128

View File

@@ -0,0 +1,25 @@
using System;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;
public class Meteorite : MonoBehaviour
{
private Rigidbody rigidbodyComponent;
private UIManager UIManager;
void Start()
{
UIManager = FindAnyObjectByType<UIManager>();
rigidbodyComponent = GetComponent<Rigidbody>();
//rigidbodyComponent.linearVelocity = new Vector3(0.7f, -0.4f, 0);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer != 9)
{
if (other.gameObject.tag == "droid")
StartCoroutine(UIManager.GameOverSequence());
Destroy(other.gameObject);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: de6caf83a032be54baf4ea65db738b13

View File

@@ -0,0 +1,66 @@
using System.Collections;
using Unity.VisualScripting;
using UnityEditor.SearchService;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class UIManager : MonoBehaviour
{
[SerializeField] private GameObject gameOverPanel;
[SerializeField] private Text gameOverText;
[SerializeField] private Text restartText;
private bool isGameOver = false;
[SerializeField] private Text LifeText;
[SerializeField] private Text FuseeText;
void Start()
{
//Disactive le panneau et les textes si actives
gameOverPanel.SetActive(false);
gameOverText.gameObject.SetActive(false);
restartText.gameObject.SetActive(false);
}
void Update()
{
//ai la touche G est press<73>e, lance la m<>thode StartCoroutine qui affiche le panneau avec le message Game Over et
//attends 5 s<>conds puis affiche un deuxi<78>me message invitant le jouer <20> presser R pour relancer le jeu
if (Input.GetKeyDown(KeyCode.G) && !isGameOver)
{
isGameOver = true;
StartCoroutine(GameOverSequence());
}
//si le jeu est termin<69> et on saisie la touche R, le jeu est relanc<6E>
if (isGameOver)
{
//If R is hit, restart the current scene
if (Input.GetKeyDown(KeyCode.R))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
//la touche Q nous permet de sortir du jeu <20> tout moment
if (Input.GetKeyDown(KeyCode.Escape))
{
print("Application Quit");
Application.Quit();
}
}
}
//la m<>thode GameOverSequence affiche le message GameOver puis attends 3 seconds et affiche le message <20>Press R to restart<72>
public IEnumerator GameOverSequence()
{
isGameOver = true;
gameOverPanel.SetActive(true);
gameOverText.gameObject.SetActive(true);
yield return new WaitForSeconds(3.0f);
restartText.text = "Press R to restart";
restartText.gameObject.SetActive(true);
}
public string LifeUp(int Life, int fusee)
{
FuseeText.text = "Nombre de Fus<75>e : " + fusee;
LifeText.text = "LIFE : " + Life;
return LifeText.text;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 09cfea691597a9f439d8643d258cf600