Compare commits
No commits in common. "37e8c8d6892d1aeefbf561514edb78f5a086b419" and "ea9203ca8adb559d70ffd97aeb70adefcac33437" have entirely different histories.
37e8c8d689
...
ea9203ca8a
4 changed files with 10 additions and 67 deletions
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -94,24 +93,9 @@ public abstract class AbstractCharacter : MonoBehaviour
|
|||
public abstract void Move(Vector2 movementDirection);
|
||||
public abstract void Shoot();
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D other)
|
||||
// TODO : Manage hurt + OnCollision + Death'n stuff
|
||||
public void Hurt()
|
||||
{
|
||||
Bullet bullet = other.gameObject.GetComponent<Bullet>();
|
||||
if (bullet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Hurt(bullet.Damage);
|
||||
}
|
||||
|
||||
public void Hurt(int damage)
|
||||
{
|
||||
CurrentHealth -= damage;
|
||||
if (CurrentHealth <= 0)
|
||||
{
|
||||
Death();
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
// Handles the death of the character, should be overriden
|
||||
protected abstract void Death();
|
||||
}
|
||||
|
|
|
@ -1,38 +1,13 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Bullet : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int _damage;
|
||||
public int Damage => _damage;
|
||||
|
||||
// Speed in m/s
|
||||
[SerializeField] private float _speed;
|
||||
public float Speed
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
get { return _speed; }
|
||||
set { _speed = value; }
|
||||
}
|
||||
|
||||
[SerializeField] private Vector2 _direction;
|
||||
public Vector2 Direction
|
||||
{
|
||||
get { return _direction; }
|
||||
set { _direction = value; }
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Mover mover = GetComponentInParent<Mover>();
|
||||
if (mover == null)
|
||||
{
|
||||
throw new MissingComponentException("Missing Mover!");
|
||||
}
|
||||
|
||||
mover.Direction = Direction;
|
||||
mover.MaxSpeed = Speed;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
@ -40,10 +15,4 @@ public class Bullet : MonoBehaviour
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
// Destroy on Stay, collision effects should be handled on Enter
|
||||
private void OnCollisionStay2D(Collision2D other)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,6 @@ public class Mover : MonoBehaviour
|
|||
private Transform _transform;
|
||||
private Vector2 _direction;
|
||||
private float _maxSpeed;
|
||||
public float MaxSpeed
|
||||
{
|
||||
get { return _maxSpeed; }
|
||||
set { _maxSpeed = value; }
|
||||
}
|
||||
|
||||
public Vector2 Direction
|
||||
{
|
||||
|
@ -20,11 +15,11 @@ public class Mover : MonoBehaviour
|
|||
set { _direction = value; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
void Start()
|
||||
{
|
||||
_transform = GetComponentInParent<Transform>();
|
||||
_character = GetComponentInParent<AbstractCharacter>();
|
||||
_maxSpeed = _character != null ? _character.MaxSpeed : 1;
|
||||
_maxSpeed = _character.MaxSpeed;
|
||||
_direction = Vector2.zero;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,4 @@ public class PlayerCharacter : AbstractCharacter
|
|||
// TODO : Implement
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void Death()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue