50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Saltosion.OneWeapon.Bullets {
|
|
[RequireComponent(typeof(Bullet))]
|
|
public class RevolverBullet : MonoBehaviour {
|
|
|
|
public Rigidbody2D Body;
|
|
public GameObject Sprite;
|
|
|
|
public ParticleSystem Trail;
|
|
public ParticleSystem Explosion;
|
|
|
|
private float DeathTimer = 0;
|
|
|
|
void Start() {
|
|
Vector2 Direction = GetComponent<Bullet>().Direction;
|
|
float Rot = GetComponent<Bullet>().InitialRotation;
|
|
|
|
Body.velocity = Direction * 15;
|
|
Body.rotation = Rot - 90;
|
|
|
|
Explosion.Stop();
|
|
}
|
|
|
|
void Update() {
|
|
DeathTimer += Time.deltaTime;
|
|
if (DeathTimer > 20) {
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D collider) {
|
|
if (collider.GetComponent<Player>() != null) {
|
|
// don't hit the player!
|
|
return;
|
|
}
|
|
Destroy(Sprite);
|
|
Destroy(Body);
|
|
Destroy(GetComponent<CapsuleCollider2D>());
|
|
Explosion.Play();
|
|
Trail.Stop();
|
|
DeathTimer = 19;
|
|
|
|
// Do damage here, kill everyone
|
|
}
|
|
}
|
|
}
|