trotFunky
ea9203ca8a
AbstractCharacter mainly fleshed out InputManager is done Player movement is done, not ennemy Energy management is done (AbstractCharacter)
32 lines
818 B
C#
32 lines
818 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Mover : MonoBehaviour
|
|
{
|
|
private AbstractCharacter _character;
|
|
private Transform _transform;
|
|
private Vector2 _direction;
|
|
private float _maxSpeed;
|
|
|
|
public Vector2 Direction
|
|
{
|
|
get { return _direction; }
|
|
set { _direction = value; }
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
_transform = GetComponentInParent<Transform>();
|
|
_character = GetComponentInParent<AbstractCharacter>();
|
|
_maxSpeed = _character.MaxSpeed;
|
|
_direction = Vector2.zero;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
_maxSpeed = _character.MaxSpeed;
|
|
Vector2 currentPosition = _transform.position;
|
|
_transform.position = currentPosition + _maxSpeed * Time.deltaTime * _direction;
|
|
}
|
|
}
|