mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Bullet resource
This commit is contained in:
parent
76221ca7a6
commit
07f6e58ebd
19 changed files with 236 additions and 50 deletions
|
|
@ -26,6 +26,8 @@ duration = 1.0
|
|||
burstInterval = 1.0
|
||||
spread = 180.0
|
||||
owner = 2
|
||||
_damageType = 0
|
||||
_bulletDamage = 1.0
|
||||
_timeModifiers = Array[Resource]([])
|
||||
WaitForCompletion = true
|
||||
|
||||
|
|
@ -40,6 +42,8 @@ duration = 1.0
|
|||
burstInterval = 1.0
|
||||
spread = 180.0
|
||||
owner = 2
|
||||
_damageType = 0
|
||||
_bulletDamage = 1.0
|
||||
_timeModifiers = null
|
||||
WaitForCompletion = true
|
||||
|
||||
|
|
|
|||
15
Resources/Bullets/simple_enemy_bullet.tres
Normal file
15
Resources/Bullets/simple_enemy_bullet.tres
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://dqnvesdj0dk3v"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="1_o3tyw"]
|
||||
[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="1_vsj6i"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_o3tyw")
|
||||
BulletScene = ExtResource("1_vsj6i")
|
||||
AmmoKey = ""
|
||||
BulletSpeed = 50.0
|
||||
BulletDamage = 1.0
|
||||
LifeTime = 10.0
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
TimeModifiers = null
|
||||
17
Resources/Bullets/simple_ice_bullet.tres
Normal file
17
Resources/Bullets/simple_ice_bullet.tres
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[gd_resource type="Resource" script_class="BulletResource" load_steps=4 format=3 uid="uid://eu6n6c5175y8"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_qjgqc"]
|
||||
[ext_resource type="PackedScene" uid="uid://dfbmny3s4rili" path="res://Scenes/Particles/IceBulletParticle.tscn" id="2_fkpjr"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="3_m6t6f"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("3_m6t6f")
|
||||
BulletScene = ExtResource("1_qjgqc")
|
||||
DestructionParticlesScene = ExtResource("2_fkpjr")
|
||||
AmmoKey = ""
|
||||
BulletSpeed = 300.0
|
||||
BulletDamage = 1.0
|
||||
LifeTime = 10.0
|
||||
Owner = 1
|
||||
DamageType = 3
|
||||
TimeModifiers = null
|
||||
|
|
@ -16,6 +16,8 @@ duration = 1.0
|
|||
burstInterval = 2.0
|
||||
spread = 360.0
|
||||
owner = 2
|
||||
_damageType = 0
|
||||
_bulletDamage = 1.0
|
||||
_timeModifiers = null
|
||||
WaitForCompletion = true
|
||||
|
||||
|
|
@ -30,6 +32,8 @@ duration = 1.0
|
|||
burstInterval = 2.0
|
||||
spread = 360.0
|
||||
owner = 2
|
||||
_damageType = 0
|
||||
_bulletDamage = 1.0
|
||||
_timeModifiers = null
|
||||
WaitForCompletion = true
|
||||
|
||||
|
|
@ -44,6 +48,8 @@ duration = 4.0
|
|||
burstInterval = 2.0
|
||||
spread = 360.0
|
||||
owner = 2
|
||||
_damageType = 0
|
||||
_bulletDamage = 1.0
|
||||
_timeModifiers = null
|
||||
WaitForCompletion = true
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://cdfmedtgp2rcn"]
|
||||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://cdfmedtgp2rcn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="1_c5ala"]
|
||||
[ext_resource type="Resource" uid="uid://dqnvesdj0dk3v" path="res://Resources/Bullets/simple_enemy_bullet.tres" id="1_eps1c"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_8ycgt"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_8ycgt")
|
||||
Name = "Enemy Weapon"
|
||||
BulletData = ExtResource("1_eps1c")
|
||||
BulletScene = ExtResource("1_c5ala")
|
||||
RateOfFire = 0.4
|
||||
BulletCapacity = 4
|
||||
|
|
@ -15,9 +17,11 @@ InfiniteAmmo = true
|
|||
BulletsPerShot = 1
|
||||
SpreadAngle = 0.0
|
||||
RandomSpread = 0.0
|
||||
AmmoKey = ""
|
||||
BulletSpeed = 50.0
|
||||
bulletPerShotCount = 1
|
||||
BulletDamage = 1.0
|
||||
LifeTime = 10.0
|
||||
_rotationOffset = 0.0
|
||||
spread = 0.0
|
||||
owner = 2
|
||||
_damageType = 0
|
||||
_timeModifiers = null
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://cyntngidhcbkc"]
|
||||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://cyntngidhcbkc"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_m44wx"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_puh43"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_utbbo"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_utbbo")
|
||||
Name = "Ice Shotgun"
|
||||
BulletData = ExtResource("1_m44wx")
|
||||
BulletScene = ExtResource("1_puh43")
|
||||
RateOfFire = 0.1
|
||||
BulletCapacity = 4
|
||||
|
|
@ -18,6 +20,8 @@ RandomSpread = 0.0
|
|||
AmmoKey = "Ammo1"
|
||||
BulletSpeed = 300.0
|
||||
BulletDamage = 1.0
|
||||
LifeTime = 10.0
|
||||
_rotationOffset = 0.0
|
||||
owner = 1
|
||||
_damageType = 0
|
||||
_timeModifiers = null
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://b8apu0l5fm4k"]
|
||||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=5 format=3 uid="uid://b8apu0l5fm4k"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_85ef1"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_yby7n"]
|
||||
[ext_resource type="PackedScene" uid="uid://dfbmny3s4rili" path="res://Scenes/Particles/IceBulletParticle.tscn" id="2_icuny"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_m8dps"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_m8dps")
|
||||
Name = "Icicle Gun"
|
||||
BulletData = ExtResource("1_85ef1")
|
||||
BulletScene = ExtResource("1_yby7n")
|
||||
DestructionParticlesScene = ExtResource("2_icuny")
|
||||
RateOfFire = 0.1
|
||||
BulletCapacity = 4
|
||||
ReloadTime = 0.2
|
||||
|
|
@ -18,6 +22,8 @@ RandomSpread = 0.0
|
|||
AmmoKey = ""
|
||||
BulletSpeed = 300.0
|
||||
BulletDamage = 1.0
|
||||
LifeTime = 10.0
|
||||
_rotationOffset = 0.0
|
||||
owner = 1
|
||||
_damageType = 0
|
||||
_timeModifiers = null
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://yuc0v7gojgep"]
|
||||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://yuc0v7gojgep"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_lg8jo"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_lmn8t"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_f4135"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_f4135")
|
||||
Name = "Icicle Gun"
|
||||
BulletData = ExtResource("1_lg8jo")
|
||||
BulletScene = ExtResource("1_lmn8t")
|
||||
RateOfFire = 0.1
|
||||
BulletCapacity = 100
|
||||
|
|
@ -15,9 +17,11 @@ InfiniteAmmo = true
|
|||
BulletsPerShot = 1
|
||||
SpreadAngle = 0.0
|
||||
RandomSpread = 0.0
|
||||
AmmoKey = ""
|
||||
BulletSpeed = 300.0
|
||||
bulletPerShotCount = 1
|
||||
BulletDamage = 1.0
|
||||
LifeTime = 10.0
|
||||
_rotationOffset = 0.0
|
||||
spread = 0.0
|
||||
owner = 1
|
||||
_damageType = 0
|
||||
_timeModifiers = null
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using Godot;
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
public partial class Barrel : Area2D, IDestructible
|
||||
{
|
||||
|
|
@ -14,8 +15,7 @@ public partial class Barrel : Area2D, IDestructible
|
|||
[Export] public PackedScene DebrisScene { get; set; }
|
||||
|
||||
[Export] public PackedScene ExplosionParticles { get; set; }
|
||||
|
||||
[Export] public PackedScene ExplosionScene { get; set; }
|
||||
[Export] public BulletResource ExplosionData { get; set; }
|
||||
|
||||
private float _currentHealth = 0f;
|
||||
|
||||
|
|
@ -43,11 +43,12 @@ public partial class Barrel : Area2D, IDestructible
|
|||
|
||||
private void CreateExplosion()
|
||||
{
|
||||
if (ExplosionScene == null) return;
|
||||
if (ExplosionData == null) return;
|
||||
|
||||
var explosion = this.CreateSibling<Bullet>(ExplosionScene);
|
||||
var explosion = this.CreateSibling<Bullet>(ExplosionData.BulletScene);
|
||||
explosion.Speed = 0;
|
||||
|
||||
explosion.Initialize(ExplosionData.MakeBullet(this.GlobalPosition));
|
||||
}
|
||||
|
||||
private void ApplyExplosionDamage()
|
||||
|
|
|
|||
23
Scenes/Particles/IceBulletParticle.tscn
Normal file
23
Scenes/Particles/IceBulletParticle.tscn
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dfbmny3s4rili"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Components/AutodeleteParticle.cs" id="1_rk44q"]
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_f8iyl"]
|
||||
particle_flag_disable_z = true
|
||||
radial_velocity_min = -2.23517e-05
|
||||
radial_velocity_max = 30.38
|
||||
gravity = Vector3(0, 0, 0)
|
||||
linear_accel_min = -23.2
|
||||
linear_accel_max = -2.23517e-06
|
||||
scale_min = 0.5
|
||||
scale_max = 0.5
|
||||
color = Color(0.054902, 0.494118, 1, 1)
|
||||
|
||||
[node name="IceBulletParticle" type="GPUParticles2D"]
|
||||
emitting = false
|
||||
amount = 4
|
||||
process_material = SubResource("ParticleProcessMaterial_f8iyl")
|
||||
lifetime = 0.4
|
||||
one_shot = true
|
||||
script = ExtResource("1_rk44q")
|
||||
LifeTime = 1.0
|
||||
|
|
@ -1,10 +1,21 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://bj28qiai2x2ar"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://bj28qiai2x2ar"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_avwdx"]
|
||||
[ext_resource type="Texture2D" uid="uid://d2f16ke8c7vwx" path="res://Sprites/Barrel.png" id="1_e66t6"]
|
||||
[ext_resource type="PackedScene" uid="uid://clyyl3jgpfoo7" path="res://Scenes/Props/Broken_Barrel.tscn" id="2_f145b"]
|
||||
[ext_resource type="PackedScene" uid="uid://jmijre3eaf8m" path="res://Scenes/Explosion.tscn" id="3_sm378"]
|
||||
[ext_resource type="PackedScene" uid="uid://h11o0et1y54v" path="res://Scenes/Weapons/Bullets/explosion.tscn" id="4_epbro"]
|
||||
[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="5_xl8uf"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_kqink"]
|
||||
script = ExtResource("5_xl8uf")
|
||||
BulletScene = ExtResource("4_epbro")
|
||||
BulletSpeed = 0.0
|
||||
BulletDamage = 8.0
|
||||
LifeTime = 1.0
|
||||
Owner = 0
|
||||
DamageType = 4
|
||||
TimeModifiers = null
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"]
|
||||
size = Vector2(11, 14)
|
||||
|
|
@ -25,7 +36,7 @@ ExplosionRadius = 4.0
|
|||
ExplosionDamage = 3.0
|
||||
DebrisScene = ExtResource("2_f145b")
|
||||
ExplosionParticles = ExtResource("3_sm378")
|
||||
ExplosionScene = ExtResource("4_epbro")
|
||||
ExplosionData = SubResource("Resource_kqink")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
[ext_resource type="Texture2D" uid="uid://b2bp03a70cpyd" path="res://Sprites/Explosion1.png" id="2_gmwb3"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||
radius = 12.0
|
||||
radius = 17.0
|
||||
|
||||
[node name="Bullet" type="Area2D" groups=["bullets"]]
|
||||
collision_layer = 136
|
||||
collision_mask = 87
|
||||
script = ExtResource("1_f0epf")
|
||||
Speed = 0.0
|
||||
Damage = 10.0
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
|
|
|
|||
|
|
@ -212,11 +212,9 @@ position = Vector2(-710, -459)
|
|||
|
||||
[node name="Barrel" parent="Factory Tilemaps" instance=ExtResource("18_vy02r")]
|
||||
position = Vector2(-711, -395)
|
||||
ExplosionScene = null
|
||||
|
||||
[node name="Barrel2" parent="Factory Tilemaps" instance=ExtResource("18_vy02r")]
|
||||
position = Vector2(-700, -381)
|
||||
ExplosionScene = null
|
||||
|
||||
[node name="CameraController" type="Camera2D" parent="."]
|
||||
script = ExtResource("6_t8ide")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
|
|
@ -111,7 +112,7 @@ public partial class Bullet : Area2D
|
|||
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
||||
{
|
||||
//Debug.WriteLine("Destroy bullet out of screen");
|
||||
QueueFree();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
private void _on_body_entered(Node2D body)
|
||||
|
|
@ -119,7 +120,7 @@ public partial class Bullet : Area2D
|
|||
if (body.IsInGroup("Solid"))
|
||||
{
|
||||
//Debug.WriteLine("Collision");
|
||||
QueueFree();
|
||||
Destroy();
|
||||
}
|
||||
//// Do not Collide with body for purpose of destroying bullets
|
||||
// else if (body.IsInGroup("Destroyable"))
|
||||
|
|
@ -134,7 +135,7 @@ public partial class Bullet : Area2D
|
|||
{
|
||||
if (area.IsInGroup("Solid"))
|
||||
{
|
||||
QueueFree();
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -144,9 +145,21 @@ public partial class Bullet : Area2D
|
|||
|
||||
destructible.Hit(Damage, DamageType);
|
||||
|
||||
QueueFree();
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
if (_bulletInfo?.DestructionParticlesScene != null)
|
||||
{
|
||||
var particle = this.CreateSibling<AutodeleteParticle>(_bulletInfo.DestructionParticlesScene);
|
||||
|
||||
particle.Init();
|
||||
}
|
||||
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
public enum BulletOwner
|
||||
|
|
|
|||
27
Scripts/Components/AutodeleteParticle.cs
Normal file
27
Scripts/Components/AutodeleteParticle.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components;
|
||||
|
||||
public partial class AutodeleteParticle : GpuParticles2D
|
||||
{
|
||||
|
||||
[Export]
|
||||
public double LifeTime { get; private set; }
|
||||
|
||||
private double _timer = 0;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
this.Emitting = true;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_timer += delta;
|
||||
|
||||
if (_timer >= LifeTime || this.Emitting == false)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,6 +91,7 @@ public class BulletInfo
|
|||
//public double Time { get; set; }
|
||||
public float Spread { get; set; }
|
||||
public PackedScene BulletScene { get; set; }
|
||||
public PackedScene DestructionParticlesScene { get; set; }
|
||||
public IBulletModifier Modifier { get; set; }
|
||||
public List<TimeModifier> TimeModifiers { get; set; } = new List<TimeModifier>();
|
||||
}
|
||||
46
Scripts/Resources/BulletResource.cs
Normal file
46
Scripts/Resources/BulletResource.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Components;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class BulletResource : Resource
|
||||
{
|
||||
[Export]
|
||||
public PackedScene BulletScene { get; set; }
|
||||
[Export] public PackedScene DestructionParticlesScene { get; set; }
|
||||
[Export] public float BulletSpeed = 100f;
|
||||
[Export] public float BulletDamage = 1;
|
||||
[Export] public float LifeTime = 10f;
|
||||
[Export] public BulletOwner Owner = BulletOwner.None;
|
||||
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||
|
||||
[Export]
|
||||
public Resource Modifier;
|
||||
[Export] public Array<Resource> TimeModifiers;
|
||||
|
||||
public BulletInfo MakeBullet(Vector2 position, int count = 1, float spread = 0f, float rotationOffset = 0f)
|
||||
{
|
||||
return new BulletInfo()
|
||||
{
|
||||
Position = position,
|
||||
Direction = Vector2.Right,
|
||||
Speed = BulletSpeed,
|
||||
Owner = Owner,
|
||||
DamageType = DamageType,
|
||||
Damage = BulletDamage,
|
||||
BulletCount = count,
|
||||
Spread = spread,
|
||||
BulletScene = BulletScene,
|
||||
RotationOffset = rotationOffset,
|
||||
Modifier = Modifier as IBulletModifier,
|
||||
LifeTime = LifeTime,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ??
|
||||
new List<TimeModifier>()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -12,8 +12,12 @@ public partial class WeaponResource : Resource
|
|||
[Export]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Export]
|
||||
public PackedScene BulletScene { get; set; }
|
||||
[Export] public BulletResource BulletData { get; private set; }
|
||||
|
||||
//[Export]
|
||||
//public PackedScene BulletScene { get; set; }
|
||||
|
||||
//[Export] public PackedScene DestructionParticlesScene { get; set; }
|
||||
|
||||
[Export] public double RateOfFire = 0.4f;
|
||||
|
||||
|
|
@ -33,35 +37,38 @@ public partial class WeaponResource : Resource
|
|||
#region Bullet spawn data
|
||||
|
||||
[Export] public string AmmoKey;
|
||||
[Export] public float BulletSpeed = 100f;
|
||||
[Export] public float BulletDamage = 1;
|
||||
[Export] public float LifeTime = 10f;
|
||||
//[Export] public float BulletSpeed = 100f;
|
||||
//[Export] public float BulletDamage = 1;
|
||||
//[Export] public float LifeTime = 10f;
|
||||
[Export] private float _rotationOffset = 0f;
|
||||
[Export] private BulletOwner owner = BulletOwner.None;
|
||||
[Export] private DamageType _damageType = DamageType.Neutral;
|
||||
[Export] private Resource _modifier;
|
||||
[Export] private Array<Resource> _timeModifiers;
|
||||
//[Export] private BulletOwner owner = BulletOwner.None;
|
||||
//[Export] private DamageType _damageType = DamageType.Neutral;
|
||||
//[Export] private Resource _modifier;
|
||||
//[Export] private Array<Resource> _timeModifiers;
|
||||
|
||||
#endregion
|
||||
|
||||
public BulletInfo MakeBullet(Vector2 position)
|
||||
{
|
||||
return new BulletInfo()
|
||||
{
|
||||
Position = position,
|
||||
Direction = Vector2.Right,
|
||||
Speed = BulletSpeed,
|
||||
Owner = owner,
|
||||
DamageType = _damageType,
|
||||
Damage = BulletDamage,
|
||||
BulletCount = BulletsPerShot,
|
||||
Spread = SpreadAngle,
|
||||
BulletScene = BulletScene,
|
||||
RotationOffset = _rotationOffset,
|
||||
Modifier = _modifier as IBulletModifier,
|
||||
LifeTime = LifeTime,
|
||||
TimeModifiers = _timeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ??
|
||||
new List<TimeModifier>()
|
||||
};
|
||||
return BulletData.MakeBullet(position, BulletsPerShot, SpreadAngle, _rotationOffset);
|
||||
|
||||
// return new BulletInfo()
|
||||
// {
|
||||
// Position = position,
|
||||
// Direction = Vector2.Right,
|
||||
// Speed = BulletSpeed,
|
||||
// Owner = owner,
|
||||
// DamageType = _damageType,
|
||||
// Damage = BulletDamage,
|
||||
// BulletCount = BulletsPerShot,
|
||||
// Spread = SpreadAngle,
|
||||
// BulletScene = BulletScene,
|
||||
// RotationOffset = _rotationOffset,
|
||||
// Modifier = _modifier as IBulletModifier,
|
||||
// LifeTime = LifeTime,
|
||||
// DestructionParticlesScene = DestructionParticlesScene,
|
||||
// TimeModifiers = _timeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ??
|
||||
// new List<TimeModifier>()
|
||||
// };
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ public partial class Weapon : Node2D
|
|||
// Rotate the ShootDirection by the spread angle
|
||||
Vector2 spreadDirection = ShootDirection.Rotated(Mathf.DegToRad(spreadOffset));
|
||||
|
||||
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, WeaponData.BulletScene, _muzzle.GlobalPosition);
|
||||
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, WeaponData.BulletData.BulletScene, _muzzle.GlobalPosition);
|
||||
|
||||
if (bullet == null)
|
||||
{
|
||||
|
|
@ -111,7 +111,7 @@ public partial class Weapon : Node2D
|
|||
|
||||
//bullet.SetDirection(ShootDirection);
|
||||
bullet.SetDirection(spreadDirection);
|
||||
bullet.Speed = WeaponData.BulletSpeed;
|
||||
bullet.Speed = WeaponData.BulletData.BulletSpeed;
|
||||
}
|
||||
|
||||
LoadedAmmo -= 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue