mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-04-17 18:56:18 +02:00
Compare commits
No commits in common. "51404e5cc63605bb8884374a6b7c4df331ae0640" and "5dc42fec95401029ace0689dcf986c0678bb3094" have entirely different histories.
51404e5cc6
...
5dc42fec95
@ -5,40 +5,44 @@ public class PlayerScript : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public Rigidbody2D rigidBody;
|
public Rigidbody2D rigidBody;
|
||||||
public GameObject playerObject;
|
public GameObject playerObject;
|
||||||
|
|
||||||
public ParticleSystem particle;
|
public ParticleSystem particle;
|
||||||
|
|
||||||
|
private bool wantsToJump = false;
|
||||||
public bool isColliding = true;
|
public bool isColliding = true;
|
||||||
public AudioSource audioSource;
|
|
||||||
private bool hasStarted = false;
|
|
||||||
|
|
||||||
private bool canJump = true;
|
public AudioSource audioSource;
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
var mainModule = particle.main;
|
var mainModule = particle.main;
|
||||||
mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
|
mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
|
||||||
particle.transform.parent = null;
|
particle.transform.parent = null;
|
||||||
|
|
||||||
Invoke(nameof(EnableInput), 0.1f);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EnableInput()
|
|
||||||
{
|
|
||||||
hasStarted = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
rigidBody.linearVelocity = new Vector2(8.6f, rigidBody.linearVelocity.y);
|
transform.position += Time.deltaTime * 8.6f * Vector3.right;
|
||||||
|
|
||||||
if (hasStarted && isColliding && Input.GetKey(KeyCode.Space) && canJump)
|
if (Input.GetKey(KeyCode.Space))
|
||||||
{
|
{
|
||||||
Jump();
|
wantsToJump = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wantsToJump = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsJumping())
|
if (!IsJumping())
|
||||||
{
|
{
|
||||||
AlignRotation();
|
AlignRotation();
|
||||||
|
|
||||||
|
if (wantsToJump)
|
||||||
|
{
|
||||||
|
Jump();
|
||||||
|
wantsToJump = false;
|
||||||
|
}
|
||||||
|
|
||||||
particle.gameObject.SetActive(true);
|
particle.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -84,14 +88,13 @@ public class PlayerScript : MonoBehaviour
|
|||||||
public void OnCollisionEnter2D(Collision2D collision)
|
public void OnCollisionEnter2D(Collision2D collision)
|
||||||
{
|
{
|
||||||
isColliding = true;
|
isColliding = true;
|
||||||
canJump = true;
|
|
||||||
|
|
||||||
if (collision.gameObject.CompareTag("Kill"))
|
if (collision.gameObject.tag == "Kill")
|
||||||
{
|
{
|
||||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collision.gameObject.CompareTag("Win"))
|
if (collision.gameObject.tag == "Win")
|
||||||
{
|
{
|
||||||
SceneManager.LoadScene("HomeScene");
|
SceneManager.LoadScene("HomeScene");
|
||||||
}
|
}
|
||||||
|
@ -5,107 +5,46 @@ skinparam classAttributeIconSize 0
|
|||||||
skinparam classFontStyle Bold
|
skinparam classFontStyle Bold
|
||||||
hide enum methods
|
hide enum methods
|
||||||
|
|
||||||
class GameManager {
|
class Position {
|
||||||
- score: int
|
{field} + column: Integer
|
||||||
- isPaused: Boolean
|
{field} + row: Integer
|
||||||
+ StartGame()
|
|
||||||
+ RestartLevel()
|
{method} + Position(column: Integer, row: Integer)
|
||||||
+ PauseGame()
|
{method} + equals(position: Position)
|
||||||
+ ResumeGame()
|
|
||||||
+ UpdateScore(points: int)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Level {
|
class Level {
|
||||||
- name: String
|
{field} + songPath: String
|
||||||
- musicPath: String
|
{field} + backgroundPath: String
|
||||||
+ StartLevel()
|
{field} + speed: Double
|
||||||
+ EndLevel()
|
|
||||||
+ CheckCompletion(): Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class LevelElement {
|
{method} + Level()
|
||||||
- x: Float
|
|
||||||
- y: Float
|
|
||||||
}
|
}
|
||||||
|
Level *--> "*\n- grid" GameObject : <<Is made up of>>
|
||||||
|
|
||||||
abstract class Obstacle extends LevelElement {
|
abstract class GameObject {
|
||||||
+ TriggerEffect(player: Player)
|
{method} + getImagePath(): String {abstract}
|
||||||
|
{method} + safeSides(): List<PositionSide> {abstract}
|
||||||
}
|
}
|
||||||
|
GameObject o--> "1\n- " Position : <<Has>>
|
||||||
|
GameObject ..> PositionSide : <<Uses>>
|
||||||
|
|
||||||
class Platform extends LevelElement {
|
class Spike extends GameObject {}
|
||||||
|
|
||||||
|
class Game {
|
||||||
|
{field} - score: Integer
|
||||||
|
|
||||||
|
{method} + start(): void
|
||||||
|
{method} + restart(): void
|
||||||
|
{method} + end(): void
|
||||||
}
|
}
|
||||||
|
Game o--> "1\n- currentLevel" Level : <<Has>>
|
||||||
|
|
||||||
class Spike extends Obstacle {
|
enum PositionSide <<enumeration>> {
|
||||||
+ TriggerEffect(player: Player)
|
TOP
|
||||||
|
RIGHT
|
||||||
|
BOTTOM
|
||||||
|
LEFT
|
||||||
}
|
}
|
||||||
|
|
||||||
class Portal extends LevelElement {
|
|
||||||
- destination: Vector2
|
|
||||||
- type: PortalType
|
|
||||||
+ Teleport(player: Player)
|
|
||||||
}
|
|
||||||
|
|
||||||
enum PortalType {
|
|
||||||
Normal, Gravity, Speed
|
|
||||||
}
|
|
||||||
|
|
||||||
class Bumper extends LevelElement {
|
|
||||||
- bounceForce: Float
|
|
||||||
+ Bounce(player: Player)
|
|
||||||
}
|
|
||||||
|
|
||||||
class LevelEnd extends LevelElement {
|
|
||||||
+ TriggerEndGame()
|
|
||||||
}
|
|
||||||
|
|
||||||
class Collectible extends LevelElement {
|
|
||||||
- points: int
|
|
||||||
+ Collect(player: Player)
|
|
||||||
}
|
|
||||||
|
|
||||||
class Player {
|
|
||||||
- JUMP_FORCE: static const Float = 26.6581
|
|
||||||
- SPEED: static const Float = 8.6
|
|
||||||
- rigidBody: Rigidbody2D
|
|
||||||
- isColliding: Boolean
|
|
||||||
- isGrounded: Boolean
|
|
||||||
- gravityScale: Float
|
|
||||||
+ Jump()
|
|
||||||
+ IsJumping(): Boolean
|
|
||||||
+ OnCollisionEnter2D(collision: Collision2D)
|
|
||||||
+ OnCollisionExit2D(collision: Collision2D)
|
|
||||||
+ ChangeGravity()
|
|
||||||
+ Die()
|
|
||||||
+ Respawn()
|
|
||||||
+ CollectItem(item: Collectible)
|
|
||||||
}
|
|
||||||
|
|
||||||
class LevelLoader {
|
|
||||||
+ LoadLevel(jsonPath: String): Level
|
|
||||||
+ UnloadLevel(level: Level)
|
|
||||||
}
|
|
||||||
|
|
||||||
class LevelParser {
|
|
||||||
+ ParseJSON(jsonData: String): Level
|
|
||||||
}
|
|
||||||
|
|
||||||
class MusicManager {
|
|
||||||
- currentTrack: String
|
|
||||||
- volume: Float
|
|
||||||
+ PlayMusic(musicPath: String)
|
|
||||||
+ StopMusic()
|
|
||||||
+ SetVolume(level: Float)
|
|
||||||
}
|
|
||||||
|
|
||||||
GameManager *--> Level : <<Manages>>
|
|
||||||
GameManager --> LevelLoader : <<Uses>>
|
|
||||||
LevelLoader --> LevelParser : <<Uses>>
|
|
||||||
Level *--> LevelElement : <<Contains>>
|
|
||||||
GameManager *--> Player : <<Owns>>
|
|
||||||
GameManager --> MusicManager : <<Controls>>
|
|
||||||
Player --> LevelEnd : <<Triggers>>
|
|
||||||
Player --> Portal : <<Interacts>>
|
|
||||||
Player --> Collectible : <<Collects>>
|
|
||||||
Obstacle --> Player : <<Affects>>
|
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user