add spawn point, death
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class Character : MonoBehaviour
|
||||
@@ -10,6 +11,9 @@ public abstract class Character : MonoBehaviour
|
||||
protected GameObject _bonesSide;
|
||||
[SerializeField]
|
||||
protected GameObject _bonesBack;
|
||||
[SerializeField]
|
||||
protected GameObject _spawnPoint;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private LayerMask _mapLayer;
|
||||
@@ -34,10 +38,20 @@ public abstract class Character : MonoBehaviour
|
||||
_capsuleCollider = GetComponent<CapsuleCollider2D>();
|
||||
}
|
||||
|
||||
protected void Spawn()
|
||||
{
|
||||
transform.position=_spawnPoint.transform.position;
|
||||
}
|
||||
|
||||
protected void MoveTo(float inputHorizontal, float inputVertical)
|
||||
{
|
||||
var mapElement = GetMapElement(Vector2.down);
|
||||
|
||||
if(mapElement==MapElementType.Water)
|
||||
{
|
||||
Death();
|
||||
}
|
||||
|
||||
_isOnBridge = mapElement == MapElementType.Bridge && !_isFalling;
|
||||
|
||||
if (mapElement == MapElementType.Wall || _isOnLadder || _isOnBridge || mapElement == MapElementType.BreakableWall)
|
||||
@@ -103,6 +117,12 @@ public abstract class Character : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
private void Death()
|
||||
{
|
||||
OnDeath();
|
||||
|
||||
}
|
||||
|
||||
private MapElementType GetMapElement(Vector2 direction)
|
||||
{
|
||||
Vector2 rayStartPoint;
|
||||
@@ -137,6 +157,7 @@ public abstract class Character : MonoBehaviour
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
protected abstract void OnDeath();
|
||||
protected abstract void SetWalkingAnimation(bool isWalking);
|
||||
protected abstract void SetClimbingAnimation(bool isClimbing);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user