2019-08-04 00:59:18 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2019-08-14 23:58:24 +02:00
|
|
|
|
using Saltosion.OneWeapon.Effects;
|
|
|
|
|
using Saltosion.OneWeapon.Enemies;
|
|
|
|
|
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
|
|
|
|
public class Bullet : MonoBehaviour {
|
|
|
|
|
|
|
|
|
|
public Vector2 Direction;
|
|
|
|
|
public float InitialRotation;
|
2019-08-14 23:58:24 +02:00
|
|
|
|
public bool HasExploded = false;
|
|
|
|
|
|
|
|
|
|
public void DoDamage(float Damage, float Intensity, Collider2D Collider, Vector2 Direction) {
|
|
|
|
|
Explodable Explodable = Collider.GetComponent<Explodable>();
|
|
|
|
|
Health Health = Collider.GetComponent<Health>();
|
2019-08-16 20:46:34 +02:00
|
|
|
|
GunDropper VendingMachine = Collider.GetComponent<GunDropper>();
|
2019-08-14 23:58:24 +02:00
|
|
|
|
if (Health != null) {
|
|
|
|
|
Health.Damage(Damage, -Direction, true);
|
|
|
|
|
} else if (VendingMachine != null) {
|
|
|
|
|
VendingMachine.ExpelGun();
|
|
|
|
|
} else if (Explodable != null) {
|
|
|
|
|
Explodable.Explode(true);
|
|
|
|
|
} else if (Collider.tag == "Environment") {
|
2019-08-14 23:27:14 +02:00
|
|
|
|
DebrisLauncher.Splatter(DebrisType.Structural, transform.position, Direction, (int)(5 * Intensity), 30 * Intensity, 360);
|
2019-08-14 23:58:24 +02:00
|
|
|
|
}
|
|
|
|
|
if (Collider.attachedRigidbody != null && Collider.attachedRigidbody.bodyType == RigidbodyType2D.Dynamic) {
|
|
|
|
|
Collider.attachedRigidbody.AddForce(Direction * 4 * Intensity, ForceMode2D.Impulse);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-04 00:59:18 +02:00
|
|
|
|
}
|
|
|
|
|
}
|