BloodAndGore/Assets/Scripts/Guns/Bullet.cs

34 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Saltosion.OneWeapon.Effects;
using Saltosion.OneWeapon.Enemies;
using Saltosion.OneWeapon.Environment;
namespace Saltosion.OneWeapon.Guns {
public class Bullet : MonoBehaviour {
public Vector2 Direction;
public float InitialRotation;
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>();
VendingMachine VendingMachine = Collider.GetComponent<VendingMachine>();
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") {
DebrisLauncher.Splatter(DebrisType.Structural, transform.position, Direction, (int)(5 * Intensity), 30 * Intensity, 360);
}
if (Collider.attachedRigidbody != null && Collider.attachedRigidbody.bodyType == RigidbodyType2D.Dynamic) {
Collider.attachedRigidbody.AddForce(Direction * 4 * Intensity, ForceMode2D.Impulse);
}
}
}
}