2019-08-04 00:59:18 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2019-08-14 16:17:48 +02:00
|
|
|
|
using Saltosion.OneWeapon.Player;
|
|
|
|
|
using Saltosion.OneWeapon.Enemies;
|
|
|
|
|
using Saltosion.OneWeapon.Effects;
|
2019-08-14 19:05:16 +02:00
|
|
|
|
using Saltosion.OneWeapon.Environment;
|
2019-08-04 00:59:18 +02:00
|
|
|
|
|
2019-08-14 16:17:48 +02:00
|
|
|
|
namespace Saltosion.OneWeapon.Guns {
|
2019-08-04 00:59:18 +02:00
|
|
|
|
[RequireComponent(typeof(Bullet))]
|
|
|
|
|
public class RevolverBullet : MonoBehaviour {
|
|
|
|
|
|
|
|
|
|
public Rigidbody2D Body;
|
2019-08-04 01:45:55 +02:00
|
|
|
|
public GameObject Sprite;
|
|
|
|
|
|
|
|
|
|
public ParticleSystem Trail;
|
|
|
|
|
public ParticleSystem Explosion;
|
|
|
|
|
|
|
|
|
|
private float DeathTimer = 0;
|
2019-08-04 00:59:18 +02:00
|
|
|
|
|
2019-08-14 23:58:24 +02:00
|
|
|
|
private Bullet Bullet;
|
|
|
|
|
|
2019-08-04 00:59:18 +02:00
|
|
|
|
void Start() {
|
2019-08-14 23:58:24 +02:00
|
|
|
|
Bullet = GetComponent<Bullet>();
|
|
|
|
|
Vector2 Direction = Bullet.Direction;
|
|
|
|
|
float Rot = Bullet.InitialRotation;
|
2019-08-04 00:59:18 +02:00
|
|
|
|
|
|
|
|
|
Body.velocity = Direction * 15;
|
|
|
|
|
Body.rotation = Rot - 90;
|
2019-08-04 01:45:55 +02:00
|
|
|
|
|
|
|
|
|
Explosion.Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update() {
|
|
|
|
|
DeathTimer += Time.deltaTime;
|
|
|
|
|
if (DeathTimer > 20) {
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
}
|
2019-08-04 00:59:18 +02:00
|
|
|
|
}
|
2019-08-04 01:10:18 +02:00
|
|
|
|
|
|
|
|
|
void OnTriggerEnter2D(Collider2D collider) {
|
2019-08-14 16:17:48 +02:00
|
|
|
|
if (collider.GetComponent<PlayerController>() != null) {
|
2019-08-04 01:10:18 +02:00
|
|
|
|
// don't hit the player!
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-08-14 23:58:24 +02:00
|
|
|
|
Bullet.HasExploded = true;
|
|
|
|
|
|
2019-08-04 01:45:55 +02:00
|
|
|
|
Destroy(Sprite);
|
|
|
|
|
Destroy(Body);
|
|
|
|
|
Destroy(GetComponent<CapsuleCollider2D>());
|
|
|
|
|
Explosion.Play();
|
|
|
|
|
Trail.Stop();
|
|
|
|
|
DeathTimer = 19;
|
|
|
|
|
|
|
|
|
|
// Do damage here, kill everyone
|
2019-08-14 23:58:24 +02:00
|
|
|
|
Bullet.DoDamage(12, 1, collider, Bullet.Direction);
|
2019-08-04 01:10:18 +02:00
|
|
|
|
}
|
2019-08-04 00:59:18 +02:00
|
|
|
|
}
|
|
|
|
|
}
|