trotFunky
37e8c8d689
Added Death() method to AbstractCharacter Implemented basic bullet collision detection and effect
49 lines
1 KiB
C#
49 lines
1 KiB
C#
using System;
|
|
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
|
|
{
|
|
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
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
// Destroy on Stay, collision effects should be handled on Enter
|
|
private void OnCollisionStay2D(Collision2D other)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|