first commit

This commit is contained in:
SimonSayeBabu
2025-01-17 13:10:20 +01:00
commit bd1057cec0
16967 changed files with 1048699 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlackHole : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer != 6)
{
Destroy(other.gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3cb1c967cd4222e4d9d21aa1202e425d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeathPlane : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer != 6)
{
Destroy(other.gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fee177e0c5c84984095adfbf4e7fecb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

155
Assets/Scripts/Droid.cs Normal file
View File

@@ -0,0 +1,155 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Droid : MonoBehaviour
{
public Camera cam;
public Rigidbody rigidbodyComponent;
private Boolean jumpKeyIsPressed = false;
private Boolean isGrounded = false;
public Boolean isJumping = false;
public float jumpStartTime;
public float jumpTime;
public float jumpForce;
public float horizontalInput;
public float speed = 2f;
public int facing;
public int Energy = 0 ;
public int HP = 1;
[SerializeField] private GameObject fusee;
public ManagerUI UIManager;
// Start is called before the first frame update
void Start()
{
UIManager = FindAnyObjectByType<ManagerUI>();
StartCoroutine(UIManager.UpdateUI(HP, Energy));
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
this.jumpKeyIsPressed = true;
}
else if (Input.GetKeyUp(KeyCode.Space))
{
this.jumpKeyIsPressed = false;
}
if (Input.GetKeyDown(KeyCode.S) && this.Energy > 0)
{
this.Energy--;
StartCoroutine(UIManager.UpdateUI(HP, Energy));
GameObject ball = Instantiate(fusee, transform.position, new Quaternion(180*this.facing,180,0,0));
ball.GetComponent<Rigidbody>().velocity = new Vector3(20*this.facing, ball.GetComponent<Rigidbody>().velocity.y, 0);
}
if(this.HP <= 0)
{
Destroy(gameObject);
}
horizontalInput = Input.GetAxis("Horizontal");
}
private void FixedUpdate()
{
Jump();
rigidbodyComponent.velocity = new Vector3(horizontalInput * speed, rigidbodyComponent.velocity.y, 0);
if (this.rigidbodyComponent.velocity.x > 0)
{
this.facing = 1;
}
else if (this.rigidbodyComponent.velocity.x < 0)
{
this.facing = -1;
}
}
private void Jump()
{
if (this.isGrounded && this.jumpKeyIsPressed)
{
this.isJumping = true;
jumpTime = jumpStartTime;
rigidbodyComponent.velocity = Vector2.up * jumpForce;
}
if(this.jumpKeyIsPressed && this.isJumping)
{
if (jumpTime > 0)
{
rigidbodyComponent.velocity = Vector2.up * jumpForce;
jumpTime -= Time.deltaTime;
}
else
{
isJumping = false;
}
}
if(!this.jumpKeyIsPressed)
{
this.isJumping = false;
}
}
private void OnCollisionStay()
{
if (!this.jumpKeyIsPressed)
{
this.isGrounded = true;
}
}
private void OnCollisionExit()
{
this.isGrounded = false;
}
private void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Enemy")
{
this.HP -= 2;
Vector3 knockbackDirection = this.rigidbodyComponent.transform.position - other.gameObject.transform.position;
this.rigidbodyComponent.velocity = knockbackDirection * 20f;
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer == 3)
{
Destroy(other.gameObject);
this.Energy += 1;
this.HP += 1;
StartCoroutine(UIManager.UpdateUI(HP,Energy));
if (this.Energy == 5)
{
this.speed *= 2f;
this.jumpForce *= 2f;
}
}
if (other.gameObject.layer == 8)
{
this.cam.transform.Rotate(new Vector3(0, 0, 180));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1abf95585fe56a4a95fde84ad7c9aaf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

18
Assets/Scripts/Enemy.cs Normal file
View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ebc29e0321e4f9944aefde3987200539
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

17
Assets/Scripts/Exit.cs Normal file
View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Exit : MonoBehaviour
{
public int nextLevel;
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
SceneManager.LoadScene(nextLevel);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 69f040784370a4d47b6d17f2aa219dfa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MainCamera : MonoBehaviour
{
public GameObject Player;
// Update is called once per frame
void Update()
{
if (Player != null)
{
this.transform.position = new Vector3(this.Player.transform.position.x, this.Player.transform.position.y, -10f);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b4e7a8c9d45bdea44a2bc2cffce18def
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,83 @@
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ManagerUI : MonoBehaviour
{
[SerializeField] public GameObject player;
[SerializeField] public GameObject gameOverPanel;
[SerializeField] public Text gameOverText;
[SerializeField] public Text restartText;
[SerializeField] public Text HP;
[SerializeField] public Text Energy;
public bool isGameOver = false;
private Droid playerDroid;
void Start()
{
//Disactive le panneau et les textes si actives
gameOverPanel.SetActive(false);
gameOverText.gameObject.SetActive(false);
restartText.gameObject.SetActive(false);
}
void Update()
{
if(this.player == null)
{
this.isGameOver = true;
}
else
{
playerDroid = this.player.GetComponent<Droid>();
}
//ai la touche G est press<73>e, lance la m<>thode StartCoroutine qui affiche le panneau avec le message Game Over etattends 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;
Destroy(this.player);
}
//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.Q))
{
print("Application Quit");
Application.Quit();
}
}
if(isGameOver)
{
StartCoroutine(GameOverSequence());
}
}
//la m<>thode GameOverSequence affiche le message GameOver puis attends 3 s<>conds et affiche le message <20>Press R to restart<72>
private IEnumerator GameOverSequence()
{
HP.text="";
Energy.text = "";
gameOverPanel.SetActive(true);
gameOverText.gameObject.SetActive(true);
yield return new WaitForSeconds(3.0f);
restartText.text = "Press R to restart";
restartText.gameObject.SetActive(true);
}
public IEnumerator UpdateUI(int hpVal, int energyVal)
{
HP.text = "HP : " + hpVal;
Energy.text = "Energy : " + energyVal;
yield return new WaitForSeconds(0f);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bde581fddd4315949850d0efbdee003b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

30
Assets/Scripts/Meteor.cs Normal file
View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Meteor : MonoBehaviour
{
public Rigidbody rigidbodyComponent;
public Vector3 RotationVector;
private void FixedUpdate()
{
rigidbodyComponent.velocity = new Vector3(0.5f, -0.7f, 0);
this.transform.Rotate(RotationVector * Time.deltaTime);
if (this.transform.position.y < -20)
{
Destroy(this.gameObject);
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer != 6)
{
Destroy(other.gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 12096d6075fb6774097027c8aef79a30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

29
Assets/Scripts/Meteor1.cs Normal file
View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Meteor1 : MonoBehaviour
{
public Rigidbody rigidbodyComponent;
public Vector3 RotationVector;
private void FixedUpdate()
{
this.transform.Rotate(RotationVector * Time.deltaTime);
if (this.transform.position.y < -20)
{
Destroy(this.gameObject);
}
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
Destroy(other.gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f5638bf8ddd2dd4498cce32c513667ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeteorRain : MonoBehaviour
{
[SerializeField] private GameObject Meteor;
// Start is called before the first frame update
IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(1.5f);
Create();
}
}
// Update is called once per frame
void Update()
{
}
void Create()
{
GameObject ball = Instantiate(Meteor, transform.position, transform.rotation);
ball.GetComponent<Rigidbody>().velocity = new Vector3(Random.Range(-5.0f, 5.0f), Random.Range(-5.0f, 0f), 0);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: efacdc03e983ce44fa039794d26c27de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

30
Assets/Scripts/fusee.cs Normal file
View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class fusee : MonoBehaviour
{
public GameObject self;
public float lifetime;
private void OnTriggerEnter(Collider other)
{
if (other.tag != "Player" && other.tag != "Platform" && other.tag != "Finish")
{
Destroy(other.gameObject);
Destroy(self);
}
}
private void FixedUpdate()
{
this.lifetime -= 1;
if (this.lifetime < 0)
{
Destroy(self);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cd6e059fead3a1348bc1798d4341ddc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: