Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Kassout committed Apr 26, 2023
1 parent ec9f635 commit 9bd8d30
Show file tree
Hide file tree
Showing 30 changed files with 455 additions and 202 deletions.
174 changes: 157 additions & 17 deletions PlatformerController/Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,12 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 169740279}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1973051728}
m_Father: {fileID: 1394428076}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &178037290
Expand Down Expand Up @@ -478,6 +478,52 @@ MonoBehaviour:
m_CameraActivatedEvent:
m_PersistentCalls:
m_Calls: []
--- !u!1 &522243857
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 522243858}
- component: {fileID: 522243859}
m_Layer: 9
m_Name: Core
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &522243858
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 522243857}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1171421165}
- {fileID: 1394428076}
m_Father: {fileID: 1973051728}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &522243859
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 522243857}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e09c571c448ed2a42ac1275a4f6061b7, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &576534574
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -586,12 +632,12 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 630794300}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1973051728}
m_Father: {fileID: 1394428076}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &908733560
Expand Down Expand Up @@ -665,12 +711,12 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 994328652}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1973051728}
m_Father: {fileID: 1394428076}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1000518789
Expand Down Expand Up @@ -768,6 +814,50 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
weaponData: {fileID: 11400000, guid: 348c44c3fa52c50439d4a4275d846945, type: 2}
--- !u!1 &1171421164
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1171421165}
- component: {fileID: 1171421166}
m_Layer: 9
m_Name: Movement
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1171421165
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1171421164}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 522243858}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1171421166
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1171421164}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0057e294e862fb84dac3ef092b364419, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1258763309
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -41504,6 +41594,63 @@ Transform:
m_Father: {fileID: 1973051728}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1394428075
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1394428076}
- component: {fileID: 1394428077}
m_Layer: 9
m_Name: Collision Senses
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1394428076
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1394428075}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1592426216}
- {fileID: 994328653}
- {fileID: 630794301}
- {fileID: 169740280}
m_Father: {fileID: 522243858}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1394428077
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1394428075}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71910b189f0fda74eae4834babaf26f7, type: 3}
m_Name:
m_EditorClassIdentifier:
groundCheckRadius: 0.3
wallCheckDistance: 0.5
whatIsGround:
serializedVersion: 2
m_Bits: 64
groundCheck: {fileID: 1592426216}
wallCheck: {fileID: 994328653}
ledgeCheck: {fileID: 630794301}
ceilingCheck: {fileID: 169740280}
--- !u!1 &1409931572
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -50500,12 +50647,12 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1592426215}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -0.95, z: 0}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -0.9499998, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1973051728}
m_Father: {fileID: 1394428076}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1643674744
Expand Down Expand Up @@ -50747,11 +50894,8 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1592426216}
- {fileID: 994328653}
- {fileID: 630794301}
- {fileID: 522243858}
- {fileID: 1907564703}
- {fileID: 169740280}
- {fileID: 1382707484}
m_Father: {fileID: 0}
m_RootOrder: 8
Expand Down Expand Up @@ -50924,10 +51068,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
playerData: {fileID: 11400000, guid: 703967f136371884d890ef809c69c335, type: 2}
groundCheck: {fileID: 1592426216}
wallCheck: {fileID: 994328653}
ledgeCheck: {fileID: 630794301}
ceilingCheck: {fileID: 169740280}
--- !u!212 &1973051732
SpriteRenderer:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions PlatformerController/Assets/Scripts/Core.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions PlatformerController/Assets/Scripts/Core/Components.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using UnityEngine;

public class CollisionSenses : CoreComponent
{
[SerializeField] private float groundCheckRadius;
[SerializeField] private float wallCheckDistance;

[SerializeField] private LayerMask whatIsGround;

[SerializeField] private Transform groundCheck;
[SerializeField] private Transform wallCheck;
[SerializeField] private Transform ledgeCheck;
[SerializeField] private Transform ceilingCheck;

public float GroundCheckRadius => groundCheckRadius;

public float WallCheckDistance => wallCheckDistance;

public LayerMask WhatIsGround => whatIsGround;

public Transform GroundCheck => groundCheck;
public Transform WallCheck => wallCheck;
public Transform LedgeCheck => ledgeCheck;
public Transform CeilingCheck => ceilingCheck;

public bool Ceiling => Physics2D.OverlapCircle(ceilingCheck.position, groundCheckRadius, whatIsGround);

public bool Ground => Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);

public bool WallFront => Physics2D.Raycast(wallCheck.position, Vector2.right * core.Movement.FacingDirection,
wallCheckDistance, whatIsGround);

public bool WallBack => Physics2D.Raycast(wallCheck.position, Vector2.right * -core.Movement.FacingDirection,
wallCheckDistance, whatIsGround);

public bool Ledge => Physics2D.Raycast(ledgeCheck.position, Vector2.right * core.Movement.FacingDirection,
wallCheckDistance, whatIsGround);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UnityEngine;

public class CoreComponent : MonoBehaviour
{
protected Core core;

protected virtual void Awake()
{
core = transform.parent.GetComponent<Core>();

if (!core)
{
Debug.LogError("There is no Core on the parent.");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9bd8d30

Please sign in to comment.