Platformer level management
This commit is contained in:
1 parent
72070901ec
commit
1aceea1b79
94 files changed
+3656
-197
No files matched your search
@@ -5,26 +5,42 @@ namespace Code.Example.Platformer.Entity
|
||||
{
|
||||
public abstract class Entity : MonoBehaviour
|
||||
{
|
||||
private static readonly int VelocityY = Animator.StringToHash("VelocityY");
|
||||
private static readonly int VelocityX = Animator.StringToHash("VelocityX");
|
||||
private static readonly int OnGround = Animator.StringToHash("OnGround");
|
||||
protected static readonly int VelocityY = Animator.StringToHash("VelocityY");
|
||||
protected static readonly int VelocityX = Animator.StringToHash("VelocityX");
|
||||
protected static readonly int OnGround = Animator.StringToHash("OnGround");
|
||||
protected static readonly int OnHit = Animator.StringToHash("OnHit");
|
||||
protected static readonly int OnDeath = Animator.StringToHash("OnDeath");
|
||||
protected static readonly int Died = Animator.StringToHash("Died");
|
||||
|
||||
[SerializeField] protected Rigidbody2D rigidbody2D;
|
||||
[SerializeField] protected Animator animator;
|
||||
[SerializeField] protected SpriteRenderer spriteRenderer;
|
||||
[SerializeField] private Vector2 groundPoint;
|
||||
|
||||
private PlatformerEntityData _data;
|
||||
|
||||
private PlatformerEntityData _data; // TODO
|
||||
protected bool isFreezed;
|
||||
protected bool onGround;
|
||||
public void SetData(PlatformerEntityData data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
protected bool onGround;
|
||||
public void Freeze()
|
||||
{
|
||||
rigidbody2D.bodyType = RigidbodyType2D.Kinematic;
|
||||
isFreezed = true;
|
||||
}
|
||||
public void UnFreeze()
|
||||
{
|
||||
rigidbody2D.bodyType = RigidbodyType2D.Dynamic;
|
||||
isFreezed = false;
|
||||
}
|
||||
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
if(isFreezed) return;
|
||||
|
||||
animator.SetFloat(VelocityX, rigidbody2D.linearVelocityX);
|
||||
animator.SetFloat(VelocityY, rigidbody2D.linearVelocityY);
|
||||
}
|
||||
@@ -33,6 +49,8 @@ namespace Code.Example.Platformer.Entity
|
||||
|
||||
protected virtual void FixedUpdate()
|
||||
{
|
||||
if(isFreezed) return;
|
||||
|
||||
onGround = CheckGround();
|
||||
animator.SetBool(OnGround, onGround);
|
||||
|
||||
@@ -48,8 +66,5 @@ namespace Code.Example.Platformer.Entity
|
||||
}
|
||||
|
||||
protected abstract void Move();
|
||||
|
||||
public virtual void OnGetDamage(){}
|
||||
public virtual void OnDeath(){}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user