mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-06 16:25:54 +00:00
Explosion sprites and lifetime
This commit is contained in:
parent
2a07a31678
commit
a0b5cedff9
10 changed files with 102 additions and 18 deletions
|
|
@ -13,6 +13,7 @@ BulletScene = ExtResource("4_epbro")
|
|||
BulletSpeed = 0.0
|
||||
BulletDamage = 8.0
|
||||
LifeTime = 1.0
|
||||
DestroyOnCollision = false
|
||||
Owner = 0
|
||||
DamageType = 4
|
||||
TimeModifiers = null
|
||||
|
|
|
|||
|
|
@ -1,8 +1,72 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://h11o0et1y54v"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://h11o0et1y54v"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Bullet.cs" id="1_f0epf"]
|
||||
[ext_resource type="Texture2D" uid="uid://b2bp03a70cpyd" path="res://Sprites/Explosion1.png" id="2_gmwb3"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ltwjd"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_b8hsa"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(32, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1jqx0"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(64, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_g2luq"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(96, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yyc14"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(128, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qhukn"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(160, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_afp5d"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(192, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cpopo"]
|
||||
atlas = ExtResource("2_gmwb3")
|
||||
region = Rect2(224, 0, 32, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_6egyg"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ltwjd")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_b8hsa")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1jqx0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_g2luq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_yyc14")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qhukn")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_afp5d")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_cpopo")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"default",
|
||||
"speed": 8.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||
radius = 17.0
|
||||
|
||||
|
|
@ -13,8 +77,10 @@ script = ExtResource("1_f0epf")
|
|||
Speed = 0.0
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_gmwb3")
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_6egyg")
|
||||
autoplay = "default"
|
||||
frame = 1
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_jxptd")
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -34,14 +34,15 @@ public partial class Bullet : Area2D
|
|||
|
||||
_gameManager = gameManager;
|
||||
|
||||
_elapsedTime = 0f;
|
||||
|
||||
// Need to clone them here
|
||||
// _modifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone()).ToList();
|
||||
|
||||
|
||||
// var clonedModifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone());
|
||||
// _modifiers = clonedModifiers.ToList();
|
||||
|
||||
|
||||
|
||||
// Ugly hack to make instances unique
|
||||
_modifiers = _bulletInfo.TimeModifiers.Select(x => x.Wrap()).ToList();
|
||||
}
|
||||
|
|
@ -136,6 +137,11 @@ public partial class Bullet : Area2D
|
|||
public override void _Process(double delta)
|
||||
{
|
||||
_elapsedTime += delta;
|
||||
|
||||
if (_elapsedTime >= _bulletInfo.LifeTime)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
|
|
@ -159,7 +165,7 @@ public partial class Bullet : Area2D
|
|||
if (body.IsInGroup("Solid"))
|
||||
{
|
||||
//Debug.WriteLine("Collision");
|
||||
Destroy();
|
||||
RequestCollisionDestruction();
|
||||
}
|
||||
//// Do not Collide with body for purpose of destroying bullets
|
||||
// else if (body.IsInGroup("Destroyable"))
|
||||
|
|
@ -173,7 +179,7 @@ public partial class Bullet : Area2D
|
|||
{
|
||||
if (area.IsInGroup("Solid"))
|
||||
{
|
||||
Destroy();
|
||||
RequestCollisionDestruction();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +189,7 @@ public partial class Bullet : Area2D
|
|||
// hit
|
||||
destructible.Hit(Damage, DamageType);
|
||||
|
||||
Destroy();
|
||||
RequestCollisionDestruction();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,8 +205,15 @@ public partial class Bullet : Area2D
|
|||
return bulletOwner != targetGroup;
|
||||
}
|
||||
|
||||
public void RequestCollisionDestruction()
|
||||
{
|
||||
if (_bulletInfo.DestroyOnCollision)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
private void Destroy()
|
||||
{
|
||||
if (_bulletInfo?.DestructionParticlesScene != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ public class BulletInfo
|
|||
public Vector2 Direction { get; set; }
|
||||
public float Speed { get; set; }
|
||||
public float LifeTime { get; set; }
|
||||
public bool DestroyOnCollision { get; set; }
|
||||
public BulletOwner Owner { get; set; }
|
||||
public DamageType DamageType { get; set; }
|
||||
public float Damage { get; set; }
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ public partial class Enemy : CharacterBody2D
|
|||
if (bullet.BulletInfo.Owner == BulletOwner.Enemy) return;
|
||||
|
||||
this.Hit(bullet.Damage);
|
||||
bullet.QueueFree();
|
||||
bullet.RequestCollisionDestruction();
|
||||
}
|
||||
|
||||
// Bullets collision
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
if (area is Bullet bullet && bullet.BulletOwner != BulletGroup)
|
||||
{
|
||||
this.Hit(bullet.Damage, bullet.DamageType);
|
||||
bullet.QueueFree();
|
||||
bullet.RequestCollisionDestruction();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public partial class BulletResource : Resource
|
|||
[Export] public float BulletSpeed = 100f;
|
||||
[Export] public float BulletDamage = 1;
|
||||
[Export] public float LifeTime = 10f;
|
||||
[Export] public bool DestroyOnCollision = true;
|
||||
[Export] public BulletOwner Owner = BulletOwner.None;
|
||||
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||
|
||||
|
|
@ -38,6 +39,7 @@ public partial class BulletResource : Resource
|
|||
RotationOffset = rotationOffset,
|
||||
Modifier = Modifier,
|
||||
LifeTime = LifeTime,
|
||||
DestroyOnCollision = DestroyOnCollision,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
TimeModifiers = TimeModifiers.Select(x => x).ToList()
|
||||
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
|
||||
|
|
|
|||
BIN
Sprites/Explosion1.aseprite
(Stored with Git LFS)
BIN
Sprites/Explosion1.aseprite
(Stored with Git LFS)
Binary file not shown.
BIN
Sprites/Explosion1.png
(Stored with Git LFS)
BIN
Sprites/Explosion1.png
(Stored with Git LFS)
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue