2019-09-17 15:43:40 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2019-09-17 18:52:55 +02:00
|
|
|
|
public class BasicShooter : AbstractShooter
|
2019-09-17 15:43:40 +02:00
|
|
|
|
{
|
2019-09-19 12:36:09 +02:00
|
|
|
|
// Bullet that will be fired
|
|
|
|
|
[SerializeField] private GameObject _bullet;
|
|
|
|
|
|
|
|
|
|
private Transform _parentTransform;
|
|
|
|
|
|
|
|
|
|
// Direction the bullet will be going
|
|
|
|
|
[SerializeField] private Vector2 _direction = Vector2.right;
|
|
|
|
|
|
|
|
|
|
// Offset between parent and newly created bullet
|
|
|
|
|
[SerializeField] private Vector2 _offset = Vector2.zero;
|
|
|
|
|
|
2019-09-17 15:43:40 +02:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
2019-09-19 12:36:09 +02:00
|
|
|
|
_parentTransform = GetComponentInParent<Transform>();
|
2019-09-17 15:43:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-19 12:36:09 +02:00
|
|
|
|
protected override void InstantiateProjectiles()
|
2019-09-17 15:43:40 +02:00
|
|
|
|
{
|
2019-09-19 12:36:09 +02:00
|
|
|
|
Vector3 newPosition = _parentTransform.position + (Vector3)_offset;
|
|
|
|
|
GameObject child = Instantiate(_bullet, newPosition, Quaternion.identity);
|
|
|
|
|
child.GetComponent<Bullet>().Direction = _direction;
|
2019-09-17 15:43:40 +02:00
|
|
|
|
}
|
|
|
|
|
}
|